@talken/talkenkit 2.8.5 → 2.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/{abcWallet-EOHU5AIB.js → abcWallet-WTHSP3A6.js} +22 -25
  2. package/dist/{chunk-WGSS57V6.js → chunk-S3KOGN7P.js} +2540 -715
  3. package/dist/gasless/api/ChainConfigApi.d.ts +2 -2
  4. package/dist/gasless/index.d.ts +1 -1
  5. package/dist/gasless/services/GaslessTransferService.d.ts +4 -3
  6. package/dist/gasless/signer/AbcWaasSigner.d.ts +9 -0
  7. package/dist/gasless/signer/GaslessSigner.d.ts +10 -0
  8. package/dist/gasless/signer/WagmiSigner.d.ts +40 -0
  9. package/dist/gasless/signer/index.d.ts +1 -1
  10. package/dist/gasless/utils/delegationGuard.d.ts +11 -11
  11. package/dist/gasless/utils/revokeDelegation.d.ts +22 -23
  12. package/dist/hooks/useMultiChainBalances.d.ts +2 -0
  13. package/dist/index.css +5 -3
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +1279 -584
  16. package/dist/services/AbcAuthService.d.ts +12 -1
  17. package/dist/solana/clusterIdentity.d.ts +5 -0
  18. package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.d.ts +0 -1
  19. package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +3 -3
  20. package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +4 -4
  21. package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.d.ts +11 -0
  22. package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.js +5 -2
  23. package/dist/wallets/walletConnectors/abcWallet/StorageService.js +2 -2
  24. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.d.ts +2 -0
  25. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +7 -5
  26. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.d.ts +1 -0
  27. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +10 -9
  28. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +23 -21
  29. package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +1 -0
  30. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +12 -11
  31. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +26 -24
  32. package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.d.ts +3 -0
  33. package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +183 -62
  34. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +1 -0
  35. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +10 -9
  36. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +24 -22
  37. package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.d.ts +1 -0
  38. package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.js +10 -9
  39. package/dist/wallets/walletConnectors/abcWallet/api/AccessKeySessionBinding.d.ts +10 -0
  40. package/dist/wallets/walletConnectors/abcWallet/api/AccessKeySessionBinding.js +13 -0
  41. package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +5 -2
  42. package/dist/wallets/walletConnectors/abcWallet/api/GasApi.js +5 -1
  43. package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.js +5 -1
  44. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +34 -12
  45. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +19 -16
  46. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.d.ts +6 -0
  47. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.js +10 -1
  48. package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +5 -2
  49. package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +13 -3
  50. package/dist/wallets/walletConnectors/abcWallet/api/index.js +26 -23
  51. package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.d.ts +20 -10
  52. package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.js +3 -3
  53. package/dist/wallets/walletConnectors/abcWallet/api/modules/bitcoin.js +11 -9
  54. package/dist/wallets/walletConnectors/abcWallet/api/modules/evm.d.ts +1 -1
  55. package/dist/wallets/walletConnectors/abcWallet/api/modules/evm.js +10 -8
  56. package/dist/wallets/walletConnectors/abcWallet/api/modules/executeBodies.js +4 -3
  57. package/dist/wallets/walletConnectors/abcWallet/api/modules/signBodies.js +2 -2
  58. package/dist/wallets/walletConnectors/abcWallet/api/modules/signingRefresh.js +6 -5
  59. package/dist/wallets/walletConnectors/abcWallet/api/modules/solana.js +6 -5
  60. package/dist/wallets/walletConnectors/abcWallet/api/modules/tron.js +10 -8
  61. package/dist/wallets/walletConnectors/abcWallet/api/modules/wallet.d.ts +2 -1
  62. package/dist/wallets/walletConnectors/abcWallet/api/modules/wallet.js +2 -2
  63. package/dist/wallets/walletConnectors/abcWallet/api/modules/walletscan.js +2 -2
  64. package/dist/wallets/walletConnectors/abcWallet/api/modules/xrp.js +10 -8
  65. package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +18 -6
  66. package/dist/wallets/walletConnectors/abcWallet/constants.js +13 -3
  67. package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -0
  68. package/dist/wallets/walletConnectors/abcWallet/index.js +40 -38
  69. package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +11 -3
  70. package/dist/wallets/walletConnectors/abcWallet/types/auth.types.d.ts +75 -0
  71. package/dist/wallets/walletConnectors/abcWallet/types/error.types.d.ts +2 -0
  72. package/dist/wallets/walletConnectors/abcWallet/types/error.types.js +5 -3
  73. package/dist/wallets/walletConnectors/abcWallet/types.js +5 -3
  74. package/dist/wallets/walletConnectors/abcWallet/utils.js +4 -4
  75. package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +6 -5
  76. package/dist/wallets/walletConnectors/chunk-2YCHXOLC.js +53 -0
  77. package/dist/wallets/walletConnectors/{chunk-6MZWQBNQ.js → chunk-3RUQ4ARU.js} +3 -3
  78. package/dist/wallets/walletConnectors/{chunk-MNGSJBPX.js → chunk-3XZJNLAA.js} +128 -77
  79. package/dist/wallets/walletConnectors/chunk-4UMY2AY7.js +414 -0
  80. package/dist/wallets/walletConnectors/chunk-5GTFKQGQ.js +739 -0
  81. package/dist/wallets/walletConnectors/{chunk-XGQUYXTL.js → chunk-5KPLYJOO.js} +12 -407
  82. package/dist/wallets/walletConnectors/{chunk-EGLT3GPM.js → chunk-5V5TLGH6.js} +58 -7
  83. package/dist/wallets/walletConnectors/{chunk-SUPFF4EQ.js → chunk-5ZTGAJ4K.js} +538 -191
  84. package/dist/wallets/walletConnectors/{chunk-PL56SINL.js → chunk-6GE2YBW5.js} +1 -1
  85. package/dist/wallets/walletConnectors/{chunk-M4SNNQU2.js → chunk-AROBVCG2.js} +29 -6
  86. package/dist/wallets/walletConnectors/{chunk-OTLZVWY7.js → chunk-BAKRM7LQ.js} +3 -1
  87. package/dist/wallets/walletConnectors/{chunk-6X2XITQP.js → chunk-BGDDDPVU.js} +3 -3
  88. package/dist/wallets/walletConnectors/{chunk-365TL36N.js → chunk-C3MTWYLE.js} +106 -53
  89. package/dist/wallets/walletConnectors/{chunk-UHVJ6AF6.js → chunk-CBXCYWLB.js} +6 -5
  90. package/dist/wallets/walletConnectors/{chunk-5SRSGEZR.js → chunk-DT2L5ADS.js} +35 -10
  91. package/dist/wallets/walletConnectors/{chunk-DKMR2ML5.js → chunk-DUEQONAP.js} +1 -1
  92. package/dist/wallets/walletConnectors/{chunk-ZBI7MSWF.js → chunk-EJB7HH6N.js} +7 -5
  93. package/dist/wallets/walletConnectors/{chunk-OTLPTGHO.js → chunk-EMFKD777.js} +4 -2
  94. package/dist/wallets/walletConnectors/{chunk-743DKBGG.js → chunk-F2TFFXON.js} +72 -20
  95. package/dist/wallets/walletConnectors/chunk-GM6AIRNT.js +71 -0
  96. package/dist/wallets/walletConnectors/chunk-H63QJV3U.js +84 -0
  97. package/dist/wallets/walletConnectors/chunk-HEZOSHLH.js +446 -0
  98. package/dist/wallets/walletConnectors/{chunk-GO6HUJTP.js → chunk-HJAUM3KX.js} +6 -6
  99. package/dist/wallets/walletConnectors/chunk-ICSPFTBY.js +246 -0
  100. package/dist/wallets/walletConnectors/{chunk-OMZSFUVN.js → chunk-LGFHSL7G.js} +7 -3
  101. package/dist/wallets/walletConnectors/{chunk-V6R6WDOQ.js → chunk-MRUBFVXX.js} +1 -1
  102. package/dist/wallets/walletConnectors/chunk-MZFLUT3E.js +243 -0
  103. package/dist/wallets/walletConnectors/chunk-N7ACKYTK.js +291 -0
  104. package/dist/wallets/walletConnectors/{chunk-RSR35XOZ.js → chunk-NNLRIZSK.js} +11 -7
  105. package/dist/wallets/walletConnectors/chunk-NWHJRPZL.js +158 -0
  106. package/dist/wallets/walletConnectors/{chunk-P64PMEPU.js → chunk-O77UF634.js} +66 -12
  107. package/dist/wallets/walletConnectors/{chunk-4CKIGJZD.js → chunk-PK5XVWRF.js} +81 -32
  108. package/dist/wallets/walletConnectors/{chunk-DFG3BSSC.js → chunk-PS66FDPT.js} +79 -30
  109. package/dist/wallets/walletConnectors/chunk-PWJLUT4Z.js +2629 -0
  110. package/dist/wallets/walletConnectors/chunk-QCVDHC6P.js +210 -0
  111. package/dist/wallets/walletConnectors/{chunk-HMIFFMGK.js → chunk-QNZQZ7IH.js} +26 -16
  112. package/dist/wallets/walletConnectors/chunk-RTECHRPH.js +154 -0
  113. package/dist/wallets/walletConnectors/{chunk-F4JUKZBB.js → chunk-RU6FIXMD.js} +3 -3
  114. package/dist/wallets/walletConnectors/{chunk-ZWIAZOVB.js → chunk-RUYSIXR3.js} +6 -4
  115. package/dist/wallets/walletConnectors/{chunk-TRFREYPH.js → chunk-S75DVWSP.js} +39 -9
  116. package/dist/wallets/walletConnectors/chunk-SN2BNZTO.js +739 -0
  117. package/dist/wallets/walletConnectors/{chunk-YPMD3ZHF.js → chunk-SRXI2XF5.js} +80 -44
  118. package/dist/wallets/walletConnectors/chunk-TOX35ET4.js +307 -0
  119. package/dist/wallets/walletConnectors/{chunk-XPZCOEQL.js → chunk-TPLIG5I7.js} +35 -7
  120. package/dist/wallets/walletConnectors/{chunk-TP4BDK7W.js → chunk-UVPRZEPJ.js} +5 -1
  121. package/dist/wallets/walletConnectors/{chunk-SORKIBWX.js → chunk-WUNGUZIQ.js} +4 -5
  122. package/dist/wallets/walletConnectors/{chunk-2OHHFQQ7.js → chunk-WZMAZENY.js} +3 -1
  123. package/dist/wallets/walletConnectors/chunk-XPOLIWQQ.js +200 -0
  124. package/dist/wallets/walletConnectors/{chunk-DRL2CDHT.js → chunk-YFYJ2CFB.js} +80 -44
  125. package/dist/wallets/walletConnectors/chunk-ZPICFPYN.js +79 -0
  126. package/dist/wallets/walletConnectors/index.js +67 -65
  127. package/package.json +1 -1
  128. package/dist/AbcCredentialManager-WZBF3GHF.js +0 -7
  129. package/dist/TalkenApiSingleton-TECFDCT4.js +0 -9
  130. package/dist/chunk-CUPPBGFC.js +0 -460
  131. package/dist/chunk-R6ZE7JAZ.js +0 -15
  132. package/dist/wallets/walletConnectors/chunk-2M6E3YXU.js +0 -382
  133. package/dist/wallets/walletConnectors/chunk-3DHUDD4U.js +0 -132
  134. package/dist/wallets/walletConnectors/chunk-GAJ4FJTW.js +0 -382
  135. package/dist/wallets/walletConnectors/chunk-R6ZE7JAZ.js +0 -15
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  TALKEN_API_ENDPOINTS
4
- } from "./chunk-XPZCOEQL.js";
4
+ } from "./chunk-TPLIG5I7.js";
5
5
 
