Skip to content

Commit

Permalink
Merge pull request #2879 from v1xingyue/plugin-sui-patch
Browse files Browse the repository at this point in the history
fet: use axios to fetch price and support two types private key
  • Loading branch information
odilitime authored Jan 28, 2025
2 parents c399b87 + 5b6878a commit 8480026
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/plugin-sui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@elizaos/core": "workspace:*",
"@mysten/sui": "^1.16.0",
"axios": "^1.7.9",
"bignumber.js": "9.1.2",
"node-cache": "5.1.2",
"tsup": "8.3.5",
Expand Down
26 changes: 13 additions & 13 deletions packages/plugin-sui/src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
Provider,
State,
} from "@elizaos/core";
import axios from "axios";

import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";

Expand Down Expand Up @@ -89,19 +90,18 @@ export class WalletProvider {
try {
const cetusSuiUsdcPoolAddr =
"0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
const response = await fetch(
`https://api.dexscreener.com/latest/dex/pairs/sui/${cetusSuiUsdcPoolAddr}`
);

if (!response.ok) {
const errorText = await response.text();
throw new Error(
`HTTP error! status: ${response.status}, message: ${errorText}`
);
}

const data = await response.json();
return data;
const url = `https://api.dexscreener.com/latest/dex/pairs/sui/${cetusSuiUsdcPoolAddr}`;
const response = await axios.get(url);

// if (!response.ok) {
// const errorText = await response.text();
// throw new Error(
// `HTTP error! status: ${response.status}, message: ${errorText}`
// );
// }

// const data = await response.json();
return response.data;
} catch (error) {
console.error(`Attempt ${i + 1} failed:`, error);
lastError = error;
Expand Down

0 comments on commit 8480026

Please sign in to comment.