@pushchain/core 6.0.25 → 6.0.27-alpha.0

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 (183) hide show
  1. package/AGW.md +194 -0
  2. package/CHANGELOG.md +74 -0
  3. package/README.md +2 -0
  4. package/package.json +7 -1
  5. package/src/lib/agentic/agentic.d.ts +23 -0
  6. package/src/lib/agentic/agentic.js +51 -0
  7. package/src/lib/agentic/agentic.types.d.ts +409 -0
  8. package/src/lib/agentic/agentic.types.js +3 -0
  9. package/src/lib/agentic/capabilities.d.ts +37 -0
  10. package/src/lib/agentic/capabilities.js +64 -0
  11. package/src/lib/agentic/chain.d.ts +3 -0
  12. package/src/lib/agentic/chain.js +15 -0
  13. package/src/lib/agentic/codec/abi-layout.d.ts +15 -0
  14. package/src/lib/agentic/codec/abi-layout.js +121 -0
  15. package/src/lib/agentic/codec/defaults.d.ts +51 -0
  16. package/src/lib/agentic/codec/defaults.js +53 -0
  17. package/src/lib/agentic/codec/ids.d.ts +35 -0
  18. package/src/lib/agentic/codec/ids.js +74 -0
  19. package/src/lib/agentic/codec/native.d.ts +75 -0
  20. package/src/lib/agentic/codec/native.js +328 -0
  21. package/src/lib/agentic/codec/rules.d.ts +45 -0
  22. package/src/lib/agentic/codec/rules.js +110 -0
  23. package/src/lib/agentic/codec/selectors.d.ts +19 -0
  24. package/src/lib/agentic/codec/selectors.js +60 -0
  25. package/src/lib/agentic/codec/session.d.ts +54 -0
  26. package/src/lib/agentic/codec/session.js +65 -0
  27. package/src/lib/agentic/codec/svm-accounts.d.ts +35 -0
  28. package/src/lib/agentic/codec/svm-accounts.js +68 -0
  29. package/src/lib/agentic/codec/svm-idl.d.ts +11 -0
  30. package/src/lib/agentic/codec/svm-idl.js +226 -0
  31. package/src/lib/agentic/codec/svm-terms.d.ts +157 -0
  32. package/src/lib/agentic/codec/svm-terms.js +242 -0
  33. package/src/lib/agentic/codec/universal-terms.d.ts +67 -0
  34. package/src/lib/agentic/codec/universal-terms.js +41 -0
  35. package/src/lib/agentic/codec/universal.d.ts +14 -0
  36. package/src/lib/agentic/codec/universal.js +157 -0
  37. package/src/lib/agentic/constants.d.ts +11 -0
  38. package/src/lib/agentic/constants.js +15 -0
  39. package/src/lib/agentic/context.d.ts +29 -0
  40. package/src/lib/agentic/context.js +56 -0
  41. package/src/lib/agentic/contracts/abi/v5/agent-validator.d.ts +105 -0
  42. package/src/lib/agentic/contracts/abi/v5/agent-validator.js +149 -0
  43. package/src/lib/agentic/contracts/abi/v5/agw-factory.d.ts +847 -0
  44. package/src/lib/agentic/contracts/abi/v5/agw-factory.js +1108 -0
  45. package/src/lib/agentic/contracts/abi/v5/agw.d.ts +1211 -0
  46. package/src/lib/agentic/contracts/abi/v5/agw.js +1588 -0
  47. package/src/lib/agentic/contracts/abi/v5/index.d.ts +6 -0
  48. package/src/lib/agentic/contracts/abi/v5/index.js +17 -0
  49. package/src/lib/agentic/contracts/abi/v5/smart-session.d.ts +1493 -0
  50. package/src/lib/agentic/contracts/abi/v5/smart-session.js +1965 -0
  51. package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.d.ts +1640 -0
  52. package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.js +2160 -0
  53. package/src/lib/agentic/contracts/donut-v5.d.ts +11 -0
  54. package/src/lib/agentic/contracts/donut-v5.js +15 -0
  55. package/src/lib/agentic/contracts/prc20-metadata.d.ts +26 -0
  56. package/src/lib/agentic/contracts/prc20-metadata.js +87 -0
  57. package/src/lib/agentic/contracts/reader.d.ts +35 -0
  58. package/src/lib/agentic/contracts/reader.js +16 -0
  59. package/src/lib/agentic/contracts/v5.d.ts +5323 -0
  60. package/src/lib/agentic/contracts/v5.js +316 -0
  61. package/src/lib/agentic/deployments.d.ts +61 -0
  62. package/src/lib/agentic/deployments.js +203 -0
  63. package/src/lib/agentic/errors.d.ts +71 -0
  64. package/src/lib/agentic/errors.js +92 -0
  65. package/src/lib/agentic/execution/guards.d.ts +9 -0
  66. package/src/lib/agentic/execution/guards.js +30 -0
  67. package/src/lib/agentic/execution/outbound.d.ts +55 -0
  68. package/src/lib/agentic/execution/outbound.js +187 -0
  69. package/src/lib/agentic/execution/send.d.ts +9 -0
  70. package/src/lib/agentic/execution/send.js +276 -0
  71. package/src/lib/agentic/execution/svm-instruction.d.ts +24 -0
  72. package/src/lib/agentic/execution/svm-instruction.js +40 -0
  73. package/src/lib/agentic/execution/svm-outbound.d.ts +18 -0
  74. package/src/lib/agentic/execution/svm-outbound.js +86 -0
  75. package/src/lib/agentic/execution/svm-payload.d.ts +18 -0
  76. package/src/lib/agentic/execution/svm-payload.js +136 -0
  77. package/src/lib/agentic/execution/svm-public.d.ts +5 -0
  78. package/src/lib/agentic/execution/svm-public.js +182 -0
  79. package/src/lib/agentic/execution/svm-quote.d.ts +11 -0
  80. package/src/lib/agentic/execution/svm-quote.js +24 -0
  81. package/src/lib/agentic/execution/svm-send.d.ts +44 -0
  82. package/src/lib/agentic/execution/svm-send.js +90 -0
  83. package/src/lib/agentic/index.d.ts +5 -0
  84. package/src/lib/agentic/index.js +10 -0
  85. package/src/lib/agentic/management/common.d.ts +29 -0
  86. package/src/lib/agentic/management/common.js +114 -0
  87. package/src/lib/agentic/management/create.d.ts +16 -0
  88. package/src/lib/agentic/management/create.js +271 -0
  89. package/src/lib/agentic/management/duplicates.d.ts +4 -0
  90. package/src/lib/agentic/management/duplicates.js +20 -0
  91. package/src/lib/agentic/management/label.d.ts +3 -0
  92. package/src/lib/agentic/management/label.js +17 -0
  93. package/src/lib/agentic/management/prepare.d.ts +7 -0
  94. package/src/lib/agentic/management/prepare.js +95 -0
  95. package/src/lib/agentic/management/rules-write.d.ts +42 -0
  96. package/src/lib/agentic/management/rules-write.js +279 -0
  97. package/src/lib/agentic/management/svm-context.d.ts +25 -0
  98. package/src/lib/agentic/management/svm-context.js +55 -0
  99. package/src/lib/agentic/management/svm-metadata.d.ts +10 -0
  100. package/src/lib/agentic/management/svm-metadata.js +56 -0
  101. package/src/lib/agentic/management/svm-public.d.ts +6 -0
  102. package/src/lib/agentic/management/svm-public.js +125 -0
  103. package/src/lib/agentic/management/svm.d.ts +27 -0
  104. package/src/lib/agentic/management/svm.js +150 -0
  105. package/src/lib/agentic/presets/catalog.d.ts +21 -0
  106. package/src/lib/agentic/presets/catalog.js +10 -0
  107. package/src/lib/agentic/presets/index.d.ts +5 -0
  108. package/src/lib/agentic/presets/index.js +190 -0
  109. package/src/lib/agentic/presets/types.d.ts +44 -0
  110. package/src/lib/agentic/presets/types.js +3 -0
  111. package/src/lib/agentic/public-rule.d.ts +9 -0
  112. package/src/lib/agentic/public-rule.js +342 -0
  113. package/src/lib/agentic/reads/checkpoints.d.ts +17 -0
  114. package/src/lib/agentic/reads/checkpoints.js +109 -0
  115. package/src/lib/agentic/reads/rules.d.ts +42 -0
  116. package/src/lib/agentic/reads/rules.js +286 -0
  117. package/src/lib/agentic/reads/snapshot.d.ts +28 -0
  118. package/src/lib/agentic/reads/snapshot.js +85 -0
  119. package/src/lib/agentic/reads/svm.d.ts +17 -0
  120. package/src/lib/agentic/reads/svm.js +52 -0
  121. package/src/lib/agentic/reads/wallets.d.ts +25 -0
  122. package/src/lib/agentic/reads/wallets.js +122 -0
  123. package/src/lib/agentic/response.d.ts +41 -0
  124. package/src/lib/agentic/response.js +358 -0
  125. package/src/lib/agentic/revert.d.ts +7 -0
  126. package/src/lib/agentic/revert.js +102 -0
  127. package/src/lib/agentic/runtime.d.ts +58 -0
  128. package/src/lib/agentic/runtime.js +95 -0
  129. package/src/lib/agentic/utils.d.ts +57 -0
  130. package/src/lib/agentic/utils.js +165 -0
  131. package/src/lib/agentic/wallet.d.ts +32 -0
  132. package/src/lib/agentic/wallet.js +130 -0
  133. package/src/lib/constants/chain.js +1 -1
  134. package/src/lib/constants/enums.d.ts +6 -3
  135. package/src/lib/constants/enums.js +6 -3
  136. package/src/lib/constants/index.d.ts +65 -7
  137. package/src/lib/constants/index.js +18 -3
  138. package/src/lib/constants/read-state.d.ts +15 -2
  139. package/src/lib/constants/read-state.js +19 -3
  140. package/src/lib/index.d.ts +9 -3
  141. package/src/lib/index.js +11 -2
  142. package/src/lib/orchestrator/internals/errors.d.ts +7 -0
  143. package/src/lib/orchestrator/internals/errors.js +13 -1
  144. package/src/lib/orchestrator/internals/execute-standard.d.ts +3 -1
  145. package/src/lib/orchestrator/internals/execute-standard.js +3 -3
  146. package/src/lib/orchestrator/internals/outbound-sync.js +52 -7
  147. package/src/lib/orchestrator/internals/push-chain-tx.d.ts +1 -1
  148. package/src/lib/orchestrator/internals/push-chain-tx.js +13 -1
  149. package/src/lib/orchestrator/orchestrator.d.ts +3 -0
  150. package/src/lib/orchestrator/orchestrator.js +13 -1
  151. package/src/lib/orchestrator/orchestrator.types.d.ts +8 -0
  152. package/src/lib/orchestrator/route-detector.js +3 -2
  153. package/src/lib/orchestrator/svm-idl/resolve.d.ts +2 -0
  154. package/src/lib/orchestrator/svm-idl/resolve.js +11 -1
  155. package/src/lib/progress-hook/progress-hook.js +84 -0
  156. package/src/lib/progress-hook/progress-hook.types.d.ts +14 -2
  157. package/src/lib/progress-hook/progress-hook.types.js +13 -0
  158. package/src/lib/push-chain/push-chain.d.ts +58 -16
  159. package/src/lib/push-chain/push-chain.js +68 -8
  160. package/src/lib/push-client/push-client.d.ts +7 -0
  161. package/src/lib/push-client/push-client.js +41 -15
  162. package/src/lib/read-state/destination.js +6 -1
  163. package/src/lib/read-state/envelopes/evm.js +2 -3
  164. package/src/lib/read-state/envelopes/svm.js +11 -1
  165. package/src/lib/read-state/read-executor.js +4 -0
  166. package/src/lib/read-state/read-params.d.ts +71 -26
  167. package/src/lib/read-state/read-params.js +60 -15
  168. package/src/lib/read-state/read-state.types.d.ts +44 -1
  169. package/src/lib/read-state/read-state.types.js +23 -1
  170. package/src/lib/read-state/read-tracker.d.ts +6 -1
  171. package/src/lib/read-state/read-tracker.js +83 -17
  172. package/src/lib/read-state/registry.js +2 -3
  173. package/src/lib/read-state/result-decoder.js +6 -0
  174. package/src/lib/read-state/spec-builder.js +2 -2
  175. package/src/lib/read-state/svm-account.d.ts +20 -0
  176. package/src/lib/read-state/svm-account.js +114 -0
  177. package/src/lib/read-state/svm-pda.d.ts +13 -0
  178. package/src/lib/read-state/svm-pda.js +147 -0
  179. package/src/lib/universal/prc20-address.d.ts +15 -0
  180. package/src/lib/universal/prc20-address.js +135 -0
  181. package/src/lib/utils.d.ts +6 -13
  182. package/src/lib/utils.js +5 -128
  183. package/src/lib/vm-client/evm-client.js +34 -20
