Skip to content

Commit

Permalink
packages-ts: allow seed of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
cfal committed Mar 19, 2024
1 parent 80ad49d commit 8b1c6b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const makeUserInput = async (flags, _, env): Promise<UserInput> => {
const keypair = ec.starkCurve.utils.randomPrivateKey()
const generatedPK = '0x' + Buffer.from(keypair).toString('hex')
const pubkey = flags.publicKey || env.publicKey || ec.starkCurve.getStarkKey(keypair)
const salt: number = flags.salt ? +flags.salt : undefined
const salt: number = !isNaN(flags.salt) ? +flags.salt : undefined
return {
publicKey: pubkey,
privateKey: (!flags.publicKey || !env.account) && generatedPK,
Expand Down Expand Up @@ -64,7 +64,7 @@ const beforeExecute: BeforeExecute<UserInput, ContractInput> = (
) => async () => {
deps.logger.info(`About to deploy an OZ 0.x Account Contract with:
public key: ${input.contract[0]}
salt: ${input.user.salt || 'randomly generated'}
salt: ${!isNaN(input.user.salt) ? input.user.salt : 'randomly generated'}
action: ${context.action}`)
if (input.user.privateKey) {
await deps.prompt(`The generated private key will be shown next, continue?`)
Expand Down
4 changes: 2 additions & 2 deletions packages-ts/starknet-gauntlet/src/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Provider implements IStarknetProvider {
const tx = await this.account.declareAndDeploy({
contract,
compiledClassHash,
salt: salt ? '0x' + salt.toString(16) : salt, // convert number to hex or leave undefined
salt: !isNaN(salt) ? '0x' + salt.toString(16) : salt, // convert number to hex or leave undefined
// unique: false,
...(!!input && input.length > 0 && { constructorCalldata: input }),
})
Expand Down Expand Up @@ -162,7 +162,7 @@ class Provider implements IStarknetProvider {
deployContract = async (classHash: string, input: any = [], wait = true, salt = undefined) => {
const tx = await this.account.deployContract({
classHash: classHash,
salt: salt ? '0x' + salt.toString(16) : salt,
salt: !isNaN(salt) ? '0x' + salt.toString(16) : salt,
...(!!input && input.length > 0 && { constructorCalldata: input }),
})
const response = wrapResponse(this, tx)
Expand Down

0 comments on commit 8b1c6b8

Please sign in to comment.