From d22e29c49c5a91e8c05a50646bef1904747e1bc4 Mon Sep 17 00:00:00 2001 From: HaykK-Solicy Date: Wed, 24 Jun 2026 12:34:32 +0400 Subject: [PATCH] fix(identities): assign real nonce to identity txs instead of hardcoded 1 inferIdentity (add/link) and removeIdentity (remove) both hardcoded nonce:1. That only validates for a fresh account (nonce 0): the first identity op succeeds and bumps the on-chain nonce, so the second (e.g. removing an XM wallet right after adding it) is rejected with '[NONCE ERROR] Nonce not assigned'. Both now fetch demos.getAddressNonce(address) and use nonce+1, matching every other native tx in the SDK (DemosTransactions.pay, nativeBridge, ContractDeployer). --- src/abstraction/Identities.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/abstraction/Identities.ts b/src/abstraction/Identities.ts index 49f34c0..f2d2c5d 100644 --- a/src/abstraction/Identities.ts +++ b/src/abstraction/Identities.ts @@ -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) tx.content = { ...tx.content, @@ -150,7 +154,7 @@ export class Identities { payload: payload, }, ], - nonce: 1, + nonce: nonce + 1, timestamp: Date.now(), } @@ -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, @@ -188,7 +196,7 @@ export class Identities { payload: payload, }, ], - nonce: 1, + nonce: nonce + 1, timestamp: Date.now(), }