From 8e42f9e2c9c6999614da50b301121eebfa693316 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Wed, 14 Feb 2024 00:29:12 +0800 Subject: [PATCH] feat: updating with latest sdk version --- package-lock.json | 14 +++++++------- package.json | 4 ++-- src/tokens/cbtc.ts | 2 +- src/tokens/djed.ts | 2 +- src/tokens/fet.ts | 4 +--- src/tokens/ibtc.ts | 2 +- src/tokens/ieth.ts | 2 +- src/tokens/iusd.ts | 2 +- src/tokens/prspr.ts | 2 +- src/tokens/shen.ts | 2 +- src/tokens/wrt.ts | 2 +- src/tokens/xvyfi.ts | 2 +- src/tokens/yummi.ts | 2 +- src/utils.ts | 17 +++++++++++++++-- 14 files changed, 35 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index c83ed16d..ad6db9fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@blockfrost/blockfrost-js": "^5.2.0", - "@maestro-org/typescript-sdk": "^1.4.1", + "@maestro-org/typescript-sdk": "^1.5.1", "axios": "^1.3.3" }, "devDependencies": { @@ -2985,9 +2985,9 @@ } }, "node_modules/@maestro-org/typescript-sdk": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@maestro-org/typescript-sdk/-/typescript-sdk-1.4.1.tgz", - "integrity": "sha512-gcpPEp1VccHMoiZLlRRucUiw0ldwWy1zxIRt17b5TMvKioGAsjesKOZ4MGZdxOuybZPGKRGgnNqLz7AoJCGE4Q==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@maestro-org/typescript-sdk/-/typescript-sdk-1.5.1.tgz", + "integrity": "sha512-I/5TEBOsx6AVNxgIjWvrJ/MmqpWsAL0Kc0dqPEggXQTgC+sFwBCPEH+M5zNRSGCb1XEs6kpm9dGmPiws03E//g==", "dependencies": { "axios": "^1.6.1" } @@ -11860,9 +11860,9 @@ } }, "@maestro-org/typescript-sdk": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@maestro-org/typescript-sdk/-/typescript-sdk-1.4.1.tgz", - "integrity": "sha512-gcpPEp1VccHMoiZLlRRucUiw0ldwWy1zxIRt17b5TMvKioGAsjesKOZ4MGZdxOuybZPGKRGgnNqLz7AoJCGE4Q==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@maestro-org/typescript-sdk/-/typescript-sdk-1.5.1.tgz", + "integrity": "sha512-I/5TEBOsx6AVNxgIjWvrJ/MmqpWsAL0Kc0dqPEggXQTgC+sFwBCPEH+M5zNRSGCb1XEs6kpm9dGmPiws03E//g==", "requires": { "axios": "^1.6.1" } diff --git a/package.json b/package.json index 50a0dea3..655ed22a 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "homepage": "https://github.com/minswap/market-cap#readme", "dependencies": { "@blockfrost/blockfrost-js": "^5.2.0", - "@maestro-org/typescript-sdk": "^1.4.1", + "@maestro-org/typescript-sdk": "^1.5.1", "axios": "^1.3.3" }, "lint-staged": { @@ -68,4 +68,4 @@ "ts-node": "^10.9.1", "typescript": "^4.9.5" } -} +} \ No newline at end of file diff --git a/src/tokens/cbtc.ts b/src/tokens/cbtc.ts index 3aa70605..e3b50807 100644 --- a/src/tokens/cbtc.ts +++ b/src/tokens/cbtc.ts @@ -7,7 +7,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const total = await maestro.assets .assetInfo(CBTC) - .then((res) => res.data.data.total_supply); + .then((res) => res.data.total_supply); const totalWithDecimals = Number(total) / 1e8; return { circulating: totalWithDecimals.toString(), diff --git a/src/tokens/djed.ts b/src/tokens/djed.ts index 75ea248e..e1b1441a 100644 --- a/src/tokens/djed.ts +++ b/src/tokens/djed.ts @@ -10,7 +10,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const total = 1e12; const res = await maestro.assets.assetAddresses(DJEDNFT); - const addresses = res.data.data; + const addresses = res.data; const treasuryRaw = await getAmountInAddresses(maestro, DJED, [ addresses[0]["address"], ]); diff --git a/src/tokens/fet.ts b/src/tokens/fet.ts index 8d2991d2..4637f113 100644 --- a/src/tokens/fet.ts +++ b/src/tokens/fet.ts @@ -7,9 +7,7 @@ const FET = const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const total = 200e6; const maestro = getMaestroClient(options); - const assetInfo = await maestro.assets - .assetInfo(FET) - .then((res) => res.data.data); + const assetInfo = await maestro.assets.assetInfo(FET).then((res) => res.data); const onchainSupply = Number(assetInfo?.total_supply) / 1e10; const treasuryRaw = await getAmountInAddresses(maestro, FET, [ "stake1uyyxjvthz4udwdrzr9pkkudpylasg99ufdzu7gpdfckxf2s5peell", // fe.dex.funds diff --git a/src/tokens/ibtc.ts b/src/tokens/ibtc.ts index cb6e7d2f..9b50a978 100644 --- a/src/tokens/ibtc.ts +++ b/src/tokens/ibtc.ts @@ -7,7 +7,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const assetInfo = await maestro.assets .assetInfo(iBTC) - .then((res) => res.data.data); + .then((res) => res.data); const circulating = Number(assetInfo?.total_supply) / 1e6; return { circulating: circulating.toString(), diff --git a/src/tokens/ieth.ts b/src/tokens/ieth.ts index 1979118d..32fdf9ca 100644 --- a/src/tokens/ieth.ts +++ b/src/tokens/ieth.ts @@ -7,7 +7,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const assetInfo = await maestro.assets .assetInfo(iETH) - .then((res) => res.data.data); + .then((res) => res.data); const circulating = Number(assetInfo?.total_supply) / 1e6; return { circulating: circulating.toString(), diff --git a/src/tokens/iusd.ts b/src/tokens/iusd.ts index 1af721ef..9c68ec4f 100644 --- a/src/tokens/iusd.ts +++ b/src/tokens/iusd.ts @@ -7,7 +7,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const assetInfo = await maestro.assets .assetInfo(iUSD) - .then((res) => res.data.data); + .then((res) => res.data); const circulating = Number(assetInfo?.total_supply) / 1e6; return { circulating: circulating.toString(), diff --git a/src/tokens/prspr.ts b/src/tokens/prspr.ts index 6710417a..9281aa69 100644 --- a/src/tokens/prspr.ts +++ b/src/tokens/prspr.ts @@ -12,7 +12,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const circulating = Number( await maestro.assets .policyInfo(PRSPR_POLICY_ID) - .then((res) => res.data.data[0].total_supply) + .then((res) => res.data[0].total_supply) ); const total = 375000000; const treasury = Number( diff --git a/src/tokens/shen.ts b/src/tokens/shen.ts index 0a76bf64..7bc6845a 100644 --- a/src/tokens/shen.ts +++ b/src/tokens/shen.ts @@ -10,7 +10,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const total = 1e12; const res = await maestro.assets.assetAddresses(DJEDNFT); - const addresses = res.data.data; + const addresses = res.data; const treasuryRaw = await getAmountInAddresses(maestro, SHEN, [ addresses[0]["address"], ]); diff --git a/src/tokens/wrt.ts b/src/tokens/wrt.ts index ab522a79..e80408cf 100644 --- a/src/tokens/wrt.ts +++ b/src/tokens/wrt.ts @@ -17,7 +17,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { }, { headers } ) - .then((res) => res.data.data.wrtDistribution.total.releasedWrt); + .then((res) => res.data.wrtDistribution.total.releasedWrt); return { circulating: (circulating / 1e6).toString(), diff --git a/src/tokens/xvyfi.ts b/src/tokens/xvyfi.ts index 0592d805..3622a13c 100644 --- a/src/tokens/xvyfi.ts +++ b/src/tokens/xvyfi.ts @@ -8,7 +8,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const maestro = getMaestroClient(options); const assetInfo = await maestro.assets .assetInfo(xVYFI) - .then((res) => res.data.data); + .then((res) => res.data); const circulating = Number(assetInfo?.total_supply) / 1e6; return { circulating: circulating.toString(), diff --git a/src/tokens/yummi.ts b/src/tokens/yummi.ts index 5bfd5674..6adebf20 100644 --- a/src/tokens/yummi.ts +++ b/src/tokens/yummi.ts @@ -21,7 +21,7 @@ const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const circulating = Number( await maestro.assets .policyInfo(YUMMI_POLICY_ID) - .then((res) => res.data.data[0].total_supply) + .then((res) => res.data[0].total_supply) ); const total = 1e10; const staking = Number( diff --git a/src/utils.ts b/src/utils.ts index d98bdff5..8fea4ba0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,8 +37,17 @@ export async function getAmountInAddresses( const getAssetsByAccount = async ( account: string ): Promise<{ unit: string; quantity: string }[]> => { + console.log("getting account assets", account); + const res = await maestro.accounts.accountAssets(account); - return res.data.data.map((asset) => ({ + console.log("completed", account, res.data); + + // if (!res.data) { + // console.log("what's happening?", res); + // return []; + // } + + return res.data.map((asset: Asset) => ({ unit: asset.unit, quantity: asset.amount, })); @@ -67,8 +76,12 @@ export async function getAmountInAddresses( return assets; }; + console.log("addr", addr); + const res = await maestro.addresses.utxosByAddress(addr); - const assets = mergeAssets(res.data.data.map((utxo) => utxo.assets)); + console.log("comleted addr", addr, res.data); + + const assets = mergeAssets(res.data.map((utxo) => utxo.assets)); return assets; };