@@ -10,6 +10,24 @@ import type { PreparedUniversalTx, CascadedTxResponse, CascadeExecutionOptions }
10
10
  import type { Hex } from 'viem';
11
11
  import type { BatchReadResponse, PreparedRead, UniversalReadResponse } from '../read-state/read-state.types';
12
12
  import { type ReadOptions, type ReadPrepareOptions, type ReadValue, type ValidateReadCall, type ReadTrackOptions, type ReadExecuteOptions } from '../read-state/read-params';
13
+ import type { AgenticNamespace } from '../agentic/agentic.types';
14
+ /** Options accepted by `PushChain.initialize` / `reinitialize`. */
15
+ export interface PushChainInitializeOptions {
16
+ network: PUSH_NETWORK;
17
+ rpcUrls?: Partial<Record<CHAIN, string[]>>;
18
+ blockExplorers?: Partial<Record<CHAIN, string[]>>;
19
+ printTraces?: boolean;
20
+ progressHook?: (progress: ProgressEvent) => void;
21
+ /**
22
+ * Act as this agentic wallet (AGW). The signer decides the door: the owner
23
+ * sends through `execute`, an agent named in an enabled rule through
24
+ * `executeAsAgent`; anyone else fails with NOT_OWNER_OR_AGENT.
25
+ * `universal.account` becomes the wallet; `universal.origin`,
26
+ * `getAccountStatus()` and gas stay the signer's. Not inherited by
27
+ * `reinitialize` — pass it again to keep acting as the wallet.
28
+ */
29
+ agenticWallet?: `0x${string}`;
30
+ }
13
31
  /**
14
32
  * @class PushChain
15
33
  *
@@ -36,7 +54,24 @@ export declare class PushChain {
36
54
  TOKEN: import("../constants").PayableTokenConstantsMap;
37
55
  };
38
56
  READ: {
39
- readonly WEB2: "web2:https";
57
+ readonly CHAIN: Readonly<{
58
+ readonly PUSH_MAINNET: CHAIN.PUSH_MAINNET;
59
+ readonly PUSH_TESTNET: CHAIN.PUSH_TESTNET;
60
+ readonly PUSH_TESTNET_DONUT: CHAIN.PUSH_TESTNET;
61
+ readonly PUSH_LOCALNET: CHAIN.PUSH_LOCALNET;
62
+ readonly ETHEREUM_MAINNET: CHAIN.ETHEREUM_MAINNET;
63
+ readonly ETHEREUM_SEPOLIA: CHAIN.ETHEREUM_SEPOLIA;
64
+ readonly ARBITRUM_SEPOLIA: CHAIN.ARBITRUM_SEPOLIA;
65
+ readonly BASE_SEPOLIA: CHAIN.BASE_SEPOLIA;
66
+ readonly BNB_TESTNET: CHAIN.BNB_TESTNET;
67
+ readonly SOLANA_MAINNET: CHAIN.SOLANA_MAINNET;
68
+ readonly SOLANA_TESTNET: CHAIN.SOLANA_TESTNET;
69
+ readonly SOLANA_DEVNET: CHAIN.SOLANA_DEVNET;
70
+ readonly WEB2: "web2";
71
+ }> & {
72
+ readonly WEB2: typeof import("../constants").WEB2_READ_CHAIN;
73
+ };
74
+ readonly WEB2: "web2";
40
75
  readonly NAMESPACE: {
41
76
  readonly EVM: "eip155";
42
77
  readonly SVM: "solana";
@@ -48,7 +83,7 @@ export declare class PushChain {
48
83
  readonly CALLBACK_BUDGET_BUFFER: 3;
49
84
  readonly REGISTRY_CALLBACK_GAS: 500000n;
50
85
  readonly UNIVERSAL_READ_REGISTRY_ADDRESS: {
51
- readonly TESTNET_DONUT: "0x91b09DAd1774bAfDE679F9ebB5F9046AE2b928C8";
86
+ readonly TESTNET_DONUT: "0x00000000000000000000000000000000000000b2";
52
87
  };
53
88
  readonly WEB2_MAX_EXTRACT_ENTRIES: 16;
54
89
  readonly WEB2_DEFAULT_TIMEOUT_MS: 5000;
@@ -57,7 +92,18 @@ export declare class PushChain {
57
92
  readonly STATUS: typeof import("../read-state/read-state.types").UNIVERSAL_READ_STATUS;
58
93
  readonly RESULT_STATUS: typeof import("../read-state/read-state.types").READ_STATUS;
59
94
  readonly ERROR_CODE: typeof import("../read-state/read-state.types").READ_ERROR_CODE;
95
+ readonly OUTCOME: typeof import("../read-state/read-state.types").READ_OUTCOME;
60
96
  };
97
+ AGENTIC: Readonly<{
98
+ WALLET: "agentic:wallet";
99
+ PRESETS: Readonly<{
100
+ CATEGORY: Readonly<{
101
+ DEXES: "DEXES";
102
+ LENDING: "LENDING";
103
+ PREDICTION: "PREDICTION";
104
+ }>;
105
+ }>;
106
+ }>;
61
107
  };
62
108
  /**
63
109
  * @static
@@ -245,6 +291,14 @@ export declare class PushChain {
245
291
  to: MoveableToken | undefined;
246
292
  }) => Promise<ConversionQuote>;
247
293
  };
294
+ /**
295
+ * Agentic wallet management (AGW): derive, create, list and per-wallet
296
+ * handles. Ownership is the connected signer's Push identity.
297
+ */
298
+ agentic: AgenticNamespace;
299
+ /** @internal AGW execution context when initialized with `agenticWallet`. */
300
+ private agenticContext?;
301
+ private readonly agenticRuntime;
248
302
  /**
249
303
  * Account status including UEA deployment state and version info.
250
304
  * Initially unloaded — call getAccountStatus() to populate.
@@ -291,13 +345,7 @@ export declare class PushChain {
291
345
  *
292
346
  * @returns An initialized instance of PushChain.
293
347
  */
