Skip to content

Commit

Permalink
refactor!: remove getAccountNonce
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `getAccountNonce` removed
Use `node.getAccountNextNonce` instead.
  • Loading branch information
davidyuk committed Jun 15, 2022
1 parent 6d76175 commit 46ede9f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
18 changes: 0 additions & 18 deletions src/tx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,6 @@ export async function calculateTtl (
return ttl
}

/**
* Get the next nonce to be used for a transaction for an account
*
* @param accountId
* @param nonce
* @returns Next Nonce
*/
export async function getAccountNonce (
accountId: string,
{ nonce, onNode }:
{ nonce: number, onNode: Node }
): Promise<number> {
if (nonce != null) return nonce
const { nonce: accountNonce } = await onNode.getAccountByPubkey(accountId)
.catch(() => ({ nonce: 0 }))
return accountNonce + 1
}

/**
* Calculate fee, get absolute ttl (ttl + height), get account nonce
*
Expand Down
6 changes: 0 additions & 6 deletions test/integration/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,4 @@ describe('Transaction', function () {
it(`build of ${name} transaction`, async () => {
expect(await getter()).to.be.equal(expected)
}))

it('Get next account nonce', async () => {
const { nonce: accountNonce } = await aeSdk.api.getAccountByPubkey(address)
expect(await aeSdk.getAccountNonce(address)).to.be.equal(+accountNonce + 1)
expect(await aeSdk.getAccountNonce(address, { nonce: 1 })).to.be.equal(1)
})
})

0 comments on commit 46ede9f

Please sign in to comment.