@pushchain/core 5.1.17 → 6.0.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/package.json +1 -1
- package/src/lib/constants/abi/cea.evm.d.ts +52 -0
- package/src/lib/constants/abi/cea.evm.js +66 -1
- package/src/lib/constants/abi/prc20.evm.d.ts +117 -11
- package/src/lib/constants/abi/prc20.evm.js +38 -11
- package/src/lib/constants/abi/uea.evm.js +41 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +117 -1
- package/src/lib/constants/abi/universalGatewayPC.evm.js +40 -1
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.js +14 -14
- package/src/lib/constants/index.d.ts +1 -1
- package/src/lib/constants/index.js +2 -1
- package/src/lib/constants/selectors.d.ts +8 -0
- package/src/lib/constants/selectors.js +9 -1
- package/src/lib/constants/tokens.js +1 -0
- package/src/lib/formatters.d.ts +7 -0
- package/src/lib/formatters.js +46 -0
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +7 -1
- package/src/lib/orchestrator/internals/cascade.d.ts +8 -1
- package/src/lib/orchestrator/internals/cascade.js +593 -192
- package/src/lib/orchestrator/internals/error-decoder.d.ts +2 -6
- package/src/lib/orchestrator/internals/error-decoder.js +10 -10
- package/src/lib/orchestrator/internals/errors.d.ts +1 -1
- package/src/lib/orchestrator/internals/errors.js +8 -5
- package/src/lib/orchestrator/internals/execute-funds-only.js +3 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +2 -1
- package/src/lib/orchestrator/internals/execute-standard.js +11 -10
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +1 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +91 -22
- package/src/lib/orchestrator/internals/helpers.d.ts +2 -1
- package/src/lib/orchestrator/internals/helpers.js +14 -11
- package/src/lib/orchestrator/internals/inbound-tracker.js +4 -2
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +1 -0
- package/src/lib/orchestrator/internals/outbound-sync.js +140 -71
- package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +1 -1
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +4 -3
- package/src/lib/orchestrator/internals/preflight.d.ts +2 -16
- package/src/lib/orchestrator/internals/preflight.js +2 -36
- package/src/lib/orchestrator/internals/push-chain-tx.js +5 -1
- package/src/lib/orchestrator/internals/response-builder.js +23 -7
- package/src/lib/orchestrator/internals/route-handlers.js +182 -227
- package/src/lib/orchestrator/internals/signing.js +7 -2
- package/src/lib/orchestrator/internals/svm-helpers.js +3 -3
- package/src/lib/orchestrator/internals/svm-rent.d.ts +42 -9
- package/src/lib/orchestrator/internals/svm-rent.js +148 -14
- package/src/lib/orchestrator/internals/tx-transformer.js +5 -2
- package/src/lib/orchestrator/max-pc-for-gas.d.ts +60 -0
- package/src/lib/orchestrator/max-pc-for-gas.js +66 -0
- package/src/lib/orchestrator/orchestrator.d.ts +8 -1
- package/src/lib/orchestrator/orchestrator.js +40 -2
- package/src/lib/orchestrator/orchestrator.types.d.ts +35 -23
- package/src/lib/orchestrator/payload-builders.d.ts +7 -6
- package/src/lib/orchestrator/payload-builders.js +18 -6
- package/src/lib/progress-hook/progress-hook.js +39 -38
- package/src/lib/push-chain/push-chain.d.ts +11 -1
- package/src/lib/push-chain/push-chain.js +2 -2
- package/src/lib/universal-tx-detector/cascade.js +14 -4
- package/src/lib/universal-tx-detector/child-inbounds.js +9 -1
- package/src/lib/universal-tx-detector/detector.js +9 -3
- package/src/lib/universal-tx-detector/events.d.ts +3 -1
- package/src/lib/universal-tx-detector/events.js +3 -1
- package/src/lib/universal-tx-detector/normalize.d.ts +42 -0
- package/src/lib/universal-tx-detector/normalize.js +127 -0
- package/src/lib/universal-tx-detector/svm-events.d.ts +1 -1
- package/src/lib/universal-tx-detector/svm-events.js +1 -1
- package/src/lib/utils/external-tx-hash.d.ts +37 -0
- package/src/lib/utils/external-tx-hash.js +62 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User-facing normalization pass for detector outputs.
|
|
4
|
+
*
|
|
5
|
+
* The detector module's internal pipeline produces `PushChainOutboundSummary`
|
|
6
|
+
* objects with raw `0x`-hex `externalTxHash` for SVM destinations — that's
|
|
7
|
+
* the form Cosmos delivers and the form `findChildUtxIdFromExternalTx` /
|
|
8
|
+
* `inbound_tx_hash='…'` queries require. For USER-facing entry points
|
|
9
|
+
* (`detectUniversalTx`, `traceUniversalTxCascade`,
|
|
10
|
+
* `resolveChildInboundsFromDetection`), the SVM hash should be base58 so
|
|
11
|
+
* consumers can paste it straight into a Solana explorer or
|
|
12
|
+
* `connection.getTransaction(sig)`.
|
|
13
|
+
*
|
|
14
|
+
* These helpers are applied at the three public-API return points (and
|
|
15
|
+
* NOWHERE else) — they walk the result tree and rewrite
|
|
16
|
+
* `PushChainOutboundSummary.externalTxHash` for SVM destinations. The
|
|
17
|
+
* internal pipeline never sees the normalized form.
|
|
18
|
+
*
|
|
19
|
+
* Helpers are idempotent: a value not starting with `0x` or whose
|
|
20
|
+
* `destinationChain` isn't SVM passes through unchanged. New objects are
|
|
21
|
+
* returned only when a field actually changed; otherwise the same reference
|
|
22
|
+
* is reused so EVM-only graphs incur near-zero allocation.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.normalizeOutboundSummaryForUser = normalizeOutboundSummaryForUser;
|
|
26
|
+
exports.normalizeDetectionForUser = normalizeDetectionForUser;
|
|
27
|
+
exports.normalizeChildInboundResolutionForUser = normalizeChildInboundResolutionForUser;
|
|
28
|
+
exports.normalizeCascadeNodeForUser = normalizeCascadeNodeForUser;
|
|
29
|
+
const external_tx_hash_1 = require("../utils/external-tx-hash");
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a single outbound summary's `externalTxHash` for user display.
|
|
32
|
+
* Returns the same reference when no change is needed.
|
|
33
|
+
*/
|
|
34
|
+
function normalizeOutboundSummaryForUser(s) {
|
|
35
|
+
if (!s.externalTxHash)
|
|
36
|
+
return s;
|
|
37
|
+
const chain = (0, external_tx_hash_1.chainFromNamespace)(s.destinationChain);
|
|
38
|
+
const next = (0, external_tx_hash_1.toExternalTxHashDisplay)(chain !== null && chain !== void 0 ? chain : undefined, s.externalTxHash);
|
|
39
|
+
if (next === s.externalTxHash)
|
|
40
|
+
return s;
|
|
41
|
+
return Object.assign(Object.assign({}, s), { externalTxHash: next });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize the outbound summaries inside `PushChainCrossRef.outboundHashes`.
|
|
45
|
+
* Reuses the input when no nested summary changed.
|
|
46
|
+
*/
|
|
47
|
+
function normalizeCrossRefForUser(x) {
|
|
48
|
+
if (!x.outboundHashes || x.outboundHashes.length === 0)
|
|
49
|
+
return x;
|
|
50
|
+
let changed = false;
|
|
51
|
+
const next = x.outboundHashes.map((s) => {
|
|
52
|
+
const n = normalizeOutboundSummaryForUser(s);
|
|
53
|
+
if (n !== s)
|
|
54
|
+
changed = true;
|
|
55
|
+
return n;
|
|
56
|
+
});
|
|
57
|
+
if (!changed)
|
|
58
|
+
return x;
|
|
59
|
+
return Object.assign(Object.assign({}, x), { outboundHashes: next });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Normalize the outbound summaries embedded in `detection.pushChainTx`.
|
|
63
|
+
* The root `detection.txHash` is left untouched — per agreed scope.
|
|
64
|
+
*/
|
|
65
|
+
function normalizeDetectionForUser(d) {
|
|
66
|
+
if (!d.pushChainTx)
|
|
67
|
+
return d;
|
|
68
|
+
const nextPushChainTx = normalizeCrossRefForUser(d.pushChainTx);
|
|
69
|
+
if (nextPushChainTx === d.pushChainTx)
|
|
70
|
+
return d;
|
|
71
|
+
return Object.assign(Object.assign({}, d), { pushChainTx: nextPushChainTx });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Normalize the outbound summaries inside a `ChildInboundResolution`.
|
|
75
|
+
* `pcTxHashes` (Push Chain — always EVM) is left untouched.
|
|
76
|
+
*/
|
|
77
|
+
function normalizeChildInboundResolutionForUser(r) {
|
|
78
|
+
if (!r.outboundHashes || r.outboundHashes.length === 0)
|
|
79
|
+
return r;
|
|
80
|
+
let changed = false;
|
|
81
|
+
const next = r.outboundHashes.map((s) => {
|
|
82
|
+
const n = normalizeOutboundSummaryForUser(s);
|
|
83
|
+
if (n !== s)
|
|
84
|
+
changed = true;
|
|
85
|
+
return n;
|
|
86
|
+
});
|
|
87
|
+
if (!changed)
|
|
88
|
+
return r;
|
|
89
|
+
return Object.assign(Object.assign({}, r), { outboundHashes: next });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Type guard: identifies a `CascadeEdge.relation` as a
|
|
93
|
+
* `PushChainOutboundSummary`. Outbound summaries carry `destinationChain` and
|
|
94
|
+
* (optionally) `externalTxHash`; refund summaries and child-inbound
|
|
95
|
+
* resolutions don't.
|
|
96
|
+
*/
|
|
97
|
+
function isOutboundRelation(r) {
|
|
98
|
+
return (typeof r.destinationChain === 'string' &&
|
|
99
|
+
!('universalTxId' in r) &&
|
|
100
|
+
!('parentOutboundId' in r));
|
|
101
|
+
}
|
|
102
|
+
function isChildInboundRelation(r) {
|
|
103
|
+
return 'universalTxId' in r;
|
|
104
|
+
}
|
|
105
|
+
/** Recursively normalize a cascade tree. */
|
|
106
|
+
function normalizeCascadeNodeForUser(n) {
|
|
107
|
+
const nextDetection = normalizeDetectionForUser(n.detection);
|
|
108
|
+
let childrenChanged = nextDetection !== n.detection;
|
|
109
|
+
const nextChildren = n.children.map((edge) => {
|
|
110
|
+
let nextRelation = edge.relation;
|
|
111
|
+
if (isOutboundRelation(edge.relation)) {
|
|
112
|
+
nextRelation = normalizeOutboundSummaryForUser(edge.relation);
|
|
113
|
+
}
|
|
114
|
+
else if (isChildInboundRelation(edge.relation)) {
|
|
115
|
+
nextRelation = normalizeChildInboundResolutionForUser(edge.relation);
|
|
116
|
+
}
|
|
117
|
+
const nextNode = edge.node ? normalizeCascadeNodeForUser(edge.node) : edge.node;
|
|
118
|
+
if (nextRelation === edge.relation && nextNode === edge.node)
|
|
119
|
+
return edge;
|
|
120
|
+
childrenChanged = true;
|
|
121
|
+
return Object.assign(Object.assign({}, edge), { relation: nextRelation, node: nextNode });
|
|
122
|
+
});
|
|
123
|
+
if (!childrenChanged)
|
|
124
|
+
return n;
|
|
125
|
+
return Object.assign(Object.assign({}, n), { detection: nextDetection, children: nextChildren });
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Mapping: 8-byte discriminator (lowercase hex, no 0x) → Anchor event name.
|
|
12
12
|
* Only events with EVM classifier parity are listed; the keeper-agnostic
|
|
13
|
-
* ones (BlockUsdCapUpdated,
|
|
13
|
+
* ones (BlockUsdCapUpdated, inbound-fee events, etc.) are intentionally
|
|
14
14
|
* skipped — they wouldn't classify to any UniversalTxKind anyway.
|
|
15
15
|
*/
|
|
16
16
|
export declare const SVM_EVENT_DISCRIMINATORS: Record<string, string>;
|
|
@@ -15,7 +15,7 @@ const toHex = (bytes) => bytes.map((b) => b.toString(16).padStart(2, '0')).join(
|
|
|
15
15
|
/**
|
|
16
16
|
* Mapping: 8-byte discriminator (lowercase hex, no 0x) → Anchor event name.
|
|
17
17
|
* Only events with EVM classifier parity are listed; the keeper-agnostic
|
|
18
|
-
* ones (BlockUsdCapUpdated,
|
|
18
|
+
* ones (BlockUsdCapUpdated, inbound-fee events, etc.) are intentionally
|
|
19
19
|
* skipped — they wouldn't classify to any UniversalTxKind anyway.
|
|
20
20
|
*/
|
|
21
21
|
exports.SVM_EVENT_DISCRIMINATORS = {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External-tx-hash display helpers.
|
|
3
|
+
*
|
|
4
|
+
* Lives at a neutral cross-module location so both the orchestrator and the
|
|
5
|
+
* universal-tx-detector module can import without creating a circular /
|
|
6
|
+
* back-layered dependency (orchestrator/internals imports detector via
|
|
7
|
+
* inbound-tracker.ts; detector must not import back into orchestrator).
|
|
8
|
+
*
|
|
9
|
+
* The SDK stores SVM (Solana) outbound tx signatures as `0x`-prefixed hex
|
|
10
|
+
* internally — that's how the Cosmos keeper indexes them. Users, however,
|
|
11
|
+
* expect Solana explorers / RPCs to see base58 signatures. `toExternalTxHashDisplay`
|
|
12
|
+
* is the one-way conversion applied at every user-facing boundary; the
|
|
13
|
+
* internal canonical form stays hex.
|
|
14
|
+
*/
|
|
15
|
+
import { CHAIN } from '../constants/enums';
|
|
16
|
+
/**
|
|
17
|
+
* Convert an outbound tx hash from the internal canonical form (`0x`-prefixed
|
|
18
|
+
* hex, as Cosmos delivers it) to the form users expect on the destination
|
|
19
|
+
* chain. SVM signatures (64 bytes) become base58; EVM hashes pass through
|
|
20
|
+
* unchanged. Idempotent: a value that already lacks `0x` or whose chain isn't
|
|
21
|
+
* SVM is returned as-is.
|
|
22
|
+
*
|
|
23
|
+
* Used at user-facing boundaries that surface `externalTxHash` (receipt
|
|
24
|
+
* construction in response-builder, cascade hop info in cascade.ts, detector
|
|
25
|
+
* public-API output normalization). Do NOT apply at internal boundaries —
|
|
26
|
+
* `findChildUtxIdFromExternalTx` and the Cosmos tx-search query in
|
|
27
|
+
* inbound-tracker.ts expect the raw hex form.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toExternalTxHashDisplay(chain: CHAIN | undefined, rawTxHash: string | undefined): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Map a CAIP namespace string (e.g. `'solana:devnet'`, `'eip155:11155111'`)
|
|
32
|
+
* to the corresponding `CHAIN` enum value, or `null` if no matching chain is
|
|
33
|
+
* registered. Used to resolve `PushChainOutboundSummary.destinationChain`
|
|
34
|
+
* (string) to a CHAIN enum so `toExternalTxHashDisplay` can decide whether
|
|
35
|
+
* to convert.
|
|
36
|
+
*/
|
|
37
|
+
export declare function chainFromNamespace(namespace: string): CHAIN | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* External-tx-hash display helpers.
|
|
4
|
+
*
|
|
5
|
+
* Lives at a neutral cross-module location so both the orchestrator and the
|
|
6
|
+
* universal-tx-detector module can import without creating a circular /
|
|
7
|
+
* back-layered dependency (orchestrator/internals imports detector via
|
|
8
|
+
* inbound-tracker.ts; detector must not import back into orchestrator).
|
|
9
|
+
*
|
|
10
|
+
* The SDK stores SVM (Solana) outbound tx signatures as `0x`-prefixed hex
|
|
11
|
+
* internally — that's how the Cosmos keeper indexes them. Users, however,
|
|
12
|
+
* expect Solana explorers / RPCs to see base58 signatures. `toExternalTxHashDisplay`
|
|
13
|
+
* is the one-way conversion applied at every user-facing boundary; the
|
|
14
|
+
* internal canonical form stays hex.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.toExternalTxHashDisplay = toExternalTxHashDisplay;
|
|
18
|
+
exports.chainFromNamespace = chainFromNamespace;
|
|
19
|
+
const chain_1 = require("../constants/chain");
|
|
20
|
+
const enums_1 = require("../constants/enums");
|
|
21
|
+
const bs58_1 = require("../internal/bs58");
|
|
22
|
+
/**
|
|
23
|
+
* Convert an outbound tx hash from the internal canonical form (`0x`-prefixed
|
|
24
|
+
* hex, as Cosmos delivers it) to the form users expect on the destination
|
|
25
|
+
* chain. SVM signatures (64 bytes) become base58; EVM hashes pass through
|
|
26
|
+
* unchanged. Idempotent: a value that already lacks `0x` or whose chain isn't
|
|
27
|
+
* SVM is returned as-is.
|
|
28
|
+
*
|
|
29
|
+
* Used at user-facing boundaries that surface `externalTxHash` (receipt
|
|
30
|
+
* construction in response-builder, cascade hop info in cascade.ts, detector
|
|
31
|
+
* public-API output normalization). Do NOT apply at internal boundaries —
|
|
32
|
+
* `findChildUtxIdFromExternalTx` and the Cosmos tx-search query in
|
|
33
|
+
* inbound-tracker.ts expect the raw hex form.
|
|
34
|
+
*/
|
|
35
|
+
function toExternalTxHashDisplay(chain, rawTxHash) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!rawTxHash)
|
|
38
|
+
return rawTxHash;
|
|
39
|
+
if (!chain || ((_a = chain_1.CHAIN_INFO[chain]) === null || _a === void 0 ? void 0 : _a.vm) !== enums_1.VM.SVM)
|
|
40
|
+
return rawTxHash;
|
|
41
|
+
if (!rawTxHash.startsWith('0x'))
|
|
42
|
+
return rawTxHash;
|
|
43
|
+
const bytes = new Uint8Array(Buffer.from(rawTxHash.slice(2), 'hex'));
|
|
44
|
+
return bs58_1.bs58.encode(Buffer.from(bytes));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Map a CAIP namespace string (e.g. `'solana:devnet'`, `'eip155:11155111'`)
|
|
48
|
+
* to the corresponding `CHAIN` enum value, or `null` if no matching chain is
|
|
49
|
+
* registered. Used to resolve `PushChainOutboundSummary.destinationChain`
|
|
50
|
+
* (string) to a CHAIN enum so `toExternalTxHashDisplay` can decide whether
|
|
51
|
+
* to convert.
|
|
52
|
+
*/
|
|
53
|
+
function chainFromNamespace(namespace) {
|
|
54
|
+
for (const [chainKey, info] of Object.entries(chain_1.CHAIN_INFO)) {
|
|
55
|
+
const expected = `${chain_1.VM_NAMESPACE[info.vm]}:${info.chainId}`;
|
|
56
|
+
if (expected === namespace) {
|
|
57
|
+
return chainKey;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=external-tx-hash.js.map
|