294
- static initialize: (universalSigner: UniversalSigner | UniversalAccount, options?: {
295
- network: PUSH_NETWORK;
296
- rpcUrls?: Partial<Record<CHAIN, string[]>>;
297
- blockExplorers?: Partial<Record<CHAIN, string[]>>;
298
- printTraces?: boolean;
299
- progressHook?: (progress: ProgressEvent) => void;
300
- }) => Promise<PushChain>;
348
+ static initialize: (universalSigner: UniversalSigner | UniversalAccount, options?: PushChainInitializeOptions) => Promise<PushChain>;
301
349
  /**
302
350
  * @method reinitialize
303
351
  * Reinitializes the PushChain SDK with a new universal signer and optional config.
@@ -310,11 +358,5 @@ export declare class PushChain {
310
358
  *
311
359
  * @returns A new initialized instance of PushChain.
312
360
  */
313
- reinitialize: (universalSigner: UniversalSigner | UniversalAccount, options?: {
314
- network: PUSH_NETWORK;
315
- rpcUrls?: Partial<Record<CHAIN, string[]>>;
316
- blockExplorers?: Partial<Record<CHAIN, string[]>>;
317
- printTraces?: boolean;
318
- progressHook?: (progress: ProgressEvent) => void;
319
- }) => Promise<PushChain>;
361
+ reinitialize: (universalSigner: UniversalSigner | UniversalAccount, options?: PushChainInitializeOptions) => Promise<PushChain>;
320
362
  }
