@pushchain/core 5.1.5-alpha.1 → 5.1.5
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/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/src/lib/constants/abi/index.d.ts +2 -0
- package/src/lib/constants/abi/index.js +6 -1
- package/src/lib/constants/abi/uniswap-v3-router.evm.d.ts +58 -0
- package/src/lib/constants/abi/uniswap-v3-router.evm.js +41 -0
- package/src/lib/constants/abi/wpc.evm.d.ts +24 -0
- package/src/lib/constants/abi/wpc.evm.js +27 -0
- package/src/lib/constants/chain.d.ts +1 -0
- package/src/lib/constants/chain.js +8 -6
- package/src/lib/constants/tokens.js +3 -3
- package/src/lib/generated/uexecutor/v2/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v2/types.js +96 -3
- package/src/lib/orchestrator/internals/cascade.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.js +521 -239
- package/src/lib/orchestrator/internals/confirmation.js +60 -15
- package/src/lib/orchestrator/internals/context.d.ts +23 -0
- package/src/lib/orchestrator/internals/context.js +54 -0
- package/src/lib/orchestrator/internals/execute-funds-only.js +47 -21
- package/src/lib/orchestrator/internals/execute-funds-payload.js +53 -31
- package/src/lib/orchestrator/internals/execute-standard.js +137 -26
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +5 -2
- package/src/lib/orchestrator/internals/gas-calculator.js +59 -11
- package/src/lib/orchestrator/internals/gas-usd-sizer.d.ts +53 -0
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +165 -0
- package/src/lib/orchestrator/internals/helpers.js +2 -0
- package/src/lib/orchestrator/internals/inbound-tracker.d.ts +83 -0
- package/src/lib/orchestrator/internals/inbound-tracker.js +322 -0
- package/src/lib/orchestrator/internals/index.d.ts +3 -1
- package/src/lib/orchestrator/internals/index.js +8 -2
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +32 -1
- package/src/lib/orchestrator/internals/outbound-sync.js +154 -17
- package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +28 -0
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +285 -0
- package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +23 -0
- package/src/lib/orchestrator/internals/progress-route-hooks.js +72 -0
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +27 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +111 -15
- package/src/lib/orchestrator/internals/rescue.js +1 -1
- package/src/lib/orchestrator/internals/response-builder.d.ts +5 -0
- package/src/lib/orchestrator/internals/response-builder.js +242 -66
- package/src/lib/orchestrator/internals/route-handlers.js +480 -206
- package/src/lib/orchestrator/internals/tx-transformer.js +293 -35
- package/src/lib/orchestrator/orchestrator.d.ts +7 -1
- package/src/lib/orchestrator/orchestrator.js +108 -56
- package/src/lib/orchestrator/orchestrator.types.d.ts +111 -5
- package/src/lib/orchestrator/payload-builders.d.ts +16 -0
- package/src/lib/orchestrator/payload-builders.js +6 -5
- package/src/lib/orchestrator/route-detector.js +20 -8
- package/src/lib/orchestrator/svm-idl/normalize-address.d.ts +19 -0
- package/src/lib/orchestrator/svm-idl/normalize-address.js +56 -0
- package/src/lib/orchestrator/svm-idl/registry.d.ts +13 -4
- package/src/lib/orchestrator/svm-idl/registry.js +15 -14
- package/src/lib/orchestrator/svm-idl/resolve.js +5 -2
- package/src/lib/progress-hook/progress-hook.d.ts +28 -0
- package/src/lib/progress-hook/progress-hook.js +545 -131
- package/src/lib/progress-hook/progress-hook.types.d.ts +76 -29
- package/src/lib/progress-hook/progress-hook.types.js +74 -35
- package/src/lib/push-client/push-client.d.ts +7 -0
- package/src/lib/push-client/push-client.js +18 -1
- package/src/lib/universal-tx-detector/__tests__/fixtures/builders.d.ts +32 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/builders.js +65 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.d.ts +72 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.js +669 -0
- package/src/lib/universal-tx-detector/auto-detect.d.ts +37 -0
- package/src/lib/universal-tx-detector/auto-detect.js +112 -0
- package/src/lib/universal-tx-detector/cascade.d.ts +64 -0
- package/src/lib/universal-tx-detector/cascade.js +254 -0
- package/src/lib/universal-tx-detector/child-inbounds.d.ts +58 -0
- package/src/lib/universal-tx-detector/child-inbounds.js +145 -0
- package/src/lib/universal-tx-detector/classify.d.ts +33 -0
- package/src/lib/universal-tx-detector/classify.js +228 -0
- package/src/lib/universal-tx-detector/detector-svm.d.ts +46 -0
- package/src/lib/universal-tx-detector/detector-svm.js +324 -0
- package/src/lib/universal-tx-detector/detector.d.ts +13 -0
- package/src/lib/universal-tx-detector/detector.js +233 -0
- package/src/lib/universal-tx-detector/events.d.ts +765 -0
- package/src/lib/universal-tx-detector/events.js +241 -0
- package/src/lib/universal-tx-detector/index.d.ts +18 -0
- package/src/lib/universal-tx-detector/index.js +36 -0
- package/src/lib/universal-tx-detector/svm-events.d.ts +41 -0
- package/src/lib/universal-tx-detector/svm-events.js +68 -0
- package/src/lib/universal-tx-detector/types.d.ts +100 -0
- package/src/lib/universal-tx-detector/types.js +3 -0
- package/src/lib/utils.d.ts +30 -13
- package/src/lib/utils.js +47 -21
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Event ABI fragments used by the universal-tx detector.
|
|
4
|
+
*
|
|
5
|
+
* Sourced from push-chain-gateway-contracts and push-chain-core-contracts:
|
|
6
|
+
* - UniversalTx, UniversalTxExecuted, RevertUniversalTx, FundsRescued
|
|
7
|
+
* → contracts/evm-gateway/src/interfaces/IUniversalGateway.sol
|
|
8
|
+
* - UniversalTxFinalized, UniversalTxReverted, FundsRescued (vault)
|
|
9
|
+
* → contracts/evm-gateway/src/interfaces/IVault.sol
|
|
10
|
+
* - UniversalTxOutbound
|
|
11
|
+
* → contracts/evm-gateway/src/interfaces/IUniversalGatewayPC.sol
|
|
12
|
+
*
|
|
13
|
+
* RevertInstructions is a struct `(address revertRecipient, bytes revertMsg)`
|
|
14
|
+
* per contracts/evm-gateway/src/libraries/Types.sol.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UNIVERSAL_TX_EVENT_ABI = exports.EVENT_UNIVERSAL_TX_OUTBOUND = exports.EVENT_UNIVERSAL_TX_REVERTED = exports.EVENT_UNIVERSAL_TX_FINALIZED = exports.EVENT_FUNDS_RESCUED = exports.EVENT_REVERT_UNIVERSAL_TX = exports.EVENT_UNIVERSAL_TX_EXECUTED = exports.EVENT_UNIVERSAL_TX = void 0;
|
|
18
|
+
const REVERT_INSTRUCTIONS_COMPONENTS = [
|
|
19
|
+
{ internalType: 'address', name: 'revertRecipient', type: 'address' },
|
|
20
|
+
{ internalType: 'bytes', name: 'revertMsg', type: 'bytes' },
|
|
21
|
+
];
|
|
22
|
+
// ── Source-chain UniversalGateway events ──────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* UniversalTx(
|
|
25
|
+
* address indexed sender,
|
|
26
|
+
* address indexed recipient,
|
|
27
|
+
* address token,
|
|
28
|
+
* uint256 amount,
|
|
29
|
+
* bytes payload,
|
|
30
|
+
* address revertRecipient,
|
|
31
|
+
* TX_TYPE txType,
|
|
32
|
+
* bytes signatureData,
|
|
33
|
+
* bool fromCEA
|
|
34
|
+
* )
|
|
35
|
+
*
|
|
36
|
+
* Note: this event does NOT carry subTxId/universalTxId. The detector
|
|
37
|
+
* derives universalTxId deterministically from (sourceChainId, txHash).
|
|
38
|
+
*/
|
|
39
|
+
exports.EVENT_UNIVERSAL_TX = {
|
|
40
|
+
anonymous: false,
|
|
41
|
+
type: 'event',
|
|
42
|
+
name: 'UniversalTx',
|
|
43
|
+
inputs: [
|
|
44
|
+
{ indexed: true, internalType: 'address', name: 'sender', type: 'address' },
|
|
45
|
+
{ indexed: true, internalType: 'address', name: 'recipient', type: 'address' },
|
|
46
|
+
{ indexed: false, internalType: 'address', name: 'token', type: 'address' },
|
|
47
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
48
|
+
{ indexed: false, internalType: 'bytes', name: 'payload', type: 'bytes' },
|
|
49
|
+
{ indexed: false, internalType: 'address', name: 'revertRecipient', type: 'address' },
|
|
50
|
+
{ indexed: false, internalType: 'uint8', name: 'txType', type: 'uint8' },
|
|
51
|
+
{ indexed: false, internalType: 'bytes', name: 'signatureData', type: 'bytes' },
|
|
52
|
+
{ indexed: false, internalType: 'bool', name: 'fromCEA', type: 'bool' },
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* UniversalTxExecuted(
|
|
57
|
+
* bytes32 indexed subTxId,
|
|
58
|
+
* bytes32 indexed universalTxId,
|
|
59
|
+
* address indexed pushAccount,
|
|
60
|
+
* address target,
|
|
61
|
+
* address token,
|
|
62
|
+
* uint256 amount,
|
|
63
|
+
* bytes data
|
|
64
|
+
* )
|
|
65
|
+
*/
|
|
66
|
+
exports.EVENT_UNIVERSAL_TX_EXECUTED = {
|
|
67
|
+
anonymous: false,
|
|
68
|
+
type: 'event',
|
|
69
|
+
name: 'UniversalTxExecuted',
|
|
70
|
+
inputs: [
|
|
71
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
72
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
73
|
+
{ indexed: true, internalType: 'address', name: 'pushAccount', type: 'address' },
|
|
74
|
+
{ indexed: false, internalType: 'address', name: 'target', type: 'address' },
|
|
75
|
+
{ indexed: false, internalType: 'address', name: 'token', type: 'address' },
|
|
76
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
77
|
+
{ indexed: false, internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* RevertUniversalTx(
|
|
82
|
+
* bytes32 indexed subTxId,
|
|
83
|
+
* bytes32 indexed universalTxId,
|
|
84
|
+
* address indexed to,
|
|
85
|
+
* address token,
|
|
86
|
+
* uint256 amount,
|
|
87
|
+
* RevertInstructions revertInstruction
|
|
88
|
+
* )
|
|
89
|
+
*/
|
|
90
|
+
exports.EVENT_REVERT_UNIVERSAL_TX = {
|
|
91
|
+
anonymous: false,
|
|
92
|
+
type: 'event',
|
|
93
|
+
name: 'RevertUniversalTx',
|
|
94
|
+
inputs: [
|
|
95
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
96
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
97
|
+
{ indexed: true, internalType: 'address', name: 'to', type: 'address' },
|
|
98
|
+
{ indexed: false, internalType: 'address', name: 'token', type: 'address' },
|
|
99
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
100
|
+
{
|
|
101
|
+
indexed: false,
|
|
102
|
+
internalType: 'struct RevertInstructions',
|
|
103
|
+
name: 'revertInstruction',
|
|
104
|
+
type: 'tuple',
|
|
105
|
+
components: REVERT_INSTRUCTIONS_COMPONENTS,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* FundsRescued(
|
|
111
|
+
* bytes32 indexed subTxId,
|
|
112
|
+
* bytes32 indexed universalTxId,
|
|
113
|
+
* address indexed token,
|
|
114
|
+
* uint256 amount,
|
|
115
|
+
* RevertInstructions revertInstruction
|
|
116
|
+
* )
|
|
117
|
+
*
|
|
118
|
+
* Emitted by both UniversalGateway and Vault.
|
|
119
|
+
*/
|
|
120
|
+
exports.EVENT_FUNDS_RESCUED = {
|
|
121
|
+
anonymous: false,
|
|
122
|
+
type: 'event',
|
|
123
|
+
name: 'FundsRescued',
|
|
124
|
+
inputs: [
|
|
125
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
126
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
127
|
+
{ indexed: true, internalType: 'address', name: 'token', type: 'address' },
|
|
128
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
129
|
+
{
|
|
130
|
+
indexed: false,
|
|
131
|
+
internalType: 'struct RevertInstructions',
|
|
132
|
+
name: 'revertInstruction',
|
|
133
|
+
type: 'tuple',
|
|
134
|
+
components: REVERT_INSTRUCTIONS_COMPONENTS,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
// ── Vault events ──────────────────────────────────────────────────────
|
|
139
|
+
/**
|
|
140
|
+
* UniversalTxFinalized(
|
|
141
|
+
* bytes32 indexed subTxId,
|
|
142
|
+
* bytes32 indexed universalTxId,
|
|
143
|
+
* address indexed pushAccount,
|
|
144
|
+
* address recipient,
|
|
145
|
+
* address token,
|
|
146
|
+
* uint256 amount,
|
|
147
|
+
* bytes data
|
|
148
|
+
* )
|
|
149
|
+
*/
|
|
150
|
+
exports.EVENT_UNIVERSAL_TX_FINALIZED = {
|
|
151
|
+
anonymous: false,
|
|
152
|
+
type: 'event',
|
|
153
|
+
name: 'UniversalTxFinalized',
|
|
154
|
+
inputs: [
|
|
155
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
156
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
157
|
+
{ indexed: true, internalType: 'address', name: 'pushAccount', type: 'address' },
|
|
158
|
+
{ indexed: false, internalType: 'address', name: 'recipient', type: 'address' },
|
|
159
|
+
{ indexed: false, internalType: 'address', name: 'token', type: 'address' },
|
|
160
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
161
|
+
{ indexed: false, internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* UniversalTxReverted(
|
|
166
|
+
* bytes32 indexed subTxId,
|
|
167
|
+
* bytes32 indexed universalTxId,
|
|
168
|
+
* address indexed token,
|
|
169
|
+
* uint256 amount,
|
|
170
|
+
* RevertInstructions revertInstruction
|
|
171
|
+
* )
|
|
172
|
+
*/
|
|
173
|
+
exports.EVENT_UNIVERSAL_TX_REVERTED = {
|
|
174
|
+
anonymous: false,
|
|
175
|
+
type: 'event',
|
|
176
|
+
name: 'UniversalTxReverted',
|
|
177
|
+
inputs: [
|
|
178
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
179
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
180
|
+
{ indexed: true, internalType: 'address', name: 'token', type: 'address' },
|
|
181
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
182
|
+
{
|
|
183
|
+
indexed: false,
|
|
184
|
+
internalType: 'struct RevertInstructions',
|
|
185
|
+
name: 'revertInstruction',
|
|
186
|
+
type: 'tuple',
|
|
187
|
+
components: REVERT_INSTRUCTIONS_COMPONENTS,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
// ── Push-chain GatewayPC event ────────────────────────────────────────
|
|
192
|
+
/**
|
|
193
|
+
* UniversalTxOutbound(
|
|
194
|
+
* bytes32 indexed subTxId,
|
|
195
|
+
* address indexed sender,
|
|
196
|
+
* string chainNamespace,
|
|
197
|
+
* address indexed token,
|
|
198
|
+
* bytes recipient,
|
|
199
|
+
* uint256 amount,
|
|
200
|
+
* address gasToken,
|
|
201
|
+
* uint256 gasFee,
|
|
202
|
+
* uint256 gasLimit,
|
|
203
|
+
* bytes payload,
|
|
204
|
+
* uint256 protocolFee,
|
|
205
|
+
* address revertRecipient,
|
|
206
|
+
* TX_TYPE txType,
|
|
207
|
+
* uint256 gasPrice
|
|
208
|
+
* )
|
|
209
|
+
*/
|
|
210
|
+
exports.EVENT_UNIVERSAL_TX_OUTBOUND = {
|
|
211
|
+
anonymous: false,
|
|
212
|
+
type: 'event',
|
|
213
|
+
name: 'UniversalTxOutbound',
|
|
214
|
+
inputs: [
|
|
215
|
+
{ indexed: true, internalType: 'bytes32', name: 'subTxId', type: 'bytes32' },
|
|
216
|
+
{ indexed: true, internalType: 'address', name: 'sender', type: 'address' },
|
|
217
|
+
{ indexed: false, internalType: 'string', name: 'chainNamespace', type: 'string' },
|
|
218
|
+
{ indexed: true, internalType: 'address', name: 'token', type: 'address' },
|
|
219
|
+
{ indexed: false, internalType: 'bytes', name: 'recipient', type: 'bytes' },
|
|
220
|
+
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
221
|
+
{ indexed: false, internalType: 'address', name: 'gasToken', type: 'address' },
|
|
222
|
+
{ indexed: false, internalType: 'uint256', name: 'gasFee', type: 'uint256' },
|
|
223
|
+
{ indexed: false, internalType: 'uint256', name: 'gasLimit', type: 'uint256' },
|
|
224
|
+
{ indexed: false, internalType: 'bytes', name: 'payload', type: 'bytes' },
|
|
225
|
+
{ indexed: false, internalType: 'uint256', name: 'protocolFee', type: 'uint256' },
|
|
226
|
+
{ indexed: false, internalType: 'address', name: 'revertRecipient', type: 'address' },
|
|
227
|
+
{ indexed: false, internalType: 'uint8', name: 'txType', type: 'uint8' },
|
|
228
|
+
{ indexed: false, internalType: 'uint256', name: 'gasPrice', type: 'uint256' },
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
/** Aggregated ABI handed to viem's parseEventLogs. */
|
|
232
|
+
exports.UNIVERSAL_TX_EVENT_ABI = [
|
|
233
|
+
exports.EVENT_UNIVERSAL_TX,
|
|
234
|
+
exports.EVENT_UNIVERSAL_TX_EXECUTED,
|
|
235
|
+
exports.EVENT_REVERT_UNIVERSAL_TX,
|
|
236
|
+
exports.EVENT_FUNDS_RESCUED,
|
|
237
|
+
exports.EVENT_UNIVERSAL_TX_FINALIZED,
|
|
238
|
+
exports.EVENT_UNIVERSAL_TX_REVERTED,
|
|
239
|
+
exports.EVENT_UNIVERSAL_TX_OUTBOUND,
|
|
240
|
+
];
|
|
241
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-Tx Detector — read-only SDK utility that, given a source-chain tx
|
|
3
|
+
* hash + chain, decodes any universal-tx events in the receipt and (optionally)
|
|
4
|
+
* cross-references the corresponding universalTx on Push Chain.
|
|
5
|
+
*
|
|
6
|
+
* Entrypoint: `detectUniversalTx(txHash, chain, opts?)`.
|
|
7
|
+
*/
|
|
8
|
+
export { detectUniversalTx } from './detector';
|
|
9
|
+
export { classify, classifyAll } from './classify';
|
|
10
|
+
export { deriveChildUniversalTxId, derivePcUniversalTxId, resolveChildInboundsFromDetection, resolveChildInboundsFromLogs, } from './child-inbounds';
|
|
11
|
+
export type { ChildInboundResolution } from './child-inbounds';
|
|
12
|
+
export { traceUniversalTxCascade, flattenCascade } from './cascade';
|
|
13
|
+
export type { CascadeEdge, CascadeNode, PcRefundSummary, TraceCascadeOptions, } from './cascade';
|
|
14
|
+
export { detectUniversalTxAuto, listAutoProbeChains, } from './auto-detect';
|
|
15
|
+
export type { AutoDetectionResult, DetectUniversalTxAutoOptions, } from './auto-detect';
|
|
16
|
+
export { EVENT_UNIVERSAL_TX, EVENT_UNIVERSAL_TX_EXECUTED, EVENT_REVERT_UNIVERSAL_TX, EVENT_FUNDS_RESCUED, EVENT_UNIVERSAL_TX_FINALIZED, EVENT_UNIVERSAL_TX_REVERTED, EVENT_UNIVERSAL_TX_OUTBOUND, UNIVERSAL_TX_EVENT_ABI, } from './events';
|
|
17
|
+
export type { KnownEventName } from './events';
|
|
18
|
+
export type { DecodedIdentifiers, DetectionEntry, DetectUniversalTxOptions, MatchingLog, PushChainCrossRef, PushChainOutboundSummary, TxTypeName, UniversalTxDetection, UniversalTxKind, } from './types';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNIVERSAL_TX_EVENT_ABI = exports.EVENT_UNIVERSAL_TX_OUTBOUND = exports.EVENT_UNIVERSAL_TX_REVERTED = exports.EVENT_UNIVERSAL_TX_FINALIZED = exports.EVENT_FUNDS_RESCUED = exports.EVENT_REVERT_UNIVERSAL_TX = exports.EVENT_UNIVERSAL_TX_EXECUTED = exports.EVENT_UNIVERSAL_TX = exports.listAutoProbeChains = exports.detectUniversalTxAuto = exports.flattenCascade = exports.traceUniversalTxCascade = exports.resolveChildInboundsFromLogs = exports.resolveChildInboundsFromDetection = exports.derivePcUniversalTxId = exports.deriveChildUniversalTxId = exports.classifyAll = exports.classify = exports.detectUniversalTx = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Universal-Tx Detector — read-only SDK utility that, given a source-chain tx
|
|
6
|
+
* hash + chain, decodes any universal-tx events in the receipt and (optionally)
|
|
7
|
+
* cross-references the corresponding universalTx on Push Chain.
|
|
8
|
+
*
|
|
9
|
+
* Entrypoint: `detectUniversalTx(txHash, chain, opts?)`.
|
|
10
|
+
*/
|
|
11
|
+
var detector_1 = require("./detector");
|
|
12
|
+
Object.defineProperty(exports, "detectUniversalTx", { enumerable: true, get: function () { return detector_1.detectUniversalTx; } });
|
|
13
|
+
var classify_1 = require("./classify");
|
|
14
|
+
Object.defineProperty(exports, "classify", { enumerable: true, get: function () { return classify_1.classify; } });
|
|
15
|
+
Object.defineProperty(exports, "classifyAll", { enumerable: true, get: function () { return classify_1.classifyAll; } });
|
|
16
|
+
var child_inbounds_1 = require("./child-inbounds");
|
|
17
|
+
Object.defineProperty(exports, "deriveChildUniversalTxId", { enumerable: true, get: function () { return child_inbounds_1.deriveChildUniversalTxId; } });
|
|
18
|
+
Object.defineProperty(exports, "derivePcUniversalTxId", { enumerable: true, get: function () { return child_inbounds_1.derivePcUniversalTxId; } });
|
|
19
|
+
Object.defineProperty(exports, "resolveChildInboundsFromDetection", { enumerable: true, get: function () { return child_inbounds_1.resolveChildInboundsFromDetection; } });
|
|
20
|
+
Object.defineProperty(exports, "resolveChildInboundsFromLogs", { enumerable: true, get: function () { return child_inbounds_1.resolveChildInboundsFromLogs; } });
|
|
21
|
+
var cascade_1 = require("./cascade");
|
|
22
|
+
Object.defineProperty(exports, "traceUniversalTxCascade", { enumerable: true, get: function () { return cascade_1.traceUniversalTxCascade; } });
|
|
23
|
+
Object.defineProperty(exports, "flattenCascade", { enumerable: true, get: function () { return cascade_1.flattenCascade; } });
|
|
24
|
+
var auto_detect_1 = require("./auto-detect");
|
|
25
|
+
Object.defineProperty(exports, "detectUniversalTxAuto", { enumerable: true, get: function () { return auto_detect_1.detectUniversalTxAuto; } });
|
|
26
|
+
Object.defineProperty(exports, "listAutoProbeChains", { enumerable: true, get: function () { return auto_detect_1.listAutoProbeChains; } });
|
|
27
|
+
var events_1 = require("./events");
|
|
28
|
+
Object.defineProperty(exports, "EVENT_UNIVERSAL_TX", { enumerable: true, get: function () { return events_1.EVENT_UNIVERSAL_TX; } });
|
|
29
|
+
Object.defineProperty(exports, "EVENT_UNIVERSAL_TX_EXECUTED", { enumerable: true, get: function () { return events_1.EVENT_UNIVERSAL_TX_EXECUTED; } });
|
|
30
|
+
Object.defineProperty(exports, "EVENT_REVERT_UNIVERSAL_TX", { enumerable: true, get: function () { return events_1.EVENT_REVERT_UNIVERSAL_TX; } });
|
|
31
|
+
Object.defineProperty(exports, "EVENT_FUNDS_RESCUED", { enumerable: true, get: function () { return events_1.EVENT_FUNDS_RESCUED; } });
|
|
32
|
+
Object.defineProperty(exports, "EVENT_UNIVERSAL_TX_FINALIZED", { enumerable: true, get: function () { return events_1.EVENT_UNIVERSAL_TX_FINALIZED; } });
|
|
33
|
+
Object.defineProperty(exports, "EVENT_UNIVERSAL_TX_REVERTED", { enumerable: true, get: function () { return events_1.EVENT_UNIVERSAL_TX_REVERTED; } });
|
|
34
|
+
Object.defineProperty(exports, "EVENT_UNIVERSAL_TX_OUTBOUND", { enumerable: true, get: function () { return events_1.EVENT_UNIVERSAL_TX_OUTBOUND; } });
|
|
35
|
+
Object.defineProperty(exports, "UNIVERSAL_TX_EVENT_ABI", { enumerable: true, get: function () { return events_1.UNIVERSAL_TX_EVENT_ABI; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVM-side universal-tx event metadata.
|
|
3
|
+
*
|
|
4
|
+
* Anchor programs emit events as base64-encoded `Program data:` log lines
|
|
5
|
+
* prefixed with an 8-byte discriminator. The map below covers the four SVM
|
|
6
|
+
* gateway events that have EVM parity (source: universalGatewayV0.json
|
|
7
|
+
* events section). The discriminator bytes come from the IDL and are
|
|
8
|
+
* converted to lowercase hex for matching.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Mapping: 8-byte discriminator (lowercase hex, no 0x) → Anchor event name.
|
|
12
|
+
* Only events with EVM classifier parity are listed; the keeper-agnostic
|
|
13
|
+
* ones (BlockUsdCapUpdated, ProtocolFeeCollected, etc.) are intentionally
|
|
14
|
+
* skipped — they wouldn't classify to any UniversalTxKind anyway.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SVM_EVENT_DISCRIMINATORS: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Classifier field names from classify.ts use EVM-style camelCase
|
|
19
|
+
* (`subTxId`, `universalTxId`, `revertRecipient`, `fromCEA`, `txType`).
|
|
20
|
+
* SVM IDL fields are snake_case. This helper renames the subset that
|
|
21
|
+
* classify.ts reads so the shared decoder logic works unchanged.
|
|
22
|
+
*
|
|
23
|
+
* The mapping is event-agnostic: keys that don't appear in a given event
|
|
24
|
+
* are simply absent from the input and ignored.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SVM_FIELD_RENAMES: Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Event-specific field aliases.
|
|
29
|
+
*
|
|
30
|
+
* EVM `UniversalTxFinalized` exposes the payload blob as `data`; on SVM
|
|
31
|
+
* the field is named `payload`. EVM `RevertUniversalTx` exposes the
|
|
32
|
+
* recipient as `to`; SVM names it `revert_recipient` (already renamed
|
|
33
|
+
* to `revertRecipient` via SVM_FIELD_RENAMES). We add both aliases so
|
|
34
|
+
* classify.ts's event-specific switch finds them under the expected key.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SVM_EVENT_FIELD_ALIASES: Record<string, Array<{
|
|
37
|
+
from: string;
|
|
38
|
+
to: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/** Lowercase hex discriminator from an Anchor program-data decoded buffer. */
|
|
41
|
+
export declare function discriminatorHex(buf: Uint8Array): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SVM-side universal-tx event metadata.
|
|
4
|
+
*
|
|
5
|
+
* Anchor programs emit events as base64-encoded `Program data:` log lines
|
|
6
|
+
* prefixed with an 8-byte discriminator. The map below covers the four SVM
|
|
7
|
+
* gateway events that have EVM parity (source: universalGatewayV0.json
|
|
8
|
+
* events section). The discriminator bytes come from the IDL and are
|
|
9
|
+
* converted to lowercase hex for matching.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SVM_EVENT_FIELD_ALIASES = exports.SVM_FIELD_RENAMES = exports.SVM_EVENT_DISCRIMINATORS = void 0;
|
|
13
|
+
exports.discriminatorHex = discriminatorHex;
|
|
14
|
+
const toHex = (bytes) => bytes.map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
15
|
+
/**
|
|
16
|
+
* Mapping: 8-byte discriminator (lowercase hex, no 0x) → Anchor event name.
|
|
17
|
+
* Only events with EVM classifier parity are listed; the keeper-agnostic
|
|
18
|
+
* ones (BlockUsdCapUpdated, ProtocolFeeCollected, etc.) are intentionally
|
|
19
|
+
* skipped — they wouldn't classify to any UniversalTxKind anyway.
|
|
20
|
+
*/
|
|
21
|
+
exports.SVM_EVENT_DISCRIMINATORS = {
|
|
22
|
+
[toHex([108, 154, 216, 41, 181, 234, 29, 124])]: 'UniversalTx',
|
|
23
|
+
[toHex([179, 64, 150, 112, 117, 140, 156, 37])]: 'UniversalTxFinalized',
|
|
24
|
+
[toHex([249, 74, 39, 203, 149, 54, 48, 186])]: 'RevertUniversalTx',
|
|
25
|
+
[toHex([159, 37, 6, 93, 98, 122, 176, 210])]: 'FundsRescued',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Classifier field names from classify.ts use EVM-style camelCase
|
|
29
|
+
* (`subTxId`, `universalTxId`, `revertRecipient`, `fromCEA`, `txType`).
|
|
30
|
+
* SVM IDL fields are snake_case. This helper renames the subset that
|
|
31
|
+
* classify.ts reads so the shared decoder logic works unchanged.
|
|
32
|
+
*
|
|
33
|
+
* The mapping is event-agnostic: keys that don't appear in a given event
|
|
34
|
+
* are simply absent from the input and ignored.
|
|
35
|
+
*/
|
|
36
|
+
exports.SVM_FIELD_RENAMES = {
|
|
37
|
+
sub_tx_id: 'subTxId',
|
|
38
|
+
universal_tx_id: 'universalTxId',
|
|
39
|
+
revert_recipient: 'revertRecipient',
|
|
40
|
+
push_account: 'pushAccount',
|
|
41
|
+
from_cea: 'fromCEA',
|
|
42
|
+
tx_type: 'txType',
|
|
43
|
+
signature_data: 'signatureData',
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Event-specific field aliases.
|
|
47
|
+
*
|
|
48
|
+
* EVM `UniversalTxFinalized` exposes the payload blob as `data`; on SVM
|
|
49
|
+
* the field is named `payload`. EVM `RevertUniversalTx` exposes the
|
|
50
|
+
* recipient as `to`; SVM names it `revert_recipient` (already renamed
|
|
51
|
+
* to `revertRecipient` via SVM_FIELD_RENAMES). We add both aliases so
|
|
52
|
+
* classify.ts's event-specific switch finds them under the expected key.
|
|
53
|
+
*/
|
|
54
|
+
exports.SVM_EVENT_FIELD_ALIASES = {
|
|
55
|
+
UniversalTxFinalized: [{ from: 'payload', to: 'data' }],
|
|
56
|
+
RevertUniversalTx: [{ from: 'revertRecipient', to: 'to' }],
|
|
57
|
+
};
|
|
58
|
+
/** Lowercase hex discriminator from an Anchor program-data decoded buffer. */
|
|
59
|
+
function discriminatorHex(buf) {
|
|
60
|
+
if (buf.length < 8)
|
|
61
|
+
return '';
|
|
62
|
+
let hex = '';
|
|
63
|
+
for (let i = 0; i < 8; i++) {
|
|
64
|
+
hex += buf[i].toString(16).padStart(2, '0');
|
|
65
|
+
}
|
|
66
|
+
return hex;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=svm-events.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for the universal-tx detector.
|
|
3
|
+
*/
|
|
4
|
+
import type { CHAIN, PUSH_NETWORK } from '../constants/enums';
|
|
5
|
+
import type { PushClient } from '../push-client/push-client';
|
|
6
|
+
/**
|
|
7
|
+
* High-level classification for a transaction.
|
|
8
|
+
* Priority when multiple universal-tx events exist in the same receipt:
|
|
9
|
+
* OUTBOUND_FINALIZED > OUTBOUND_REVERTED > OUTBOUND_INITIATED
|
|
10
|
+
* > INBOUND_REVERTED > INBOUND_FROM_CEA > INBOUND_FROM_EOA
|
|
11
|
+
* > EXECUTED_ON_DEST > RESCUED_FUNDS > UNKNOWN
|
|
12
|
+
*/
|
|
13
|
+
export type UniversalTxKind = 'INBOUND_FROM_EOA' | 'INBOUND_FROM_CEA' | 'OUTBOUND_INITIATED' | 'OUTBOUND_FINALIZED' | 'OUTBOUND_REVERTED' | 'INBOUND_REVERTED' | 'EXECUTED_ON_DEST' | 'RESCUED_FUNDS' | 'UNKNOWN';
|
|
14
|
+
export type TxTypeName = 'GAS' | 'GAS_AND_PAYLOAD' | 'FUNDS' | 'FUNDS_AND_PAYLOAD' | 'RESCUE_FUNDS' | 'UNKNOWN';
|
|
15
|
+
export interface DecodedIdentifiers {
|
|
16
|
+
subTxId?: `0x${string}`;
|
|
17
|
+
universalTxId?: `0x${string}`;
|
|
18
|
+
sender?: `0x${string}`;
|
|
19
|
+
recipient?: `0x${string}` | string;
|
|
20
|
+
pushAccount?: `0x${string}`;
|
|
21
|
+
token?: `0x${string}`;
|
|
22
|
+
amount?: bigint;
|
|
23
|
+
payloadPreview?: `0x${string}`;
|
|
24
|
+
payloadLength?: number;
|
|
25
|
+
txType?: number;
|
|
26
|
+
txTypeName?: TxTypeName;
|
|
27
|
+
fromCEA?: boolean;
|
|
28
|
+
destinationChainNamespace?: string;
|
|
29
|
+
gasFee?: bigint;
|
|
30
|
+
gasLimit?: bigint;
|
|
31
|
+
protocolFee?: bigint;
|
|
32
|
+
revertRecipient?: `0x${string}`;
|
|
33
|
+
revertMsgPreview?: `0x${string}`;
|
|
34
|
+
}
|
|
35
|
+
export interface MatchingLog {
|
|
36
|
+
eventName: string;
|
|
37
|
+
address: `0x${string}`;
|
|
38
|
+
logIndex: number;
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
export interface PushChainOutboundSummary {
|
|
42
|
+
subTxId: string;
|
|
43
|
+
status: string;
|
|
44
|
+
destinationChain: string;
|
|
45
|
+
externalTxHash?: string;
|
|
46
|
+
amount?: string;
|
|
47
|
+
recipient?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface PushChainCrossRef {
|
|
50
|
+
id: string;
|
|
51
|
+
status: number;
|
|
52
|
+
statusName: string;
|
|
53
|
+
pcTxHashes: string[];
|
|
54
|
+
outboundHashes: PushChainOutboundSummary[];
|
|
55
|
+
/** Set when cosmos has not progressed the status for an inbound tx. */
|
|
56
|
+
stuckObservation?: 'UNSPECIFIED' | 'PENDING_INBOUND_ONLY';
|
|
57
|
+
/** Cosmos query returned no record for this universalTxId. */
|
|
58
|
+
notFound?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface DetectionEntry {
|
|
61
|
+
kind: UniversalTxKind;
|
|
62
|
+
decoded: DecodedIdentifiers;
|
|
63
|
+
log: MatchingLog;
|
|
64
|
+
}
|
|
65
|
+
export interface UniversalTxDetection {
|
|
66
|
+
txHash: `0x${string}`;
|
|
67
|
+
chain: CHAIN;
|
|
68
|
+
/**
|
|
69
|
+
* Primary classification (highest-priority event in the receipt).
|
|
70
|
+
* See `detections` for the per-log list when a receipt carries multiple
|
|
71
|
+
* universal events (e.g. outbound finalize + CEA-originated inbound).
|
|
72
|
+
*/
|
|
73
|
+
kind: UniversalTxKind;
|
|
74
|
+
/** Decoded identifiers for the primary log. */
|
|
75
|
+
decoded: DecodedIdentifiers;
|
|
76
|
+
/** Unique emitter addresses of the matching logs. */
|
|
77
|
+
emitters: `0x${string}`[];
|
|
78
|
+
matchingLogs: MatchingLog[];
|
|
79
|
+
/** One entry per matching universal-tx log. Empty when kind is UNKNOWN. */
|
|
80
|
+
detections: DetectionEntry[];
|
|
81
|
+
pushChainTx?: PushChainCrossRef;
|
|
82
|
+
notes: string[];
|
|
83
|
+
}
|
|
84
|
+
export interface DetectUniversalTxOptions {
|
|
85
|
+
/**
|
|
86
|
+
* PushClient used to cross-reference the cosmos side. When omitted
|
|
87
|
+
* (or skipPushChainLookup=true), `pushChainTx` stays undefined.
|
|
88
|
+
*/
|
|
89
|
+
pushClient?: PushClient;
|
|
90
|
+
/**
|
|
91
|
+
* Per-chain RPC overrides. Falls back to CHAIN_INFO[chain].defaultRPC.
|
|
92
|
+
*/
|
|
93
|
+
rpcUrls?: Partial<Record<CHAIN, string[]>>;
|
|
94
|
+
skipPushChainLookup?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* PUSH_NETWORK used for deriving universalTxId on inbound txs where the
|
|
97
|
+
* emitted UniversalTx event does not carry one. Defaults to TESTNET_DONUT.
|
|
98
|
+
*/
|
|
99
|
+
pushNetwork?: PUSH_NETWORK;
|
|
100
|
+
}
|
package/src/lib/utils.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { construct, toUniversal as toUniversalSigner, toUniversalFromKeypair } f
|
|
|
3
3
|
import { CHAIN, PUSH_NETWORK } from './constants/enums';
|
|
4
4
|
import { type MoveableToken } from './constants/tokens';
|
|
5
5
|
import type { PushChain } from './push-chain/push-chain';
|
|
6
|
-
import {
|
|
6
|
+
import type { Idl } from '@coral-xyz/anchor';
|
|
7
|
+
import { registerIdl as registerSvmIdl, getRegisteredIdls as getRegisteredSvmIdls } from './orchestrator/svm-idl/registry';
|
|
7
8
|
/**
|
|
8
9
|
* @dev - THESE UTILS ARE EXPORTED TO SDK CONSUMER
|
|
9
10
|
* @dev - Make sure each exported fn has good comments to help out sdk consumer
|
|
@@ -34,22 +35,17 @@ export declare class Utils {
|
|
|
34
35
|
resolveControllerAccount: typeof resolveControllerAccount;
|
|
35
36
|
};
|
|
36
37
|
/**
|
|
37
|
-
* SVM (Solana) utilities
|
|
38
|
+
* SVM (Solana) escape-hatch utilities.
|
|
38
39
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* to pass `data` (discriminator + Borsh args), the same shape used for EVM.
|
|
40
|
+
* `PushChain.utils.helpers.encodeTxData({ abi: idl, ... })` auto-registers
|
|
41
|
+
* the Anchor IDL internally, so normal callers never need these.
|
|
42
42
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* PROGRAM_ADDRESS_HEX,
|
|
46
|
-
* testCounterIdl
|
|
47
|
-
* );
|
|
43
|
+
* Use `registerIdl` directly only when you build `data` manually (raw
|
|
44
|
+
* Anchor discriminator + Borsh bytes) and bypass `encodeTxData`.
|
|
48
45
|
*/
|
|
49
46
|
static svm: {
|
|
50
47
|
registerIdl: typeof registerSvmIdl;
|
|
51
48
|
getRegisteredIdls: typeof getRegisteredSvmIdls;
|
|
52
|
-
getIdl: typeof getSvmIdl;
|
|
53
49
|
};
|
|
54
50
|
static signer: {
|
|
55
51
|
/**
|
|
@@ -116,8 +112,29 @@ export declare class Utils {
|
|
|
116
112
|
* and delegates to Utils.chains.getChainNamespace.
|
|
117
113
|
*/
|
|
118
114
|
getChainName: (chainName: string) => string | undefined;
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Encode calldata for a universal tx.
|
|
117
|
+
*
|
|
118
|
+
* Pass `abi` for EVM targets, or `idl` for SVM (Anchor) targets. Exactly
|
|
119
|
+
* one of the two is required.
|
|
120
|
+
*
|
|
121
|
+
* @example EVM
|
|
122
|
+
* PushChain.utils.helpers.encodeTxData({
|
|
123
|
+
* abi: erc20Abi,
|
|
124
|
+
* functionName: 'transfer',
|
|
125
|
+
* args: [to, amount],
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* @example SVM (Anchor)
|
|
129
|
+
* PushChain.utils.helpers.encodeTxData({
|
|
130
|
+
* idl: counterIdl,
|
|
131
|
+
* functionName: 'increment',
|
|
132
|
+
* args: [],
|
|
133
|
+
* });
|
|
134
|
+
*/
|
|
135
|
+
encodeTxData({ abi, idl, functionName, args, }: {
|
|
136
|
+
abi?: any;
|
|
137
|
+
idl?: Idl;
|
|
121
138
|
functionName: string;
|
|
122
139
|
args?: any[];
|
|
123
140
|
}): `0x${string}`;
|