6
6
  // src/wallets/walletConnectors/abcWallet/api/modules/walletscan.ts
7
7
  var TalkenWalletscanModule = class {
@@ -1,13 +1,17 @@
1
1
  "use client";
2
+ import {
3
+ ownsTalkenApiSession,
4
+ ownsTalkenApiStorage
5
+ } from "./chunk-2YCHXOLC.js";
2
6
  import {
3
7
  getCredentialManager
4
- } from "./chunk-SORKIBWX.js";
8
+ } from "./chunk-WUNGUZIQ.js";
5
9
  import {
6
10
  TalkenApiError
7
- } from "./chunk-TP4BDK7W.js";
11
+ } from "./chunk-UVPRZEPJ.js";
8
12
  import {
9
13
  TALKEN_API_ENDPOINTS
10
- } from "./chunk-XPZCOEQL.js";
14
+ } from "./chunk-TPLIG5I7.js";
11
15
 
12
16
  // src/wallets/walletConnectors/abcWallet/api/modules/signingRefresh.ts
13
17
  function isSigningCredentialError(error) {
@@ -26,27 +30,46 @@ function broadcastMarker(details) {
26
30
  return typeof details === "object" && details !== null ? details.broadcast : void 0;
27
31
  }
28
32
  async function withSigningCredentialRefresh(client, call, options) {
33
+ const revision = client.getSessionRevision();
34
+ const assertCurrent = () => {
35
+ if (!ownsTalkenApiSession(client) || client.getSessionRevision() !== revision)
36
+ throw new TalkenApiError(
37
+ "AUTH_SESSION_CHANGED",
38
+ "The wallet session changed during signing recovery.",
39
+ 401
40
+ );
41
+ };
42
+ assertCurrent();
29
43
  try {
30
- return await call();
44
+ const result = await call();
45
+ assertCurrent();
46
+ return result;
31
47
  } catch (error) {
48
+ assertCurrent();
32
49
  if (!isSigningCredentialError(error))
33
50
  throw error;
51
+ if (!ownsTalkenApiStorage(client))
52
+ throw error;
34
53
  let pin = null;
35
54
  let email = null;
36
55
  try {
37
56
  const credentials = getCredentialManager();
38
57
  pin = credentials.getPinHash();
39
- email = options?.email || credentials.getEmail();
58
+ email = client.isAccessKeyMode() ? client.getAuthenticatedWalletSession()?.user.email ?? null : options?.email || credentials.getEmail();
40
59
  } catch {
41
60
  }
42
61
  if (!pin || !email)
43
62
  throw error;
63
+ assertCurrent();
44
64
  await client.post(TALKEN_API_ENDPOINTS.WALLET_MPC, {
45
65
  action: "create",
46
66
  email,
47
67
  pin
48
68
  });
49
- return call();
69
+ assertCurrent();
70
+ const result = await call();
71
+ assertCurrent();
72
+ return result;
50
73
  }
51
74
  }
52
75
 
@@ -1,7 +1,9 @@
1
1
  "use client";
2
+ import {
3
+ getTalkenApiClient
4
+ } from "./chunk-2YCHXOLC.js";
2
5
 
3
6
  // src/wallets/walletConnectors/abcWallet/api/SolanaApi.ts
4
- import { getTalkenApiClient } from "@talken/talkenkit";
5
7
  var SolanaApi = class {
6
8
  async getLatestBlockhash(network) {
7
9
  const api = getTalkenApiClient();
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import {
3
3
  withSigningCredentialRefresh
4
- } from "./chunk-M4SNNQU2.js";
4
+ } from "./chunk-ZPICFPYN.js";
5
5
  import {
6
6
  toTronSendBody
7
- } from "./chunk-XGQUYXTL.js";
7
+ } from "./chunk-4UMY2AY7.js";
8
8
  import {
9
9
  SEND_REQUEST_TIMEOUT,
10
10
  TALKEN_API_ENDPOINTS
11
- } from "./chunk-XPZCOEQL.js";
11
+ } from "./chunk-TPLIG5I7.js";
12
12
 
