Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): remove indexCanisterVersion #3620

Merged
merged 9 commits into from
Nov 20, 2024
52 changes: 2 additions & 50 deletions scripts/build.tokens.sns.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/usr/bin/env node

import { AnonymousIdentity } from '@dfinity/agent';
import { Ed25519KeyIdentity } from '@dfinity/identity';
import { IcrcIndexNgCanister, IcrcMetadataResponseEntries } from '@dfinity/ledger-icrc';
import { Principal } from '@dfinity/principal';
import { IcrcMetadataResponseEntries } from '@dfinity/ledger-icrc';
import {
candidNumberArrayToBigInt,
createAgent,
fromNullable,
isNullish,
jsonReplacer,
Expand Down Expand Up @@ -115,34 +111,6 @@ const mapOptionalToken = (response) => {
return nullishToken;
};

const assertIndexCanister = async (indexCanisterId) => {
try {
const agent = await createAgent({
identity: new AnonymousIdentity(),
host: 'https://icp-api.io'
});

const { getTransactions } = IcrcIndexNgCanister.create({
agent,
canisterId: Principal.fromText(indexCanisterId)
});

const { balance } = await getTransactions({
certified: true,
max_results: 0n,
account: { owner: Ed25519KeyIdentity.generate().getPrincipal() }
});

return balance >= 0n;
} catch (err) {
if (err.response?.body?.reject_message?.includes('out of cycles')) {
throw new Error(err.response.body.reject_message);
}

return false;
}
};

export const findSnses = async () => {
const data = await querySnsAggregator();

Expand Down Expand Up @@ -199,23 +167,7 @@ export const findSnses = async () => {
{ tokens: [], icons: [] }
);

const indexCanisterVersion = async (token) => {
const { indexCanisterId } = token;

const valid = await assertIndexCanister(indexCanisterId);

return {
...token,
indexCanisterVersion: valid ? 'up-to-date' : 'outdated'
};
};

const enhancedTokens = await Promise.all(tokens.map(indexCanisterVersion));

writeFileSync(
join(DATA_FOLDER, 'tokens.sns.json'),
JSON.stringify(enhancedTokens, jsonReplacer, 8)
);
writeFileSync(join(DATA_FOLDER, 'tokens.sns.json'), JSON.stringify(tokens, jsonReplacer, 8));

await saveLogos(icons);
};
Expand Down
5 changes: 1 addition & 4 deletions src/frontend/src/env/schema/env-sns-token.schema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { EnvIcrcTokenMetadataSchema, EnvIcTokenSchema } from '$env/schema/env-icrc-token.schema';
import { z } from 'zod';

const IndexCanisterVersionSchema = z.union([z.literal('up-to-date'), z.literal('outdated')]);

export const EnvSnsTokenSchema = EnvIcTokenSchema.extend({
rootCanisterId: z.string(),
metadata: EnvIcrcTokenMetadataSchema,
indexCanisterVersion: IndexCanisterVersionSchema
metadata: EnvIcrcTokenMetadataSchema
});

export const EnvSnsTokensSchema = z.array(EnvSnsTokenSchema);
90 changes: 30 additions & 60 deletions src/frontend/src/env/tokens.sns.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
},
"alternativeName": "Dragginz",
"url": "https://dragginz.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "2ouva-viaaa-aaaaq-aaamq-cai",
Expand All @@ -28,8 +27,7 @@
},
"alternativeName": "OpenChat",
"url": "https://oc.app"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "73mez-iiaaa-aaaaq-aaasq-cai",
Expand All @@ -44,8 +42,7 @@
},
"alternativeName": "Kinic",
"url": "https://kinic.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "6rdgd-kyaaa-aaaaq-aaavq-cai",
Expand All @@ -60,8 +57,7 @@
},
"alternativeName": "YRAL",
"url": "https://yral.com"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "4c4fd-caaaa-aaaaq-aaa3a-cai",
Expand All @@ -76,8 +72,7 @@
},
"alternativeName": "ICGhost",
"url": "https://yadjb-mqaaa-aaaan-qaqlq-cai.raw.ic0.app/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "xsi2v-cyaaa-aaaaq-aabfq-cai",
Expand All @@ -92,8 +87,7 @@
},
"alternativeName": "DecideAI DAO",
"url": "https://decideai.xyz"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "vtrom-gqaaa-aaaaq-aabia-cai",
Expand All @@ -108,8 +102,7 @@
},
"alternativeName": "BOOM DAO",
"url": "https://boomdao.xyz/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "uf2wh-taaaa-aaaaq-aabna-cai",
Expand All @@ -124,8 +117,7 @@
},
"alternativeName": "Catalyze",
"url": "https://catalyze.one"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "rffwt-piaaa-aaaaq-aabqq-cai",
Expand All @@ -140,8 +132,7 @@
},
"alternativeName": "Seers AI",
"url": "https://seers.social"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "rxdbk-dyaaa-aaaaq-aabtq-cai",
Expand All @@ -156,8 +147,7 @@
},
"alternativeName": "Nuance",
"url": "https://nuance.xyz"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "qbizb-wiaaa-aaaaq-aabwq-cai",
Expand All @@ -172,8 +162,7 @@
},
"alternativeName": "SONIC",
"url": "https://app.sonic.ooo"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "tyyy3-4aaaa-aaaaq-aab7a-cai",
Expand All @@ -188,8 +177,7 @@
},
"alternativeName": "Gold DAO",
"url": "https://www.gold-dao.org"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "emww2-4yaaa-aaaaq-aacbq-cai",
Expand All @@ -204,8 +192,7 @@
},
"alternativeName": "TRAX",
"url": "https://trax.so"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "f54if-eqaaa-aaaaq-aacea-cai",
Expand All @@ -220,8 +207,7 @@
},
"alternativeName": "Neutrinite",
"url": "https://icpcoins.com"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "hvgxa-wqaaa-aaaaq-aacia-cai",
Expand All @@ -236,8 +222,7 @@
},
"alternativeName": "Sneed",
"url": "https://4pk43-5qaaa-aaaag-qc44a-cai.icp0.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "hhaaz-2aaaa-aaaaq-aacla-cai",
Expand All @@ -252,8 +237,7 @@
},
"alternativeName": "ICLighthouse DAO",
"url": "https://iclight.io"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "gemj7-oyaaa-aaaaq-aacnq-cai",
Expand All @@ -268,8 +252,7 @@
},
"alternativeName": "ELNA AI",
"url": "https://dapp.elna.ai"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "ddsp7-7iaaa-aaaaq-aacqq-cai",
Expand All @@ -284,8 +267,7 @@
},
"alternativeName": "OpenFPL",
"url": "https://openfpl.xyz/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "druyg-tyaaa-aaaaq-aactq-cai",
Expand All @@ -300,8 +282,7 @@
},
"alternativeName": "ICPanda DAO",
"url": "https://panda.fans"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "ca6gz-lqaaa-aaaaq-aacwa-cai",
Expand All @@ -316,8 +297,7 @@
},
"alternativeName": "ICPSwap",
"url": "https://www.icpswap.com"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "atbfz-diaaa-aaaaq-aacyq-cai",
Expand All @@ -332,8 +312,7 @@
},
"alternativeName": "Yuku DAO",
"url": "https://yuku.app/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "bliq2-niaaa-aaaaq-aac4q-cai",
Expand All @@ -348,8 +327,7 @@
},
"alternativeName": "EstateDAO",
"url": "https://wbdy5-yyaaa-aaaap-abysq-cai.icp0.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "k45jy-aiaaa-aaaaq-aadcq-cai",
Expand All @@ -364,8 +342,7 @@
},
"alternativeName": "Motoko",
"url": "https://2uktw-yiaaa-aaaah-adwxq-cai.icp0.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "lrtnw-paaaa-aaaaq-aadfa-cai",
Expand All @@ -380,8 +357,7 @@
},
"alternativeName": "ICPCC DAO LLC",
"url": "https://osjzm-oaaaa-aaaal-ajcoq-cai.icp0.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "lkwrt-vyaaa-aaaaq-aadhq-cai",
Expand All @@ -396,8 +372,7 @@
},
"alternativeName": "ORIGYN",
"url": "https://www.origyn.com/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "jcmow-hyaaa-aaaaq-aadlq-cai",
Expand All @@ -412,8 +387,7 @@
},
"alternativeName": "WaterNeuron",
"url": "https://waterneuron.fi/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "itgqj-7qaaa-aaaaq-aadoa-cai",
Expand All @@ -428,8 +402,7 @@
},
"alternativeName": "CYCLES-TRANSFER-STATION",
"url": "https://cycles-transfer-station.com"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "np5km-uyaaa-aaaaq-aadrq-cai",
Expand All @@ -444,8 +417,7 @@
},
"alternativeName": "DOGMI",
"url": "https://qu2gy-uqaaa-aaaal-qcv6a-cai.icp0.io"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "m6xut-mqaaa-aaaaq-aadua-cai",
Expand All @@ -460,8 +432,7 @@
},
"alternativeName": "ICVC",
"url": "https://mnc6b-aaaaa-aaaap-qhnrq-cai.icp0.io/"
},
"indexCanisterVersion": "up-to-date"
}
},
{
"ledgerCanisterId": "o7oak-iyaaa-aaaaq-aadzq-cai",
Expand All @@ -476,7 +447,6 @@
},
"alternativeName": "KongSwap",
"url": "https://www.kongswap.io/"
},
"indexCanisterVersion": "up-to-date"
}
}
]
Loading