Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
feat: accept providedNonce (#247)
Browse files Browse the repository at this point in the history
* feat: accept providedNonce

* feat: ignore nonce for estimateFee call
  • Loading branch information
Sekhmet authored Jan 8, 2024
1 parent fd85846 commit 84945f8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/clients/starknet/starknet-tx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ type UpdateSettingsInput = {
votingStrategyMetadataUrisToAdd?: string[];
};

type Opts = {
nonce?: string;
};

const NO_UPDATE_U32 = '0xf2cda9b1';
const NO_UPDATE_ADDRESS = '0xf2cda9b13ed04e585461605c0d6e804933ca828111bd94d4e6a96c75e8b048';
const NO_UPDATE_STRING = 'No update';
Expand Down Expand Up @@ -133,7 +137,7 @@ export class StarknetTx {
);
}

async propose(account: Account, envelope: Envelope<Propose>) {
async propose(account: Account, envelope: Envelope<Propose>, opts?: Opts) {
const authorAddress = envelope.signatureData?.address || account.address;

const authenticator = getAuthenticator(envelope.data.authenticator, this.config.networkConfig);
Expand Down Expand Up @@ -163,10 +167,11 @@ export class StarknetTx {

const calls = [call];

return account.execute(calls);
const fee = await account.estimateFee(calls);
return account.execute(calls, undefined, { ...opts, maxFee: fee.suggestedMaxFee });
}

async updateProposal(account: Account, envelope: Envelope<UpdateProposal>) {
async updateProposal(account: Account, envelope: Envelope<UpdateProposal>, opts?: Opts) {
const authorAddress = envelope.signatureData?.address || account.address;

const authenticator = getAuthenticator(envelope.data.authenticator, this.config.networkConfig);
Expand All @@ -186,10 +191,11 @@ export class StarknetTx {

const calls = [call];

return account.execute(calls);
const fee = await account.estimateFee(calls);
return account.execute(calls, undefined, { ...opts, maxFee: fee.suggestedMaxFee });
}

async vote(account: Account, envelope: Envelope<Vote>) {
async vote(account: Account, envelope: Envelope<Vote>, opts?: Opts) {
const voterAddress = envelope.signatureData?.address || account.address;

const authenticator = getAuthenticator(envelope.data.authenticator, this.config.networkConfig);
Expand All @@ -213,7 +219,8 @@ export class StarknetTx {
metadataUri: ''
});

return account.execute(call);
const fee = await account.estimateFee(call);
return account.execute(call, undefined, { ...opts, maxFee: fee.suggestedMaxFee });
}

execute({
Expand Down

0 comments on commit 84945f8

Please sign in to comment.