13
13
  // src/wallets/walletConnectors/abcWallet/api/modules/tron.ts
14
14
  var TalkenTronModule = class {
@@ -5,13 +5,10 @@ import {
5
5
  import {
6
6
  NATIVE_DECIMALS,
7
7
  toBaseUnits
8
- } from "./chunk-XGQUYXTL.js";
9
- import {
10
- getCredentialManager
11
- } from "./chunk-SORKIBWX.js";
8
+ } from "./chunk-4UMY2AY7.js";
12
9
  import {
13
10
  AbstractChainProvider
14
- } from "./chunk-3DHUDD4U.js";
11
+ } from "./chunk-ICSPFTBY.js";
15
12
  import {
16
13
  BitcoinProviderError,
17
14
  ProviderErrorCode
@@ -49,19 +46,26 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
49
46
  this.cacheExpiry = /* @__PURE__ */ new Map();
50
47
  this.CACHE_TTL = 6e4;
51
48
  }
49
+ getWalletOperationNetwork() {
50
+ return this.network.type;
51
+ }
52
52
  extractHashSignature(result) {
53
53
  const data = result;
54
54
  return data?.signatureHex || data?.signstr || data?.result?.signstr || data?.data?.signatureHex || data?.data?.signstr || data?.data?.result?.signstr || "";
55
55
  }
