Skip to content

Commit

Permalink
fix default salt for create (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshka committed Dec 21, 2023
1 parent 6f7f687 commit 4dce1f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-pants-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@soundxyz/legacy-sdk': minor
'@soundxyz/sdk': minor
---

Fix default salt for create
4 changes: 2 additions & 2 deletions packages/legacy-sdk/src/client/edition/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/contract/edition-v2/read/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export async function getExpectedEditionAddress<Client extends Pick<PublicClient
client: Client,
{ deployer, salt: customSalt }: GetExpectedEditionAddressParams,
): Promise<GetExpectedEditionAddressReturnType> {
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,
Expand Down

0 comments on commit 4dce1f4

Please sign in to comment.