@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
@@ -0,0 +1,11 @@
1
+ /** Source 2e61e13; code/proxy wiring checked at Donut block 23991912. */
2
+ export declare const V5_SOURCE_COMMIT = "2e61e133e641b4e0e1ddbdc9306b0903b60e4dbb";
3
+ export declare const DONUT_V5_START_BLOCK: bigint;
4
+ export declare const DONUT_V5_ADDRESSES: {
5
+ readonly factory: "0x8137F96A50EBF41d904e3678c84c391a0D1BCcc5";
6
+ readonly walletImplementation: "0x4D459Da499C14548aa16c46c57fD92880A88EBb4";
7
+ readonly sessionEngine: "0x165A5E6782f39D30B38c7D97e1303e4CB2aD102a";
8
+ readonly rulesPolicy: "0x603E7f0aF6e1aAFf46DDfb28b1e99364f8BC59af";
9
+ readonly sessionValidator: "0x068EE2388475A98EE1f5a434C58bFF3444fffFe6";
10
+ readonly gateway: "0x00000000000000000000000000000000000000C1";
11
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DONUT_V5_ADDRESSES = exports.DONUT_V5_START_BLOCK = exports.V5_SOURCE_COMMIT = void 0;
4
+ /** Source 2e61e13; code/proxy wiring checked at Donut block 23991912. */
5
+ exports.V5_SOURCE_COMMIT = '2e61e133e641b4e0e1ddbdc9306b0903b60e4dbb';
6
+ exports.DONUT_V5_START_BLOCK = BigInt(23989983);
7
+ exports.DONUT_V5_ADDRESSES = {
8
+ factory: '0x8137F96A50EBF41d904e3678c84c391a0D1BCcc5',
9
+ walletImplementation: '0x4D459Da499C14548aa16c46c57fD92880A88EBb4',
10
+ sessionEngine: '0x165A5E6782f39D30B38c7D97e1303e4CB2aD102a',
11
+ rulesPolicy: '0x603E7f0aF6e1aAFf46DDfb28b1e99364f8BC59af',
12
+ sessionValidator: '0x068EE2388475A98EE1f5a434C58bFF3444fffFe6',
13
+ gateway: '0x00000000000000000000000000000000000000C1',
14
+ };
15
+ //# sourceMappingURL=donut-v5.js.map
@@ -0,0 +1,26 @@
1
+ import { type Address, type Hex } from 'viem';
2
+ import type { Snapshot } from '../reads/snapshot';
3
+ import { PUSH_NETWORK } from '../../constants/enums';
4
+ export declare const PRC20_SOURCE_ABI: readonly [{
5
+ readonly name: "SOURCE_CHAIN_NAMESPACE";
6
+ readonly type: "function";
7
+ readonly stateMutability: "view";
8
+ readonly inputs: readonly [];
9
+ readonly outputs: readonly [{
10
+ readonly type: "string";
11
+ }];
12
+ }, {
13
+ readonly name: "SOURCE_TOKEN_ADDRESS";
14
+ readonly type: "function";
15
+ readonly stateMutability: "view";
16
+ readonly inputs: readonly [];
17
+ readonly outputs: readonly [{
18
+ readonly type: "string";
19
+ }];
20
+ }];
21
+ /** Resolve the SVM source mint from metadata or the current chain-specific token registry. */
22
+ export declare function readSvmSourceToken(snap: Snapshot, token: Address, chain: string, network?: PUSH_NETWORK): Promise<Hex>;
23
+ export declare const CORE_ADDRESS: Address;
24
+ export declare function readGasPrc20(snap: Snapshot, chain: string): Promise<Address>;
25
+ /** Donut native precompile returns a zero word; ERC20 metadata is a dynamic string. */
26
+ export declare function readOriginToken(snap: Snapshot, token: Address, chain: string): Promise<Address>;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CORE_ADDRESS = exports.PRC20_SOURCE_ABI = void 0;
4
+ exports.readSvmSourceToken = readSvmSourceToken;
5
+ exports.readGasPrc20 = readGasPrc20;
6
+ exports.readOriginToken = readOriginToken;
7
+ const viem_1 = require("viem");
8
+ const prc20_evm_1 = require("../../constants/abi/prc20.evm");
9
+ const errors_1 = require("../errors");
10
+ const enums_1 = require("../../constants/enums");
11
+ const tokens_1 = require("../../constants/tokens");
12
+ const prc20_address_1 = require("../../universal/prc20-address");
13
+ const svm_accounts_1 = require("../codec/svm-accounts");
14
+ exports.PRC20_SOURCE_ABI = (0, viem_1.parseAbi)([
15
+ 'function SOURCE_CHAIN_NAMESPACE() view returns (string)',
16
+ 'function SOURCE_TOKEN_ADDRESS() view returns (string)',
17
+ ]);
18
+ const NATIVE_SOURCE_ABI = (0, viem_1.parseAbi)([
19
+ 'function SOURCE_TOKEN_ADDRESS() view returns (address)',
20
+ ]);
21
+ const SVM_SOURCE_WORD_ABI = (0, viem_1.parseAbi)([
22
+ 'function SOURCE_TOKEN_ADDRESS() view returns (bytes32)',
23
+ ]);
24
+ /** Resolve the SVM source mint from metadata or the current chain-specific token registry. */
25
+ async function readSvmSourceToken(snap, token, chain, network = enums_1.PUSH_NETWORK.TESTNET_DONUT) {
26
+ let source;
27
+ try {
28
+ source = await snap.read(token, exports.PRC20_SOURCE_ABI, 'SOURCE_TOKEN_ADDRESS');
29
+ }
30
+ catch (cause) {
31
+ try {
32
+ source = await snap.read(token, SVM_SOURCE_WORD_ABI, 'SOURCE_TOKEN_ADDRESS');
33
+ }
34
+ catch {
35
+ throw cause;
36
+ }
37
+ }
38
+ const zeroKey = `0x${'00'.repeat(32)}`;
39
+ if (source === '' ||
40
+ source.toLowerCase() === viem_1.zeroAddress ||
41
+ source.toLowerCase() === zeroKey) {
42
+ if ((0, viem_1.getAddress)(token) === (await readGasPrc20(snap, chain)))
43
+ return zeroKey;
44
+ // Current Donut SVM synthetic metadata exposes a zero word for SPL assets.
45
+ // Ordinary Route 2 already resolves these through the same token registry.
46
+ // Match both full origin chain and exact PRC20; never infer an unknown mint.
47
+ for (const asset of tokens_1.MOVEABLE_TOKENS[chain] ?? []) {
48
+ if (asset.mechanism === 'native')
49
+ continue;
50
+ try {
51
+ const resolved = (0, prc20_address_1.getPRC20Address)({ chain, address: asset.address }, { network });
52
+ if ((0, viem_1.getAddress)(resolved.address) === (0, viem_1.getAddress)(token))
53
+ return (0, svm_accounts_1.svmKey)(asset.address);
54
+ }
55
+ catch {
56
+ // A token without a deployment in this network is not a candidate.
57
+ }
58
+ }
59
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, `source mint unavailable for PRC20 ${token} on ${chain}; no registered mapping matches`);
60
+ }
61
+ return (0, svm_accounts_1.svmKey)(source);
62
+ }
63
+ exports.CORE_ADDRESS = '0x00000000000000000000000000000000000000C0';
64
+ async function readGasPrc20(snap, chain) {
65
+ return (0, viem_1.getAddress)(await snap.read(exports.CORE_ADDRESS, prc20_evm_1.UNIVERSAL_CORE_EVM, 'gasTokenPRC20ByChainNamespace', [chain]));
66
+ }
67
+ /** Donut native precompile returns a zero word; ERC20 metadata is a dynamic string. */
68
+ async function readOriginToken(snap, token, chain) {
69
+ let source;
70
+ try {
71
+ source = await snap.read(token, exports.PRC20_SOURCE_ABI, 'SOURCE_TOKEN_ADDRESS');
72
+ }
73
+ catch (cause) {
74
+ if ((await readGasPrc20(snap, chain)) !== (0, viem_1.getAddress)(token))
75
+ throw cause;
76
+ const native = await snap.read(token, NATIVE_SOURCE_ABI, 'SOURCE_TOKEN_ADDRESS');
77
+ if ((0, viem_1.getAddress)(native) === viem_1.zeroAddress)
78
+ return viem_1.zeroAddress;
79
+ throw cause;
80
+ }
81
+ if ((0, viem_1.isAddress)(source, { strict: false }))
82
+ return (0, viem_1.getAddress)(source);
83
+ if (source === '' && (await readGasPrc20(snap, chain)) === (0, viem_1.getAddress)(token))
84
+ return viem_1.zeroAddress;
85
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, `PRC20 ${token} has an invalid source token address`);
86
+ }
87
+ //# sourceMappingURL=prc20-metadata.js.map
@@ -0,0 +1,35 @@
1
+ import type { Abi, AbiEvent, Address, Hex, Log, PublicClient, TransactionReceipt } from 'viem';
2
+ /**
3
+ * The narrow chain-read surface the AGW module needs. Tests mock it; the SDK
4
+ * adapts the Push client's viem PublicClient. Every snapshot read passes an
5
+ * explicit `blockNumber` so dependent reads observe one state.
6
+ */
7
+ export interface ChainReader {
8
+ readContract(args: {
9
+ address: Address;
10
+ abi: Abi | readonly unknown[];
11
+ functionName: string;
12
+ args?: readonly unknown[];
13
+ blockNumber?: bigint;
14
+ }): Promise<unknown>;
15
+ getBlockNumber(): Promise<bigint>;
16
+ getCode(args: {
17
+ address: Address;
18
+ blockNumber?: bigint;
19
+ }): Promise<Hex | undefined>;
20
+ getBalance(args: {
21
+ address: Address;
22
+ blockNumber?: bigint;
23
+ }): Promise<bigint>;
24
+ getLogs(args: {
25
+ address: Address;
26
+ event: AbiEvent;
27
+ args?: Record<string, unknown>;
28
+ fromBlock: bigint;
29
+ toBlock: bigint;
30
+ }): Promise<Log[]>;
31
+ getTransactionReceipt(args: {
32
+ hash: Hex;
33
+ }): Promise<TransactionReceipt>;
34
+ }
35
+ export declare function chainReaderFromPublicClient(client: PublicClient): ChainReader;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainReaderFromPublicClient = chainReaderFromPublicClient;
4
+ function chainReaderFromPublicClient(client) {
5
+ // viem's generics are narrower than this module's needs; the casts are
6
+ // confined to this adapter.
7
+ return {
8
+ readContract: (args) => client.readContract(args),
9
+ getBlockNumber: () => client.getBlockNumber({ cacheTime: 0 }),
10
+ getCode: (args) => client.getCode(args),
11
+ getBalance: (args) => client.getBalance(args),
12
+ getLogs: (args) => client.getLogs(args),
13
+ getTransactionReceipt: (args) => client.getTransactionReceipt(args),
14
+ };
15
+ }
16
+ //# sourceMappingURL=reader.js.map