@pushchain/core 6.0.19 → 6.0.21
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 +54 -0
- package/package.json +1 -1
- package/src/lib/cache/cache.js +2 -0
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +8 -1
- package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
- package/src/lib/constants/abi/pc20.evm.js +150 -0
- package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
- package/src/lib/constants/abi/prc20.evm.js +97 -0
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.js +38 -8
- package/src/lib/constants/selectors.js +2 -2
- package/src/lib/constants/tokens.js +4 -3
- package/src/lib/formatters.js +16 -6
- package/src/lib/generated/uexecutor/v1/query.js +2 -4
- package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v1/types.js +90 -47
- package/src/lib/generated/uexecutor/v2/query.js +2 -4
- package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
- package/src/lib/generated/uexecutor/v2/types.js +49 -33
- package/src/lib/generated/v1/tx.js +30 -37
- package/src/lib/index.d.ts +4 -1
- package/src/lib/index.js +21 -3
- package/src/lib/internal/buffer.js +1 -2
- package/src/lib/orchestrator/cea-utils.js +73 -83
- package/src/lib/orchestrator/internals/account-manager.js +130 -139
- package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
- package/src/lib/orchestrator/internals/cascade.js +1184 -1059
- package/src/lib/orchestrator/internals/confirmation.js +138 -148
- package/src/lib/orchestrator/internals/error-decoder.js +1 -1
- package/src/lib/orchestrator/internals/errors.js +12 -3
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
- package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
- package/src/lib/orchestrator/internals/execute-standard.js +339 -342
- package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
- package/src/lib/orchestrator/internals/gateway-client.js +102 -103
- package/src/lib/orchestrator/internals/helpers.js +30 -27
- package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
- package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
- package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
- package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
- package/src/lib/orchestrator/internals/payload-builder.js +119 -100
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
- package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
- package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
- package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
- package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
- package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
- package/src/lib/orchestrator/internals/pc20/export.js +412 -0
- package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
- package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
- package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
- package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
- package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
- package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
- package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
- package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
- package/src/lib/orchestrator/internals/preflight.js +1 -1
- package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
- package/src/lib/orchestrator/internals/push-chain-tx.js +319 -331
- package/src/lib/orchestrator/internals/quote.js +90 -94
- package/src/lib/orchestrator/internals/rescue.js +76 -79
- package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
- package/src/lib/orchestrator/internals/response-builder.js +817 -701
- package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
- package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
- package/src/lib/orchestrator/internals/signing.js +78 -83
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
- package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
- package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
- package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
- package/src/lib/orchestrator/internals/svm-rent.js +163 -141
- package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
- package/src/lib/orchestrator/internals/uea-manager.js +89 -86
- package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
- package/src/lib/orchestrator/orchestrator.js +217 -200
- package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
- package/src/lib/orchestrator/orchestrator.types.js +19 -0
- package/src/lib/orchestrator/payload-builders.d.ts +2 -2
- package/src/lib/orchestrator/payload-builders.js +26 -24
- package/src/lib/orchestrator/route-detector.js +26 -9
- package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
- package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
- package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
- package/src/lib/price-fetch/price-fetch.js +67 -68
- package/src/lib/progress-hook/progress-hook.js +124 -72
- package/src/lib/push-chain/push-chain.js +171 -153
- package/src/lib/push-client/push-client.js +223 -237
- package/src/lib/universal/account/account.js +349 -365
- package/src/lib/universal/signer/signer.d.ts +2 -1
- package/src/lib/universal/signer/signer.js +315 -299
- package/src/lib/universal-tx-detector/auto-detect.js +55 -60
- package/src/lib/universal-tx-detector/cascade.js +160 -172
- package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
- package/src/lib/universal-tx-detector/classify.js +2 -3
- package/src/lib/universal-tx-detector/detector-svm.js +139 -147
- package/src/lib/universal-tx-detector/detector.js +145 -157
- package/src/lib/universal-tx-detector/normalize.js +7 -7
- package/src/lib/utils/external-tx-hash.js +1 -2
- package/src/lib/utils.d.ts +44 -0
- package/src/lib/utils.js +762 -683
- package/src/lib/vm-client/evm-client.js +186 -202
- package/src/lib/vm-client/svm-client.d.ts +1 -1
- package/src/lib/vm-client/svm-client.js +220 -224
- package/src/lib/vm-client/vm-client.types.d.ts +14 -2
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PC20 registry resolver — the one module that reads PC20 state.
|
|
3
|
+
*
|
|
4
|
+
* Used by `sendTransaction`, `prepareTransaction`, cascade construction,
|
|
5
|
+
* `getPC20Address`, and the outbound tracking fallback.
|
|
6
|
+
* Nothing else may read the registry directly; a second reader is how the
|
|
7
|
+
* validation tiers and the cache policy drift apart.
|
|
8
|
+
*
|
|
9
|
+
* ## Read budget
|
|
10
|
+
*
|
|
11
|
+
* Validation is tiered so a send does not pay for the full identity sweep:
|
|
12
|
+
*
|
|
13
|
+
* Tier A (every send) — `getPC20Source` then `getPC20Wrapper`. Forward and
|
|
14
|
+
* reverse agreement proves the address is registered
|
|
15
|
+
* for that exact namespace, which is what defeats a
|
|
16
|
+
* wrapper address copied onto the wrong chain.
|
|
17
|
+
* Tier B (prepare-time, first use per session, or strict mode) — live gateway
|
|
18
|
+
* factory identity, `isPC20Wrapper`, `wrapperToSource`,
|
|
19
|
+
* `SOURCE_ASSET`, deployed bytecode. Largely redundant
|
|
20
|
+
* once Tier A holds, but it is what catches a
|
|
21
|
+
* misconfigured deployment where the gateway would not
|
|
22
|
+
* take the PC20 burn path at all.
|
|
23
|
+
*
|
|
24
|
+
* Each tier is one multicall against one chain. Budget: at most 2 sequential
|
|
25
|
+
* round trips warm, 4 cold. `__readCount` exists so tests can assert that.
|
|
26
|
+
*
|
|
27
|
+
* ## Cache policy
|
|
28
|
+
*
|
|
29
|
+
* Positive results are cached for the client's lifetime, keyed by
|
|
30
|
+
* `(pushNetwork, chain, address)`. Registered mappings are immutable in
|
|
31
|
+
* practice — a factory reconfiguration is a redeploy-level event.
|
|
32
|
+
*
|
|
33
|
+
* Negative results are NEVER cached. The first successful export creates a
|
|
34
|
+
* mapping that did not previously exist, and a cached "not registered" would
|
|
35
|
+
* make the SDK permanently wrong about a token that now works.
|
|
36
|
+
*/
|
|
37
|
+
import { type Hex } from 'viem';
|
|
38
|
+
import { CHAIN, PUSH_NETWORK, VM } from '../../../constants/enums';
|
|
39
|
+
/** Metadata read off a Push-native PC20 via `pc20Metadata()`. */
|
|
40
|
+
export type PC20Metadata = {
|
|
41
|
+
name: string;
|
|
42
|
+
symbol: string;
|
|
43
|
+
decimals: number;
|
|
44
|
+
originAddress: `0x${string}`;
|
|
45
|
+
};
|
|
46
|
+
/** A confirmed wrapper deployment on one external chain. */
|
|
47
|
+
export type PC20DeploymentInfo = {
|
|
48
|
+
chain: CHAIN;
|
|
49
|
+
chainNamespace: string;
|
|
50
|
+
vm: VM;
|
|
51
|
+
/** Chain-native form: checksummed hex (EVM) or base58 (SVM). */
|
|
52
|
+
address: string;
|
|
53
|
+
/** Registry form, as stored in UniversalCore. */
|
|
54
|
+
rawAddress: Hex;
|
|
55
|
+
};
|
|
56
|
+
/** Everything the execution path needs about a resolved funds token. */
|
|
57
|
+
export type ResolvedPC20 = {
|
|
58
|
+
direction: 'import' | 'export';
|
|
59
|
+
/** Chain the token the caller named lives on. */
|
|
60
|
+
originChain: CHAIN;
|
|
61
|
+
/** Chain-native address of the token the caller named. */
|
|
62
|
+
originAddress: string;
|
|
63
|
+
/** Canonical Push-native PC20. */
|
|
64
|
+
pushAddress: `0x${string}`;
|
|
65
|
+
name: string;
|
|
66
|
+
symbol: string;
|
|
67
|
+
decimals: number;
|
|
68
|
+
/** External wrapper, when one is registered. Absent before a first export. */
|
|
69
|
+
wrapperAddress?: string;
|
|
70
|
+
/** Namespace of the external side (origin for import, destination for export). */
|
|
71
|
+
chainNamespace?: string;
|
|
72
|
+
};
|
|
73
|
+
export type PC20ResolverOptions = {
|
|
74
|
+
network: PUSH_NETWORK;
|
|
75
|
+
/** Per-chain RPC overrides. Falls back to `CHAIN_INFO[chain].defaultRPC`. */
|
|
76
|
+
rpcUrls?: Partial<Record<CHAIN, string[]>>;
|
|
77
|
+
/** Run Tier B factory-identity checks even on a warm path. */
|
|
78
|
+
strict?: boolean;
|
|
79
|
+
/** Re-read the wrapper/source registry even when a positive cache entry exists. */
|
|
80
|
+
bypassCache?: boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Instrumentation for the round-trip budget assertion. Incremented once per
|
|
84
|
+
* network round trip (a batch counts as one, which is the whole point).
|
|
85
|
+
*/
|
|
86
|
+
export declare const __readCount: {
|
|
87
|
+
n: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Resolve UniversalCore through the UGPC precompile, matching how
|
|
91
|
+
* `gas-calculator.queryOutboundGasFee` does it. Cached per network — the
|
|
92
|
+
* precompile's `universalCore` pointer does not move within a session.
|
|
93
|
+
*/
|
|
94
|
+
export declare function getUniversalCoreAddress(opts: PC20ResolverOptions): Promise<`0x${string}`>;
|
|
95
|
+
/** Test seam. Never call from product code — it would drop verified Tier B state. */
|
|
96
|
+
export declare function __clearPC20Caches(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve an external wrapper to its canonical Push-native source.
|
|
99
|
+
*
|
|
100
|
+
* One multicall: `getPC20Source(wrapper, ns)` and, in the same batch, the
|
|
101
|
+
* reverse `getPC20Wrapper` cannot be issued because it depends on the source.
|
|
102
|
+
* The reverse read is therefore a second round trip — this is the "2 sequential
|
|
103
|
+
* round trips" in the budget, and it is not collapsible: the registry has no
|
|
104
|
+
* combined accessor.
|
|
105
|
+
*
|
|
106
|
+
* @throws {PC20WrapperNotRegisteredError} when the wrapper is unknown.
|
|
107
|
+
* @throws {PC20RegistryMismatchError} when forward and reverse disagree.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveWrapperToSource(chain: CHAIN, address: string, opts: PC20ResolverOptions): Promise<{
|
|
110
|
+
pushAddress: `0x${string}`;
|
|
111
|
+
chainNamespace: string;
|
|
112
|
+
rawWrapper: Hex;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Verify the live external gateway will actually take the PC20 burn path for
|
|
116
|
+
* this wrapper, and that its factory is the one UniversalCore knows about.
|
|
117
|
+
*
|
|
118
|
+
* Two multicalls: the gateway's factory pointer must be read before the
|
|
119
|
+
* factory-scoped calls can be addressed.
|
|
120
|
+
*
|
|
121
|
+
* @throws {PC20FactoryMismatchError} on any identity disagreement.
|
|
122
|
+
*/
|
|
123
|
+
export declare function verifyEvmWrapperIdentity(chain: CHAIN, address: string, pushAddress: `0x${string}`, opts: PC20ResolverOptions): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Read and validate `pc20Metadata()` on a Push-native token.
|
|
126
|
+
*
|
|
127
|
+
* The absence of `pc20Metadata` is the discriminator between a PC20 and any
|
|
128
|
+
* other ERC20 — never the symbol. A synthetic PRC20 is detected separately so
|
|
129
|
+
* it gets an error that points at the right API rather than reading as
|
|
130
|
+
* "your token is broken".
|
|
131
|
+
*/
|
|
132
|
+
export declare function readPushPC20Metadata(pushAddress: `0x${string}`, opts: PC20ResolverOptions): Promise<PC20Metadata>;
|
|
133
|
+
/**
|
|
134
|
+
* Confirmed wrapper deployments for a Push-native PC20.
|
|
135
|
+
*
|
|
136
|
+
* One multicall regardless of chain count — every `getPC20Wrapper` read targets
|
|
137
|
+
* UniversalCore on Push Chain, so fanning out per chain would be N round trips
|
|
138
|
+
* to the same endpoint for no reason.
|
|
139
|
+
*
|
|
140
|
+
* Returns confirmed deployments only. A predicted first-export address is the
|
|
141
|
+
* outbound builder's concern, not discovery's.
|
|
142
|
+
*/
|
|
143
|
+
export declare function listPC20Deployments(pushAddress: `0x${string}`, opts: PC20ResolverOptions & {
|
|
144
|
+
chains?: CHAIN[];
|
|
145
|
+
}): Promise<PC20DeploymentInfo[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Registered wrapper for a Push PC20 on one destination chain.
|
|
148
|
+
*
|
|
149
|
+
* `undefined` means not yet deployed — a legitimate state before a first
|
|
150
|
+
* export, not an error. Callers that need an address for a first export must go
|
|
151
|
+
* through the prediction path, which verifies against the live factory.
|
|
152
|
+
*/
|
|
153
|
+
export declare function getRegisteredWrapper(pushAddress: `0x${string}`, destinationChain: CHAIN, opts: PC20ResolverOptions): Promise<PC20DeploymentInfo | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Work out which chain an address belongs to, when the caller did not say.
|
|
156
|
+
*
|
|
157
|
+
* Used ONLY by the read-only `getPC20Address` utility. The transaction path
|
|
158
|
+
* never calls this — `funds.token` requires an explicit `chain`, and
|
|
159
|
+
* `gate.ts` rejects one that disagrees with where the funds actually are. A
|
|
160
|
+
* wrapper address copied from the wrong chain still fails on send; it merely
|
|
161
|
+
* resolves informationally on lookup.
|
|
162
|
+
*
|
|
163
|
+
* Order is cheapest-first:
|
|
164
|
+
* 1. narrow candidates by address format (local, free);
|
|
165
|
+
* 2. try Push-native, which short-circuits with no registry read at all;
|
|
166
|
+
* 3. probe every remaining namespace in one multicall.
|
|
167
|
+
*
|
|
168
|
+
* @throws {PC20AmbiguousAddressError} when several chains claim the address
|
|
169
|
+
* with different Push sources.
|
|
170
|
+
*/
|
|
171
|
+
export declare function discoverPC20Chain(address: string, opts: PC20ResolverOptions): Promise<{
|
|
172
|
+
chain: CHAIN;
|
|
173
|
+
pushAddress: `0x${string}`;
|
|
174
|
+
} | null>;
|
|
175
|
+
/**
|
|
176
|
+
* Resolve a `{ chain, address }` PC20 reference into everything the execution
|
|
177
|
+
* path needs, exactly once per transaction.
|
|
178
|
+
*
|
|
179
|
+
* `expectedChain` is where the funds actually are — the signer's chain for a
|
|
180
|
+
* direct external route, `params.from.chain` for a CEA-origin route, the Push
|
|
181
|
+
* chain for an export. Chain-ownership validation is the caller's job because
|
|
182
|
+
* only the caller knows which of those applies; this function assumes it has
|
|
183
|
+
* already passed.
|
|
184
|
+
*/
|
|
185
|
+
export declare function resolvePC20Token(chain: CHAIN, address: string, opts: PC20ResolverOptions & {
|
|
186
|
+
tierB?: boolean;
|
|
187
|
+
}): Promise<ResolvedPC20>;
|