56
56
  getRecoveryEmail() {
57
- return getCredentialManager().getEmail() || void 0;
57
+ return this.getSharedCredentials()?.getEmail() || void 0;
58
58
  }
59
59
  /**
60
60
  * Call request interceptor if set (throws on user cancel)
61
61
  */
62
62
  async callInterceptor(request) {
63
+ const assertOperation = this.captureWalletOperation();
63
64
  if (this.requestInterceptor) {
64
- await this.requestInterceptor(request);
65
+ await this.awaitWalletOperation(
66
+ assertOperation,
67
+ async () => this.requestInterceptor(request)
68
+ );
65
69
  }
66
70
  }
67
71
  onWalletSet(wallet) {
@@ -94,6 +98,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
94
98
  );
95
99
  }
96
100
  const previousType = this.network.type;
101
+ this.invalidateWalletOperations();
97
102
  this.network = newNetwork;
98
103
  if (previousType !== newNetwork.type) {
99
104
  this.emit("networkChanged", newNetwork.type);
@@ -110,6 +115,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
110
115
  * Get Bitcoin address
111
116
  */
112
117
  async getAddress() {
118
+ this.assertWalletSession();
113
119
  if (!this.wallet) {
114
120
  throw new BitcoinProviderError(
115
121
  ProviderErrorCode.DISCONNECTED,
@@ -122,6 +128,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
122
128
  * Get compressed public key (33 bytes)
123
129
  */
124
130
  async getPublicKey() {
131
+ this.assertWalletSession();
125
132
  if (!this.wallet) {
126
133
  throw new BitcoinProviderError(
127
134
  ProviderErrorCode.DISCONNECTED,
@@ -189,16 +196,21 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
189
196
  return cached;
190
197
  }
191
198
  }
199
+ const assertOperation = this.captureWalletOperation();
192
200
  try {
193
201
  logger.debug("Fetching UTXOs from network...");
194
202
  const api = this.getTalkenApiClientOrThrow();
195
- const result = await api.bitcoin.getUtxos(this.network.type, address);
203
+ const result = await this.awaitWalletOperation(
204
+ assertOperation,
205
+ async () => api.bitcoin.getUtxos(this.network.type, address)
206
+ );
196
207
  const utxos = this.normalizeUtxos(result.utxos || []);
197
208
  this.utxoCache.set(address, utxos);
198
209
  this.cacheExpiry.set(address, Date.now() + this.CACHE_TTL);
199
210
  logger.info(`Fetched ${utxos.length} UTXOs`);
200
211
  return utxos;
201
212
  } catch (error) {
213
+ assertOperation();
202
214
  logger.error("Failed to fetch UTXOs:", error.message);
203
215
  throw new BitcoinProviderError(
204
216
  ProviderErrorCode.INTERNAL_ERROR,
@@ -212,7 +224,11 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
212
224
  * Returns balance in satoshis
213
225
  */
214
226
  async getBalance(forceRefresh = false) {
215
- const utxos = await this.getUtxos(forceRefresh);
227
+ const assertOperation = this.captureWalletOperation();
228
+ const utxos = await this.awaitWalletOperation(
229
+ assertOperation,
230
+ async () => this.getUtxos(forceRefresh)
231
+ );
216
232
  const balance = utxos.reduce((sum, utxo) => sum + utxo.value, 0);
217
233
  logger.debug(`Balance: ${balance} satoshis (${balance / 1e8} BTC)`);
218
234
  return balance;
@@ -222,11 +238,12 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
222
238
  * Returns fee rate in satoshis per byte
223
239
  */
224
240
  async estimateFee(targetBlocks = 6) {
241
+ const assertOperation = this.captureWalletOperation();
225
242
  try {
226
243
  const api = this.getTalkenApiClientOrThrow();
227
- const result = await api.bitcoin.getFeeRate(
228
- this.network.type,
229
- targetBlocks
244
+ const result = await this.awaitWalletOperation(
245
+ assertOperation,
246
+ async () => api.bitcoin.getFeeRate(this.network.type, targetBlocks)
230
247
  );
231
248
  const feeRate = Number(result.feeRate);
232
249
  if (!Number.isFinite(feeRate) || feeRate <= 0) {
@@ -235,6 +252,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
235
252
  logger.debug(`Fee rate: ${feeRate} sat/byte`);
236
253
  return feeRate;
237
254
  } catch (_error) {
255
+ assertOperation();
238
256
  logger.warn("Fee estimation failed, using default");
239
257
  return 1;
240
258
  }
@@ -255,13 +273,17 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
255
273
  "Wallet not connected"
256
274
  );
257
275
  }
258
- await this.callInterceptor({
259
- chain: "bitcoin",
260
- method: "signMessage",
261
- address: this.wallet.address,
262
- network: this.network.type,
263
- message
264
- });
276
+ const assertOperation = this.captureWalletOperation();
277
+ await this.awaitWalletOperation(
278
+ assertOperation,
279
+ async () => this.callInterceptor({
280
+ chain: "bitcoin",
281
+ method: "signMessage",
282
+ address: this.wallet.address,
283
+ network: this.network.type,
284
+ message
285
+ })
286
+ );
265
287
  logger.info("Signing Bitcoin message...");
266
288
  const prefix = "Bitcoin Signed Message:\n";
267
289
  const msgBytes = new TextEncoder().encode(message);
@@ -273,8 +295,14 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
273
295
  preimage.set(prefixBytes, 0);
274
296
  preimage.set(varint, prefixBytes.length);
275
297
  preimage.set(msgBytes, prefixBytes.length + varint.length);
276
- const hash1 = await crypto.subtle.digest("SHA-256", preimage);
277
- const hash2 = await crypto.subtle.digest("SHA-256", hash1);
298
+ const hash1 = await this.awaitWalletOperation(
299
+ assertOperation,
300
+ async () => crypto.subtle.digest("SHA-256", preimage)
301
+ );
302
+ const hash2 = await this.awaitWalletOperation(
303
+ assertOperation,
304
+ async () => crypto.subtle.digest("SHA-256", hash1)
305
+ );
278
306
  const hashHex = Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
279
307
  const api = this.getTalkenApiClientOrThrow();
280
308
  if (!api) {
@@ -283,15 +311,18 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
283
311
  "TalkenApiClient not initialized"
284
312
  );
285
313
  }
286
- const pinHash = getCredentialManager().getPinHash() || "";
314
+ const pinHash = this.getSharedCredentials()?.getPinHash() || "";
287
315
  const email = this.getRecoveryEmail();
288
316
  const signstr = this.extractHashSignature(
289
- await api.bitcoin.signHash({
290
- hash: hashHex,
291
- pin: pinHash || void 0,
292
- network: this.network.type,
293
- ...email && { email }
294
- })
317
+ await this.awaitWalletOperation(
318
+ assertOperation,
319
+ async () => api.bitcoin.signHash({
320
+ hash: hashHex,
321
+ pin: pinHash || void 0,
322
+ network: this.network.type,
323
+ ...email && { email }
324
+ })
325
+ )
295
326
  );
296
327
  if (!signstr) {
297
328
  throw new BitcoinProviderError(
@@ -341,31 +372,39 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
341
372
  params.amount,
342
373
  NATIVE_DECIMALS.bitcoin
343
374
  ).toString();
375
+ const assertOperation = this.captureWalletOperation();
344
376
  try {
345
377
  const INPUT_PER_BYTE = 141;
346
378
  const BUFFER = 500;
347
379
  let estimatedFeeBtc;
348
380
  try {
349
- const feeRate = await this.estimateFee();
381
+ const feeRate = await this.awaitWalletOperation(
382
+ assertOperation,
383
+ async () => this.estimateFee()
384
+ );
350
385
  const estimatedSatoshi = feeRate * 2 * INPUT_PER_BYTE + BUFFER;
351
386
  estimatedFeeBtc = (estimatedSatoshi / 1e8).toFixed(8).replace(/0+$/, "").replace(/\.$/, "");
352
387
  } catch {
388
+ assertOperation();
353
389
  }
354
- await this.callInterceptor({
355
- chain: "bitcoin",
356
- method: "sendTransaction",
357
- fromAddress: this.wallet.address,
358
- toAddress: params.toAddress,
359
- amount: String(params.amount),
360
- symbol: "BTC",
361
- network: this.network.type,
362
- isNativeToken: true,
363
- estimatedFee: estimatedFeeBtc,
364
- feeSymbol: "BTC"
365
- });
390
+ await this.awaitWalletOperation(
391
+ assertOperation,
392
+ async () => this.callInterceptor({
393
+ chain: "bitcoin",
394
+ method: "sendTransaction",
395
+ fromAddress: this.wallet.address,
396
+ toAddress: params.toAddress,
397
+ amount: String(params.amount),
398
+ symbol: "BTC",
399
+ network: this.network.type,
400
+ isNativeToken: true,
401
+ estimatedFee: estimatedFeeBtc,
402
+ feeSymbol: "BTC"
403
+ })
404
+ );
366
405
  logger.info("Starting high-level transaction...");
367
406
  const api = this.getTalkenApiClientOrThrow();
368
- const pinHash = api.isAccessKeyMode() ? void 0 : getCredentialManager().getPinHash();
407
+ const pinHash = api.isAccessKeyMode() ? void 0 : this.getSharedCredentials()?.getPinHash();
369
408
  if (!pinHash && !api.isAccessKeyMode()) {
370
409
  throw new BitcoinProviderError(
371
410
  ProviderErrorCode.INTERNAL_ERROR,
@@ -373,13 +412,16 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
373
412
  );
374
413
  }
375
414
  const email = this.getRecoveryEmail();
376
- const result = await api.bitcoin.sendTransaction({
377
- toAddress: params.toAddress,
378
- amountSats,
379
- network: this.network.type,
380
- pin: pinHash || void 0,
381
- ...email && { email }
382
- });
415
+ const result = await this.awaitWalletOperation(
416
+ assertOperation,
417
+ async () => api.bitcoin.sendTransaction({
418
+ toAddress: params.toAddress,
419
+ amountSats,
420
+ network: this.network.type,
421
+ pin: pinHash || void 0,
422
+ ...email && { email }
423
+ })
424
+ );
383
425
  logger.info(
384
426
  "BTC transaction complete via TalkenApiClient:",
385
427
  result.txHash
@@ -391,6 +433,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
391
433
  this.clearUtxoCache();
392
434
  return result.txHash;
393
435
  } catch (error) {
436
+ assertOperation();
394
437
  if (error.message?.includes("cancelled") || error.message?.includes("rejected")) {
395
438
  logger.info("User cancelled transaction");
396
439
  throw new BitcoinProviderError(
@@ -437,6 +480,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
437
480
  "Wallet not connected"
438
481
  );
439
482
  }
483
+ const assertOperation = this.captureWalletOperation();
440
484
  try {
441
485
  logger.info("Broadcasting transaction...");
442
486
  if (psbt) {
@@ -445,10 +489,13 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
445
489
  );
446
490
  }
447
491
  const api = this.getTalkenApiClientOrThrow();
448
- const result = await api.bitcoin.broadcastRawTransaction({
449
- network: this.network.type,
450
- rawTransaction
451
- });
492
+ const result = await this.awaitWalletOperation(
493
+ assertOperation,
494
+ async () => api.bitcoin.broadcastRawTransaction({
495
+ network: this.network.type,
496
+ rawTransaction
497
+ })
498
+ );
452
499
  logger.info("Transaction broadcasted:", result.txHash);
453
500
  this.emit("transactionBroadcasted", {
454
501
  txHash: result.txHash,
@@ -457,6 +504,7 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
457
504
  this.clearUtxoCache();
458
505
  return result.txHash;
459
506
  } catch (error) {
507
+ assertOperation();
460
508
  logger.error("Transaction broadcast failed:", error.message);
461
509
  this.emit("error", error);
462
510
  throw sendFailure(
@@ -474,6 +522,11 @@ var AbcBitcoinProvider = class extends AbstractChainProvider {
474
522
  * Get wallet info
475
523
  */
476
524
  getWalletInfo() {
525
+ try {
526
+ this.assertWalletSession();
527
+ } catch {
528
+ return null;
529
+ }
477
530
  if (!this.wallet)
478
531
  return null;
479
532
  return {
@@ -1,17 +1,18 @@
1
1
  "use client";
2
2
  import {
3
- TALKEN_API_ENDPOINTS
4
- } from "./chunk-XPZCOEQL.js";
3
+ getTalkenApiClient
4
+ } from "./chunk-2YCHXOLC.js";
5
+ import {
6
+ chainTokenBalancesPath
7
+ } from "./chunk-TPLIG5I7.js";
5
8
 
6
9
  // src/wallets/walletConnectors/abcWallet/api/TokenApi.ts
7
- import { getTalkenApiClient } from "@talken/talkenkit";
8
10
  var TokenApi = class {
9
11
  async getBalances(address, chainKey) {
10
12
  const api = getTalkenApiClient();
11
13
  if (!api)
12
14
  throw new Error("TalkenApiClient not initialized");
13
- const query = new URLSearchParams({ address, chainKey }).toString();
14
- const response = await api.get(`${TALKEN_API_ENDPOINTS.TOKENS_BALANCES}?${query}`);
15
+ const response = await api.get(chainTokenBalancesPath(chainKey, address));
15
16
  return Array.isArray(response) ? response : response.tokens ?? [];
16
17
  }
17
18
  async getTokenBalance(address, chainKey, tokenAddress) {
@@ -1,7 +1,4 @@
1
1
  "use client";
2
- import {
3
- getCredentialManager
4
- } from "./chunk-SORKIBWX.js";
5
2
  import {
6
3
  getBitcoinNetwork,
7
4
  getEvmNetwork,
@@ -12,14 +9,19 @@ import {
12
9
  import {
13
10
  createLogger
14
11
  } from "./chunk-2DFJ6LEN.js";
12
+ import {
13
+ getTalkenApiClient
14
+ } from "./chunk-2YCHXOLC.js";
15
+ import {
16
+ getCredentialManager
17
+ } from "./chunk-WUNGUZIQ.js";
15
18
  import {
16
19
  AbcError
17
- } from "./chunk-TP4BDK7W.js";
20
+ } from "./chunk-UVPRZEPJ.js";
18
21
 
19
22
  // src/wallets/walletConnectors/abcWallet/walletGeneration.ts
20
- import { getTalkenApiClient } from "@talken/talkenkit";
21
23
  var logger = createLogger("WalletGeneration");
22
- async function mapApiResponseToWallets(genResponse, infoResponse, email) {
24
+ async function mapApiResponseToWallets(genResponse, infoResponse, email, api, assertCurrent) {
23
25
  const accounts = infoResponse?.accounts || [];
24
26
  const evmAccount = accounts[0] || infoResponse || {};
25
27
  const uid = String(genResponse.uid || evmAccount.uid || "");
@@ -34,9 +36,10 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
34
36
  let xrpAddress = genResponse.xrpAddress || "";
35
37
  if ((!btcAddress || !trxAddress || !xrpAddress) && pubkey) {
36
38
  try {
37
- const api = getTalkenApiClient();
38
- if (api) {
39
+ assertCurrent();
40
+ {
39
41
  const addrResponse = await api.wallet.getAddressForChain("all");
42
+ assertCurrent();
40
43
  if (!btcAddress)
41
44
  btcAddress = addrResponse?.btc || addrResponse?.btcAddress || "";
42
45
  if (!trxAddress)
@@ -45,10 +48,12 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
45
48
  xrpAddress = addrResponse?.xrp || addrResponse?.xrpAddress || "";
46
49
  }
47
50
  } catch (err) {
51
+ assertCurrent();
48
52
  logger.warn("Failed to derive BTC/TRX/XRP addresses:", err);
49
53
  }
50
54
  }
51
55
  const pvencstr = String(evmAccount.pvencstr || "");
56
+ assertCurrent();
52
57
  const edp = String(evmAccount.encryptDevicePassword || "");
53
58
  if (uid && wid && sid && pvencstr && edp) {
54
59
  getCredentialManager().setEvmSigningCredentials({
@@ -124,13 +129,23 @@ async function generateMpcWallets(hashedPin, email) {
124
129
  "TalkenApiClient not initialized"
125
130
  );
126
131
  }
132
+ const revision = api.getSessionRevision();
133
+ const assertCurrent = () => {
134
+ if (getTalkenApiClient() !== api || api.getSessionRevision() !== revision || api.isAccessKeyMode() && !api.getAuthenticatedWalletSession())
135
+ throw new Error("AUTH_SESSION_CHANGED");
136
+ };
137
+ assertCurrent();
127
138
  try {
128
139
  const genResponse = await api.wallet.generate(hashedPin, email);
140
+ assertCurrent();
129
141
  const infoResponse = await api.wallet.getInfo().catch(() => ({}));
142
+ assertCurrent();
130
143
  return await mapApiResponseToWallets(
131
144
  genResponse,
132
145
  infoResponse,
133
- email || ""
146
+ email || "",
147
+ api,
148
+ assertCurrent
134
149
  );
135
150
  } catch (error) {
136
151
  throw new AbcError(
@@ -148,13 +163,23 @@ async function recoverMpcWallets(hashedPin, email) {
148
163
  "TalkenApiClient not initialized"
149
164
  );
150
165
  }
166
+ const revision = api.getSessionRevision();
167
+ const assertCurrent = () => {
168
+ if (getTalkenApiClient() !== api || api.getSessionRevision() !== revision || api.isAccessKeyMode() && !api.getAuthenticatedWalletSession())
169
+ throw new Error("AUTH_SESSION_CHANGED");
170
+ };
171
+ assertCurrent();
151
172
  try {
152
173
  const genResponse = await api.wallet.recover(hashedPin, email);
174
+ assertCurrent();
153
175
  const infoResponse = await api.wallet.getInfo().catch(() => ({}));
176
+ assertCurrent();
154
177
  return await mapApiResponseToWallets(
155
178
  genResponse,
156
179
  infoResponse,
157
- email || ""
180
+ email || "",
181
+ api,
182
+ assertCurrent
158
183
  );
159
184
  } catch (error) {
160
185
  throw new AbcError(
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  TalkenApiError
4
- } from "./chunk-TP4BDK7W.js";
4
+ } from "./chunk-UVPRZEPJ.js";
5
5
 
6
6
  // src/wallets/walletConnectors/abcWallet/api/modules/signBodies.ts
7
7
  function badRequest(message) {
@@ -1,20 +1,22 @@
1
1
  "use client";
2
2
  import {
3
3
  abcConnector
4
- } from "./chunk-4CKIGJZD.js";
4
+ } from "./chunk-PK5XVWRF.js";
5
+ import {
6
+ createTalkenApiClient
7
+ } from "./chunk-SN2BNZTO.js";
5
8
  import {
6
9
  resolveTalkenApiUrl
7
10
  } from "./chunk-GFWUFYT2.js";
8
11
  import {
9
- createTalkenApiClient
10
- } from "./chunk-2M6E3YXU.js";
12
+ setTalkenApiClient
13
+ } from "./chunk-2YCHXOLC.js";
11
14
  import {
12
15
  ABC_WALLET_METADATA,
13
16
  loadTgAccessKey
14
- } from "./chunk-XPZCOEQL.js";
17
+ } from "./chunk-TPLIG5I7.js";
15
18
 
16
19
  // src/wallets/walletConnectors/abcWallet/abcWallet.ts
17
- import { setTalkenApiClient } from "@talken/talkenkit";
18
20
  var abcWallet = (specificOptions) => ({ projectId }) => {
19
21
  const talkenApiUrl = resolveTalkenApiUrl(specificOptions?.talkenApiUrl);
20
22
  const talkenApi = createTalkenApiClient({
@@ -1,10 +1,12 @@
1
1
  "use client";
2
+ import {
3
+ getTalkenApiClient
4
+ } from "./chunk-2YCHXOLC.js";
2
5
  import {
3
6
  TALKEN_API_ENDPOINTS
4
- } from "./chunk-XPZCOEQL.js";
7
+ } from "./chunk-TPLIG5I7.js";
5
8
 
6
9
  // src/wallets/walletConnectors/abcWallet/api/ConfigApi.ts
7
- import { getTalkenApiClient } from "@talken/talkenkit";
8
10
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
9
11
  var toStatusCode = (status) => {
10
12
  if (typeof status === "number")