From e47ae9e4e975ae84879469247a396dddf39bd477 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 24 Jun 2024 11:26:04 +0100 Subject: [PATCH 01/23] basic scripts --- scripts/claim-dust.ts | 43 ++++++++++++++++++++++++++++++++++++++ scripts/jsonTxBuilder.ts | 9 ++++++++ scripts/pause.ts | 18 ++++++++++++++++ scripts/propose-upgrade.ts | 33 +++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 scripts/claim-dust.ts create mode 100644 scripts/jsonTxBuilder.ts create mode 100644 scripts/pause.ts create mode 100644 scripts/propose-upgrade.ts diff --git a/scripts/claim-dust.ts b/scripts/claim-dust.ts new file mode 100644 index 0000000..8e02aa4 --- /dev/null +++ b/scripts/claim-dust.ts @@ -0,0 +1,43 @@ +import { CallData } from "starknet"; +import { Claim, buildCallDataClaim } from "../lib/claim"; +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - dustReceiver: the address of the dust receiver +/// - claim: the claim object + +const factoryAddress = ""; +const dustReceiver = "0"; +const claim: Claim = { + factory: factoryAddress, + class_hash: "", + sender: "", + gift_token: "", + gift_amount: 0n, + fee_token: "", + fee_amount: 0n, + claim_pubkey: 0n, +}; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +if (!dustReceiver) { + throw new Error("Dust receiver address is not set. Please set it in the script file."); +} + +for (let key in claim) { + if (!claim[key] && key !== "fee_amount" && key !== "gift_amount") { + throw new Error(`The property ${key} is empty in the claim object.`); + } +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "get_dust", + calldata: CallData.compile([buildCallDataClaim(claim), dustReceiver]), +}; + +logTransactionJson([tx]); diff --git a/scripts/jsonTxBuilder.ts b/scripts/jsonTxBuilder.ts new file mode 100644 index 0000000..f2616c9 --- /dev/null +++ b/scripts/jsonTxBuilder.ts @@ -0,0 +1,9 @@ +interface Transaction { + contractAddress: string; + entrypoint: string; + calldata: (string | number | undefined)[]; +} + +export function logTransactionJson(transaction: Transaction[]) { + console.log(JSON.stringify(transaction, null, 2)); +} diff --git a/scripts/pause.ts b/scripts/pause.ts new file mode 100644 index 0000000..371a7e4 --- /dev/null +++ b/scripts/pause.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "pause", + calldata: [], +}; + +logTransactionJson([tx]); diff --git a/scripts/propose-upgrade.ts b/scripts/propose-upgrade.ts new file mode 100644 index 0000000..6eed047 --- /dev/null +++ b/scripts/propose-upgrade.ts @@ -0,0 +1,33 @@ +import { CallData } from "starknet"; +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - newImplementation: the class ahs of the new implementation contract +/// - callData: the call data for the propose_upgrade function + +const factoryAddress = ""; +const newImplementation = ""; +const callData = []; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +if (!newImplementation) { + throw new Error("New implementation class hash is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "propose_upgrade", + calldata: CallData.compile([newImplementation, callData]), +}; + +// date 7 days from now +const date = new Date(); +date.setDate(date.getDate() + 7); + +logTransactionJson([tx]); + +console.log("Proposed upgrade will be ready at: ", date); From 1c892ea187de2f6ea9b37c12f3a3a9ae216344fe Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 24 Jun 2024 11:29:39 +0100 Subject: [PATCH 02/23] scripts --- scripts/upgrade.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/upgrade.ts diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts new file mode 100644 index 0000000..e7c7e09 --- /dev/null +++ b/scripts/upgrade.ts @@ -0,0 +1,22 @@ +import { CallData } from "starknet"; +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - callData: upgrade call data + +const factoryAddress = ""; + +const callData = []; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "upgrade", + calldata: CallData.compile(callData), +}; + +logTransactionJson([tx]); From 87944cf302fbda317a625a3edb6761ba8fb6a66a Mon Sep 17 00:00:00 2001 From: Leonard-Pat <106159231+Leonard-Pat@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:53:27 +0100 Subject: [PATCH 03/23] Update scripts/claim-dust.ts Co-authored-by: gaetbout --- scripts/claim-dust.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/claim-dust.ts b/scripts/claim-dust.ts index 8e02aa4..eb81134 100644 --- a/scripts/claim-dust.ts +++ b/scripts/claim-dust.ts @@ -28,7 +28,7 @@ if (!dustReceiver) { throw new Error("Dust receiver address is not set. Please set it in the script file."); } -for (let key in claim) { +for (const key in claim) { if (!claim[key] && key !== "fee_amount" && key !== "gift_amount") { throw new Error(`The property ${key} is empty in the claim object.`); } From e8559d13f13165178ab5b52f82fac5c07c61aa95 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 24 Jun 2024 11:59:17 +0100 Subject: [PATCH 04/23] fix linting errors --- scripts/claim-dust.ts | 4 ++-- scripts/propose-upgrade.ts | 2 +- scripts/upgrade.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/claim-dust.ts b/scripts/claim-dust.ts index eb81134..e4932be 100644 --- a/scripts/claim-dust.ts +++ b/scripts/claim-dust.ts @@ -8,7 +8,7 @@ import { logTransactionJson } from "./jsonTxBuilder"; /// - claim: the claim object const factoryAddress = ""; -const dustReceiver = "0"; +const dustReceiver = ""; const claim: Claim = { factory: factoryAddress, class_hash: "", @@ -29,7 +29,7 @@ if (!dustReceiver) { } for (const key in claim) { - if (!claim[key] && key !== "fee_amount" && key !== "gift_amount") { + if (key in claim && !claim[key as keyof typeof claim] && key !== "fee_amount" && key !== "gift_amount") { throw new Error(`The property ${key} is empty in the claim object.`); } } diff --git a/scripts/propose-upgrade.ts b/scripts/propose-upgrade.ts index 6eed047..bc24f7e 100644 --- a/scripts/propose-upgrade.ts +++ b/scripts/propose-upgrade.ts @@ -8,7 +8,7 @@ import { logTransactionJson } from "./jsonTxBuilder"; const factoryAddress = ""; const newImplementation = ""; -const callData = []; +const callData: any[] = []; if (!factoryAddress) { throw new Error("Factory contract address is not set. Please set it in the script file."); diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts index e7c7e09..cdbd03b 100644 --- a/scripts/upgrade.ts +++ b/scripts/upgrade.ts @@ -7,7 +7,7 @@ import { logTransactionJson } from "./jsonTxBuilder"; const factoryAddress = ""; -const callData = []; +const callData: any[] = []; if (!factoryAddress) { throw new Error("Factory contract address is not set. Please set it in the script file."); From 14b125849be85eae60efafce46d057d3373beade Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 14:33:06 +0200 Subject: [PATCH 05/23] update gas report for baseline --- gas-report.txt | 16 ++++++++-------- lib/claim.ts | 9 ++++++++- scripts/profile.ts | 14 ++++++++++++++ tests-integration/claim_external.test.ts | 2 ++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index b20933e..02e3c94 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -24,15 +24,15 @@ Resources: │ Transfer ETH (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Transfer STRK (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14506 │ -│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13662 │ -│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ +│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20478 │ -│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13860 │ -│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ +│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20477 │ -│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13662 │ -│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ +│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14507 │ -│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13860 │ -│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ +│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/lib/claim.ts b/lib/claim.ts index 513d263..e839acb 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -106,10 +106,17 @@ export async function claimExternal(args: { receiver: string; dustReceiver?: string; claimPrivateKey: string; + useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string; account?: Account }; details?: UniversalDetails; }): Promise { - const account = args.overrides?.account || deployer; + let account = args.overrides?.account || deployer; + // Ugly tmp fix + if (args.useTxV3) { + const devnetAddress = "0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691"; + const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; + account = new Account(manager, devnetAddress, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + } const signature = await signExternalClaim({ claim: args.claim, receiver: args.receiver, diff --git a/scripts/profile.ts b/scripts/profile.ts index f08c778..7bb0b9e 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,4 +1,5 @@ import { + calculateClaimAddress, claimExternal, claimInternal, defaultDepositTestSetup, @@ -67,10 +68,23 @@ for (const { giftTokenContract, unit } of tokens) { await claimInternal({ claim, receiver, claimPrivateKey }), ); + // TODO Claim external doesn't align on using txv3 + await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), ); + + // await profiler.profile( + // `Claiming dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, + // await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), + // ); + + const tokenContract = await manager.tokens.feeTokenContract(useTxV3); + const claimAddress = calculateClaimAddress(claim); + const balance = await tokenContract.balance_of(claimAddress); + console.log(balance); + console.log("Claimed"); } } diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 3d42fbb..52c2b66 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -15,6 +15,7 @@ import { describe("Claim External", function () { for (const useTxV3 of [false, true]) { + // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (no dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); @@ -29,6 +30,7 @@ describe("Claim External", function () { await manager.tokens.tokenBalance(claimAddress, claim.fee_token).should.eventually.equal(claim.fee_amount); }); + // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (w/ dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); From d98ec5a6f54f7e03b0206312b2a6d066f5ec5dd1 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 14:38:01 +0200 Subject: [PATCH 06/23] format + useTxV3 --- gas-report.txt | 4 ++-- scripts/profile.ts | 4 +--- tests-integration/claim_external.test.ts | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 02e3c94..0058f97 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -9,13 +9,13 @@ Summary: │ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ diff --git a/scripts/profile.ts b/scripts/profile.ts index 7bb0b9e..3dfc1dd 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -68,11 +68,9 @@ for (const { giftTokenContract, unit } of tokens) { await claimInternal({ claim, receiver, claimPrivateKey }), ); - // TODO Claim external doesn't align on using txv3 - await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, - await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), + await claimExternal({ claim: claimExternalOj, receiver, useTxV3, claimPrivateKey: claimPrivateKeyExternal }), ); // await profiler.profile( diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 52c2b66..721cb3e 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -22,7 +22,7 @@ describe("Claim External", function () { const receiver = randomReceiver(); const claimAddress = calculateClaimAddress(claim); - await claimExternal({ claim, receiver, claimPrivateKey }); + await claimExternal({ claim, receiver, useTxV3, claimPrivateKey }); const finalBalance = await manager.tokens.tokenBalance(claimAddress, claim.gift_token); expect(finalBalance).to.equal(claim.fee_amount); @@ -39,7 +39,7 @@ describe("Claim External", function () { const claimAddress = calculateClaimAddress(claim); const balanceBefore = await manager.tokens.tokenBalance(claimAddress, claim.gift_token); - await claimExternal({ claim, receiver, claimPrivateKey, dustReceiver }); + await claimExternal({ claim, receiver, claimPrivateKey, useTxV3, dustReceiver }); await manager.tokens.tokenBalance(receiver, claim.gift_token).should.eventually.equal(claim.gift_amount); await manager.tokens From 2ff001177ff2f8a82ec85116667310695e1659cc Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:07:29 +0200 Subject: [PATCH 07/23] get dust + claim external using txv3 --- gas-report.txt | 8 ++++++++ scripts/profile.ts | 24 ++++++++++++------------ tests-integration/claim_external.test.ts | 2 -- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 0058f97..92802df 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -7,15 +7,19 @@ Summary: │ Gifting WEI (FeeToken: WEI) │ '1.548.000.000.288' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 3 │ 288 │ 'BLOB' │ │ Claiming WEI (FeeToken: WEI) │ '1.368.000.000.192' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust WEI (FeeToken: WEI) │ '1.440.000.000.192' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.320' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: WEI) │ '1.548.000.000.192' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.320' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -26,13 +30,17 @@ Resources: │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14506 │ │ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ │ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 61 │ 0 │ 436 │ 14637 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20478 │ │ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ │ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 62 │ 0 │ 470 │ 15852 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20477 │ │ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ │ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 62 │ 0 │ 470 │ 15852 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14507 │ │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ │ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 61 │ 0 │ 436 │ 14637 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/scripts/profile.ts b/scripts/profile.ts index 3dfc1dd..380f074 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,5 +1,5 @@ import { - calculateClaimAddress, + buildCallDataClaim, claimExternal, claimInternal, defaultDepositTestSetup, @@ -7,6 +7,7 @@ import { manager, randomReceiver, setupGiftProtocol, + } from "../lib"; import { newProfiler } from "../lib/gas"; @@ -42,7 +43,7 @@ for (const { giftTokenContract, unit } of tokens) { const receiver = "0x42"; const { factory } = await setupGiftProtocol(); - // Make a gift + // Profiling deposit const { response, claim, claimPrivateKey } = await defaultDepositTestSetup({ factory, useTxV3, @@ -63,26 +64,25 @@ for (const { giftTokenContract, unit } of tokens) { await profiler.profile(`Gifting ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, response); + // Profiling claim internal await profiler.profile( `Claiming ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimInternal({ claim, receiver, claimPrivateKey }), ); + // Profiling claim external await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimExternal({ claim: claimExternalOj, receiver, useTxV3, claimPrivateKey: claimPrivateKeyExternal }), ); - // await profiler.profile( - // `Claiming dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, - // await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), - // ); - - const tokenContract = await manager.tokens.feeTokenContract(useTxV3); - const claimAddress = calculateClaimAddress(claim); - const balance = await tokenContract.balance_of(claimAddress); - console.log(balance); - console.log("Claimed"); + // Profiling getting the dust + factory.connect(deployer); + // TODO useTxV3 not used... + await profiler.profile( + `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, + await factory.get_dust(buildCallDataClaim(claim), deployer.address), + ); } } diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 721cb3e..d6f9082 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -15,7 +15,6 @@ import { describe("Claim External", function () { for (const useTxV3 of [false, true]) { - // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (no dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); @@ -30,7 +29,6 @@ describe("Claim External", function () { await manager.tokens.tokenBalance(claimAddress, claim.fee_token).should.eventually.equal(claim.fee_amount); }); - // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (w/ dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); From a07d41e400e2250ab09794df3f9f8130838c5c31 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:08:05 +0200 Subject: [PATCH 08/23] format --- scripts/profile.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/profile.ts b/scripts/profile.ts index 380f074..b59a2fb 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -7,7 +7,6 @@ import { manager, randomReceiver, setupGiftProtocol, - } from "../lib"; import { newProfiler } from "../lib/gas"; From abae971d7136ad7be903fa4094894e3ee75371ee Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:14:57 +0200 Subject: [PATCH 09/23] remove useless arg --- lib/claim.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index e839acb..5e04594 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -107,15 +107,14 @@ export async function claimExternal(args: { dustReceiver?: string; claimPrivateKey: string; useTxV3?: boolean; - overrides?: { claimAccountAddress?: string; factoryAddress?: string; account?: Account }; + overrides?: { claimAccountAddress?: string; factoryAddress?: string;}; details?: UniversalDetails; }): Promise { - let account = args.overrides?.account || deployer; + let account = deployer; // Ugly tmp fix if (args.useTxV3) { - const devnetAddress = "0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691"; const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; - account = new Account(manager, devnetAddress, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + account = new Account(manager, account.address, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); } const signature = await signExternalClaim({ claim: args.claim, From 8ba369bb5e35ba6004d935c19a42a3184be4a335 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:18:31 +0200 Subject: [PATCH 10/23] use setDefaultTransactionVersionV3 --- lib/claim.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index 5e04594..be00ac3 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -16,6 +16,7 @@ import { deployer, ethAddress, manager, + setDefaultTransactionVersionV3, strkAddress, } from "."; @@ -113,8 +114,7 @@ export async function claimExternal(args: { let account = deployer; // Ugly tmp fix if (args.useTxV3) { - const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; - account = new Account(manager, account.address, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + account = setDefaultTransactionVersionV3(deployer); } const signature = await signExternalClaim({ claim: args.claim, From c8c09f0af8d1e3086a558a748677074ea792000f Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:22:04 +0200 Subject: [PATCH 11/23] update get dust to use tx version --- gas-report.txt | 4 ++-- lib/claim.ts | 1 - scripts/profile.ts | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 92802df..bbeedb7 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -11,7 +11,7 @@ Summary: │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.320' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.192' │ 0 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ @@ -19,7 +19,7 @@ Summary: │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.320' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.192' │ 0 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ diff --git a/lib/claim.ts b/lib/claim.ts index be00ac3..d214631 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -112,7 +112,6 @@ export async function claimExternal(args: { details?: UniversalDetails; }): Promise { let account = deployer; - // Ugly tmp fix if (args.useTxV3) { account = setDefaultTransactionVersionV3(deployer); } diff --git a/scripts/profile.ts b/scripts/profile.ts index b59a2fb..54e1d9f 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -6,6 +6,7 @@ import { deployer, manager, randomReceiver, + setDefaultTransactionVersionV3, setupGiftProtocol, } from "../lib"; import { newProfiler } from "../lib/gas"; @@ -76,8 +77,8 @@ for (const { giftTokenContract, unit } of tokens) { ); // Profiling getting the dust - factory.connect(deployer); - // TODO useTxV3 not used... + const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + factory.connect(account); await profiler.profile( `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await factory.get_dust(buildCallDataClaim(claim), deployer.address), From ab28b5abaf28e586ea7b7f7769fac6df2a805877 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:22:29 +0200 Subject: [PATCH 12/23] format --- lib/claim.ts | 4 ++-- scripts/profile.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index d214631..333c458 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -108,10 +108,10 @@ export async function claimExternal(args: { dustReceiver?: string; claimPrivateKey: string; useTxV3?: boolean; - overrides?: { claimAccountAddress?: string; factoryAddress?: string;}; + overrides?: { claimAccountAddress?: string; factoryAddress?: string }; details?: UniversalDetails; }): Promise { - let account = deployer; + let account = deployer; if (args.useTxV3) { account = setDefaultTransactionVersionV3(deployer); } diff --git a/scripts/profile.ts b/scripts/profile.ts index 54e1d9f..d43b437 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -77,7 +77,7 @@ for (const { giftTokenContract, unit } of tokens) { ); // Profiling getting the dust - const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; factory.connect(account); await profiler.profile( `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, From 1139cae6f3fa7d72a0c221adf185e33e2f6380a5 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:28:17 +0200 Subject: [PATCH 13/23] remove never used details --- lib/claim.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index 333c458..fd0d6f9 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -109,7 +109,6 @@ export async function claimExternal(args: { claimPrivateKey: string; useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string }; - details?: UniversalDetails; }): Promise { let account = deployer; if (args.useTxV3) { @@ -122,17 +121,13 @@ export async function claimExternal(args: { forceClaimAddress: args.overrides?.claimAccountAddress, dustReceiver: args.dustReceiver, }); - return await account.execute( - [ - { - contractAddress: args.overrides?.factoryAddress || args.claim.factory, - calldata: [buildCallDataClaim(args.claim), args.receiver, args.dustReceiver || "0x0", signature], - entrypoint: "claim_external", - }, - ], - undefined, - { ...args.details }, - ); + return await account.execute([ + { + contractAddress: args.overrides?.factoryAddress || args.claim.factory, + calldata: [buildCallDataClaim(args.claim), args.receiver, args.dustReceiver || "0x0", signature], + entrypoint: "claim_external", + }, + ]); } export async function claimInternal(args: { From 78440f42b165a9631abd31caf5f68578dfd8344a Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:29:54 +0200 Subject: [PATCH 14/23] account ternary operator --- lib/claim.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index fd0d6f9..7d52f3b 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -110,10 +110,8 @@ export async function claimExternal(args: { useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string }; }): Promise { - let account = deployer; - if (args.useTxV3) { - account = setDefaultTransactionVersionV3(deployer); - } + const account = args.useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + const signature = await signExternalClaim({ claim: args.claim, receiver: args.receiver, From eec0a6c59927a12dd5493d67cf657ca6e41cb331 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Fri, 28 Jun 2024 10:54:54 +0200 Subject: [PATCH 15/23] format + update gas report --- gas-report.txt | 32 ++++++++++++++++---------------- lib/claim.ts | 2 +- scripts/profile.ts | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 2fc476c..c8f9ada 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -6,20 +6,20 @@ Summary: │ Transfer STRK (FeeToken: WEI) │ '828.000.000.320' │ 0.0033 │ 828000000000 │ 23 │ 21 │ 2 │ 1 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting WEI (FeeToken: WEI) │ '1.548.000.000.288' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 3 │ 288 │ 'BLOB' │ │ Claiming WEI (FeeToken: WEI) │ '1.188.000.000.192' │ 0.0047 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust WEI (FeeToken: WEI) │ '1.512.000.000.192' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: WEI) │ '1.620.000.000.256' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust WEI (FeeToken: WEI) │ '1.620.000.000.192' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.188.000.000.320' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust WEI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: FRI) │ '1.620.000.000.320' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.728.000.000.320' │ 0.0069 │ 1728000000000 │ 48 │ 45 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.188.000.000.320' │ 0.0047 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust FRI (FeeToken: WEI) │ '1.620.000.000.192' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: WEI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: WEI) │ '1.728.000.000.192' │ 0.0069 │ 1728000000000 │ 48 │ 45 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.188.000.000.192' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust FRI (FeeToken: FRI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: FRI) │ '1.620.000.000.256' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -29,18 +29,18 @@ Resources: │ Transfer STRK (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14624 │ │ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715 │ -│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 433 │ 15372 │ +│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20607 │ │ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ -│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 467 │ 16544 │ +│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20606 │ │ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715 │ -│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 467 │ 16544 │ +│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14625 │ │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ -│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 433 │ 15372 │ +│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/lib/claim.ts b/lib/claim.ts index e93dd82..bcce5e3 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -129,7 +129,7 @@ export async function claimExternal(args: { signature, ]); const response = await account.execute( - executeActionOnAccount("claim_external", calculateEscrowAddress(args.gift), claimExternalCallData) + executeActionOnAccount("claim_external", calculateEscrowAddress(args.gift), claimExternalCallData), ); return manager.waitForTransaction(response.transaction_hash); } diff --git a/scripts/profile.ts b/scripts/profile.ts index a14cfdd..8f2204a 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,9 +1,9 @@ import { + claimDust, claimExternal, claimInternal, defaultDepositTestSetup, deployer, - claimDust, manager, randomReceiver, setDefaultTransactionVersionV3, From b66de94510d6a51022e5a15be7710de5dd3c7052 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Fri, 28 Jun 2024 11:49:00 +0200 Subject: [PATCH 16/23] get dust for multiple claims --- gas-report.txt | 8 ++++++++ scripts/profile.ts | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index c8f9ada..a9c1f55 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -20,6 +20,10 @@ Summary: │ Claiming FRI (FeeToken: FRI) │ '1.188.000.000.192' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.620.000.000.256' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ │ Get dust FRI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust 2 (FeeToken: WEI) │ '2.772.000.000.320' │ 0.011 │ 2772000000000 │ 77 │ 71 │ 3 │ 4 │ 'steps' │ 5 │ 320 │ 'BLOB' │ +│ Get dust 3 (FeeToken: WEI) │ '3.960.000.000.384' │ 0.0158 │ 3960000000000 │ 110 │ 101 │ 4 │ 6 │ 'steps' │ 6 │ 384 │ 'BLOB' │ +│ Get dust 4 (FeeToken: WEI) │ '5.112.000.000.448' │ 0.0204 │ 5112000000000 │ 142 │ 130 │ 5 │ 8 │ 'steps' │ 7 │ 448 │ 'BLOB' │ +│ Get dust 5 (FeeToken: WEI) │ '6.264.000.000.512' │ 0.025 │ 6264000000000 │ 174 │ 160 │ 6 │ 9 │ 'steps' │ 8 │ 512 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -43,4 +47,8 @@ Resources: │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ │ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ │ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ +│ Get dust 2 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 83 │ 0 │ 856 │ 28376 │ +│ Get dust 3 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 117 │ 0 │ 1232 │ 40167 │ +│ Get dust 4 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 151 │ 0 │ 1608 │ 51958 │ +│ Get dust 5 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 185 │ 0 │ 1984 │ 63749 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/scripts/profile.ts b/scripts/profile.ts index 8f2204a..05d9516 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,9 +1,13 @@ +import { CallData } from "starknet"; import { + buildGiftCallData, + calculateEscrowAddress, claimDust, claimExternal, claimInternal, defaultDepositTestSetup, deployer, + executeActionOnAccount, manager, randomReceiver, setDefaultTransactionVersionV3, @@ -38,11 +42,11 @@ await profiler.profile( await strkContract.transfer(randomReceiver(), 1), ); +const receiver = "0x42"; +const { factory } = await setupGiftProtocol(); + for (const { giftTokenContract, unit } of tokens) { for (const useTxV3 of [false, true]) { - const receiver = "0x42"; - const { factory } = await setupGiftProtocol(); - // Profiling deposit const { txReceipt, gift, giftPrivateKey } = await defaultDepositTestSetup({ factory, @@ -86,5 +90,29 @@ for (const { giftTokenContract, unit } of tokens) { } } +const limits = [2, 3, 4, 5]; +for (const limit of limits) { + const claimDustCalls = []; + for (let i = 0; i < limit; i++) { + const { gift, giftPrivateKey } = await defaultDepositTestSetup({ + factory, + overrides: { + giftTokenAddress: ethContract.address, + }, + }); + + await claimInternal({ gift, receiver, giftPrivateKey: giftPrivateKey }); + const claimDustCallData = CallData.compile([buildGiftCallData(gift), receiver]); + const call = executeActionOnAccount("claim_dust", calculateEscrowAddress(gift), claimDustCallData); + + claimDustCalls.push(call); + } + + await profiler.profile( + `Get dust ${limit} (FeeToken: ${manager.tokens.unitTokenContract(false)})`, + await deployer.execute(claimDustCalls), + ); +} + profiler.printSummary(); profiler.updateOrCheckReport(); From e42c4085d8a8e0c3085b1a0b479306b72bbf27c6 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Fri, 28 Jun 2024 15:22:05 +0100 Subject: [PATCH 17/23] update scripts --- scripts/cancel-upgrade.ts | 18 ++++++++++++++++++ scripts/claim-dust.ts | 25 +++++++++++++++---------- scripts/jsonTxBuilder.ts | 8 ++------ scripts/unpause.ts | 18 ++++++++++++++++++ 4 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 scripts/cancel-upgrade.ts create mode 100644 scripts/unpause.ts diff --git a/scripts/cancel-upgrade.ts b/scripts/cancel-upgrade.ts new file mode 100644 index 0000000..0989d5c --- /dev/null +++ b/scripts/cancel-upgrade.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "cancel_upgrade", + calldata: [], +}; + +logTransactionJson([tx]); diff --git a/scripts/claim-dust.ts b/scripts/claim-dust.ts index e4932be..a36302f 100644 --- a/scripts/claim-dust.ts +++ b/scripts/claim-dust.ts @@ -1,23 +1,25 @@ import { CallData } from "starknet"; -import { Claim, buildCallDataClaim } from "../lib/claim"; +import { Gift, buildGiftCallData, executeActionOnAccount } from "../lib/claim"; import { logTransactionJson } from "./jsonTxBuilder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract +/// - escrowAddress: the address of the escrow account /// - dustReceiver: the address of the dust receiver /// - claim: the claim object const factoryAddress = ""; +const escrowAddress = ""; const dustReceiver = ""; -const claim: Claim = { +const claim: Gift = { factory: factoryAddress, - class_hash: "", + escrow_class_hash: "", sender: "", gift_token: "", gift_amount: 0n, fee_token: "", fee_amount: 0n, - claim_pubkey: 0n, + gift_pubkey: 0n, }; if (!factoryAddress) { @@ -28,16 +30,19 @@ if (!dustReceiver) { throw new Error("Dust receiver address is not set. Please set it in the script file."); } +if (!escrowAddress) { + throw new Error("Escrow address is not set. Please set it in the script file."); +} + for (const key in claim) { if (key in claim && !claim[key as keyof typeof claim] && key !== "fee_amount" && key !== "gift_amount") { throw new Error(`The property ${key} is empty in the claim object.`); } } -const tx = { - contractAddress: factoryAddress, - entrypoint: "get_dust", - calldata: CallData.compile([buildCallDataClaim(claim), dustReceiver]), -}; - +const tx = executeActionOnAccount( + "get_dust", + escrowAddress, + CallData.compile([(buildGiftCallData(claim), dustReceiver)]), +); logTransactionJson([tx]); diff --git a/scripts/jsonTxBuilder.ts b/scripts/jsonTxBuilder.ts index f2616c9..31f2b8d 100644 --- a/scripts/jsonTxBuilder.ts +++ b/scripts/jsonTxBuilder.ts @@ -1,9 +1,5 @@ -interface Transaction { - contractAddress: string; - entrypoint: string; - calldata: (string | number | undefined)[]; -} +import { Call } from "starknet"; -export function logTransactionJson(transaction: Transaction[]) { +export function logTransactionJson(transaction: Call[]) { console.log(JSON.stringify(transaction, null, 2)); } diff --git a/scripts/unpause.ts b/scripts/unpause.ts new file mode 100644 index 0000000..5fb1fc7 --- /dev/null +++ b/scripts/unpause.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./jsonTxBuilder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "unpause", + calldata: [], +}; + +logTransactionJson([tx]); From 624857c0557e401ef90d1ae8a2ac52aa3e431cd1 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Fri, 28 Jun 2024 15:44:35 +0100 Subject: [PATCH 18/23] deployment --- Scarb.toml | 3 ++- deployments.txt | 5 +++++ scripts/deploy.ts | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 deployments.txt create mode 100644 scripts/deploy.ts diff --git a/Scarb.toml b/Scarb.toml index d10d58d..f957cbd 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -24,4 +24,5 @@ start-devnet = "docker build -t devnet . && docker run -d -p 127.0.0.1:5050:5050 kill-devnet = "docker ps -q --filter 'ancestor=devnet' | xargs docker stop" test-ts = "scarb --profile release build && yarn tsc && yarn mocha tests-integration/*.test.ts" profile = "scarb --profile release build && node --loader ts-node/esm scripts/profile.ts" -format = "scarb fmt && yarn prettier --write ." \ No newline at end of file +format = "scarb fmt && yarn prettier --write ." +deploy = "scarb --profile release build && node --loader ts-node/esm scripts/deploy.ts" diff --git a/deployments.txt b/deployments.txt new file mode 100644 index 0000000..7072db0 --- /dev/null +++ b/deployments.txt @@ -0,0 +1,5 @@ + +# Sepolia Deployment +GiftFactory address: 0x33ef0f42296853cd65c0e972576604e3c7c43f0a66952e7eaa6d3932bfa2d35 +EscrowAccount class hash: 0x4e2ac27f56cf97077cf43788c831acdc8734e447a5ec676e93101b9dd22eace +EscrowLibrary class hash: 0x4ee1fc3650c515e0c30705c326dbda34a07ebe32bddf39be43b5110dd4ead16 diff --git a/scripts/deploy.ts b/scripts/deploy.ts new file mode 100644 index 0000000..85838a7 --- /dev/null +++ b/scripts/deploy.ts @@ -0,0 +1,12 @@ +import { protocolCache, setupGiftProtocol } from "../lib"; + +const { factory, escrowAccountClassHash, escrowLibraryClassHash } = await setupGiftProtocol(); + +console.log("GiftFactory address:", factory.address); +console.log("EscrowAccount class hash:", escrowAccountClassHash); +console.log("EscrowLibrary class hash:", escrowLibraryClassHash); + +// clear from cache just in case +delete protocolCache["GiftFactory"]; +delete protocolCache["EscrowLibrary"]; +delete protocolCache["EscrowAccount"]; From dd519e89ec4019cb46a5ee27a52fd5c14c78a748 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Fri, 28 Jun 2024 15:53:15 +0100 Subject: [PATCH 19/23] deployed with shared account --- deployments.txt | 5 ++++- scripts/deploy.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/deployments.txt b/deployments.txt index 7072db0..6876c60 100644 --- a/deployments.txt +++ b/deployments.txt @@ -1,5 +1,8 @@ # Sepolia Deployment -GiftFactory address: 0x33ef0f42296853cd65c0e972576604e3c7c43f0a66952e7eaa6d3932bfa2d35 + +GiftFactory classhash: 0x6240992fd28e14bf2757a2b7320831220ffa7816cf962403b13f94aec95d7da +GiftFactory address: 0x7e0f5a5364e197200461a18d695082848b3d4d1e90d3349492263f4c913ae3c +GiftFactory owner: 0x6b054e8dbc5756e3f43b70cf1bfa4639c560898a3c70b2f753ba53bef549a1c EscrowAccount class hash: 0x4e2ac27f56cf97077cf43788c831acdc8734e447a5ec676e93101b9dd22eace EscrowLibrary class hash: 0x4ee1fc3650c515e0c30705c326dbda34a07ebe32bddf39be43b5110dd4ead16 diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 85838a7..546e776 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -1,8 +1,11 @@ -import { protocolCache, setupGiftProtocol } from "../lib"; +import { num } from "starknet"; +import { manager, protocolCache, setupGiftProtocol } from "../lib"; const { factory, escrowAccountClassHash, escrowLibraryClassHash } = await setupGiftProtocol(); +console.log("GiftFactory classhash:", await manager.getClassHashAt(factory.address)); console.log("GiftFactory address:", factory.address); +console.log("GiftFactory owner:", num.toHex(await factory.owner())); console.log("EscrowAccount class hash:", escrowAccountClassHash); console.log("EscrowLibrary class hash:", escrowLibraryClassHash); From 1594ca4df5988fb37355fd9e561afd4c7196242c Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 1 Jul 2024 10:28:35 +0100 Subject: [PATCH 20/23] remove owner --- deployments.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/deployments.txt b/deployments.txt index 6876c60..efb1ca0 100644 --- a/deployments.txt +++ b/deployments.txt @@ -3,6 +3,5 @@ GiftFactory classhash: 0x6240992fd28e14bf2757a2b7320831220ffa7816cf962403b13f94aec95d7da GiftFactory address: 0x7e0f5a5364e197200461a18d695082848b3d4d1e90d3349492263f4c913ae3c -GiftFactory owner: 0x6b054e8dbc5756e3f43b70cf1bfa4639c560898a3c70b2f753ba53bef549a1c EscrowAccount class hash: 0x4e2ac27f56cf97077cf43788c831acdc8734e447a5ec676e93101b9dd22eace EscrowLibrary class hash: 0x4ee1fc3650c515e0c30705c326dbda34a07ebe32bddf39be43b5110dd4ead16 From 10eeca5347f2f2e59306732cc916885236e391cf Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 1 Jul 2024 10:39:26 +0100 Subject: [PATCH 21/23] update claim dust --- scripts/claim-dust.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/scripts/claim-dust.ts b/scripts/claim-dust.ts index a36302f..c5f179d 100644 --- a/scripts/claim-dust.ts +++ b/scripts/claim-dust.ts @@ -1,15 +1,14 @@ import { CallData } from "starknet"; +import { calculateEscrowAddress } from "../lib"; import { Gift, buildGiftCallData, executeActionOnAccount } from "../lib/claim"; import { logTransactionJson } from "./jsonTxBuilder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract -/// - escrowAddress: the address of the escrow account /// - dustReceiver: the address of the dust receiver /// - claim: the claim object const factoryAddress = ""; -const escrowAddress = ""; const dustReceiver = ""; const claim: Gift = { factory: factoryAddress, @@ -30,10 +29,6 @@ if (!dustReceiver) { throw new Error("Dust receiver address is not set. Please set it in the script file."); } -if (!escrowAddress) { - throw new Error("Escrow address is not set. Please set it in the script file."); -} - for (const key in claim) { if (key in claim && !claim[key as keyof typeof claim] && key !== "fee_amount" && key !== "gift_amount") { throw new Error(`The property ${key} is empty in the claim object.`); @@ -41,8 +36,8 @@ for (const key in claim) { } const tx = executeActionOnAccount( - "get_dust", - escrowAddress, + "claim_dust", + calculateEscrowAddress(claim), CallData.compile([(buildGiftCallData(claim), dustReceiver)]), ); logTransactionJson([tx]); From 936ef2800bf23c75aa9129ad392f24944c737619 Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 1 Jul 2024 10:46:57 +0100 Subject: [PATCH 22/23] rename file to snake --- scripts/{cancel-upgrade.ts => cancel_upgrade.ts} | 2 +- scripts/{claim-dust.ts => claim_dust.ts} | 2 +- scripts/{jsonTxBuilder.ts => json_tx_builder.ts} | 0 scripts/pause.ts | 2 +- scripts/{propose-upgrade.ts => propose_upgrade.ts} | 0 scripts/unpause.ts | 2 +- scripts/upgrade.ts | 2 +- 7 files changed, 5 insertions(+), 5 deletions(-) rename scripts/{cancel-upgrade.ts => cancel_upgrade.ts} (87%) rename scripts/{claim-dust.ts => claim_dust.ts} (95%) rename scripts/{jsonTxBuilder.ts => json_tx_builder.ts} (100%) rename scripts/{propose-upgrade.ts => propose_upgrade.ts} (100%) diff --git a/scripts/cancel-upgrade.ts b/scripts/cancel_upgrade.ts similarity index 87% rename from scripts/cancel-upgrade.ts rename to scripts/cancel_upgrade.ts index 0989d5c..034eda8 100644 --- a/scripts/cancel-upgrade.ts +++ b/scripts/cancel_upgrade.ts @@ -1,4 +1,4 @@ -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract diff --git a/scripts/claim-dust.ts b/scripts/claim_dust.ts similarity index 95% rename from scripts/claim-dust.ts rename to scripts/claim_dust.ts index c5f179d..6b2fb73 100644 --- a/scripts/claim-dust.ts +++ b/scripts/claim_dust.ts @@ -1,7 +1,7 @@ import { CallData } from "starknet"; import { calculateEscrowAddress } from "../lib"; import { Gift, buildGiftCallData, executeActionOnAccount } from "../lib/claim"; -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract diff --git a/scripts/jsonTxBuilder.ts b/scripts/json_tx_builder.ts similarity index 100% rename from scripts/jsonTxBuilder.ts rename to scripts/json_tx_builder.ts diff --git a/scripts/pause.ts b/scripts/pause.ts index 371a7e4..c7c1889 100644 --- a/scripts/pause.ts +++ b/scripts/pause.ts @@ -1,4 +1,4 @@ -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract diff --git a/scripts/propose-upgrade.ts b/scripts/propose_upgrade.ts similarity index 100% rename from scripts/propose-upgrade.ts rename to scripts/propose_upgrade.ts diff --git a/scripts/unpause.ts b/scripts/unpause.ts index 5fb1fc7..3c64e00 100644 --- a/scripts/unpause.ts +++ b/scripts/unpause.ts @@ -1,4 +1,4 @@ -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts index cdbd03b..9168a60 100644 --- a/scripts/upgrade.ts +++ b/scripts/upgrade.ts @@ -1,5 +1,5 @@ import { CallData } from "starknet"; -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract From 570b9b9ac226224bb7322f6404d196e2a3eb052a Mon Sep 17 00:00:00 2001 From: Leonard Paturel Date: Mon, 1 Jul 2024 10:51:56 +0100 Subject: [PATCH 23/23] import --- scripts/propose_upgrade.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/propose_upgrade.ts b/scripts/propose_upgrade.ts index bc24f7e..49e64bf 100644 --- a/scripts/propose_upgrade.ts +++ b/scripts/propose_upgrade.ts @@ -1,5 +1,5 @@ import { CallData } from "starknet"; -import { logTransactionJson } from "./jsonTxBuilder"; +import { logTransactionJson } from "./json_tx_builder"; /// To use this script, fill in the following value: /// - factoryAddress: the address of the factory contract