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

Commit

Permalink
add random value as a note on submit tx
Browse files Browse the repository at this point in the history
To make sure the transaction is accepted.
There might be a scenario where the same transaction is already on the transaction pool
and it hasn't been finalised.
  • Loading branch information
seromenho committed Oct 25, 2022
1 parent 6f7a12e commit 2ed6544
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion services/app/src/utils/algo-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export const getGlobalStateValue = async (
return getValueFromKeyValue(keyValue, false)
}

const encoder = new TextEncoder()

export const submitValue = async (
client: algosdk.Algodv2,
blockNumber: number,
Expand All @@ -75,6 +77,8 @@ export const submitValue = async (
const sp = await client.getTransactionParams().do()
const comp = new algosdk.AtomicTransactionComposer()

const timestamp = Date.now()
const note = encoder.encode(timestamp.toString())
sp.firstRound = blockNumber + 1
sp.lastRound = sp.firstRound + 1000
comp.addMethodCall({
Expand All @@ -84,10 +88,12 @@ export const submitValue = async (
sender: serviceAccount.addr,
suggestedParams: sp,
signer,
note,
})

for (let i = 0; i < numDummyTransactions; i++) {
const txn = algosdk.makeApplicationNoOpTxn(serviceAccount.addr, sp, dummyAppId, [], [], [], [], new Uint8Array([i]))
const dummyTxNote = encoder.encode(`${i}-${timestamp.toString()}`)
const txn = algosdk.makeApplicationNoOpTxn(serviceAccount.addr, sp, dummyAppId, [], [], [], [], dummyTxNote)
comp.addTransaction({ txn, signer })
}

Expand Down

0 comments on commit 2ed6544

Please sign in to comment.