@@ -13,6 +13,12 @@ const evm_client_1 = require("../vm-client/evm-client");
13
13
  const tokens_1 = require("../constants/tokens");
14
14
  const read_params_1 = require("../read-state/read-params");
15
15
  const read_executor_1 = require("../read-state/read-executor");
16
+ const agentic_1 = require("../agentic/agentic");
17
+ const context_1 = require("../agentic/context");
18
+ const send_1 = require("../agentic/execution/send");
19
+ const guards_1 = require("../agentic/execution/guards");
20
+ const response_1 = require("../agentic/response");
21
+ const runtime_1 = require("../agentic/runtime");
16
22
  /**
17
23
  * @class PushChain
18
24
  *
@@ -52,6 +58,14 @@ class PushChain {
52
58
  moveable;
53
59
  payable;
54
60
  funds;
61
+ /**
62
+ * Agentic wallet management (AGW): derive, create, list and per-wallet
63
+ * handles. Ownership is the connected signer's Push identity.
64
+ */
65
+ agentic;
66
+ /** @internal AGW execution context when initialized with `agenticWallet`. */
67
+ agenticContext;
68
+ agenticRuntime;
55
69
  /**
56
70
  * Account status including UEA deployment state and version info.
57
71
  * Initially unloaded — call getAccountStatus() to populate.
@@ -81,61 +95,96 @@ class PushChain {
81
95
  };
82
96
  // Default — overwritten in createInstance() with the background fetch
83
97
  this.accountStatusReady = Promise.resolve();
98
+ this.agenticRuntime = (0, runtime_1.createAgenticRuntime)(orchestrator, isReadMode);
99
+ this.agentic = new agentic_1.AgenticNamespaceImpl(this.agenticRuntime);
100
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- getters below need the instance
101
+ const self = this;
102
+ // In agenticWallet mode, request transactions execute through the wallet
103
+ // and the wallet pays the request value, so its balance gates the read.
104
+ const readDeps = () => {
105
+ const actx = self.agenticContext;
106
+ if (!actx)
107
+ return orchestrator;
108
+ return {
109
+ execute: (params, options) => (0, send_1.agenticSend)(self.agenticRuntime, actx, params, options),
110
+ trackRead: orchestrator.trackRead.bind(orchestrator),
111
+ revalidateRead: orchestrator.revalidateRead.bind(orchestrator),
112
+ getProgressHook: orchestrator.getProgressHook.bind(orchestrator),
113
+ getReadBalance: () => self.agenticRuntime.reader.getBalance({ address: actx.wallet }),
114
+ };
115
+ };
116
+ // Unspent read budget returns to whoever paid it: the wallet in agentic mode.
117
+ const withReadRefund = (options) => self.agenticContext && options.refundTo === undefined
118
+ ? { ...options, refundTo: self.agenticContext.wallet }
119
+ : options;
84
120
  this.universal = {
85
121
  get origin() {
86
122
  return orchestrator.getUOA();
87
123
  },
88
124
  get account() {
89
- return orchestrator.computeUEAOffchain();
125
+ return self.agenticContext?.wallet ?? orchestrator.computeUEAOffchain();
90
126
  },
91
127
  sendTransaction: (...args) => {
92
128
  if (this.isReadMode) {
93
129
  throw new Error('Read only mode cannot call sendTransaction function');
94
130
  }
131
+ if (this.agenticContext) {
132
+ return (0, send_1.agenticSend)(this.agenticRuntime, this.agenticContext, ...args);
133
+ }
95
134
  return orchestrator.execute.bind(orchestrator)(...args);
96
135
  },
97
136
  prepareTransaction: (params, options) => {
137
+ if (this.agenticContext)
138
+ throw (0, guards_1.notAllowedInAgenticMode)('prepareTransaction');
98
139
  return orchestrator.prepareTransaction.bind(orchestrator)(params, options);
99
140
  },
100
141
  executeTransactions: async (txs, options) => {
101
142
  if (this.isReadMode) {
102
143
  throw new Error('Read only mode cannot call executeTransactions function');
103
144
  }
145
+ if (this.agenticContext)
146
+ throw (0, guards_1.notAllowedInAgenticMode)('executeTransactions');
104
147
  return orchestrator.createCascadedBuilder(txs, options).send();
105
148
  },
106
- trackTransaction: (txHash, options) => {
107
- return orchestrator.trackTransaction.bind(orchestrator)(txHash, options);
149
+ trackTransaction: async (txHash, options) => {
150
+ const tracked = await orchestrator.trackTransaction.bind(orchestrator)(txHash, options);
151
+ return (0, response_1.adaptTrackedResponse)(this.agenticRuntime, tracked);
108
152
  },
109
153
  migrateCEA: (chain) => {
110
154
  if (this.isReadMode) {
111
155
  throw new Error('Read only mode cannot call migrateCEA function');
112
156
  }
157
+ if (this.agenticContext)
158
+ throw (0, guards_1.notAllowedInAgenticMode)('migrateCEA');
113
159
  return orchestrator.migrateCEA.bind(orchestrator)(chain);
114
160
  },
115
161
  rescueFunds: (params) => {
116
162
  if (this.isReadMode) {
117
163
  throw new Error('Read only mode cannot call rescueFunds function');
118
164
  }
165
+ if (this.agenticContext)
166
+ throw (0, guards_1.notAllowedInAgenticMode)('rescueFunds');
119
167
  return orchestrator.rescueFunds.bind(orchestrator)(params);
120
168
  },
121
169
  // Only read()/executeReads() send transactions; prepare/simulate/track remain read-only.
122
170
  read: async (subject, options) => {
123
- const params = (0, read_params_1.toBuildReadSpecParams)(subject, options, orchestrator.getNetwork());
171
+ const params = await (0, read_params_1.resolveReadSpecParams)(subject, withReadRefund(options), orchestrator.getNetwork(), orchestrator.getRpcUrls());
124
172
  (0, read_executor_1.assertRequestEntrypoint)(params.callback, 'read');
125
173
  if (this.isReadMode)
126
174
  throw new Error('Read only mode cannot call read function');
127
175
  const prepared = await orchestrator.prepareRead(params, options.progressHook);
128
- const { reads: [response] } = await (0, read_executor_1.executeReads)(orchestrator, [prepared], options);
176
+ const { reads: [response] } = await (0, read_executor_1.executeReads)(readDeps(), [prepared], options);
129
177
  return response;
130
178
  },
131
- prepareRead: (subject, options) => {
132
- return orchestrator.prepareRead.bind(orchestrator)((0, read_params_1.toBuildReadSpecParams)(subject, options, orchestrator.getNetwork()));
179
+ prepareRead: async (subject, options) => {
180
+ const params = await (0, read_params_1.resolveReadSpecParams)(subject, withReadRefund(options), orchestrator.getNetwork(), orchestrator.getRpcUrls());
181
+ return orchestrator.prepareRead(params);
133
182
  },
134
183
  executeReads: (async (reads, options) => {
135
184
  reads.forEach((r) => (0, read_executor_1.assertRequestEntrypoint)(r.callback));
136
185
  if (this.isReadMode)
137
186
  throw new Error('Read only mode cannot call executeReads function');
138
- return (0, read_executor_1.executeReads)(orchestrator, reads, options);
187
+ return (0, read_executor_1.executeReads)(readDeps(), reads, options);
139
188
  }),
140
189
  trackRead: ((ref, options) => {
141
190
  const opts = { ...(0, read_params_1.toLifecycleOptions)(options), progressHook: options?.progressHook };
@@ -450,6 +499,12 @@ class PushChain {
450
499
  });
451
500
  // Let execute() await the background fetch instead of re-fetching
452
501
  orchestrator.accountStatusReadyPromise = instance.accountStatusReady;
502
+ // Agentic mode: validate the wallet, its generation and the signer's door
503
+ // before returning a client. A read-only client may hold the context (so
504
+ // universal.account shows the wallet) but every signing path stays closed.
505
+ if (options?.agenticWallet !== undefined) {
506
+ instance.agenticContext = await (0, context_1.resolveAgenticContext)(instance.agenticRuntime, options.agenticWallet);
507
+ }
453
508
  return instance;
454
509
  }
455
510
  /**
@@ -480,12 +535,17 @@ class PushChain {
480
535
  * @returns A new initialized instance of PushChain.
481
536
  */
