Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/abstraction/Identities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export class Identities {
const tx = DemosTransactions.empty()
const ed25519 = await demos.crypto.getIdentity("ed25519")
const address = uint8ArrayToHex(ed25519.publicKey as Uint8Array)
// Use the address' current nonce (+1) like every other native tx in
// this SDK — hardcoding nonce:1 only validated for a fresh account and
// broke the second identity op (e.g. remove after add).
const nonce = await demos.getAddressNonce(address)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect confirm() and getAddressNonce() to confirm sequencing guarantees.
fd -t f 'demosclass.ts' --exec ast-grep outline {} \;
rg -nP --type=ts -C8 '\b(confirm|getAddressNonce)\s*\(' src/websdk/demosclass.ts

Repository: kynesyslabs/sdks

Length of output: 3584


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the confirm path and nonce lookup behavior around the relevant methods.
ast-grep outline src/websdk/demosclass.ts --view expanded | sed -n '1,220p'
printf '\n--- confirm/getAddressNonce context ---\n'
sed -n '430,520p' src/websdk/demosclass.ts
printf '\n--- getAddressNonce context ---\n'
sed -n '1298,1335p' src/websdk/demosclass.ts
printf '\n--- DemosTransactions references ---\n'
rg -n -C 6 'class DemosTransactions|static confirm|confirm\(transaction|broadcastAndWait|broadcast\(' src/websdk/demosclass.ts

Repository: kynesyslabs/sdks

Length of output: 10224


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the confirm path and nonce lookup behavior around the relevant methods.
ast-grep outline src/websdk/demosclass.ts --view expanded | sed -n '1,220p'
printf '\n--- confirm/getAddressNonce context ---\n'
sed -n '430,520p' src/websdk/demosclass.ts
printf '\n--- getAddressNonce context ---\n'
sed -n '1298,1335p' src/websdk/demosclass.ts
printf '\n--- DemosTransactions references ---\n'
rg -n -C 6 'class DemosTransactions|static confirm|confirm\(transaction|broadcastAndWait|broadcast\(' src/websdk/demosclass.ts

Repository: kynesyslabs/sdks

Length of output: 10224


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the DemosTransactions implementation and inspect confirm/broadcast semantics.
fd -t f . src/websdk | sed -n '1,200p'
printf '\n--- search ---\n'
rg -n -C 8 'class DemosTransactions|confirm\(transaction|broadcastAndWait|getTransactionStatus|getAddressNonce' src/websdk

Repository: kynesyslabs/sdks

Length of output: 25480


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the DemosTransactions implementation and inspect confirm/broadcast semantics.
fd -t f . src/websdk | sed -n '1,200p'
printf '\n--- search ---\n'
rg -n -C 8 'class DemosTransactions|confirm\(transaction|broadcastAndWait|getTransactionStatus|getAddressNonce' src/websdk

Repository: kynesyslabs/sdks

Length of output: 25480


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the reviewed file and the transaction confirmation implementation.
ast-grep outline src/abstraction/Identities.ts --view expanded | sed -n '1,220p'
printf '\n--- identities excerpt ---\n'
sed -n '120,210p' src/abstraction/Identities.ts
printf '\n--- DemosTransactions.confirm implementation ---\n'
sed -n '1,360p' src/websdk/DemosTransactions.ts | sed -n '300,360p'

Repository: kynesyslabs/sdks

Length of output: 8195


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the reviewed file and the transaction confirmation implementation.
ast-grep outline src/abstraction/Identities.ts --view expanded | sed -n '1,220p'
printf '\n--- identities excerpt ---\n'
sed -n '120,210p' src/abstraction/Identities.ts
printf '\n--- DemosTransactions.confirm implementation ---\n'
sed -n '1,360p' src/websdk/DemosTransactions.ts | sed -n '300,360p'

Repository: kynesyslabs/sdks

Length of output: 8195


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the confirm implementation and nearby transaction flow.
rg -n -C 12 'confirm: async function|confirm\s*\(' src/websdk/DemosTransactions.ts
sed -n '240,340p' src/websdk/DemosTransactions.ts

Repository: kynesyslabs/sdks

Length of output: 4390


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the confirm implementation and nearby transaction flow.
rg -n -C 12 'confirm: async function|confirm\s*\(' src/websdk/DemosTransactions.ts
sed -n '240,340p' src/websdk/DemosTransactions.ts

Repository: kynesyslabs/sdks

Length of output: 4390


Wait for the add tx to land before fetching the next nonce. demos.confirm() only runs confirmTx validation and returns immediately; it does not wait for on-chain inclusion. In the remove-after-add flow, use broadcastAndWait() or poll getTransactionStatus before calling getAddressNonce(), or the second tx can reuse the old nonce and collide.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/abstraction/Identities.ts` at line 142, The add/remove flow in
Identities.ts is fetching the next nonce too early because demos.confirm() only
validates the tx and does not wait for on-chain inclusion. Update the logic
around the add transaction and the subsequent getAddressNonce() call to wait
until the add tx is actually landed, using broadcastAndWait() or polling
getTransactionStatus() first, so the remove tx does not reuse the old nonce.


tx.content = {
...tx.content,
Expand All @@ -150,7 +154,7 @@ export class Identities {
payload: payload,
},
],
nonce: 1,
nonce: nonce + 1,
timestamp: Date.now(),
}

Expand All @@ -174,6 +178,10 @@ export class Identities {

const ed25519 = await demos.crypto.getIdentity("ed25519")
const address = uint8ArrayToHex(ed25519.publicKey as Uint8Array)
// Use the address' current nonce (+1) like every other native tx in
// this SDK — hardcoding nonce:1 broke removing an identity once the
// account had already done one identity op (e.g. the add).
const nonce = await demos.getAddressNonce(address)

tx.content = {
...tx.content,
Expand All @@ -188,7 +196,7 @@ export class Identities {
payload: payload,
},
],
nonce: 1,
nonce: nonce + 1,
timestamp: Date.now(),
}

Expand Down