@pushchain/core 6.0.26 → 6.0.27-alpha.1
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.
- package/AGW.md +226 -0
- package/CHANGELOG.md +18 -0
- package/README.md +2 -0
- package/package.json +7 -1
- package/src/lib/agentic/agentic.d.ts +23 -0
- package/src/lib/agentic/agentic.js +51 -0
- package/src/lib/agentic/agentic.types.d.ts +414 -0
- package/src/lib/agentic/agentic.types.js +3 -0
- package/src/lib/agentic/capabilities.d.ts +37 -0
- package/src/lib/agentic/capabilities.js +64 -0
- package/src/lib/agentic/chain.d.ts +3 -0
- package/src/lib/agentic/chain.js +15 -0
- package/src/lib/agentic/codec/abi-layout.d.ts +20 -0
- package/src/lib/agentic/codec/abi-layout.js +168 -0
- package/src/lib/agentic/codec/defaults.d.ts +51 -0
- package/src/lib/agentic/codec/defaults.js +53 -0
- package/src/lib/agentic/codec/ids.d.ts +35 -0
- package/src/lib/agentic/codec/ids.js +74 -0
- package/src/lib/agentic/codec/native.d.ts +73 -0
- package/src/lib/agentic/codec/native.js +341 -0
- package/src/lib/agentic/codec/pins.d.ts +20 -0
- package/src/lib/agentic/codec/pins.js +29 -0
- package/src/lib/agentic/codec/rules.d.ts +45 -0
- package/src/lib/agentic/codec/rules.js +110 -0
- package/src/lib/agentic/codec/selectors.d.ts +19 -0
- package/src/lib/agentic/codec/selectors.js +60 -0
- package/src/lib/agentic/codec/session.d.ts +54 -0
- package/src/lib/agentic/codec/session.js +65 -0
- package/src/lib/agentic/codec/svm-accounts.d.ts +35 -0
- package/src/lib/agentic/codec/svm-accounts.js +68 -0
- package/src/lib/agentic/codec/svm-idl.d.ts +11 -0
- package/src/lib/agentic/codec/svm-idl.js +226 -0
- package/src/lib/agentic/codec/svm-terms.d.ts +157 -0
- package/src/lib/agentic/codec/svm-terms.js +246 -0
- package/src/lib/agentic/codec/universal-terms.d.ts +82 -0
- package/src/lib/agentic/codec/universal-terms.js +43 -0
- package/src/lib/agentic/codec/universal.d.ts +14 -0
- package/src/lib/agentic/codec/universal.js +173 -0
- package/src/lib/agentic/constants.d.ts +12 -0
- package/src/lib/agentic/constants.js +16 -0
- package/src/lib/agentic/context.d.ts +29 -0
- package/src/lib/agentic/context.js +56 -0
- package/src/lib/agentic/contracts/abi/v6/agent-validator.d.ts +105 -0
- package/src/lib/agentic/contracts/abi/v6/agent-validator.js +149 -0
- package/src/lib/agentic/contracts/abi/v6/agw-factory.d.ts +1146 -0
- package/src/lib/agentic/contracts/abi/v6/agw-factory.js +1499 -0
- package/src/lib/agentic/contracts/abi/v6/agw.d.ts +1306 -0
- package/src/lib/agentic/contracts/abi/v6/agw.js +1713 -0
- package/src/lib/agentic/contracts/abi/v6/index.d.ts +6 -0
- package/src/lib/agentic/contracts/abi/v6/index.js +17 -0
- package/src/lib/agentic/contracts/abi/v6/smart-session.d.ts +1493 -0
- package/src/lib/agentic/contracts/abi/v6/smart-session.js +1965 -0
- package/src/lib/agentic/contracts/abi/v6/universal-rules-policy.d.ts +1661 -0
- package/src/lib/agentic/contracts/abi/v6/universal-rules-policy.js +2187 -0
- package/src/lib/agentic/contracts/donut-v6.d.ts +11 -0
- package/src/lib/agentic/contracts/donut-v6.js +15 -0
- package/src/lib/agentic/contracts/prc20-metadata.d.ts +26 -0
- package/src/lib/agentic/contracts/prc20-metadata.js +87 -0
- package/src/lib/agentic/contracts/reader.d.ts +35 -0
- package/src/lib/agentic/contracts/reader.js +16 -0
- package/src/lib/agentic/contracts/v6.d.ts +5739 -0
- package/src/lib/agentic/contracts/v6.js +343 -0
- package/src/lib/agentic/deployments.d.ts +61 -0
- package/src/lib/agentic/deployments.js +203 -0
- package/src/lib/agentic/errors.d.ts +65 -0
- package/src/lib/agentic/errors.js +84 -0
- package/src/lib/agentic/execution/guards.d.ts +9 -0
- package/src/lib/agentic/execution/guards.js +30 -0
- package/src/lib/agentic/execution/outbound.d.ts +55 -0
- package/src/lib/agentic/execution/outbound.js +187 -0
- package/src/lib/agentic/execution/send.d.ts +9 -0
- package/src/lib/agentic/execution/send.js +268 -0
- package/src/lib/agentic/execution/svm-instruction.d.ts +24 -0
- package/src/lib/agentic/execution/svm-instruction.js +40 -0
- package/src/lib/agentic/execution/svm-outbound.d.ts +18 -0
- package/src/lib/agentic/execution/svm-outbound.js +86 -0
- package/src/lib/agentic/execution/svm-payload.d.ts +18 -0
- package/src/lib/agentic/execution/svm-payload.js +136 -0
- package/src/lib/agentic/execution/svm-public.d.ts +5 -0
- package/src/lib/agentic/execution/svm-public.js +176 -0
- package/src/lib/agentic/execution/svm-quote.d.ts +11 -0
- package/src/lib/agentic/execution/svm-quote.js +24 -0
- package/src/lib/agentic/execution/svm-send.d.ts +44 -0
- package/src/lib/agentic/execution/svm-send.js +87 -0
- package/src/lib/agentic/index.d.ts +5 -0
- package/src/lib/agentic/index.js +10 -0
- package/src/lib/agentic/management/common.d.ts +29 -0
- package/src/lib/agentic/management/common.js +116 -0
- package/src/lib/agentic/management/create.d.ts +4 -0
- package/src/lib/agentic/management/create.js +138 -0
- package/src/lib/agentic/management/duplicates.d.ts +4 -0
- package/src/lib/agentic/management/duplicates.js +20 -0
- package/src/lib/agentic/management/label.d.ts +3 -0
- package/src/lib/agentic/management/label.js +17 -0
- package/src/lib/agentic/management/prepare.d.ts +7 -0
- package/src/lib/agentic/management/prepare.js +95 -0
- package/src/lib/agentic/management/rules-write.d.ts +42 -0
- package/src/lib/agentic/management/rules-write.js +279 -0
- package/src/lib/agentic/management/svm-context.d.ts +25 -0
- package/src/lib/agentic/management/svm-context.js +55 -0
- package/src/lib/agentic/management/svm-metadata.d.ts +10 -0
- package/src/lib/agentic/management/svm-metadata.js +56 -0
- package/src/lib/agentic/management/svm-public.d.ts +6 -0
- package/src/lib/agentic/management/svm-public.js +125 -0
- package/src/lib/agentic/management/svm.d.ts +27 -0
- package/src/lib/agentic/management/svm.js +150 -0
- package/src/lib/agentic/presets/catalog.d.ts +26 -0
- package/src/lib/agentic/presets/catalog.js +307 -0
- package/src/lib/agentic/presets/index.d.ts +5 -0
- package/src/lib/agentic/presets/index.js +265 -0
- package/src/lib/agentic/presets/types.d.ts +48 -0
- package/src/lib/agentic/presets/types.js +3 -0
- package/src/lib/agentic/public-rule.d.ts +9 -0
- package/src/lib/agentic/public-rule.js +326 -0
- package/src/lib/agentic/reads/checkpoints.d.ts +17 -0
- package/src/lib/agentic/reads/checkpoints.js +109 -0
- package/src/lib/agentic/reads/rules.d.ts +42 -0
- package/src/lib/agentic/reads/rules.js +302 -0
- package/src/lib/agentic/reads/snapshot.d.ts +28 -0
- package/src/lib/agentic/reads/snapshot.js +85 -0
- package/src/lib/agentic/reads/svm.d.ts +17 -0
- package/src/lib/agentic/reads/svm.js +52 -0
- package/src/lib/agentic/reads/wallets.d.ts +25 -0
- package/src/lib/agentic/reads/wallets.js +122 -0
- package/src/lib/agentic/response.d.ts +41 -0
- package/src/lib/agentic/response.js +358 -0
- package/src/lib/agentic/revert.d.ts +7 -0
- package/src/lib/agentic/revert.js +102 -0
- package/src/lib/agentic/runtime.d.ts +58 -0
- package/src/lib/agentic/runtime.js +104 -0
- package/src/lib/agentic/utils.d.ts +57 -0
- package/src/lib/agentic/utils.js +165 -0
- package/src/lib/agentic/wallet.d.ts +32 -0
- package/src/lib/agentic/wallet.js +130 -0
- package/src/lib/constants/enums.d.ts +6 -3
- package/src/lib/constants/enums.js +6 -3
- package/src/lib/constants/index.d.ts +61 -4
- package/src/lib/constants/index.js +17 -3
- package/src/lib/constants/read-state.d.ts +9 -0
- package/src/lib/constants/read-state.js +13 -1
- package/src/lib/index.d.ts +8 -2
- package/src/lib/index.js +9 -1
- package/src/lib/orchestrator/internals/errors.d.ts +7 -0
- package/src/lib/orchestrator/internals/errors.js +13 -1
- package/src/lib/orchestrator/internals/execute-standard.d.ts +3 -1
- package/src/lib/orchestrator/internals/execute-standard.js +3 -3
- package/src/lib/orchestrator/internals/outbound-sync.js +52 -7
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +1 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +13 -1
- package/src/lib/orchestrator/orchestrator.d.ts +3 -0
- package/src/lib/orchestrator/orchestrator.js +13 -1
- package/src/lib/orchestrator/orchestrator.types.d.ts +8 -0
- package/src/lib/orchestrator/route-detector.js +3 -2
- package/src/lib/orchestrator/svm-idl/resolve.d.ts +2 -0
- package/src/lib/orchestrator/svm-idl/resolve.js +11 -1
- package/src/lib/progress-hook/progress-hook.js +63 -0
- package/src/lib/progress-hook/progress-hook.types.d.ts +10 -1
- package/src/lib/progress-hook/progress-hook.types.js +10 -0
- package/src/lib/push-chain/push-chain.d.ts +57 -15
- package/src/lib/push-chain/push-chain.js +66 -7
- package/src/lib/read-state/destination.js +6 -1
- package/src/lib/read-state/read-params.d.ts +3 -3
- package/src/lib/read-state/read-params.js +3 -2
- package/src/lib/read-state/read-state.types.d.ts +3 -1
- package/src/lib/read-state/read-tracker.js +2 -2
- package/src/lib/read-state/spec-builder.js +1 -1
- package/src/lib/universal/prc20-address.d.ts +15 -0
- package/src/lib/universal/prc20-address.js +135 -0
- package/src/lib/utils.d.ts +6 -13
- package/src/lib/utils.js +5 -128
- package/src/lib/vm-client/evm-client.js +34 -20
|
@@ -1233,6 +1233,68 @@ const RAW_HOOKS_READ = {
|
|
|
1233
1233
|
level: 'ERROR',
|
|
1234
1234
|
}),
|
|
1235
1235
|
};
|
|
1236
|
+
const RAW_HOOKS_AGENTIC = {
|
|
1237
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_101]: (address, index, deployed) => ({
|
|
1238
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_101,
|
|
1239
|
+
title: 'Agentic Wallet Derived',
|
|
1240
|
+
message: `Wallet ${address} at index ${index} (${deployed ? 'deployed' : 'not deployed'}).`,
|
|
1241
|
+
response: { address, index, deployed },
|
|
1242
|
+
level: 'INFO',
|
|
1243
|
+
}),
|
|
1244
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_102]: (address, strategy) => ({
|
|
1245
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_102,
|
|
1246
|
+
title: 'Deploy Step Added',
|
|
1247
|
+
message: `Deploying agentic wallet ${address} (${strategy}).`,
|
|
1248
|
+
response: { address, strategy },
|
|
1249
|
+
level: 'INFO',
|
|
1250
|
+
}),
|
|
1251
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_104]: (rulesIds) => ({
|
|
1252
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_104,
|
|
1253
|
+
title: 'Rules Granted',
|
|
1254
|
+
message: `Granted ${rulesIds.length} rule${rulesIds.length === 1 ? '' : 's'}.`,
|
|
1255
|
+
response: { rulesIds },
|
|
1256
|
+
level: 'INFO',
|
|
1257
|
+
}),
|
|
1258
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_105]: (target) => ({
|
|
1259
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_105,
|
|
1260
|
+
title: 'Rules Revoked',
|
|
1261
|
+
message: 'all' in target
|
|
1262
|
+
? 'Revoked every rule on the wallet.'
|
|
1263
|
+
: `Revoked ${target.rulesIds.length} rule${target.rulesIds.length === 1 ? '' : 's'}.`,
|
|
1264
|
+
response: target,
|
|
1265
|
+
level: 'INFO',
|
|
1266
|
+
}),
|
|
1267
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_106]: (label) => ({
|
|
1268
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_106,
|
|
1269
|
+
title: 'Label Set',
|
|
1270
|
+
message: `Wallet label set to "${label}".`,
|
|
1271
|
+
response: { label },
|
|
1272
|
+
level: 'INFO',
|
|
1273
|
+
}),
|
|
1274
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_107]: (rulesId, chainNamespace, door) => ({
|
|
1275
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_107,
|
|
1276
|
+
title: 'Rule Resolved',
|
|
1277
|
+
message: door === 'owner'
|
|
1278
|
+
? `Owner door on ${chainNamespace}; no rule applies.`
|
|
1279
|
+
: `Agent door on ${chainNamespace} under rule ${rulesId}.`,
|
|
1280
|
+
response: { rulesId: rulesId ?? null, chainNamespace, door },
|
|
1281
|
+
level: 'INFO',
|
|
1282
|
+
}),
|
|
1283
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_199_01]: (operation, txHash) => ({
|
|
1284
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_199_01,
|
|
1285
|
+
title: 'Agentic Operation Done',
|
|
1286
|
+
message: `${operation} completed.`,
|
|
1287
|
+
response: { operation, txHash: txHash ?? null },
|
|
1288
|
+
level: 'SUCCESS',
|
|
1289
|
+
}),
|
|
1290
|
+
[progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_199_02]: (operation, code, message, decodedError) => ({
|
|
1291
|
+
id: progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_199_02,
|
|
1292
|
+
title: 'Agentic Operation Failed',
|
|
1293
|
+
message: `${operation} failed: ${message}`,
|
|
1294
|
+
response: { operation, code, decodedError: decodedError ?? null },
|
|
1295
|
+
level: 'ERROR',
|
|
1296
|
+
}),
|
|
1297
|
+
};
|
|
1236
1298
|
// Combine all routes into the master record
|
|
1237
1299
|
const RAW_HOOKS = {
|
|
1238
1300
|
...RAW_HOOKS_R1,
|
|
@@ -1241,6 +1303,7 @@ const RAW_HOOKS = {
|
|
|
1241
1303
|
...RAW_HOOKS_MULTICHAIN,
|
|
1242
1304
|
...RAW_HOOKS_MIG,
|
|
1243
1305
|
...RAW_HOOKS_READ,
|
|
1306
|
+
...RAW_HOOKS_AGENTIC,
|
|
1244
1307
|
};
|
|
1245
1308
|
// Build final hooks with timestamp injection
|
|
1246
1309
|
const PROGRESS_HOOKS = Object.fromEntries(Object.entries(RAW_HOOKS).map(([key, value]) => [key, withTimestamp(value)]));
|
|
@@ -134,7 +134,15 @@ export declare enum PROGRESS_HOOK {
|
|
|
134
134
|
UEA_MIG_03 = "UEA-MIG-03",
|
|
135
135
|
UEA_MIG_9901 = "UEA-MIG-9901",
|
|
136
136
|
UEA_MIG_9902 = "UEA-MIG-9902",
|
|
137
|
-
UEA_MIG_9903 = "UEA-MIG-9903"
|
|
137
|
+
UEA_MIG_9903 = "UEA-MIG-9903",
|
|
138
|
+
AGENTIC_TX_101 = "AGENTIC-TX-101",
|
|
139
|
+
AGENTIC_TX_102 = "AGENTIC-TX-102",
|
|
140
|
+
AGENTIC_TX_104 = "AGENTIC-TX-104",
|
|
141
|
+
AGENTIC_TX_105 = "AGENTIC-TX-105",
|
|
142
|
+
AGENTIC_TX_106 = "AGENTIC-TX-106",
|
|
143
|
+
AGENTIC_TX_107 = "AGENTIC-TX-107",
|
|
144
|
+
AGENTIC_TX_199_01 = "AGENTIC-TX-199-01",
|
|
145
|
+
AGENTIC_TX_199_02 = "AGENTIC-TX-199-02"
|
|
138
146
|
}
|
|
139
147
|
export type PROGRESS_HOOK_R1 = PROGRESS_HOOK.SEND_TX_101 | PROGRESS_HOOK.SEND_TX_102_01 | PROGRESS_HOOK.SEND_TX_103_01 | PROGRESS_HOOK.SEND_TX_103_02 | PROGRESS_HOOK.SEND_TX_103_03 | PROGRESS_HOOK.SEND_TX_103_03_01 | PROGRESS_HOOK.SEND_TX_103_03_02 | PROGRESS_HOOK.SEND_TX_103_03_03 | PROGRESS_HOOK.SEND_TX_103_03_04 | PROGRESS_HOOK.SEND_TX_104_01 | PROGRESS_HOOK.SEND_TX_104_02 | PROGRESS_HOOK.SEND_TX_104_03 | PROGRESS_HOOK.SEND_TX_104_04 | PROGRESS_HOOK.SEND_TX_105_01 | PROGRESS_HOOK.SEND_TX_105_02 | PROGRESS_HOOK.SEND_TX_106_01 | PROGRESS_HOOK.SEND_TX_106_02 | PROGRESS_HOOK.SEND_TX_106_03 | PROGRESS_HOOK.SEND_TX_106_03_01 | PROGRESS_HOOK.SEND_TX_106_03_02 | PROGRESS_HOOK.SEND_TX_106_04 | PROGRESS_HOOK.SEND_TX_106_05 | PROGRESS_HOOK.SEND_TX_106_06 | PROGRESS_HOOK.SEND_TX_107 | PROGRESS_HOOK.SEND_TX_199_01 | PROGRESS_HOOK.SEND_TX_199_02 | PROGRESS_HOOK.SEND_TX_199_03 | PROGRESS_HOOK.SEND_TX_199_99;
|
|
140
148
|
export type PROGRESS_HOOK_R2 = PROGRESS_HOOK.SEND_TX_201 | PROGRESS_HOOK.SEND_TX_202_01 | PROGRESS_HOOK.SEND_TX_202_02 | PROGRESS_HOOK.SEND_TX_203_01 | PROGRESS_HOOK.SEND_TX_203_02 | PROGRESS_HOOK.SEND_TX_203_03 | PROGRESS_HOOK.SEND_TX_203_04 | PROGRESS_HOOK.SEND_TX_203_05 | PROGRESS_HOOK.SEND_TX_204_01 | PROGRESS_HOOK.SEND_TX_204_02 | PROGRESS_HOOK.SEND_TX_204_03 | PROGRESS_HOOK.SEND_TX_204_04 | PROGRESS_HOOK.SEND_TX_207 | PROGRESS_HOOK.SEND_TX_209_01 | PROGRESS_HOOK.SEND_TX_209_02 | PROGRESS_HOOK.SEND_TX_299_01 | PROGRESS_HOOK.SEND_TX_299_02 | PROGRESS_HOOK.SEND_TX_299_03 | PROGRESS_HOOK.SEND_TX_299_99;
|
|
@@ -142,4 +150,5 @@ export type PROGRESS_HOOK_R3 = PROGRESS_HOOK.SEND_TX_301 | PROGRESS_HOOK.SEND_TX
|
|
|
142
150
|
export type PROGRESS_HOOK_MULTICHAIN = PROGRESS_HOOK.SEND_TX_001 | PROGRESS_HOOK.SEND_TX_002_01 | PROGRESS_HOOK.SEND_TX_002_99_99 | PROGRESS_HOOK.SEND_TX_003_03 | PROGRESS_HOOK.SEND_TX_003_04 | PROGRESS_HOOK.SEND_TX_003_05 | PROGRESS_HOOK.SEND_TX_999_01 | PROGRESS_HOOK.SEND_TX_999_02 | PROGRESS_HOOK.SEND_TX_999_03;
|
|
143
151
|
export type PROGRESS_HOOK_MIG = PROGRESS_HOOK.UEA_MIG_01 | PROGRESS_HOOK.UEA_MIG_02 | PROGRESS_HOOK.UEA_MIG_03 | PROGRESS_HOOK.UEA_MIG_9901 | PROGRESS_HOOK.UEA_MIG_9902 | PROGRESS_HOOK.UEA_MIG_9903;
|
|
144
152
|
export type PROGRESS_HOOK_READ = PROGRESS_HOOK.READ_TX_101 | PROGRESS_HOOK.READ_TX_102_01 | PROGRESS_HOOK.READ_TX_102_02 | PROGRESS_HOOK.READ_TX_102_03 | PROGRESS_HOOK.READ_TX_102_04 | PROGRESS_HOOK.READ_TX_102_05 | PROGRESS_HOOK.READ_TX_103_01 | PROGRESS_HOOK.READ_TX_103_02 | PROGRESS_HOOK.READ_TX_103_03 | PROGRESS_HOOK.READ_TX_104_01 | PROGRESS_HOOK.READ_TX_104_02 | PROGRESS_HOOK.READ_TX_104_03 | PROGRESS_HOOK.READ_TX_104_04 | PROGRESS_HOOK.READ_TX_104_05 | PROGRESS_HOOK.READ_TX_105_01 | PROGRESS_HOOK.READ_TX_105_02 | PROGRESS_HOOK.READ_TX_105_03 | PROGRESS_HOOK.READ_TX_105_04 | PROGRESS_HOOK.READ_TX_106_01 | PROGRESS_HOOK.READ_TX_106_02 | PROGRESS_HOOK.READ_TX_106_03 | PROGRESS_HOOK.READ_TX_106_04 | PROGRESS_HOOK.READ_TX_106_05 | PROGRESS_HOOK.READ_TX_106_06 | PROGRESS_HOOK.READ_TX_199_01 | PROGRESS_HOOK.READ_TX_199_02 | PROGRESS_HOOK.READ_TX_199_03 | PROGRESS_HOOK.READ_TX_199_99 | PROGRESS_HOOK.READ_TX_001 | PROGRESS_HOOK.READ_TX_002_01 | PROGRESS_HOOK.READ_TX_002_99_99 | PROGRESS_HOOK.READ_TX_999_01 | PROGRESS_HOOK.READ_TX_999_02 | PROGRESS_HOOK.READ_TX_999_03;
|
|
153
|
+
export type PROGRESS_HOOK_AGENTIC = PROGRESS_HOOK.AGENTIC_TX_101 | PROGRESS_HOOK.AGENTIC_TX_102 | PROGRESS_HOOK.AGENTIC_TX_104 | PROGRESS_HOOK.AGENTIC_TX_105 | PROGRESS_HOOK.AGENTIC_TX_106 | PROGRESS_HOOK.AGENTIC_TX_107 | PROGRESS_HOOK.AGENTIC_TX_199_01 | PROGRESS_HOOK.AGENTIC_TX_199_02;
|
|
145
154
|
export {};
|
|
@@ -147,5 +147,15 @@ var PROGRESS_HOOK;
|
|
|
147
147
|
PROGRESS_HOOK["UEA_MIG_9901"] = "UEA-MIG-9901";
|
|
148
148
|
PROGRESS_HOOK["UEA_MIG_9902"] = "UEA-MIG-9902";
|
|
149
149
|
PROGRESS_HOOK["UEA_MIG_9903"] = "UEA-MIG-9903";
|
|
150
|
+
// Agentic wallet (AGW) — AGENTIC-TX (PROPOSED in the AGW SDK spec 3.f).
|
|
151
|
+
// AGENTIC-TX-103 was removed by the spec (create no longer funds).
|
|
152
|
+
PROGRESS_HOOK["AGENTIC_TX_101"] = "AGENTIC-TX-101";
|
|
153
|
+
PROGRESS_HOOK["AGENTIC_TX_102"] = "AGENTIC-TX-102";
|
|
154
|
+
PROGRESS_HOOK["AGENTIC_TX_104"] = "AGENTIC-TX-104";
|
|
155
|
+
PROGRESS_HOOK["AGENTIC_TX_105"] = "AGENTIC-TX-105";
|
|
156
|
+
PROGRESS_HOOK["AGENTIC_TX_106"] = "AGENTIC-TX-106";
|
|
157
|
+
PROGRESS_HOOK["AGENTIC_TX_107"] = "AGENTIC-TX-107";
|
|
158
|
+
PROGRESS_HOOK["AGENTIC_TX_199_01"] = "AGENTIC-TX-199-01";
|
|
159
|
+
PROGRESS_HOOK["AGENTIC_TX_199_02"] = "AGENTIC-TX-199-02";
|
|
150
160
|
})(PROGRESS_HOOK || (exports.PROGRESS_HOOK = PROGRESS_HOOK = {}));
|
|
151
161
|
//# sourceMappingURL=progress-hook.types.js.map
|
|
@@ -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
|
|
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";
|
|
@@ -59,6 +94,17 @@ export declare class PushChain {
|
|
|
59
94
|
readonly ERROR_CODE: typeof import("../read-state/read-state.types").READ_ERROR_CODE;
|
|
60
95
|
readonly OUTCOME: typeof import("../read-state/read-state.types").READ_OUTCOME;
|
|
61
96
|
};
|
|
97
|
+
AGENTIC: Readonly<{
|
|
98
|
+
WALLET: "agentic:wallet";
|
|
99
|
+
PRESETS: Readonly<{
|
|
100
|
+
CATEGORY: Readonly<{
|
|
101
|
+
DEXES: "DEXES";
|
|
102
|
+
LENDING: "LENDING";
|
|
103
|
+
STAKING: "STAKING";
|
|
104
|
+
PREDICTION: "PREDICTION";
|
|
105
|
+
}>;
|
|
106
|
+
}>;
|
|
107
|
+
}>;
|
|
62
108
|
};
|
|
63
109
|
/**
|
|
64
110
|
* @static
|
|
@@ -246,6 +292,14 @@ export declare class PushChain {
|
|
|
246
292
|
to: MoveableToken | undefined;
|
|
247
293
|
}) => Promise<ConversionQuote>;
|
|
248
294
|
};
|
|
295
|
+
/**
|
|
296
|
+
* Agentic wallet management (AGW): derive, create, list and per-wallet
|
|
297
|
+
* handles. Ownership is the connected signer's Push identity.
|
|
298
|
+
*/
|
|
299
|
+
agentic: AgenticNamespace;
|
|
300
|
+
/** @internal AGW execution context when initialized with `agenticWallet`. */
|
|
301
|
+
private agenticContext?;
|
|
302
|
+
private readonly agenticRuntime;
|
|
249
303
|
/**
|
|
250
304
|
* Account status including UEA deployment state and version info.
|
|
251
305
|
* Initially unloaded — call getAccountStatus() to populate.
|
|
@@ -292,13 +346,7 @@ export declare class PushChain {
|
|
|
292
346
|
*
|
|
293
347
|
* @returns An initialized instance of PushChain.
|
|
294
348
|
*/
|
|
295
|
-
static initialize: (universalSigner: UniversalSigner | UniversalAccount, options?:
|
|
296
|
-
network: PUSH_NETWORK;
|
|
297
|
-
rpcUrls?: Partial<Record<CHAIN, string[]>>;
|
|
298
|
-
blockExplorers?: Partial<Record<CHAIN, string[]>>;
|
|
299
|
-
printTraces?: boolean;
|
|
300
|
-
progressHook?: (progress: ProgressEvent) => void;
|
|
301
|
-
}) => Promise<PushChain>;
|
|
349
|
+
static initialize: (universalSigner: UniversalSigner | UniversalAccount, options?: PushChainInitializeOptions) => Promise<PushChain>;
|
|
302
350
|
/**
|
|
303
351
|
* @method reinitialize
|
|
304
352
|
* Reinitializes the PushChain SDK with a new universal signer and optional config.
|
|
@@ -311,11 +359,5 @@ export declare class PushChain {
|
|
|
311
359
|
*
|
|
312
360
|
* @returns A new initialized instance of PushChain.
|
|
313
361
|
*/
|
|
314
|
-
reinitialize: (universalSigner: UniversalSigner | UniversalAccount, options?:
|
|
315
|
-
network: PUSH_NETWORK;
|
|
316
|
-
rpcUrls?: Partial<Record<CHAIN, string[]>>;
|
|
317
|
-
blockExplorers?: Partial<Record<CHAIN, string[]>>;
|
|
318
|
-
printTraces?: boolean;
|
|
319
|
-
progressHook?: (progress: ProgressEvent) => void;
|
|
320
|
-
}) => Promise<PushChain>;
|
|
362
|
+
reinitialize: (universalSigner: UniversalSigner | UniversalAccount, options?: PushChainInitializeOptions) => Promise<PushChain>;
|
|
321
363
|
}
|
|
@@ -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,62 +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
|
-
|
|
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 = await (0, read_params_1.resolveReadSpecParams)(subject, options, orchestrator.getNetwork(), orchestrator.getRpcUrls());
|
|
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)(
|
|
176
|
+
const { reads: [response] } = await (0, read_executor_1.executeReads)(readDeps(), [prepared], options);
|
|
129
177
|
return response;
|
|
130
178
|
},
|
|
131
179
|
prepareRead: async (subject, options) => {
|
|
132
|
-
const params = await (0, read_params_1.resolveReadSpecParams)(subject, options, orchestrator.getNetwork(), orchestrator.getRpcUrls());
|
|
180
|
+
const params = await (0, read_params_1.resolveReadSpecParams)(subject, withReadRefund(options), orchestrator.getNetwork(), orchestrator.getRpcUrls());
|
|
133
181
|
return orchestrator.prepareRead(params);
|
|
134
182
|
},
|
|
135
183
|
executeReads: (async (reads, options) => {
|
|
136
184
|
reads.forEach((r) => (0, read_executor_1.assertRequestEntrypoint)(r.callback));
|
|
137
185
|
if (this.isReadMode)
|
|
138
186
|
throw new Error('Read only mode cannot call executeReads function');
|
|
139
|
-
return (0, read_executor_1.executeReads)(
|
|
187
|
+
return (0, read_executor_1.executeReads)(readDeps(), reads, options);
|
|
140
188
|
}),
|
|
141
189
|
trackRead: ((ref, options) => {
|
|
142
190
|
const opts = { ...(0, read_params_1.toLifecycleOptions)(options), progressHook: options?.progressHook };
|
|
@@ -451,6 +499,12 @@ class PushChain {
|
|
|
451
499
|
});
|
|
452
500
|
// Let execute() await the background fetch instead of re-fetching
|
|
453
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
|
+
}
|
|
454
508
|
return instance;
|
|
455
509
|
}
|
|
456
510
|
/**
|
|
@@ -481,12 +535,17 @@ class PushChain {
|
|
|
481
535
|
* @returns A new initialized instance of PushChain.
|
|
482
536
|
*/
|
|
483
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.
|
|
484
540
|
const mergedOptions = {
|
|
485
541
|
network: options?.network ?? this.orchestrator.getNetwork(),
|
|
486
542
|
rpcUrls: options?.rpcUrls ?? this.orchestrator.getRpcUrls(),
|
|
487
543
|
blockExplorers: options?.blockExplorers ?? this.blockExplorers,
|
|
488
544
|
printTraces: options?.printTraces ?? this.orchestrator.getPrintTraces(),
|
|
489
545
|
progressHook: options?.progressHook ?? this.orchestrator.getProgressHook(),
|
|
546
|
+
...(options?.agenticWallet !== undefined
|
|
547
|
+
? { agenticWallet: options.agenticWallet }
|
|
548
|
+
: {}),
|
|
490
549
|
};
|
|
491
550
|
return PushChain.createInstance(universalSigner, mergedOptions);
|
|
492
551
|
};
|
|
@@ -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}`);
|
|
@@ -15,7 +15,7 @@ import type { Abi, AbiStateMutability, Address, Hex, ContractFunctionReturnType,
|
|
|
15
15
|
import type { Idl, IdlAccounts } from '@coral-xyz/anchor';
|
|
16
16
|
import { PublicKey } from '@solana/web3.js';
|
|
17
17
|
import { CHAIN, PUSH_NETWORK } from '../constants/enums';
|
|
18
|
-
import type { BuildReadSpecParams, ReadChain, ReadDestination, ReadLifecycleOptions, ReadQuery, ReadResultShape, Web2Extract } from './read-state.types';
|
|
18
|
+
import type { BuildReadSpecParams, ReadChain, ReadDestination, ReadLifecycleOptions, ReadQuery, ReadResultShape, Web2Extract, Web2ReadChain } from './read-state.types';
|
|
19
19
|
import type { ReadCallback } from './read-state.types';
|
|
20
20
|
import type { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
21
21
|
export interface ReadWeb2Options {
|
|
@@ -116,7 +116,7 @@ export type ReadQueryOptions = ({
|
|
|
116
116
|
} & Query<'storageSlot', {
|
|
117
117
|
storageSlot: Hex | bigint;
|
|
118
118
|
}>) | ({
|
|
119
|
-
chain:
|
|
119
|
+
chain: Web2ReadChain;
|
|
120
120
|
} & Query<'web2', {
|
|
121
121
|
web2: ReadWeb2Options;
|
|
122
122
|
}>);
|
|
@@ -146,7 +146,7 @@ type FinalizedDestinationOptions = {
|
|
|
146
146
|
export type ReadPrepareOptions = SharedPrepareOptions & ((Extract<ReadQueryOptions, {
|
|
147
147
|
chain: EvmChain;
|
|
148
148
|
}> & EvmPinningOptions) | (Extract<ReadQueryOptions, {
|
|
149
|
-
chain: SvmChain |
|
|
149
|
+
chain: SvmChain | Web2ReadChain;
|
|
150
150
|
}> & FinalizedDestinationOptions));
|
|
151
151
|
export type ReadExecuteOptions = Pick<ReadOptionsInput, 'advanced' | 'waitForCompletion' | 'progressHook'>;
|
|
152
152
|
type WithExecutionOptions<T> = T extends unknown ? Omit<T, 'advanced' | 'waitForCompletion' | 'progressHook'> & ReadExecuteOptions : never;
|
|
@@ -43,7 +43,8 @@ function queryKind(o) {
|
|
|
43
43
|
return present[0] ?? 'native';
|
|
44
44
|
}
|
|
45
45
|
function toReadDestination(chain) {
|
|
46
|
-
|
|
46
|
+
// Both public spellings normalize to the unchanged wire identity web2:https.
|
|
47
|
+
return (0, read_state_1.isWeb2ReadChain)(chain) ? read_state_1.WEB2_DESTINATION : { chain };
|
|
47
48
|
}
|
|
48
49
|
/** Build the internal query from the public grammar. Pure. */
|
|
49
50
|
function toReadQuery(subject, o, resolvedTokenProgram) {
|
|
@@ -57,7 +58,7 @@ function toReadQuery(subject, o, resolvedTokenProgram) {
|
|
|
57
58
|
return { type: 'http', url: subject, ...o.web2 };
|
|
58
59
|
}
|
|
59
60
|
if (kind === 'web2')
|
|
60
|
-
throw new errors_1.InvalidReadQueryError('`web2` is only valid with chain CHAIN.WEB2');
|
|
61
|
+
throw new errors_1.InvalidReadQueryError('`web2` is only valid with chain READ.CHAIN.WEB2');
|
|
61
62
|
if (dest.namespace === read_state_1.READ_NAMESPACE.EVM) {
|
|
62
63
|
if (!(0, viem_1.isAddress)(subject))
|
|
63
64
|
throw new errors_1.InvalidReadQueryError(`EVM subject must be an address, got ${subject}`);
|
|
@@ -6,7 +6,9 @@ import type { ReadNamespace } from '../constants/read-state';
|
|
|
6
6
|
* Where a read goes. `CHAIN` enum values are CAIP-2 and split cleanly; the
|
|
7
7
|
* explicit form is the low-level escape hatch; the public API uses `CHAIN.WEB2`.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/** Web2 read source: `READ.CHAIN.WEB2` (`'web2'`) or the legacy `'web2:https'` literal. */
|
|
10
|
+
export type Web2ReadChain = 'web2' | 'web2:https';
|
|
11
|
+
export type ReadChain = CHAIN | Web2ReadChain;
|
|
10
12
|
export type ReadDestination = {
|
|
11
13
|
chain: ReadChain;
|
|
12
14
|
} | {
|
|
@@ -309,8 +309,8 @@ function inferResultShape(namespace, query) {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
function chainFromCaip2(caip2) {
|
|
312
|
-
if (
|
|
313
|
-
return
|
|
312
|
+
if ((0, read_state_1.isWeb2ReadChain)(caip2))
|
|
313
|
+
return read_state_1.WEB2_READ_CHAIN;
|
|
314
314
|
return Object.values(enums_1.CHAIN).includes(caip2) ? caip2 : undefined;
|
|
315
315
|
}
|
|
316
316
|
function explorerTxUrl(network, txHash) {
|
|
@@ -106,7 +106,7 @@ function buildReadSpecFromPreflight(preflight, params, defaults = {}) {
|
|
|
106
106
|
return {
|
|
107
107
|
callback: params.callback,
|
|
108
108
|
queryKey: (0, registry_1.computeReadQueryKey)(params.destination, params.query),
|
|
109
|
-
chain: dest.caip2,
|
|
109
|
+
chain: (isWeb2 ? read_state_1.WEB2_READ_CHAIN : dest.caip2),
|
|
110
110
|
spec,
|
|
111
111
|
specTuple: toTuple(spec),
|
|
112
112
|
encodedSpec: encodeSpec(spec),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CHAIN, PUSH_NETWORK } from '../constants/enums';
|
|
2
|
+
import { type MoveableToken } from '../constants/tokens';
|
|
3
|
+
/** Shared pure origin-to-PRC20 mapping; no signer or network reads. */
|
|
4
|
+
export declare function getPRC20Address(token: MoveableToken | {
|
|
5
|
+
chain: string;
|
|
6
|
+
address: string;
|
|
7
|
+
}, options?: {
|
|
8
|
+
network?: PUSH_NETWORK;
|
|
9
|
+
}): {
|
|
10
|
+
address: `0x${string}`;
|
|
11
|
+
chain: CHAIN;
|
|
12
|
+
symbol: string;
|
|
13
|
+
decimals: number;
|
|
14
|
+
network: PUSH_NETWORK;
|
|
15
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPRC20Address = getPRC20Address;
|
|
4
|
+
const enums_1 = require("../constants/enums");
|
|
5
|
+
const tokens_1 = require("../constants/tokens");
|
|
6
|
+
const chain_1 = require("../constants/chain");
|
|
7
|
+
/** Shared pure origin-to-PRC20 mapping; no signer or network reads. */
|
|
8
|
+
function getPRC20Address(token, options) {
|
|
9
|
+
const network = options?.network ?? enums_1.PUSH_NETWORK.TESTNET_DONUT;
|
|
10
|
+
const assertDeployed = (addr, ctx) => {
|
|
11
|
+
if (!addr || addr === '0xTBD') {
|
|
12
|
+
throw new Error(`PRC20 address not available for ${ctx} on network ${network}`);
|
|
13
|
+
}
|
|
14
|
+
return addr;
|
|
15
|
+
};
|
|
16
|
+
// PushChainMoveableToken (pETH, pSOL, pUSDT(BNB), …) carries its PRC-20 address
|
|
17
|
+
// and origin `sourceChain` directly — no registry lookup needed.
|
|
18
|
+
const pcToken = token;
|
|
19
|
+
if (pcToken.prc20Address) {
|
|
20
|
+
return {
|
|
21
|
+
address: assertDeployed(pcToken.prc20Address, `${pcToken.symbol ?? 'token'} (${pcToken.sourceChain ?? 'unknown'})`),
|
|
22
|
+
chain: pcToken.sourceChain,
|
|
23
|
+
symbol: pcToken.symbol,
|
|
24
|
+
decimals: pcToken.decimals,
|
|
25
|
+
network,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Infer origin chain, symbol, decimals by matching against MOVEABLE_TOKENS
|
|
29
|
+
let originChain;
|
|
30
|
+
let tokenSymbol;
|
|
31
|
+
let tokenDecimals;
|
|
32
|
+
if ('symbol' in token) {
|
|
33
|
+
// MoveableToken path: infer chain by symbol + address
|
|
34
|
+
for (const [key, list] of Object.entries(tokens_1.MOVEABLE_TOKENS)) {
|
|
35
|
+
const k = key;
|
|
36
|
+
const match = (list ?? []).find((t) => t.symbol === token.symbol && t.address === token.address);
|
|
37
|
+
if (match) {
|
|
38
|
+
originChain = k;
|
|
39
|
+
tokenSymbol = match.symbol;
|
|
40
|
+
tokenDecimals = match.decimals;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// { chain, address } path: trust the provided chain and resolve symbol via registry
|
|
47
|
+
originChain = token.chain;
|
|
48
|
+
const list = tokens_1.MOVEABLE_TOKENS[originChain] ?? [];
|
|
49
|
+
const match = list.find((t) => t.address === token.address);
|
|
50
|
+
if (match) {
|
|
51
|
+
tokenSymbol = match.symbol;
|
|
52
|
+
tokenDecimals = match.decimals;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!originChain || !tokenSymbol || tokenDecimals === undefined) {
|
|
56
|
+
throw new Error('Unable to infer origin chain or token symbol for token');
|
|
57
|
+
}
|
|
58
|
+
const map = chain_1.SYNTHETIC_PUSH_ERC20[network];
|
|
59
|
+
if (!map) {
|
|
60
|
+
throw new Error(`No PRC20 address map configured for network: ${network}`);
|
|
61
|
+
}
|
|
62
|
+
// Map token → synthetic key by origin chain family
|
|
63
|
+
const isEthFamily = originChain === enums_1.CHAIN.ETHEREUM_MAINNET ||
|
|
64
|
+
originChain === enums_1.CHAIN.ETHEREUM_SEPOLIA;
|
|
65
|
+
const isArbFamily = originChain === enums_1.CHAIN.ARBITRUM_SEPOLIA;
|
|
66
|
+
const isBaseFamily = originChain === enums_1.CHAIN.BASE_SEPOLIA;
|
|
67
|
+
const isBnbFamily = originChain === enums_1.CHAIN.BNB_TESTNET;
|
|
68
|
+
const isSolFamily = originChain === enums_1.CHAIN.SOLANA_DEVNET;
|
|
69
|
+
let key;
|
|
70
|
+
switch (tokenSymbol) {
|
|
71
|
+
case 'ETH': {
|
|
72
|
+
if (isEthFamily)
|
|
73
|
+
key = 'pETH';
|
|
74
|
+
else if (isArbFamily)
|
|
75
|
+
key = 'pETH_ARB';
|
|
76
|
+
else if (isBaseFamily)
|
|
77
|
+
key = 'pETH_BASE';
|
|
78
|
+
else
|
|
79
|
+
throw new Error('Unsupported ETH origin chain for synthetic mapping');
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'SOL': {
|
|
83
|
+
if (!isSolFamily)
|
|
84
|
+
throw new Error('SOL token provided but origin is not Solana');
|
|
85
|
+
key = 'pSOL';
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case 'BNB': {
|
|
89
|
+
if (!isBnbFamily)
|
|
90
|
+
throw new Error('BNB token provided but origin is not BNB Testnet');
|
|
91
|
+
key = 'pBNB';
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'USDT': {
|
|
95
|
+
if (isEthFamily)
|
|
96
|
+
key = 'USDT_ETH';
|
|
97
|
+
else if (isArbFamily)
|
|
98
|
+
key = 'USDT_ARB';
|
|
99
|
+
else if (isBaseFamily)
|
|
100
|
+
key = 'USDT_BASE';
|
|
101
|
+
else if (isBnbFamily)
|
|
102
|
+
key = 'USDT_BSC';
|
|
103
|
+
else if (isSolFamily)
|
|
104
|
+
key = 'USDT_SOL';
|
|
105
|
+
else
|
|
106
|
+
throw new Error('Unsupported USDT origin chain for synthetic mapping');
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'USDC': {
|
|
110
|
+
if (isEthFamily)
|
|
111
|
+
key = 'USDC_ETH';
|
|
112
|
+
else if (isArbFamily)
|
|
113
|
+
key = 'USDC_ARB';
|
|
114
|
+
else if (isBaseFamily)
|
|
115
|
+
key = 'USDC_BASE';
|
|
116
|
+
else if (isBnbFamily)
|
|
117
|
+
key = 'USDC_BSC';
|
|
118
|
+
else if (isSolFamily)
|
|
119
|
+
key = 'USDC_SOL';
|
|
120
|
+
else
|
|
121
|
+
throw new Error('Unsupported USDC origin chain for synthetic mapping');
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`Unsupported token symbol: ${tokenSymbol}`);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
address: assertDeployed(map[key], `${tokenSymbol} on ${originChain}`),
|
|
129
|
+
chain: originChain,
|
|
130
|
+
symbol: tokenSymbol,
|
|
131
|
+
decimals: tokenDecimals,
|
|
132
|
+
network,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=prc20-address.js.map
|