Skip to content

Commit

Permalink
feat: updating with latest sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Feb 13, 2024
1 parent 83e6a79 commit 8e42f9e
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 24 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -68,4 +68,4 @@
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
}
2 changes: 1 addition & 1 deletion src/tokens/cbtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/djed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
]);
Expand Down
4 changes: 1 addition & 3 deletions src/tokens/fet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/ibtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/ieth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/iusd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/prspr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/shen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
]);
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/wrt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/xvyfi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/yummi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 15 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit 8e42f9e

Please sign in to comment.