Skip to content

Commit

Permalink
fix(ui): update simulate params to use skipSignatures
Browse files Browse the repository at this point in the history
Remove `makeEmptyTransactionSigner` in favor of `skipSignatures` flag for
simulate transactions. This aligns with updated algosdk best practices for
handling simulate calls without signatures (from normal or rekeyed accounts).
  • Loading branch information
drichar committed Dec 6, 2024
1 parent ee8698f commit a0efd10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
4 changes: 1 addition & 3 deletions ui/src/api/clients.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import algosdk, { makeEmptyTransactionSigner } from 'algosdk'
import algosdk from 'algosdk'
import { FEE_SINK } from '@/constants/accounts'
import { StakingPoolClient, StakingPoolFactory } from '@/contracts/StakingPoolClient'
import { ValidatorRegistryClient } from '@/contracts/ValidatorRegistryClient'
Expand Down Expand Up @@ -31,7 +31,6 @@ export async function getSimulateValidatorClient(
): Promise<ValidatorRegistryClient> {
return algorandClient.client.getTypedAppClientById(ValidatorRegistryClient, {
defaultSender: senderAddr,
defaultSigner: makeEmptyTransactionSigner(),
appId: RETI_APP_ID,
})
}
Expand All @@ -54,7 +53,6 @@ export async function getSimulateStakingPoolClient(
): Promise<StakingPoolClient> {
return algorandClient.client.getTypedAppClientById(StakingPoolClient, {
defaultSender: senderAddr,
defaultSigner: makeEmptyTransactionSigner(),
appId: poolAppId,
})
}
19 changes: 7 additions & 12 deletions ui/src/api/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ export async function addValidator(
const { addValidatorMbr } = (
await validatorClient.send.getMbrAmounts({
args: {},
signer: algosdk.makeEmptyTransactionSigner(),
})
).return!

Expand Down Expand Up @@ -467,7 +466,7 @@ export async function findPoolForStaker(
},
extraFee: AlgoAmount.MicroAlgos(1000),
})
.simulate({ allowEmptySignatures: true, allowUnnamedResources: true })
.simulate({ skipSignatures: true, allowUnnamedResources: true })

const errorMessage = result.simulateResponse.txnGroups[0].failureMessage

Expand Down Expand Up @@ -531,11 +530,11 @@ export async function addStake(
suggestedParams,
})

simulateComposer.addTransaction(rewardTokenOptInTxn, algosdk.makeEmptyTransactionSigner())
simulateComposer.addTransaction(rewardTokenOptInTxn)
}

const simulateResults = await simulateComposer.simulate({
allowEmptySignatures: true,
skipSignatures: true,
allowUnnamedResources: true,
})

Expand Down Expand Up @@ -784,11 +783,11 @@ export async function removeStake(
suggestedParams,
})

simulateComposer.addTransaction(rewardTokenOptInTxn, algosdk.makeEmptyTransactionSigner())
simulateComposer.addTransaction(rewardTokenOptInTxn)
}

const simulateResult = await simulateComposer.simulate({
allowEmptySignatures: true,
skipSignatures: true,
allowUnnamedResources: true,
})

Expand Down Expand Up @@ -847,20 +846,17 @@ export async function epochBalanceUpdate(
args: [],
note: '1',
staticFee: AlgoAmount.MicroAlgos(0),
signer: algosdk.makeEmptyTransactionSigner(),
})
.gas({
args: [],
note: '2',
staticFee: AlgoAmount.MicroAlgos(0),
signer: algosdk.makeEmptyTransactionSigner(),
})
.epochBalanceUpdate({
args: {},
staticFee: AlgoAmount.MicroAlgos(240_000),
signer: algosdk.makeEmptyTransactionSigner(),
})
.simulate({ allowEmptySignatures: true, allowUnnamedResources: true })
.simulate({ skipSignatures: true, allowUnnamedResources: true })

const feeAmount = AlgoAmount.MicroAlgos(
1000 *
Expand Down Expand Up @@ -978,7 +974,6 @@ export async function claimTokens(
const client = stakingFactory.getAppClientById({
appId: pool.poolAppId,
defaultSender: activeAddress,
defaultSigner: algosdk.makeEmptyTransactionSigner(),
})
feeComposer
.addAppCallMethodCall(
Expand All @@ -993,7 +988,7 @@ export async function claimTokens(
}

const simulateResult = await feeComposer.simulate({
allowEmptySignatures: true,
skipSignatures: true,
allowUnnamedResources: true,
})

Expand Down

0 comments on commit a0efd10

Please sign in to comment.