482
537
  reinitialize = async (universalSigner, options) => {
538
+ // agenticWallet is NOT inherited: an omitted value yields an ordinary
539
+ // client, and a supplied one reruns every wallet/role check.
483
540
  const mergedOptions = {
484
541
  network: options?.network ?? this.orchestrator.getNetwork(),
485
542
  rpcUrls: options?.rpcUrls ?? this.orchestrator.getRpcUrls(),
486
543
  blockExplorers: options?.blockExplorers ?? this.blockExplorers,
487
544
  printTraces: options?.printTraces ?? this.orchestrator.getPrintTraces(),
488
545
  progressHook: options?.progressHook ?? this.orchestrator.getProgressHook(),
546
+ ...(options?.agenticWallet !== undefined
547
+ ? { agenticWallet: options.agenticWallet }
548
+ : {}),
489
549
  };
490
550
  return PushChain.createInstance(universalSigner, mergedOptions);
491
551
  };
@@ -54,6 +54,13 @@ export declare class PushClient extends EvmClient {
54
54
  */
55
55
  private readonly archiveTendermintRpc;
56
56
  private readonly archivePublicClient?;
57
+ /**
58
+ * Prune endpoints with transport retries off, raced against the archive. A
59
+ * receipt miss on the prune node answers -32002 "Requested resource not
60
+ * available" after ~8 s (measured on Donut 2026-09-23), and the shared
61
+ * client's `http({ retryCount: 5 })` would retry that on top.
62
+ */
63
+ private readonly pruneProbeClient?;
57
64
  constructor(clientOptions: PushClientOptions);
58
65
  /**
59
66
  * Executes an operation with automatic fallback to next RPC endpoint on failure.
@@ -48,6 +48,13 @@ class PushClient extends evm_client_1.EvmClient {
48
48
  */
49
49
  archiveTendermintRpc;
50
50
  archivePublicClient;
51
+ /**
52
+ * Prune endpoints with transport retries off, raced against the archive. A
53
+ * receipt miss on the prune node answers -32002 "Requested resource not
54
+ * available" after ~8 s (measured on Donut 2026-09-23), and the shared
55
+ * client's `http({ retryCount: 5 })` would retry that on top.
56
+ */
57
+ pruneProbeClient;
51
58
  constructor(clientOptions) {
52
59
  const pushChainKey = pushNetworkToChain(clientOptions.network);
53
60
  const chain = clientOptions.chain ?? (0, chain_1.getPushViemChain)(pushChainKey);
@@ -66,6 +73,10 @@ class PushClient extends evm_client_1.EvmClient {
66
73
  chain,
67
74
  transport: (0, viem_1.fallback)(archiveEvmUrls.map((url) => (0, viem_1.http)(url, { retryCount: 5, retryDelay: 500 }))),
68
75
  });
76
+ this.pruneProbeClient = (0, viem_1.createPublicClient)({
77
+ chain,
78
+ transport: (0, viem_1.fallback)(clientOptions.rpcUrls.map((url) => (0, viem_1.http)(url, { retryCount: 0 }))),
79
+ });
69
80
  }
