From 4dce1f467ad6050f1177eb2c61cd85411105bcad Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 21 Dec 2023 14:33:01 -0800 Subject: [PATCH] fix default salt for create (#300) --- .changeset/chilled-pants-compete.md | 6 ++++++ packages/legacy-sdk/src/client/edition/create.ts | 4 ++-- packages/sdk/src/contract/edition-v2/read/create.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/chilled-pants-compete.md diff --git a/.changeset/chilled-pants-compete.md b/.changeset/chilled-pants-compete.md new file mode 100644 index 00000000..3ae9f069 --- /dev/null +++ b/.changeset/chilled-pants-compete.md @@ -0,0 +1,6 @@ +--- +'@soundxyz/legacy-sdk': minor +'@soundxyz/sdk': minor +--- + +Fix default salt for create diff --git a/packages/legacy-sdk/src/client/edition/create.ts b/packages/legacy-sdk/src/client/edition/create.ts index 64505675..d0a72f1a 100644 --- a/packages/legacy-sdk/src/client/edition/create.ts +++ b/packages/legacy-sdk/src/client/edition/create.ts @@ -50,7 +50,7 @@ async function createEditionHelper( maxPriorityFeePerGas, } - const formattedSalt = keccak256(toHex(customSalt || Math.random() * 1_000_000_000_000_000)) + const formattedSalt = keccak256(toHex(customSalt || Math.floor(Math.random() * 1_000_000_000_000_000))) // Precompute the edition address. const [editionAddress, _] = await retry( @@ -355,7 +355,7 @@ export async function expectedEditionAddress( { deployer, salt: customSalt }: { deployer: Address; salt: string | number }, ) { const { readContract } = await this.expectClient() - const formattedSalt = keccak256(toHex(customSalt || Math.random() * 1_000_000_000_000_000)) + const formattedSalt = keccak256(toHex(customSalt)) const [editionAddress, exists] = await readContract({ abi: soundCreatorV1Abi, diff --git a/packages/sdk/src/contract/edition-v2/read/create.ts b/packages/sdk/src/contract/edition-v2/read/create.ts index 7cbc6e4a..0d1f7d47 100644 --- a/packages/sdk/src/contract/edition-v2/read/create.ts +++ b/packages/sdk/src/contract/edition-v2/read/create.ts @@ -320,7 +320,7 @@ export async function getExpectedEditionAddress { - const formattedSalt = keccak256(toHex(customSalt || Math.random() * 1_000_000_000_000_000)) + const formattedSalt = keccak256(toHex(customSalt || Math.floor(Math.random() * 1_000_000_000_000_000))) const [edition, exists] = await client.readContract({ abi: SOUND_CREATOR_V2_ABI,