From c2c8a2ba620e6f3fb9803c439d5a87c8f0a8a50e Mon Sep 17 00:00:00 2001 From: David de Kloet Date: Tue, 13 Aug 2024 14:24:21 +0200 Subject: [PATCH 1/6] DOGMI fee --- dfx.json | 35 ++++++++++++++++--- .../src/lib/services/$public/sns.services.ts | 1 + frontend/src/lib/utils/icrc-tokens.utils.ts | 2 ++ .../utils/sns-aggregator-converters.utils.ts | 15 ++++++-- rs/sns_aggregator/src/state.rs | 5 +++ 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/dfx.json b/dfx.json index 823b67c8a25..7f5507c135d 100644 --- a/dfx.json +++ b/dfx.json @@ -102,7 +102,12 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_governance/sns_governance.did", "wasm": "target/ic/sns-governance-canister.wasm", - "type": "custom" + "type": "custom", + "remote": { + "id": { + "local": "nondm-44aaa-aaaaa-qabnq-cai" + } + } }, "sns_ledger": { "build": [ @@ -110,7 +115,12 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_ledger/sns_ledger.did", "wasm": "target/ic/ic-icrc1-ledger.wasm", - "type": "custom" + "type": "custom", + "remote": { + "id": { + "local": "n3ksb-5uaaa-aaaaa-qaboa-cai" + } + } }, "sns_archive": { "build": [ @@ -126,7 +136,12 @@ ], "candid": "target/ic/ic-icrc1-index.did", "wasm": "target/ic/ic-icrc1-index.wasm", - "type": "custom" + "type": "custom", + "remote": { + "id": { + "local": "nvi7j-geaaa-aaaaa-qabpa-cai" + } + } }, "sns_swap": { "build": [ @@ -134,7 +149,12 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_swap/sns_swap.did", "wasm": "target/ic/sns-swap-canister.wasm", - "type": "custom" + "type": "custom", + "remote": { + "id": { + "local": "n4luv-qmaaa-aaaaa-qaboq-cai" + } + } }, "sns_root": { "build": [ @@ -142,7 +162,12 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_root/sns_root.did", "wasm": "target/ic/sns-root-canister.wasm", - "type": "custom" + "type": "custom", + "remote": { + "id": { + "local": "njmfy-reaaa-aaaaa-qabna-cai" + } + } }, "sns_aggregator": { "build": [ diff --git a/frontend/src/lib/services/$public/sns.services.ts b/frontend/src/lib/services/$public/sns.services.ts index bf149c835d0..19f044ee342 100644 --- a/frontend/src/lib/services/$public/sns.services.ts +++ b/frontend/src/lib/services/$public/sns.services.ts @@ -51,6 +51,7 @@ export const loadSnsProjects = async (): Promise => { // This call is not necessary because the canister ids are already provided by the SNS aggregator. // As soon as the aggregator store is filled, SNS components may start rendering, resulting in calls on the SNS wrappers. // We set the aggregator store after building the wrappers' caches to avoid calls to the root canister when the SNS wrapper is initialized. + //console.log('dskloetx aggregatorData', aggregatorData); snsAggregatorStore.setData(aggregatorData); snsTotalTokenSupplyStore.setTotalTokenSupplies( aggregatorData.map(({ icrc1_total_supply, canister_ids }) => ({ diff --git a/frontend/src/lib/utils/icrc-tokens.utils.ts b/frontend/src/lib/utils/icrc-tokens.utils.ts index f50ed5eab88..a636179a187 100644 --- a/frontend/src/lib/utils/icrc-tokens.utils.ts +++ b/frontend/src/lib/utils/icrc-tokens.utils.ts @@ -14,6 +14,7 @@ import { isNullish, nonNullish } from "@dfinity/utils"; export const mapOptionalToken = ( response: IcrcTokenMetadataResponse ): IcrcTokenMetadata | undefined => { + console.log('dskloetx response', response); const nullishToken: Partial = response.reduce( (acc, [key, value]) => { switch (key) { @@ -49,6 +50,7 @@ export const mapOptionalToken = ( return undefined; } + console.log('dskloetx nullishToken', nullishToken); return nullishToken as IcrcTokenMetadata; }; diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index b10f0c01be5..61191d65d6f 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -279,15 +279,26 @@ const convertDerived = ({ ), }); +const arrayToBigInt = (array: number[]): bigint[] => { + let result = 0n; + let d = 1n; + for (const num of array) { + result += d * BigInt(num); + d *= (2n ** 32n); + } + console.log('dskloetx array', array, result); + return result; +}; + export const convertIcrc1Metadata = ( icrc1Metadata: CachedSnsTokenMetadataDto ): IcrcTokenMetadataResponse => { return icrc1Metadata.map(([key, value]) => { if ("Int" in value) { - return [key, { Int: BigInt(value.Int[0]) }]; + return [key, { Int: arrayToBigInt(value.Int) }]; } if ("Nat" in value) { - return [key, { Nat: BigInt(value.Nat[0]) }]; + return [key, { Nat: arrayToBigInt(value.Nat) }]; } return [key, value]; }); diff --git a/rs/sns_aggregator/src/state.rs b/rs/sns_aggregator/src/state.rs index 4621dc3810f..e00eea3005a 100644 --- a/rs/sns_aggregator/src/state.rs +++ b/rs/sns_aggregator/src/state.rs @@ -182,8 +182,13 @@ impl State { } // Adds an http path for just this SNS. { + ic_cdk::println!("root_canister_str: {root_canister_str}"); let slow_data = SlowSnsData::from(upstream_data); let json_data = serde_json::to_string(&slow_data)?; + if root_canister_str.as_str() == "njmfy-reaaa-aaaaa-qabna-cai" { + ic_cdk::println!("slow_data: {:?}", slow_data); + ic_cdk::println!("json_data: {json_data}"); + } let path = format!("{prefix}/sns/root/{root_canister_str}/slow.json"); let asset = Asset { headers: Vec::new(), From f1f0c58b1a8c64c5187bd97b47bac6aabef35e40 Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 13 Aug 2024 16:29:21 +0200 Subject: [PATCH 2/6] Remove console logs --- frontend/src/lib/services/$public/sns.services.ts | 1 - frontend/src/lib/utils/icrc-tokens.utils.ts | 2 -- frontend/src/lib/utils/sns-aggregator-converters.utils.ts | 1 - 3 files changed, 4 deletions(-) diff --git a/frontend/src/lib/services/$public/sns.services.ts b/frontend/src/lib/services/$public/sns.services.ts index 19f044ee342..bf149c835d0 100644 --- a/frontend/src/lib/services/$public/sns.services.ts +++ b/frontend/src/lib/services/$public/sns.services.ts @@ -51,7 +51,6 @@ export const loadSnsProjects = async (): Promise => { // This call is not necessary because the canister ids are already provided by the SNS aggregator. // As soon as the aggregator store is filled, SNS components may start rendering, resulting in calls on the SNS wrappers. // We set the aggregator store after building the wrappers' caches to avoid calls to the root canister when the SNS wrapper is initialized. - //console.log('dskloetx aggregatorData', aggregatorData); snsAggregatorStore.setData(aggregatorData); snsTotalTokenSupplyStore.setTotalTokenSupplies( aggregatorData.map(({ icrc1_total_supply, canister_ids }) => ({ diff --git a/frontend/src/lib/utils/icrc-tokens.utils.ts b/frontend/src/lib/utils/icrc-tokens.utils.ts index a636179a187..f50ed5eab88 100644 --- a/frontend/src/lib/utils/icrc-tokens.utils.ts +++ b/frontend/src/lib/utils/icrc-tokens.utils.ts @@ -14,7 +14,6 @@ import { isNullish, nonNullish } from "@dfinity/utils"; export const mapOptionalToken = ( response: IcrcTokenMetadataResponse ): IcrcTokenMetadata | undefined => { - console.log('dskloetx response', response); const nullishToken: Partial = response.reduce( (acc, [key, value]) => { switch (key) { @@ -50,7 +49,6 @@ export const mapOptionalToken = ( return undefined; } - console.log('dskloetx nullishToken', nullishToken); return nullishToken as IcrcTokenMetadata; }; diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index 61191d65d6f..c9d1832834d 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -286,7 +286,6 @@ const arrayToBigInt = (array: number[]): bigint[] => { result += d * BigInt(num); d *= (2n ** 32n); } - console.log('dskloetx array', array, result); return result; }; From 4b0d0332eeda371b1008aa15620c4d7180c0fc0c Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 13 Aug 2024 16:29:30 +0200 Subject: [PATCH 3/6] Reset dfx --- dfx.json | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/dfx.json b/dfx.json index 7f5507c135d..823b67c8a25 100644 --- a/dfx.json +++ b/dfx.json @@ -102,12 +102,7 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_governance/sns_governance.did", "wasm": "target/ic/sns-governance-canister.wasm", - "type": "custom", - "remote": { - "id": { - "local": "nondm-44aaa-aaaaa-qabnq-cai" - } - } + "type": "custom" }, "sns_ledger": { "build": [ @@ -115,12 +110,7 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_ledger/sns_ledger.did", "wasm": "target/ic/ic-icrc1-ledger.wasm", - "type": "custom", - "remote": { - "id": { - "local": "n3ksb-5uaaa-aaaaa-qaboa-cai" - } - } + "type": "custom" }, "sns_archive": { "build": [ @@ -136,12 +126,7 @@ ], "candid": "target/ic/ic-icrc1-index.did", "wasm": "target/ic/ic-icrc1-index.wasm", - "type": "custom", - "remote": { - "id": { - "local": "nvi7j-geaaa-aaaaa-qabpa-cai" - } - } + "type": "custom" }, "sns_swap": { "build": [ @@ -149,12 +134,7 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_swap/sns_swap.did", "wasm": "target/ic/sns-swap-canister.wasm", - "type": "custom", - "remote": { - "id": { - "local": "n4luv-qmaaa-aaaaa-qaboq-cai" - } - } + "type": "custom" }, "sns_root": { "build": [ @@ -162,12 +142,7 @@ ], "candid": "declarations/used_by_sns_aggregator/sns_root/sns_root.did", "wasm": "target/ic/sns-root-canister.wasm", - "type": "custom", - "remote": { - "id": { - "local": "njmfy-reaaa-aaaaa-qabna-cai" - } - } + "type": "custom" }, "sns_aggregator": { "build": [ From 5b8219564ccacc56cb32d616722ecbda2e7ee64e Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 13 Aug 2024 16:29:38 +0200 Subject: [PATCH 4/6] Fix type --- frontend/src/lib/utils/sns-aggregator-converters.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index c9d1832834d..468eac206d0 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -279,7 +279,7 @@ const convertDerived = ({ ), }); -const arrayToBigInt = (array: number[]): bigint[] => { +const arrayToBigInt = (array: number[]): bigint => { let result = 0n; let d = 1n; for (const num of array) { From 08c06925cb06727c3c1e30c543b179feedfb81d5 Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 13 Aug 2024 16:33:13 +0200 Subject: [PATCH 5/6] Formatting --- frontend/src/lib/utils/sns-aggregator-converters.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index 468eac206d0..a57bd810716 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -284,7 +284,7 @@ const arrayToBigInt = (array: number[]): bigint => { let d = 1n; for (const num of array) { result += d * BigInt(num); - d *= (2n ** 32n); + d *= 2n ** 32n; } return result; }; From 98a39c5ce15fa6e1df2967e3dd4a1722a41c25b6 Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Tue, 13 Aug 2024 16:46:54 +0200 Subject: [PATCH 6/6] Formatting --- rs/sns_aggregator/src/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rs/sns_aggregator/src/state.rs b/rs/sns_aggregator/src/state.rs index e00eea3005a..0da97eaebad 100644 --- a/rs/sns_aggregator/src/state.rs +++ b/rs/sns_aggregator/src/state.rs @@ -186,8 +186,8 @@ impl State { let slow_data = SlowSnsData::from(upstream_data); let json_data = serde_json::to_string(&slow_data)?; if root_canister_str.as_str() == "njmfy-reaaa-aaaaa-qabna-cai" { - ic_cdk::println!("slow_data: {:?}", slow_data); - ic_cdk::println!("json_data: {json_data}"); + ic_cdk::println!("slow_data: {:?}", slow_data); + ic_cdk::println!("json_data: {json_data}"); } let path = format!("{prefix}/sns/root/{root_canister_str}/slow.json"); let asset = Asset {