70
81
  this.ephemeralKey = (0, accounts_1.generatePrivateKey)();
71
82
  this.ephemeralAccount = (0, accounts_1.privateKeyToAccount)(this.ephemeralKey);
@@ -357,17 +368,20 @@ class PushClient extends evm_client_1.EvmClient {
357
368
  * no EVM-indexed tx or receipt. Attribute values are plain strings.
358
369
  */
359
370
  async getBlockResultEvents(height) {
360
- return this.executeWithRpcFallback(async (rpcUrl) => {
371
+ // Prune nodes drop old heights ("height N is not available"); the archive keeps them.
372
+ return this.executeWithArchiveFallback(async (rpcUrl) => {
361
373
  const url = `${rpcUrl.replace(/\/+$/, '')}/block_results?height=${height}`;
362
374
  const res = await fetch(url);
363
- if (!res.ok)
364
- throw new Error(`HTTP request failed: ${res.status} ${url}`);
365
- const body = (await res.json());
366
- if (body.error)
375
+ // CometBFT answers a pruned height with HTTP 500 plus a JSON-RPC error. Surface that
376
+ // error so it reads as a definite miss (→ archive), not a transient HTTP failure to retry.
377
+ const body = (await res.json().catch(() => undefined));
378
+ if (body?.error)
367
379
  throw new Error(`block_results ${height}: ${body.error.data ?? body.error.message ?? 'error'}`);
380
+ if (!res.ok || !body)
381
+ throw new Error(`HTTP request failed: ${res.status} ${url}`);
368
382
  const events = body.result?.finalize_block_events ?? body.result?.end_block_events ?? [];
369
383
  return events;
370
- }, 'getBlockResultEvents');
384
+ }, 'getBlockResultEvents', () => false);
371
385
  }
372
386
  /**
373
387
  * Queries x/ucallback for every read a Push transaction requested. One tx can emit
@@ -479,17 +493,29 @@ class PushClient extends evm_client_1.EvmClient {
479
493
  * Prune first; on not-found, retry the archive EVM client if configured.
480
494
  */
481
495
  async getTransactionReceiptWithArchiveFallback(txHash) {
482
- try {
483
- return await this.publicClient.getTransactionReceipt({ hash: txHash });
484
- }
485
- catch (error) {
486
- if (!this.hasArchiveEvm)
487
- throw error;
488
- return this.archivePublicClient.getTransactionReceipt({
489
- hash: txHash,
490
- });
496
+ if (!this.hasArchiveEvm || !this.pruneProbeClient) {
497
+ return this.publicClient.getTransactionReceipt({ hash: txHash });
491
498
  }
499
+ // Race prune and archive; the first receipt wins. A pruned receipt costs one
500
+ // archive round trip, a fresh one the prune round trip (if the archive lags).
501
+ const prune = this.pruneProbeClient.getTransactionReceipt({ hash: txHash });
502
+ const archive = this.archivePublicClient.getTransactionReceipt({
503
+ hash: txHash,
504
+ });
505
+ return firstFulfilled([archive, prune]);
492
506
  }
493
507
  }
494
508
  exports.PushClient = PushClient;
509
+ /** First promise to resolve; if all reject, the last rejection. */
510
+ function firstFulfilled(promises) {
511
+ return new Promise((resolve, reject) => {
512
+ let pending = promises.length;
513
+ for (const p of promises) {
514
+ p.then(resolve, (error) => {
515
+ if (--pending === 0)
516
+ reject(error);
517
+ });
518
+ }
519
+ });
520
+ }
495
521
  //# sourceMappingURL=push-client.js.map
@@ -17,7 +17,12 @@ const KNOWN = new Set(Object.values(read_state_1.READ_NAMESPACE));
17
17
  function resolveDestination(dest) {
18
18
  let chainNamespace;
19
19
  let chainId;
20
- if ('chain' in dest) {
20
+ if ('chain' in dest && dest.chain === read_state_1.WEB2_READ_CHAIN) {
21
+ // The public 'web2' spelling has no ':'; its wire identity is web2:https.
22
+ chainNamespace = read_state_1.WEB2_DESTINATION.chainNamespace;
23
+ chainId = read_state_1.WEB2_DESTINATION.chainId;
24
+ }
25
+ else if ('chain' in dest) {
21
26
  const idx = dest.chain.indexOf(':');
22
27
  if (idx <= 0) {
23
28
  throw new errors_1.UnsupportedReadDestinationError(`chain is not CAIP-2: ${dest.chain}`);
@@ -104,9 +104,8 @@ function encodeEvmQueryEnvelope(query, options) {
104
104
  if (!item || item.type !== 'function') {
105
105
  throw new errors_1.InvalidReadQueryError(`function not found in abi: ${query.functionName}`);
106
106
  }
107
- if (item.stateMutability !== 'view' && item.stateMutability !== 'pure') {
108
- throw new errors_1.InvalidReadQueryError(`${query.functionName} is ${item.stateMutability}; reads must target view/pure functions`);
109
- }
107
+ // Any mutability: validators run the call as an eth_call simulation at the
108
+ // pinned block, so nonpayable/payable functions return data and never execute.
110
109
  callData = (0, viem_1.encodeFunctionData)({
111
110
  abi: query.abi,
112
111
  functionName: query.functionName,
@@ -11,6 +11,7 @@ const bs58_1 = tslib_1.__importDefault(require("bs58"));
11
11
  const viem_1 = require("viem");
12
12
  const read_state_1 = require("../../constants/read-state");
13
13
  const errors_1 = require("../errors");
14
+ const svm_account_1 = require("../svm-account");
14
15
  /** `universalClient/externalchains/svm/read_envelope.go` — solanaQueryType. */
15
16
  exports.SVM_QUERY_TYPE = {
16
17
  LAMPORT_BALANCE: 0,
@@ -83,7 +84,16 @@ function encodeSvmQueryEnvelope(query, options = {}) {
83
84
  break;
84
85
  case 'rawAccountData':
85
86
  queryType = exports.SVM_QUERY_TYPE.RAW_ACCOUNT_DATA;
86
- resultShape = { kind: 'raw' };
87
+ if (query.idl !== undefined) {
88
+ (0, svm_account_1.validateIdl)(query.idl);
89
+ const accountName = query.accountName === undefined ? undefined : (0, svm_account_1.resolveAccountName)(query.idl, query.accountName);
90
+ resultShape = accountName === undefined ? { kind: 'svmAccount', idl: query.idl } : { kind: 'svmAccount', idl: query.idl, accountName };
91
+ }
92
+ else if (query.accountName !== undefined) {
93
+ throw new errors_1.InvalidReadQueryError('accountName needs idl');
94
+ }
95
+ else
96
+ resultShape = { kind: 'raw' };
87
97
  break;
88
98
  default:
89
99
  throw new errors_1.InvalidReadQueryError(`unknown SVM query type: ${query.type}`);
@@ -11,6 +11,7 @@ const spec_builder_1 = require("./spec-builder");
11
11
  const progress_hook_1 = tslib_1.__importDefault(require("../progress-hook/progress-hook"));
12
12
  const progress_hook_types_1 = require("../progress-hook/progress-hook.types");
13
13
  const read_state_types_1 = require("./read-state.types");
14
+ const read_state_1 = require("../constants/read-state");
14
15
  /**
15
16
  * The custom-receiver contract of `read()` / `executeReads()`: a non-zero target and the
16
17
  * app's request entrypoint. Pure — call it before any preflight so a malformed request
@@ -58,6 +59,9 @@ async function executeReads(deps, reads, options = {}) {
58
59
  failedAt = i + 1;
59
60
  if (batch)
60
61
  emit(progress_hook_types_1.PROGRESS_HOOK.READ_TX_002_01, i + 1, reads.length, prepared.preflight.destination.caip2);
62
+ const ageMs = Date.now() - prepared.preflight.fetchedAt;
63
+ if (ageMs > read_state_1.READ_PREFLIGHT_STALE_MS)
64
+ emit(progress_hook_types_1.PROGRESS_HOOK.READ_TX_102_04, prepared.preflight.fetchedAt, ageMs);
61
65
  await deps.revalidateRead(prepared);
62
66
  }
63
67
  failedAt = 0;