Skip to content

Commit

Permalink
Merge pull request argentlabs#1995 from argentlabs/cleanup/deployment…
Browse files Browse the repository at this point in the history
…-logic

fix: cleanup deployment logic
  • Loading branch information
gergold committed Apr 5, 2023
2 parents dc7dc7b + 000ad58 commit 926952c
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions packages/extension/src/background/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import {
getPreDeployedAccount,
} from "./devnet/declareAccounts"
import {
getIndexForPath,
getNextPathIndex,
getPathForIndex,
getStarkPair,
Expand Down Expand Up @@ -447,17 +446,15 @@ export class Wallet {

const index = getNextPathIndex(currentPaths, baseDerivationPath)

const payload = await this.getDeployContractPayloadForAccountIndex(
index,
networkId,
)
const { addressSalt, constructorCalldata } =
await this.getDeployContractPayloadForAccountIndex(index, networkId)

const proxyClassHash = PROXY_CONTRACT_CLASS_HASHES[0]

const proxyAddress = calculateContractAddressFromHash(
payload.addressSalt,
addressSalt,
proxyClassHash,
payload.constructorCalldata,
constructorCalldata,
0,
)

Expand Down Expand Up @@ -524,29 +521,14 @@ export class Wallet {
if (!this.isSessionOpen()) {
throw Error("no open session")
}
const networkId = account.networkId
const network = await this.getNetwork(networkId)

const provider = getProvider(network)

const index = getIndexForPath(
account.signer.derivationPath,
baseDerivationPath,
)

const payload = await this.getDeployContractPayloadForAccountIndex(
index,
networkId,
)

const nonce = await getNonce(account, this)

const deployTransaction = await provider.deployAccountContract(payload, {
nonce,
})
const deployTransaction = await this.deployAccount(account, { nonce })

await increaseStoredNonce(account)

return { account, txHash: deployTransaction.transaction_hash }
return { account, txHash: deployTransaction.txHash }
}
/** Get the Account Deployment Payload
* Use it in the deployAccount and getAccountDeploymentFee methods
Expand Down Expand Up @@ -613,10 +595,10 @@ export class Wallet {
return deployAccountPayload
}

public async getDeployContractPayloadForAccountIndex(
private async getDeployContractPayloadForAccountIndex(
index: number,
networkId: string,
): Promise<Required<DeployAccountContractTransaction>> {
): Promise<Omit<Required<DeployAccountContractTransaction>, "signature">> {
const hasSession = await this.isSessionOpen()
const session = await this.sessionStore.get()
const initialised = await this.isInitialized()
Expand Down Expand Up @@ -645,7 +627,6 @@ export class Wallet {
calldata: stark.compileCalldata({ signer: starkPub, guardian: "0" }),
}),
addressSalt: starkPub,
signature: [],
}

return payload
Expand Down

0 comments on commit 926952c

Please sign in to comment.