@pushchain/core 6.0.26 → 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.
- package/AGW.md +194 -0
- package/CHANGELOG.md +8 -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 +409 -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 +15 -0
- package/src/lib/agentic/codec/abi-layout.js +121 -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 +75 -0
- package/src/lib/agentic/codec/native.js +328 -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 +242 -0
- package/src/lib/agentic/codec/universal-terms.d.ts +67 -0
- package/src/lib/agentic/codec/universal-terms.js +41 -0
- package/src/lib/agentic/codec/universal.d.ts +14 -0
- package/src/lib/agentic/codec/universal.js +157 -0
- package/src/lib/agentic/constants.d.ts +11 -0
- package/src/lib/agentic/constants.js +15 -0
- package/src/lib/agentic/context.d.ts +29 -0
- package/src/lib/agentic/context.js +56 -0
- package/src/lib/agentic/contracts/abi/v5/agent-validator.d.ts +105 -0
- package/src/lib/agentic/contracts/abi/v5/agent-validator.js +149 -0
- package/src/lib/agentic/contracts/abi/v5/agw-factory.d.ts +847 -0
- package/src/lib/agentic/contracts/abi/v5/agw-factory.js +1108 -0
- package/src/lib/agentic/contracts/abi/v5/agw.d.ts +1211 -0
- package/src/lib/agentic/contracts/abi/v5/agw.js +1588 -0
- package/src/lib/agentic/contracts/abi/v5/index.d.ts +6 -0
- package/src/lib/agentic/contracts/abi/v5/index.js +17 -0
- package/src/lib/agentic/contracts/abi/v5/smart-session.d.ts +1493 -0
- package/src/lib/agentic/contracts/abi/v5/smart-session.js +1965 -0
- package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.d.ts +1640 -0
- package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.js +2160 -0
- package/src/lib/agentic/contracts/donut-v5.d.ts +11 -0
- package/src/lib/agentic/contracts/donut-v5.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/v5.d.ts +5323 -0
- package/src/lib/agentic/contracts/v5.js +316 -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 +71 -0
- package/src/lib/agentic/errors.js +92 -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 +276 -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 +182 -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 +90 -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 +114 -0
- package/src/lib/agentic/management/create.d.ts +16 -0
- package/src/lib/agentic/management/create.js +271 -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 +21 -0
- package/src/lib/agentic/presets/catalog.js +10 -0
- package/src/lib/agentic/presets/index.d.ts +5 -0
- package/src/lib/agentic/presets/index.js +190 -0
- package/src/lib/agentic/presets/types.d.ts +44 -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 +342 -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 +286 -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 +95 -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 +60 -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 +56 -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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agenticUtils = exports.internalAgenticUtils = void 0;
|
|
4
|
+
const svm_terms_1 = require("./codec/svm-terms");
|
|
5
|
+
const svm_accounts_1 = require("./codec/svm-accounts");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const enums_1 = require("../constants/enums");
|
|
8
|
+
const tokens_1 = require("../constants/tokens");
|
|
9
|
+
const prc20_address_1 = require("../universal/prc20-address");
|
|
10
|
+
const capabilities_1 = require("./capabilities");
|
|
11
|
+
const deployments_1 = require("./deployments");
|
|
12
|
+
const ids_1 = require("./codec/ids");
|
|
13
|
+
const native_1 = require("./codec/native");
|
|
14
|
+
const rules_1 = require("./codec/rules");
|
|
15
|
+
const selectors_1 = require("./codec/selectors");
|
|
16
|
+
const session_1 = require("./codec/session");
|
|
17
|
+
const errors_1 = require("./errors");
|
|
18
|
+
const chain_1 = require("./chain");
|
|
19
|
+
const universal_terms_1 = require("./codec/universal-terms");
|
|
20
|
+
const universal_1 = require("./codec/universal");
|
|
21
|
+
function nativeNamespace(ctx) {
|
|
22
|
+
if (ctx.pushChainNamespace)
|
|
23
|
+
return ctx.pushChainNamespace;
|
|
24
|
+
return (0, chain_1.pushChainNamespaceFor)(ctx.network ?? enums_1.PUSH_NETWORK.TESTNET_DONUT);
|
|
25
|
+
}
|
|
26
|
+
/** Internal codecs and identities — not exported from the package entry point. */
|
|
27
|
+
exports.internalAgenticUtils = {
|
|
28
|
+
/** The ID a grant with this grantNonce produces. Chain is not part of the hash. */
|
|
29
|
+
rulesId(agent, grantNonce, ctx) {
|
|
30
|
+
return (0, ids_1.rulesId)({
|
|
31
|
+
validator: (0, viem_1.getAddress)(ctx.validator),
|
|
32
|
+
agent: (0, viem_1.getAddress)(agent),
|
|
33
|
+
grantNonce: BigInt(grantNonce),
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
/** Hash of one allowed call: keccak256(target ‖ selector). */
|
|
37
|
+
actionId(target, selector) {
|
|
38
|
+
return (0, ids_1.actionId)((0, viem_1.getAddress)(target), (0, selectors_1.parseSelector)(selector).selector);
|
|
39
|
+
},
|
|
40
|
+
/** Key of one allowed call's stored config under one rule on one wallet. */
|
|
41
|
+
configId(wallet, rulesId, actionId) {
|
|
42
|
+
return (0, ids_1.configId)((0, viem_1.getAddress)(wallet), rulesId, actionId);
|
|
43
|
+
},
|
|
44
|
+
/** Any-owner wallet address. */
|
|
45
|
+
deriveWallet(owner, index, ctx) {
|
|
46
|
+
return (0, ids_1.deriveWallet)({
|
|
47
|
+
factory: (0, viem_1.getAddress)(ctx.factory),
|
|
48
|
+
walletImplementation: (0, viem_1.getAddress)(ctx.walletImplementation),
|
|
49
|
+
owner: (0, viem_1.getAddress)(owner),
|
|
50
|
+
index,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Encode rules into the grant `Session` bytes, one per rule, in order.
|
|
55
|
+
* EVM universal rules require wallet/token resolution in the internal context.
|
|
56
|
+
*/
|
|
57
|
+
encodeRules(rules, ctx) {
|
|
58
|
+
return (0, rules_1.prepareRules)(rules, {
|
|
59
|
+
owner: ctx.owner ? (0, viem_1.getAddress)(ctx.owner) : undefined,
|
|
60
|
+
pushChainNamespace: nativeNamespace(ctx),
|
|
61
|
+
validator: (0, viem_1.getAddress)(ctx.validator),
|
|
62
|
+
rulesPolicy: (0, viem_1.getAddress)(ctx.rulesPolicy),
|
|
63
|
+
gateway: ctx.gateway,
|
|
64
|
+
universal: ctx.universal,
|
|
65
|
+
capabilities: deployments_1.V5_CAPABILITIES,
|
|
66
|
+
nowSeconds: ctx.nowSeconds ?? Math.floor(Date.now() / 1000),
|
|
67
|
+
}).map((p) => (0, session_1.encodeSession)(p.session));
|
|
68
|
+
},
|
|
69
|
+
/** Inverse of encodeRules for one Session encoding. */
|
|
70
|
+
decodeRules(bytes, ctx = {}) {
|
|
71
|
+
if (!(0, viem_1.isHex)(bytes))
|
|
72
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, 'decodeRules expects hex bytes');
|
|
73
|
+
const session = (0, session_1.decodeSession)(bytes);
|
|
74
|
+
if (session.actions.length === 0 ||
|
|
75
|
+
session.actions.some((a) => a.actionPolicies.length !== 1)) {
|
|
76
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, 'every action needs exactly one URP policy to be representable as a public InternalRule');
|
|
77
|
+
}
|
|
78
|
+
const agent = (0, viem_1.getAddress)(`0x${session.sessionValidatorInitData.slice(26, 66)}`);
|
|
79
|
+
const { chainNamespace, body } = (0, session_1.decodeEnvelope)(session.actions[0].actionPolicies[0].initData);
|
|
80
|
+
if (chainNamespace !== nativeNamespace(ctx) &&
|
|
81
|
+
session.actions.length !== 1) {
|
|
82
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, 'only native rules carry more than one action');
|
|
83
|
+
}
|
|
84
|
+
if (chainNamespace !== nativeNamespace(ctx)) {
|
|
85
|
+
if (chainNamespace.startsWith('solana:')) {
|
|
86
|
+
const terms = (0, svm_terms_1.decodeSvmTerms)(body);
|
|
87
|
+
(0, svm_terms_1.validateSvmTerms)(terms, -1);
|
|
88
|
+
const assets = terms.assets.map((a) => {
|
|
89
|
+
const chain = chainNamespace;
|
|
90
|
+
const token = (tokens_1.MOVEABLE_TOKENS[chain] ?? []).find((candidate) => {
|
|
91
|
+
try {
|
|
92
|
+
return ((0, viem_1.getAddress)((0, prc20_address_1.getPRC20Address)({ chain, address: candidate.address }, { network: ctx.network ?? enums_1.PUSH_NETWORK.TESTNET_DONUT }).address) === (0, viem_1.getAddress)(a.token));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (!token)
|
|
99
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, 'SVM source token is absent from the static registry; use wallet.rules.get()');
|
|
100
|
+
return {
|
|
101
|
+
token: token.mechanism === 'native'
|
|
102
|
+
? viem_1.zeroAddress
|
|
103
|
+
: (0, svm_accounts_1.svmKey)(token.address),
|
|
104
|
+
maxPerCall: a.maxPerCall,
|
|
105
|
+
maxTotal: a.maxTotal,
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
...terms,
|
|
110
|
+
format: 'decoded',
|
|
111
|
+
agent,
|
|
112
|
+
chainNamespace: chainNamespace,
|
|
113
|
+
assets,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!chainNamespace.startsWith('eip155:'))
|
|
117
|
+
throw (0, errors_1.capabilityUnavailable)(capabilities_1.AgenticCapability.UNIVERSAL_SVM_RULES, 'unsupported universal chain namespace');
|
|
118
|
+
let terms;
|
|
119
|
+
try {
|
|
120
|
+
terms = (0, universal_terms_1.decodeUniversalTerms)(body);
|
|
121
|
+
}
|
|
122
|
+
catch (cause) {
|
|
123
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, 'malformed universal terms', { cause });
|
|
124
|
+
}
|
|
125
|
+
const chain = chainNamespace;
|
|
126
|
+
const network = ctx.network ?? enums_1.PUSH_NETWORK.TESTNET_DONUT;
|
|
127
|
+
const tokens = terms.assets.map((asset) => {
|
|
128
|
+
const token = (tokens_1.MOVEABLE_TOKENS[chain] ?? []).find((candidate) => {
|
|
129
|
+
try {
|
|
130
|
+
return ((0, viem_1.getAddress)((0, prc20_address_1.getPRC20Address)({ chain, address: candidate.address }, { network }).address) === (0, viem_1.getAddress)(asset.token));
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
if (!token)
|
|
137
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, `PRC20 ${asset.token} is not in the static ${chain} token registry`, {
|
|
138
|
+
hint: 'Use wallet.rules.get() for on-chain source-token resolution.',
|
|
139
|
+
});
|
|
140
|
+
return token.mechanism === 'native'
|
|
141
|
+
? viem_1.zeroAddress
|
|
142
|
+
: (0, viem_1.getAddress)(token.address);
|
|
143
|
+
});
|
|
144
|
+
return (0, universal_1.universalTermsToRule)(terms, agent, chainNamespace, tokens);
|
|
145
|
+
}
|
|
146
|
+
// Native: one stored terms body per action, all on the native chain.
|
|
147
|
+
const terms = session.actions.map((a, i) => {
|
|
148
|
+
const env = i === 0
|
|
149
|
+
? { chainNamespace, body }
|
|
150
|
+
: (0, session_1.decodeEnvelope)(a.actionPolicies[0].initData);
|
|
151
|
+
if (env.chainNamespace !== chainNamespace) {
|
|
152
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RULE_READ_FAILED, `action ${i} names chain ${env.chainNamespace}, not ${chainNamespace}`);
|
|
153
|
+
}
|
|
154
|
+
return (0, native_1.decodeNativeTerms)(env.body);
|
|
155
|
+
});
|
|
156
|
+
return (0, native_1.nativeActionTermsToRule)(terms, agent);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
/** Public helpers requiring no contract deployment context. */
|
|
160
|
+
exports.agenticUtils = {
|
|
161
|
+
actionId: exports.internalAgenticUtils.actionId,
|
|
162
|
+
configId: exports.internalAgenticUtils.configId,
|
|
163
|
+
decodeRules: exports.internalAgenticUtils.decodeRules,
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgenticRuntime } from './runtime';
|
|
2
|
+
import type { AgenticAddress, AgenticProgressHook, AgenticWallet, Checkpoint, WalletInfo } from './agentic.types';
|
|
3
|
+
import type { UniversalTxResponse } from '../orchestrator/orchestrator.types';
|
|
4
|
+
/**
|
|
5
|
+
* Management handle for one wallet (spec 1.d). Reads work for any wallet;
|
|
6
|
+
* writes require the connected signer to be the owner. It never sends AS the
|
|
7
|
+
* wallet — that is PushChain.initialize(signer, { agenticWallet }).
|
|
8
|
+
*/
|
|
9
|
+
export declare class AgenticWalletHandle implements AgenticWallet {
|
|
10
|
+
private readonly runtime;
|
|
11
|
+
readonly address: AgenticAddress;
|
|
12
|
+
readonly rules: AgenticWallet['rules'];
|
|
13
|
+
private generation?;
|
|
14
|
+
constructor(runtime: AgenticRuntime, address: string);
|
|
15
|
+
/** Deployed wallets resolve their own generation; undeployed ones use the network's current one. */
|
|
16
|
+
private gen;
|
|
17
|
+
info(): Promise<WalletInfo>;
|
|
18
|
+
owner(): Promise<{
|
|
19
|
+
owner: AgenticAddress;
|
|
20
|
+
}>;
|
|
21
|
+
setLabel(label: string, opts?: {
|
|
22
|
+
progressHook?: AgenticProgressHook;
|
|
23
|
+
}): Promise<UniversalTxResponse>;
|
|
24
|
+
checkpoints(opts?: {
|
|
25
|
+
sinceBlock?: bigint;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
checkpoints: Checkpoint[];
|
|
28
|
+
}>;
|
|
29
|
+
private listRules;
|
|
30
|
+
private getRule;
|
|
31
|
+
private signerIdentity;
|
|
32
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgenticWalletHandle = void 0;
|
|
4
|
+
const public_rule_1 = require("./public-rule");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const capabilities_1 = require("./capabilities");
|
|
7
|
+
const deployments_1 = require("./deployments");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const rules_write_1 = require("./management/rules-write");
|
|
10
|
+
const checkpoints_1 = require("./reads/checkpoints");
|
|
11
|
+
const rules_1 = require("./reads/rules");
|
|
12
|
+
const snapshot_1 = require("./reads/snapshot");
|
|
13
|
+
const wallets_1 = require("./reads/wallets");
|
|
14
|
+
const deployments_2 = require("./deployments");
|
|
15
|
+
const label_1 = require("./management/label");
|
|
16
|
+
/**
|
|
17
|
+
* Management handle for one wallet (spec 1.d). Reads work for any wallet;
|
|
18
|
+
* writes require the connected signer to be the owner. It never sends AS the
|
|
19
|
+
* wallet — that is PushChain.initialize(signer, { agenticWallet }).
|
|
20
|
+
*/
|
|
21
|
+
class AgenticWalletHandle {
|
|
22
|
+
runtime;
|
|
23
|
+
address;
|
|
24
|
+
rules;
|
|
25
|
+
generation;
|
|
26
|
+
constructor(runtime, address) {
|
|
27
|
+
this.runtime = runtime;
|
|
28
|
+
try {
|
|
29
|
+
this.address = (0, viem_1.getAddress)(address);
|
|
30
|
+
}
|
|
31
|
+
catch (cause) {
|
|
32
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.NOT_AGENTIC_WALLET, `"${address}" is not an address`, { cause });
|
|
33
|
+
}
|
|
34
|
+
this.rules = {
|
|
35
|
+
list: () => this.listRules(),
|
|
36
|
+
get: (rulesId) => this.getRule(rulesId),
|
|
37
|
+
add: async (rules, opts) => (0, rules_write_1.addRules)(this.runtime, await this.gen(), this.address, (0, public_rule_1.publicRules)(rules), opts?.progressHook),
|
|
38
|
+
update: async (params) => {
|
|
39
|
+
if (!params ||
|
|
40
|
+
!Array.isArray(params.rules) ||
|
|
41
|
+
params.rules.length === 0 ||
|
|
42
|
+
params.rules.some((p) => !p ||
|
|
43
|
+
typeof p.rulesId !== 'string' ||
|
|
44
|
+
!/^0x[0-9a-fA-F]{64}$/.test(p.rulesId))) {
|
|
45
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, 'rules.update needs { rulesId, rule } pairs with 32-byte rule IDs');
|
|
46
|
+
}
|
|
47
|
+
const rules = params.rules.map((p) => ({
|
|
48
|
+
...p,
|
|
49
|
+
rule: (0, public_rule_1.publicRules)([p.rule])[0],
|
|
50
|
+
}));
|
|
51
|
+
return (0, rules_write_1.updateRules)(this.runtime, await this.gen(), this.address, {
|
|
52
|
+
...params,
|
|
53
|
+
rules,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
delete: (async (target, opts) => {
|
|
57
|
+
// Validate the target shape before any RPC so a bare revoke costs nothing.
|
|
58
|
+
(0, rules_write_1.assertRevokeTarget)(target);
|
|
59
|
+
return (0, rules_write_1.revokeRules)(this.runtime, await this.gen(), this.address, target, opts?.progressHook);
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Deployed wallets resolve their own generation; undeployed ones use the network's current one. */
|
|
64
|
+
gen() {
|
|
65
|
+
if (!this.generation) {
|
|
66
|
+
this.generation = (0, deployments_1.resolveWalletGeneration)(this.runtime.reader, this.runtime.network, this.address);
|
|
67
|
+
this.generation.catch(() => {
|
|
68
|
+
this.generation = undefined;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return this.generation;
|
|
72
|
+
}
|
|
73
|
+
async info() {
|
|
74
|
+
let gen;
|
|
75
|
+
try {
|
|
76
|
+
gen = await this.gen();
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (err instanceof errors_1.AgenticError &&
|
|
80
|
+
err.code === errors_1.AGENTIC_ERROR_CODE.WALLET_NOT_DEPLOYED) {
|
|
81
|
+
gen = (0, deployments_2.currentGeneration)(this.runtime.network);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
(0, capabilities_1.requireCapability)(gen.capabilities, capabilities_1.AgenticCapability.WALLET_READS);
|
|
88
|
+
return (0, wallets_1.walletInfo)(this.runtime.reader, gen, this.address, this.signerIdentity());
|
|
89
|
+
}
|
|
90
|
+
async owner() {
|
|
91
|
+
const gen = await this.gen();
|
|
92
|
+
return {
|
|
93
|
+
owner: (await (0, wallets_1.walletOwner)(this.runtime.reader, gen, this.address)),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async setLabel(label, opts) {
|
|
97
|
+
(0, label_1.assertLabel)(label);
|
|
98
|
+
return (0, rules_write_1.setLabel)(this.runtime, await this.gen(), this.address, label, opts?.progressHook);
|
|
99
|
+
}
|
|
100
|
+
async checkpoints(opts) {
|
|
101
|
+
const gen = await this.gen();
|
|
102
|
+
const { checkpoints } = await (0, checkpoints_1.readCheckpoints)(this.runtime.reader, gen, this.address, opts?.sinceBlock);
|
|
103
|
+
return { checkpoints };
|
|
104
|
+
}
|
|
105
|
+
async listRules() {
|
|
106
|
+
const gen = await this.gen();
|
|
107
|
+
const snap = await snapshot_1.Snapshot.at(this.runtime.reader);
|
|
108
|
+
return {
|
|
109
|
+
rules: await (0, rules_1.listRules)(snap, gen, this.address, this.runtime.pushChainNamespace),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async getRule(rulesId) {
|
|
113
|
+
if (typeof rulesId !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(rulesId)) {
|
|
114
|
+
throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, 'rulesId must be a 32-byte hex string');
|
|
115
|
+
}
|
|
116
|
+
const gen = await this.gen();
|
|
117
|
+
const snap = await snapshot_1.Snapshot.at(this.runtime.reader);
|
|
118
|
+
return (0, rules_1.getRule)(snap, gen, this.address, rulesId, this.runtime.pushChainNamespace);
|
|
119
|
+
}
|
|
120
|
+
signerIdentity() {
|
|
121
|
+
try {
|
|
122
|
+
return this.runtime.signerPushAccount();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.AgenticWalletHandle = AgenticWalletHandle;
|
|
130
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -27,11 +27,14 @@ export declare enum CHAIN {
|
|
|
27
27
|
SOLANA_DEVNET = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Read-only
|
|
31
|
-
*
|
|
30
|
+
* Read-only Web2 source kept on `CHAIN` for compatibility without widening the
|
|
31
|
+
* blockchain enum type accepted by transaction APIs.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use `PushChain.CONSTANTS.READ.CHAIN.WEB2`. Same value (`'web2'`);
|
|
34
|
+
* the legacy literal `'web2:https'` is still accepted as read input.
|
|
32
35
|
*/
|
|
33
36
|
export declare namespace CHAIN {
|
|
34
|
-
const WEB2: "web2
|
|
37
|
+
const WEB2: "web2";
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Represents the virtual machine or execution environment for a chain.
|
|
@@ -35,12 +35,15 @@ var CHAIN;
|
|
|
35
35
|
CHAIN["SOLANA_DEVNET"] = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
36
36
|
})(CHAIN || (exports.CHAIN = CHAIN = {}));
|
|
37
37
|
/**
|
|
38
|
-
* Read-only
|
|
39
|
-
*
|
|
38
|
+
* Read-only Web2 source kept on `CHAIN` for compatibility without widening the
|
|
39
|
+
* blockchain enum type accepted by transaction APIs.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated Use `PushChain.CONSTANTS.READ.CHAIN.WEB2`. Same value (`'web2'`);
|
|
42
|
+
* the legacy literal `'web2:https'` is still accepted as read input.
|
|
40
43
|
*/
|
|
41
44
|
// eslint-disable-next-line @typescript-eslint/no-namespace -- declaration merging keeps Web2 out of the transaction enum union
|
|
42
45
|
(function (CHAIN) {
|
|
43
|
-
CHAIN.WEB2 = 'web2
|
|
46
|
+
CHAIN.WEB2 = 'web2';
|
|
44
47
|
})(CHAIN || (exports.CHAIN = CHAIN = {}));
|
|
45
48
|
// Namespace properties are normally enumerable after TypeScript emits them.
|
|
46
49
|
// Keep blockchain enumeration (`Object.values(CHAIN)`) blockchain-only.
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { CHAIN, LIBRARY, PUSH_NETWORK } from './enums';
|
|
2
2
|
import { TypedDataDomain, TypedData } from '../universal/signer/signer.types';
|
|
3
|
+
import { WEB2_READ_CHAIN } from './read-state';
|
|
3
4
|
import { UNIVERSAL_READ_STATUS, READ_STATUS, READ_ERROR_CODE, READ_OUTCOME } from '../read-state/read-state.types';
|
|
5
|
+
/**
|
|
6
|
+
* `PushChain.CONSTANTS.READ.CHAIN` — every read source: all of `CHAIN` (same
|
|
7
|
+
* string values) plus the enumerable Web2 source. A superset of CHAIN, so
|
|
8
|
+
* `read({ chain: CHAIN.X })` keeps compiling.
|
|
9
|
+
*/
|
|
10
|
+
export declare const READ_CHAIN: Readonly<{ [K in keyof typeof CHAIN]: (typeof CHAIN)[K]; }> & {
|
|
11
|
+
readonly WEB2: typeof WEB2_READ_CHAIN;
|
|
12
|
+
};
|
|
4
13
|
/** `PushChain.CONSTANTS.READ` — cross-chain read state. Values verified against the deployed UniversalCallback. */
|
|
5
14
|
export declare const READ_CONSTANTS: {
|
|
6
|
-
/**
|
|
7
|
-
readonly
|
|
15
|
+
/** Every read source, enumerable (spec page 5 §4). */
|
|
16
|
+
readonly CHAIN: Readonly<{
|
|
17
|
+
readonly PUSH_MAINNET: CHAIN.PUSH_MAINNET;
|
|
18
|
+
readonly PUSH_TESTNET: CHAIN.PUSH_TESTNET;
|
|
19
|
+
readonly PUSH_TESTNET_DONUT: CHAIN.PUSH_TESTNET;
|
|
20
|
+
readonly PUSH_LOCALNET: CHAIN.PUSH_LOCALNET;
|
|
21
|
+
readonly ETHEREUM_MAINNET: CHAIN.ETHEREUM_MAINNET;
|
|
22
|
+
readonly ETHEREUM_SEPOLIA: CHAIN.ETHEREUM_SEPOLIA;
|
|
23
|
+
readonly ARBITRUM_SEPOLIA: CHAIN.ARBITRUM_SEPOLIA;
|
|
24
|
+
readonly BASE_SEPOLIA: CHAIN.BASE_SEPOLIA;
|
|
25
|
+
readonly BNB_TESTNET: CHAIN.BNB_TESTNET;
|
|
26
|
+
readonly SOLANA_MAINNET: CHAIN.SOLANA_MAINNET;
|
|
27
|
+
readonly SOLANA_TESTNET: CHAIN.SOLANA_TESTNET;
|
|
28
|
+
readonly SOLANA_DEVNET: CHAIN.SOLANA_DEVNET;
|
|
29
|
+
readonly WEB2: "web2";
|
|
30
|
+
}> & {
|
|
31
|
+
readonly WEB2: typeof WEB2_READ_CHAIN;
|
|
32
|
+
};
|
|
33
|
+
/** @deprecated Use `READ.CHAIN.WEB2`. Same value (`'web2'`). */
|
|
34
|
+
readonly WEB2: "web2";
|
|
8
35
|
readonly NAMESPACE: {
|
|
9
36
|
readonly EVM: "eip155";
|
|
10
37
|
readonly SVM: "solana";
|
|
@@ -39,8 +66,26 @@ export declare const CONSTANTS: {
|
|
|
39
66
|
TOKEN: import("./tokens").PayableTokenConstantsMap;
|
|
40
67
|
};
|
|
41
68
|
READ: {
|
|
42
|
-
/**
|
|
43
|
-
readonly
|
|
69
|
+
/** Every read source, enumerable (spec page 5 §4). */
|
|
70
|
+
readonly CHAIN: Readonly<{
|
|
71
|
+
readonly PUSH_MAINNET: CHAIN.PUSH_MAINNET;
|
|
72
|
+
readonly PUSH_TESTNET: CHAIN.PUSH_TESTNET;
|
|
73
|
+
readonly PUSH_TESTNET_DONUT: CHAIN.PUSH_TESTNET;
|
|
74
|
+
readonly PUSH_LOCALNET: CHAIN.PUSH_LOCALNET;
|
|
75
|
+
readonly ETHEREUM_MAINNET: CHAIN.ETHEREUM_MAINNET;
|
|
76
|
+
readonly ETHEREUM_SEPOLIA: CHAIN.ETHEREUM_SEPOLIA;
|
|
77
|
+
readonly ARBITRUM_SEPOLIA: CHAIN.ARBITRUM_SEPOLIA;
|
|
78
|
+
readonly BASE_SEPOLIA: CHAIN.BASE_SEPOLIA;
|
|
79
|
+
readonly BNB_TESTNET: CHAIN.BNB_TESTNET;
|
|
80
|
+
readonly SOLANA_MAINNET: CHAIN.SOLANA_MAINNET;
|
|
81
|
+
readonly SOLANA_TESTNET: CHAIN.SOLANA_TESTNET;
|
|
82
|
+
readonly SOLANA_DEVNET: CHAIN.SOLANA_DEVNET;
|
|
83
|
+
readonly WEB2: "web2";
|
|
84
|
+
}> & {
|
|
85
|
+
readonly WEB2: typeof WEB2_READ_CHAIN;
|
|
86
|
+
};
|
|
87
|
+
/** @deprecated Use `READ.CHAIN.WEB2`. Same value (`'web2'`). */
|
|
88
|
+
readonly WEB2: "web2";
|
|
44
89
|
readonly NAMESPACE: {
|
|
45
90
|
readonly EVM: "eip155";
|
|
46
91
|
readonly SVM: "solana";
|
|
@@ -63,6 +108,17 @@ export declare const CONSTANTS: {
|
|
|
63
108
|
readonly ERROR_CODE: typeof READ_ERROR_CODE;
|
|
64
109
|
readonly OUTCOME: typeof READ_OUTCOME;
|
|
65
110
|
};
|
|
111
|
+
/** Checked v5 agentic wallet deployments by Push network (Donut only). */
|
|
112
|
+
AGENTIC: Readonly<{
|
|
113
|
+
WALLET: "agentic:wallet";
|
|
114
|
+
PRESETS: Readonly<{
|
|
115
|
+
CATEGORY: Readonly<{
|
|
116
|
+
DEXES: "DEXES";
|
|
117
|
+
LENDING: "LENDING";
|
|
118
|
+
PREDICTION: "PREDICTION";
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
}>;
|
|
66
122
|
};
|
|
67
123
|
export type { TypedDataDomain, TypedData };
|
|
68
124
|
export { CHAIN_EXPLORERS, CEA_FACTORY_ADDRESSES, UNIVERSAL_GATEWAY_ADDRESSES, VAULT_ADDRESSES, getExplorerTxUrl, getExplorerAddressUrl, } from './chain';
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UNIVERSAL_CALLBACK_ADDRESSES = exports.UNIVERSAL_CORE_ADDRESSES = exports.DEFAULT_CEA_TO_PUSH_GAS_LIMIT = exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = exports.getExplorerAddressUrl = exports.getExplorerTxUrl = exports.VAULT_ADDRESSES = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.CEA_FACTORY_ADDRESSES = exports.CHAIN_EXPLORERS = exports.CONSTANTS = exports.READ_CONSTANTS = void 0;
|
|
3
|
+
exports.UNIVERSAL_CALLBACK_ADDRESSES = exports.UNIVERSAL_CORE_ADDRESSES = exports.DEFAULT_CEA_TO_PUSH_GAS_LIMIT = exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = exports.getExplorerAddressUrl = exports.getExplorerTxUrl = exports.VAULT_ADDRESSES = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.CEA_FACTORY_ADDRESSES = exports.CHAIN_EXPLORERS = exports.CONSTANTS = exports.READ_CONSTANTS = exports.READ_CHAIN = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const enums_1 = require("./enums");
|
|
6
6
|
const tokens_1 = require("./tokens");
|
|
7
7
|
const chain_1 = require("./chain");
|
|
8
8
|
const read_state_1 = require("./read-state");
|
|
9
9
|
const read_state_types_1 = require("../read-state/read-state.types");
|
|
10
|
+
const constants_1 = require("../agentic/constants");
|
|
11
|
+
/**
|
|
12
|
+
* `PushChain.CONSTANTS.READ.CHAIN` — every read source: all of `CHAIN` (same
|
|
13
|
+
* string values) plus the enumerable Web2 source. A superset of CHAIN, so
|
|
14
|
+
* `read({ chain: CHAIN.X })` keeps compiling.
|
|
15
|
+
*/
|
|
16
|
+
exports.READ_CHAIN = Object.freeze({
|
|
17
|
+
...enums_1.CHAIN,
|
|
18
|
+
WEB2: read_state_1.WEB2_READ_CHAIN,
|
|
19
|
+
});
|
|
10
20
|
/** `PushChain.CONSTANTS.READ` — cross-chain read state. Values verified against the deployed UniversalCallback. */
|
|
11
21
|
exports.READ_CONSTANTS = {
|
|
12
|
-
/**
|
|
13
|
-
|
|
22
|
+
/** Every read source, enumerable (spec page 5 §4). */
|
|
23
|
+
CHAIN: exports.READ_CHAIN,
|
|
24
|
+
/** @deprecated Use `READ.CHAIN.WEB2`. Same value (`'web2'`). */
|
|
25
|
+
WEB2: read_state_1.WEB2_READ_CHAIN,
|
|
14
26
|
NAMESPACE: read_state_1.READ_NAMESPACE,
|
|
15
27
|
MAX_CALLBACK_GAS_LIMIT: read_state_1.MAX_CALLBACK_GAS_LIMIT,
|
|
16
28
|
MIN_CONFIRMATIONS_FLOOR: read_state_1.MIN_CONFIRMATIONS_FLOOR,
|
|
@@ -35,6 +47,8 @@ exports.CONSTANTS = {
|
|
|
35
47
|
MOVEABLE: { TOKEN: tokens_1.MOVEABLE_TOKEN_CONSTANTS },
|
|
36
48
|
PAYABLE: { TOKEN: tokens_1.PAYABLE_TOKEN_CONSTANTS },
|
|
37
49
|
READ: exports.READ_CONSTANTS,
|
|
50
|
+
/** Checked v5 agentic wallet deployments by Push network (Donut only). */
|
|
51
|
+
AGENTIC: constants_1.AGENTIC,
|
|
38
52
|
};
|
|
39
53
|
// Multi-chain configuration exports
|
|
40
54
|
var chain_2 = require("./chain");
|
|
@@ -32,6 +32,15 @@ export declare const WEB2_MAX_TIMEOUT_MS = 15000;
|
|
|
32
32
|
* Web2 is not a blockchain and is not a `CHAIN` enum member. Reads target it via
|
|
33
33
|
* an explicit destination; the node routes on namespace `web2`, id `https`.
|
|
34
34
|
*/
|
|
35
|
+
/** Public Web2 read source (`READ.CHAIN.WEB2`). */
|
|
36
|
+
export declare const WEB2_READ_CHAIN: "web2";
|
|
37
|
+
/**
|
|
38
|
+
* Legacy public spelling, and the unchanged CAIP-2 wire identity validators
|
|
39
|
+
* route on. Still accepted as read input.
|
|
40
|
+
*/
|
|
41
|
+
export declare const LEGACY_WEB2_READ_CHAIN: "web2:https";
|
|
42
|
+
/** True for either public Web2 spelling. */
|
|
43
|
+
export declare function isWeb2ReadChain(chain: unknown): chain is typeof WEB2_READ_CHAIN | typeof LEGACY_WEB2_READ_CHAIN;
|
|
35
44
|
export declare const WEB2_DESTINATION: {
|
|
36
45
|
readonly chainNamespace: "web2";
|
|
37
46
|
readonly chainId: "https";
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* `read-state/__tests__/abi-selectors.spec.ts`.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.READ_TRACK_LOOKUP_TIMEOUT_MS = exports.READ_EXPIRY_WARNING_BLOCKS = exports.READ_PREFLIGHT_STALE_MS = exports.READ_TRACK_MAX_TIMEOUT_MS = exports.READ_TRACK_MIN_POLL_INTERVAL_MS = exports.READ_TRACK_POLL_INTERVAL_MS = exports.PUSH_BLOCK_TIME_MS = exports.READ_NAMESPACE = exports.WEB2_DESTINATION = exports.WEB2_MAX_TIMEOUT_MS = exports.WEB2_DEFAULT_TIMEOUT_MS = exports.WEB2_MAX_EXTRACT_ENTRIES = exports.CALLBACK_BUDGET_BUFFER = exports.DEFAULT_EXPIRY_BLOCKS = exports.MIN_CONFIRMATIONS_FLOOR = exports.UNIVERSAL_READ_REGISTRY_ADDRESS = exports.REGISTRY_CALLBACK_GAS = exports.MAX_CALLBACK_GAS_LIMIT = void 0;
|
|
10
|
+
exports.READ_TRACK_LOOKUP_TIMEOUT_MS = exports.READ_EXPIRY_WARNING_BLOCKS = exports.READ_PREFLIGHT_STALE_MS = exports.READ_TRACK_MAX_TIMEOUT_MS = exports.READ_TRACK_MIN_POLL_INTERVAL_MS = exports.READ_TRACK_POLL_INTERVAL_MS = exports.PUSH_BLOCK_TIME_MS = exports.READ_NAMESPACE = exports.WEB2_DESTINATION = exports.LEGACY_WEB2_READ_CHAIN = exports.WEB2_READ_CHAIN = exports.WEB2_MAX_TIMEOUT_MS = exports.WEB2_DEFAULT_TIMEOUT_MS = exports.WEB2_MAX_EXTRACT_ENTRIES = exports.CALLBACK_BUDGET_BUFFER = exports.DEFAULT_EXPIRY_BLOCKS = exports.MIN_CONFIRMATIONS_FLOOR = exports.UNIVERSAL_READ_REGISTRY_ADDRESS = exports.REGISTRY_CALLBACK_GAS = exports.MAX_CALLBACK_GAS_LIMIT = void 0;
|
|
11
|
+
exports.isWeb2ReadChain = isWeb2ReadChain;
|
|
11
12
|
/** Hard upper bound on the gas an app callback may declare — `ReadTypes.sol:50`. */
|
|
12
13
|
exports.MAX_CALLBACK_GAS_LIMIT = 1000000n;
|
|
13
14
|
/** Default callback gas (registry and custom targets); large results may need an explicit override up to the maximum. */
|
|
@@ -35,6 +36,17 @@ exports.WEB2_MAX_TIMEOUT_MS = 15_000;
|
|
|
35
36
|
* Web2 is not a blockchain and is not a `CHAIN` enum member. Reads target it via
|
|
36
37
|
* an explicit destination; the node routes on namespace `web2`, id `https`.
|
|
37
38
|
*/
|
|
39
|
+
/** Public Web2 read source (`READ.CHAIN.WEB2`). */
|
|
40
|
+
exports.WEB2_READ_CHAIN = 'web2';
|
|
41
|
+
/**
|
|
42
|
+
* Legacy public spelling, and the unchanged CAIP-2 wire identity validators
|
|
43
|
+
* route on. Still accepted as read input.
|
|
44
|
+
*/
|
|
45
|
+
exports.LEGACY_WEB2_READ_CHAIN = 'web2:https';
|
|
46
|
+
/** True for either public Web2 spelling. */
|
|
47
|
+
function isWeb2ReadChain(chain) {
|
|
48
|
+
return chain === exports.WEB2_READ_CHAIN || chain === exports.LEGACY_WEB2_READ_CHAIN;
|
|
49
|
+
}
|
|
38
50
|
exports.WEB2_DESTINATION = {
|
|
39
51
|
chainNamespace: 'web2',
|
|
40
52
|
chainId: 'https',
|
package/src/lib/index.d.ts
CHANGED
|
@@ -7,17 +7,23 @@ export { isPC20Reference } from './orchestrator/orchestrator.types';
|
|
|
7
7
|
export { PC20Error, InvalidPC20AddressError, PC20TokenChainMismatchError, PC20WrapperNotRegisteredError, PC20RegistryMismatchError, PC20FactoryMismatchError, InvalidPC20MetadataError, PC20ExpectedButPRC20Error, PC20AmbiguousAddressError, UnsupportedPC20DestinationError, InsufficientPC20BalanceError, PC20UnknownChainNamespaceError, PC20WrapperPredictionUnavailableError, PC20ExportRevertedError, PC20UnsafeEmptyPayloadError, } from './orchestrator/internals/pc20/errors';
|
|
8
8
|
export type { ChainTarget, ChainSource, UniversalTo, TransactionRouteType, UniversalExecuteParams, UniversalOutboundTxRequest, PreparedUniversalTx, CascadedTxResponse, CascadeHopInfo, CascadeTrackOptions, CascadeProgressEvent, CascadeCompletionResult, MultiChainTxResponse, OutboundTxDetails, WaitForOutboundOptions, SvmGatewayAccountMeta, SvmExecutePayloadFields, AccountStatus, UEAStatus, RescueFundsParams, } from './orchestrator/orchestrator.types';
|
|
9
9
|
export { parseUEAVersion } from './orchestrator/orchestrator.types';
|
|
10
|
-
export { TransactionRoute, detectRoute, isChainTarget } from './orchestrator/route-detector';
|
|
10
|
+
export { TransactionRoute, detectRoute, isChainTarget, } from './orchestrator/route-detector';
|
|
11
11
|
export { DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS, MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT, quoteMaxPCForGasCap, quoteMaxPCForGasCapFromNativeValue, } from './orchestrator/max-pc-for-gas';
|
|
12
12
|
export type { MaxPCForGasCapInput, MaxPCForGasCapFromNativeValueInput, MaxPCForGasCapQuote, } from './orchestrator/max-pc-for-gas';
|
|
13
13
|
export { getCEAAddress, getPushAccountForCEA, isCEA, chainSupportsCEA, chainSupportsOutbound, getCEAFactoryAddress, getAllCEAAddresses, } from './orchestrator/cea-utils';
|
|
14
14
|
export { encodeSvmExecutePayload, isSvmChain, isValidSolanaHexAddress, buildMigrationPayload, buildErc20WithdrawalMulticall, } from './orchestrator/payload-builders';
|
|
15
15
|
export type { ReadChain, ReadDestination, ResolvedDestination, ReadQuery, EvmReadQuery, SvmReadQuery, Web2ReadQuery, Web2Extract, Web2ValueType, EncodedReadQuery, ReadResultShape, DecodedReadResult, ReadPreflight, ReadSpec, ReadSpecTuple, BuildReadSpecParams, PreparedRead, ReadCallback, SimulateReadResult, ParsedReadRequest, FulfilOutcome, ReceiptLike, ReadRef, ReadLifecycleOptions, ReadFees, UniversalReadResponse, ReadResponseTuple, BatchReadResponse, } from './read-state/read-state.types';
|
|
16
|
-
export type { ReadOptions, ReadPrepareOptions, ReadQueryOptions, ReadCallbackOptions, ReadValue, ValidateReadCall, ReadWeb2Options, ReadTrackOptions, ReadExecuteOptions } from './read-state/read-params';
|
|
16
|
+
export type { ReadOptions, ReadPrepareOptions, ReadQueryOptions, ReadCallbackOptions, ReadValue, ValidateReadCall, ReadWeb2Options, ReadTrackOptions, ReadExecuteOptions, } from './read-state/read-params';
|
|
17
17
|
export { UNIVERSAL_READ_STATUS, READ_STATUS, READ_ERROR_CODE, READ_OUTCOME, CONTRACT_REQUEST_STATUS, TERMINAL_READ_STATUSES, } from './read-state/read-state.types';
|
|
18
18
|
export { ReadStateError, InvalidReadQueryError, InvalidReadSpecError, ReadHeightUnavailableError, UnsupportedReadDestinationError, ReadDecodeError, ReadTimeoutError, ReadNotFoundError, ReadRegistryUnavailableError, } from './read-state/errors';
|
|
19
19
|
export type { ReadSpecViolation } from './read-state/errors';
|
|
20
20
|
export { resolveDestination, encodeReadQuery, decodeReadResult, parseReadRequestsFromReceipt, parseFulfilOutcome, buildReadSpecFromPreflight, validateReadSpec, toCallData, sizeCallbackBudget, inferResultShape, toRequestIdHex, toReadQuery, } from './read-state';
|
|
21
21
|
export { UNIVERSAL_CALLBACK_EVM } from './constants/abi/universalCallback.evm';
|
|
22
22
|
export { UNIVERSAL_READ_REGISTRY_EVM } from './constants/abi/universalReadRegistry.evm';
|
|
23
|
+
export { PushChainExecutionError, PushChainBatchExecutionError, } from './orchestrator/internals/errors';
|
|
24
|
+
export type { DecodedErrorPayload } from './orchestrator/internals/errors';
|
|
25
|
+
export type { PushChainInitializeOptions } from './push-chain/push-chain';
|
|
26
|
+
export { AGENTIC_ERROR_CODE, AgenticError, AgenticRevertError, } from './agentic';
|
|
27
|
+
export type { AgenticAddress, AgenticDoor, AgenticErrorCode, AgenticHex, AgenticNamespace, AgenticProgressHook, AgenticTxMetadata, AgenticWallet, AllowedCall, AssetCap, Checkpoint, CheckpointKind, CreateOptions, CreateResult, ForeignChainNamespace, DecodedSolanaRule, Rule, RuleInput, Pin, Spent, WalletMarker, RulesRecord, Selector, WalletInfo, WalletSummary, } from './agentic';
|
|
23
28
|
export { PushChain };
|
|
29
|
+
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, AgenticPresets, } from './agentic';
|
package/src/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReadTimeoutError = exports.ReadDecodeError = exports.UnsupportedReadDestinationError = exports.ReadHeightUnavailableError = exports.InvalidReadSpecError = exports.InvalidReadQueryError = exports.ReadStateError = exports.TERMINAL_READ_STATUSES = exports.CONTRACT_REQUEST_STATUS = exports.READ_OUTCOME = exports.READ_ERROR_CODE = exports.READ_STATUS = exports.UNIVERSAL_READ_STATUS = exports.buildErc20WithdrawalMulticall = exports.buildMigrationPayload = exports.isValidSolanaHexAddress = exports.isSvmChain = exports.encodeSvmExecutePayload = exports.getAllCEAAddresses = exports.getCEAFactoryAddress = exports.chainSupportsOutbound = exports.chainSupportsCEA = exports.isCEA = exports.getPushAccountForCEA = exports.getCEAAddress = exports.quoteMaxPCForGasCapFromNativeValue = exports.quoteMaxPCForGasCap = exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = exports.isChainTarget = exports.detectRoute = exports.TransactionRoute = exports.parseUEAVersion = exports.PC20UnsafeEmptyPayloadError = exports.PC20ExportRevertedError = exports.PC20WrapperPredictionUnavailableError = exports.PC20UnknownChainNamespaceError = exports.InsufficientPC20BalanceError = exports.UnsupportedPC20DestinationError = exports.PC20AmbiguousAddressError = exports.PC20ExpectedButPRC20Error = exports.InvalidPC20MetadataError = exports.PC20FactoryMismatchError = exports.PC20RegistryMismatchError = exports.PC20WrapperNotRegisteredError = exports.PC20TokenChainMismatchError = exports.InvalidPC20AddressError = exports.PC20Error = exports.isPC20Reference = exports.CHAIN = void 0;
|
|
4
|
-
exports.PushChain = exports.UNIVERSAL_READ_REGISTRY_EVM = exports.UNIVERSAL_CALLBACK_EVM = exports.toReadQuery = exports.toRequestIdHex = exports.inferResultShape = exports.sizeCallbackBudget = exports.toCallData = exports.validateReadSpec = exports.buildReadSpecFromPreflight = exports.parseFulfilOutcome = exports.parseReadRequestsFromReceipt = exports.decodeReadResult = exports.encodeReadQuery = exports.resolveDestination = exports.ReadRegistryUnavailableError = exports.ReadNotFoundError = void 0;
|
|
4
|
+
exports.PushChain = exports.AgenticRevertError = exports.AgenticError = exports.AGENTIC_ERROR_CODE = exports.PushChainBatchExecutionError = exports.PushChainExecutionError = exports.UNIVERSAL_READ_REGISTRY_EVM = exports.UNIVERSAL_CALLBACK_EVM = exports.toReadQuery = exports.toRequestIdHex = exports.inferResultShape = exports.sizeCallbackBudget = exports.toCallData = exports.validateReadSpec = exports.buildReadSpecFromPreflight = exports.parseFulfilOutcome = exports.parseReadRequestsFromReceipt = exports.decodeReadResult = exports.encodeReadQuery = exports.resolveDestination = exports.ReadRegistryUnavailableError = exports.ReadNotFoundError = void 0;
|
|
5
5
|
const push_chain_1 = require("./push-chain/push-chain");
|
|
6
6
|
Object.defineProperty(exports, "PushChain", { enumerable: true, get: function () { return push_chain_1.PushChain; } });
|
|
7
7
|
var enums_1 = require("./constants/enums");
|
|
@@ -88,4 +88,12 @@ var universalCallback_evm_1 = require("./constants/abi/universalCallback.evm");
|
|
|
88
88
|
Object.defineProperty(exports, "UNIVERSAL_CALLBACK_EVM", { enumerable: true, get: function () { return universalCallback_evm_1.UNIVERSAL_CALLBACK_EVM; } });
|
|
89
89
|
var universalReadRegistry_evm_1 = require("./constants/abi/universalReadRegistry.evm");
|
|
90
90
|
Object.defineProperty(exports, "UNIVERSAL_READ_REGISTRY_EVM", { enumerable: true, get: function () { return universalReadRegistry_evm_1.UNIVERSAL_READ_REGISTRY_EVM; } });
|
|
91
|
+
// Structured execution errors (base class of AgenticRevertError)
|
|
92
|
+
var errors_3 = require("./orchestrator/internals/errors");
|
|
93
|
+
Object.defineProperty(exports, "PushChainExecutionError", { enumerable: true, get: function () { return errors_3.PushChainExecutionError; } });
|
|
94
|
+
Object.defineProperty(exports, "PushChainBatchExecutionError", { enumerable: true, get: function () { return errors_3.PushChainBatchExecutionError; } });
|
|
95
|
+
var agentic_1 = require("./agentic");
|
|
96
|
+
Object.defineProperty(exports, "AGENTIC_ERROR_CODE", { enumerable: true, get: function () { return agentic_1.AGENTIC_ERROR_CODE; } });
|
|
97
|
+
Object.defineProperty(exports, "AgenticError", { enumerable: true, get: function () { return agentic_1.AgenticError; } });
|
|
98
|
+
Object.defineProperty(exports, "AgenticRevertError", { enumerable: true, get: function () { return agentic_1.AgenticRevertError; } });
|
|
91
99
|
//# sourceMappingURL=index.js.map
|
|
@@ -39,11 +39,18 @@ export declare class PushChainExecutionError extends Error {
|
|
|
39
39
|
readonly code: "PUSH_CHAIN_EXECUTION_FAILED";
|
|
40
40
|
readonly gatewayTxHash?: string;
|
|
41
41
|
readonly decodedError?: DecodedErrorPayload;
|
|
42
|
+
/** Underlying transport/RPC error, kept so raw revert data is not lost. */
|
|
43
|
+
readonly cause?: unknown;
|
|
42
44
|
constructor(message: string, opts?: {
|
|
43
45
|
gatewayTxHash?: string;
|
|
44
46
|
decodedError?: DecodedErrorPayload;
|
|
47
|
+
cause?: unknown;
|
|
45
48
|
});
|
|
46
49
|
}
|
|
50
|
+
/** @internal A caller required an atomic native batch; sequential fallback is forbidden. */
|
|
51
|
+
export declare class AtomicBatchUnavailableError extends PushChainExecutionError {
|
|
52
|
+
constructor(message: string, cause?: unknown);
|
|
53
|
+
}
|
|
47
54
|
/** Recovery metadata for a non-atomic Push batch. A pending hash is broadcast but unconfirmed. */
|
|
48
55
|
export declare class PushChainBatchExecutionError extends PushChainExecutionError {
|
|
49
56
|
readonly transactionHashes: `0x${string}`[];
|