@pushchain/core 6.0.24 → 6.0.25
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 +84 -0
- package/package.json +1 -1
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +4 -1
- package/src/lib/constants/abi/prc20.evm.d.ts +32 -0
- package/src/lib/constants/abi/prc20.evm.js +20 -0
- package/src/lib/constants/abi/uea-factory.d.ts +31 -0
- package/src/lib/constants/abi/uea-factory.js +19 -0
- package/src/lib/constants/abi/universalCallback.evm.d.ts +561 -0
- package/src/lib/constants/abi/universalCallback.evm.js +247 -0
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/abi/universalReadRegistry.evm.d.ts +247 -0
- package/src/lib/constants/abi/universalReadRegistry.evm.js +38 -0
- package/src/lib/constants/chain.d.ts +12 -0
- package/src/lib/constants/chain.js +23 -1
- package/src/lib/constants/enums.d.ts +7 -0
- package/src/lib/constants/enums.js +11 -0
- package/src/lib/constants/index.d.ts +52 -0
- package/src/lib/constants/index.js +37 -8
- package/src/lib/constants/read-state.d.ts +53 -0
- package/src/lib/constants/read-state.js +59 -0
- package/src/lib/generated/ucallback/v1/index.d.ts +2 -0
- package/src/lib/generated/ucallback/v1/index.js +6 -0
- package/src/lib/generated/ucallback/v1/query.d.ts +47 -0
- package/src/lib/generated/ucallback/v1/query.js +131 -0
- package/src/lib/generated/ucallback/v1/types.d.ts +99 -0
- package/src/lib/generated/ucallback/v1/types.js +366 -0
- package/src/lib/generated/uexecutor/v1/query.d.ts +29 -0
- package/src/lib/generated/uexecutor/v1/query.js +98 -1
- package/src/lib/index.d.ts +9 -0
- package/src/lib/index.js +37 -1
- package/src/lib/orchestrator/internals/cascade.js +5 -2
- package/src/lib/orchestrator/internals/errors.d.ts +6 -0
- package/src/lib/orchestrator/internals/errors.js +13 -1
- package/src/lib/orchestrator/internals/index.d.ts +1 -0
- package/src/lib/orchestrator/internals/index.js +6 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +81 -61
- package/src/lib/orchestrator/internals/read-state.d.ts +24 -0
- package/src/lib/orchestrator/internals/read-state.js +47 -0
- package/src/lib/orchestrator/internals/route-handlers.js +6 -1
- package/src/lib/orchestrator/internals/svm-helpers.js +24 -0
- package/src/lib/orchestrator/orchestrator.d.ts +26 -0
- package/src/lib/orchestrator/orchestrator.js +22 -0
- package/src/lib/orchestrator/orchestrator.types.d.ts +2 -0
- package/src/lib/orchestrator/route-detector.js +4 -0
- package/src/lib/progress-hook/progress-hook.js +271 -0
- package/src/lib/progress-hook/progress-hook.types.d.ts +32 -0
- package/src/lib/progress-hook/progress-hook.types.js +34 -0
- package/src/lib/push-chain/push-chain.d.ts +70 -0
- package/src/lib/push-chain/push-chain.js +27 -0
- package/src/lib/push-client/push-client.d.ts +35 -2
- package/src/lib/push-client/push-client.js +117 -4
- package/src/lib/read-state/budget.d.ts +16 -0
- package/src/lib/read-state/budget.js +32 -0
- package/src/lib/read-state/destination.d.ts +12 -0
- package/src/lib/read-state/destination.js +51 -0
- package/src/lib/read-state/envelopes/evm.d.ts +24 -0
- package/src/lib/read-state/envelopes/evm.js +148 -0
- package/src/lib/read-state/envelopes/index.d.ts +12 -0
- package/src/lib/read-state/envelopes/index.js +45 -0
- package/src/lib/read-state/envelopes/svm.d.ts +32 -0
- package/src/lib/read-state/envelopes/svm.js +107 -0
- package/src/lib/read-state/envelopes/web2.d.ts +29 -0
- package/src/lib/read-state/envelopes/web2.js +149 -0
- package/src/lib/read-state/errors.d.ts +70 -0
- package/src/lib/read-state/errors.js +116 -0
- package/src/lib/read-state/index.d.ts +13 -0
- package/src/lib/read-state/index.js +38 -0
- package/src/lib/read-state/preflight.d.ts +21 -0
- package/src/lib/read-state/preflight.js +70 -0
- package/src/lib/read-state/read-events.d.ts +27 -0
- package/src/lib/read-state/read-events.js +135 -0
- package/src/lib/read-state/read-executor.d.ts +18 -0
- package/src/lib/read-state/read-executor.js +212 -0
- package/src/lib/read-state/read-params.d.ts +205 -0
- package/src/lib/read-state/read-params.js +120 -0
- package/src/lib/read-state/read-state.types.d.ts +417 -0
- package/src/lib/read-state/read-state.types.js +50 -0
- package/src/lib/read-state/read-tracker.d.ts +50 -0
- package/src/lib/read-state/read-tracker.js +415 -0
- package/src/lib/read-state/registry.d.ts +21 -0
- package/src/lib/read-state/registry.js +54 -0
- package/src/lib/read-state/result-decoder.d.ts +16 -0
- package/src/lib/read-state/result-decoder.js +73 -0
- package/src/lib/read-state/spec-builder.d.ts +47 -0
- package/src/lib/read-state/spec-builder.js +251 -0
- package/src/lib/read-state/validate.d.ts +22 -0
- package/src/lib/read-state/validate.js +80 -0
- package/src/lib/universal-tx-detector/child-inbounds.d.ts +3 -1
- package/src/lib/universal-tx-detector/child-inbounds.js +4 -5
- package/src/lib/universal-tx-detector/detector-svm.js +29 -20
- package/src/lib/universal-tx-detector/svm-events.d.ts +17 -5
- package/src/lib/universal-tx-detector/svm-events.js +81 -6
- package/src/lib/vm-client/evm-client.js +27 -10
|
@@ -1,12 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryGetUniversalTxResponse = exports.QueryGetUniversalTxRequest = exports.protobufPackage = void 0;
|
|
3
|
+
exports.QueryGetUniversalTxResponse = exports.QueryGetUniversalTxRequest = exports.QueryParamsResponse = exports.QueryParamsRequest = exports.UexecutorParams = exports.protobufPackage = void 0;
|
|
4
4
|
// Minimal generated types for uexecutor.v1 Query service
|
|
5
5
|
// Hand-authored to avoid requiring protoc at build time in this repo
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
const wire_1 = require("@bufbuild/protobuf/wire");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
9
|
exports.protobufPackage = 'uexecutor.v1';
|
|
10
|
+
function createBaseUexecutorParams() {
|
|
11
|
+
return { someValue: false, maxGaslessTxGas: BigInt(0) };
|
|
12
|
+
}
|
|
13
|
+
exports.UexecutorParams = {
|
|
14
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
15
|
+
if (message.someValue === true)
|
|
16
|
+
writer.uint32(16).bool(message.someValue);
|
|
17
|
+
if (message.maxGaslessTxGas !== BigInt(0)) {
|
|
18
|
+
writer.uint32(24).uint64(message.maxGaslessTxGas);
|
|
19
|
+
}
|
|
20
|
+
return writer;
|
|
21
|
+
},
|
|
22
|
+
decode(input, length) {
|
|
23
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
24
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
25
|
+
const message = createBaseUexecutorParams();
|
|
26
|
+
while (reader.pos < end) {
|
|
27
|
+
const tag = reader.uint32();
|
|
28
|
+
switch (tag >>> 3) {
|
|
29
|
+
case 2:
|
|
30
|
+
message.someValue = reader.bool();
|
|
31
|
+
break;
|
|
32
|
+
case 3:
|
|
33
|
+
message.maxGaslessTxGas = BigInt(reader.uint64().toString());
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
if ((tag & 7) === 4 || tag === 0)
|
|
37
|
+
return message;
|
|
38
|
+
reader.skip(tag & 7);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return message;
|
|
43
|
+
},
|
|
44
|
+
fromPartial(object) {
|
|
45
|
+
return {
|
|
46
|
+
someValue: object.someValue ?? false,
|
|
47
|
+
maxGaslessTxGas: object.maxGaslessTxGas ?? BigInt(0),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
exports.QueryParamsRequest = {
|
|
52
|
+
encode(_message, writer = new wire_1.BinaryWriter()) {
|
|
53
|
+
return writer;
|
|
54
|
+
},
|
|
55
|
+
decode(input, length) {
|
|
56
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
57
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
58
|
+
while (reader.pos < end) {
|
|
59
|
+
const tag = reader.uint32();
|
|
60
|
+
if ((tag & 7) === 4 || tag === 0)
|
|
61
|
+
return {};
|
|
62
|
+
reader.skip(tag & 7);
|
|
63
|
+
}
|
|
64
|
+
return {};
|
|
65
|
+
},
|
|
66
|
+
fromPartial(_object) {
|
|
67
|
+
return {};
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
function createBaseQueryParamsResponse() {
|
|
71
|
+
return { params: undefined };
|
|
72
|
+
}
|
|
73
|
+
exports.QueryParamsResponse = {
|
|
74
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
75
|
+
if (message.params !== undefined) {
|
|
76
|
+
exports.UexecutorParams.encode(message.params, writer.uint32(10).fork()).join();
|
|
77
|
+
}
|
|
78
|
+
return writer;
|
|
79
|
+
},
|
|
80
|
+
decode(input, length) {
|
|
81
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
82
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
83
|
+
const message = createBaseQueryParamsResponse();
|
|
84
|
+
while (reader.pos < end) {
|
|
85
|
+
const tag = reader.uint32();
|
|
86
|
+
switch (tag >>> 3) {
|
|
87
|
+
case 1:
|
|
88
|
+
message.params = exports.UexecutorParams.decode(reader, reader.uint32());
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
if ((tag & 7) === 4 || tag === 0)
|
|
92
|
+
return message;
|
|
93
|
+
reader.skip(tag & 7);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return message;
|
|
98
|
+
},
|
|
99
|
+
fromPartial(object) {
|
|
100
|
+
return {
|
|
101
|
+
params: object.params === undefined
|
|
102
|
+
? undefined
|
|
103
|
+
: exports.UexecutorParams.fromPartial(object.params),
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
};
|
|
10
107
|
function createBaseQueryGetUniversalTxRequest() {
|
|
11
108
|
return { id: '' };
|
|
12
109
|
}
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PushChain } from './push-chain/push-chain';
|
|
2
|
+
export { CHAIN } from './constants/enums';
|
|
2
3
|
export type { ConversionQuote } from './constants/tokens';
|
|
3
4
|
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, SignAuthorizationParams, SignedAuthorization, DerivedExecutorAccount, ResolvedAccount, ResolvedControllerAccounts, AccountType, AccountRole, } from './universal/universal.types';
|
|
4
5
|
export type { PC20TokenReference, FundsToken, PC20RegistryEntry, PC20AddressResult, } from './orchestrator/orchestrator.types';
|
|
@@ -11,4 +12,12 @@ export { DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS, MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT, quo
|
|
|
11
12
|
export type { MaxPCForGasCapInput, MaxPCForGasCapFromNativeValueInput, MaxPCForGasCapQuote, } from './orchestrator/max-pc-for-gas';
|
|
12
13
|
export { getCEAAddress, getPushAccountForCEA, isCEA, chainSupportsCEA, chainSupportsOutbound, getCEAFactoryAddress, getAllCEAAddresses, } from './orchestrator/cea-utils';
|
|
13
14
|
export { encodeSvmExecutePayload, isSvmChain, isValidSolanaHexAddress, buildMigrationPayload, buildErc20WithdrawalMulticall, } from './orchestrator/payload-builders';
|
|
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';
|
|
17
|
+
export { UNIVERSAL_READ_STATUS, READ_STATUS, READ_ERROR_CODE, CONTRACT_REQUEST_STATUS, TERMINAL_READ_STATUSES, } from './read-state/read-state.types';
|
|
18
|
+
export { ReadStateError, InvalidReadQueryError, InvalidReadSpecError, ReadHeightUnavailableError, UnsupportedReadDestinationError, ReadDecodeError, ReadTimeoutError, ReadNotFoundError, ReadRegistryUnavailableError, } from './read-state/errors';
|
|
19
|
+
export type { ReadSpecViolation } from './read-state/errors';
|
|
20
|
+
export { resolveDestination, encodeReadQuery, decodeReadResult, parseReadRequestsFromReceipt, parseFulfilOutcome, buildReadSpecFromPreflight, validateReadSpec, toCallData, sizeCallbackBudget, inferResultShape, toRequestIdHex, toReadQuery, } from './read-state';
|
|
21
|
+
export { UNIVERSAL_CALLBACK_EVM } from './constants/abi/universalCallback.evm';
|
|
22
|
+
export { UNIVERSAL_READ_REGISTRY_EVM } from './constants/abi/universalReadRegistry.evm';
|
|
14
23
|
export { PushChain };
|
package/src/lib/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ReadNotFoundError = exports.ReadTimeoutError = exports.ReadDecodeError = exports.UnsupportedReadDestinationError = exports.ReadHeightUnavailableError = exports.InvalidReadSpecError = exports.InvalidReadQueryError = exports.ReadStateError = exports.TERMINAL_READ_STATUSES = exports.CONTRACT_REQUEST_STATUS = 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 = void 0;
|
|
4
5
|
const push_chain_1 = require("./push-chain/push-chain");
|
|
5
6
|
Object.defineProperty(exports, "PushChain", { enumerable: true, get: function () { return push_chain_1.PushChain; } });
|
|
7
|
+
var enums_1 = require("./constants/enums");
|
|
8
|
+
Object.defineProperty(exports, "CHAIN", { enumerable: true, get: function () { return enums_1.CHAIN; } });
|
|
6
9
|
var orchestrator_types_1 = require("./orchestrator/orchestrator.types");
|
|
7
10
|
Object.defineProperty(exports, "isPC20Reference", { enumerable: true, get: function () { return orchestrator_types_1.isPC20Reference; } });
|
|
8
11
|
var errors_1 = require("./orchestrator/internals/pc20/errors");
|
|
@@ -51,4 +54,37 @@ Object.defineProperty(exports, "isSvmChain", { enumerable: true, get: function (
|
|
|
51
54
|
Object.defineProperty(exports, "isValidSolanaHexAddress", { enumerable: true, get: function () { return payload_builders_1.isValidSolanaHexAddress; } });
|
|
52
55
|
Object.defineProperty(exports, "buildMigrationPayload", { enumerable: true, get: function () { return payload_builders_1.buildMigrationPayload; } });
|
|
53
56
|
Object.defineProperty(exports, "buildErc20WithdrawalMulticall", { enumerable: true, get: function () { return payload_builders_1.buildErc20WithdrawalMulticall; } });
|
|
57
|
+
var read_state_types_1 = require("./read-state/read-state.types");
|
|
58
|
+
Object.defineProperty(exports, "UNIVERSAL_READ_STATUS", { enumerable: true, get: function () { return read_state_types_1.UNIVERSAL_READ_STATUS; } });
|
|
59
|
+
Object.defineProperty(exports, "READ_STATUS", { enumerable: true, get: function () { return read_state_types_1.READ_STATUS; } });
|
|
60
|
+
Object.defineProperty(exports, "READ_ERROR_CODE", { enumerable: true, get: function () { return read_state_types_1.READ_ERROR_CODE; } });
|
|
61
|
+
Object.defineProperty(exports, "CONTRACT_REQUEST_STATUS", { enumerable: true, get: function () { return read_state_types_1.CONTRACT_REQUEST_STATUS; } });
|
|
62
|
+
Object.defineProperty(exports, "TERMINAL_READ_STATUSES", { enumerable: true, get: function () { return read_state_types_1.TERMINAL_READ_STATUSES; } });
|
|
63
|
+
var errors_2 = require("./read-state/errors");
|
|
64
|
+
Object.defineProperty(exports, "ReadStateError", { enumerable: true, get: function () { return errors_2.ReadStateError; } });
|
|
65
|
+
Object.defineProperty(exports, "InvalidReadQueryError", { enumerable: true, get: function () { return errors_2.InvalidReadQueryError; } });
|
|
66
|
+
Object.defineProperty(exports, "InvalidReadSpecError", { enumerable: true, get: function () { return errors_2.InvalidReadSpecError; } });
|
|
67
|
+
Object.defineProperty(exports, "ReadHeightUnavailableError", { enumerable: true, get: function () { return errors_2.ReadHeightUnavailableError; } });
|
|
68
|
+
Object.defineProperty(exports, "UnsupportedReadDestinationError", { enumerable: true, get: function () { return errors_2.UnsupportedReadDestinationError; } });
|
|
69
|
+
Object.defineProperty(exports, "ReadDecodeError", { enumerable: true, get: function () { return errors_2.ReadDecodeError; } });
|
|
70
|
+
Object.defineProperty(exports, "ReadTimeoutError", { enumerable: true, get: function () { return errors_2.ReadTimeoutError; } });
|
|
71
|
+
Object.defineProperty(exports, "ReadNotFoundError", { enumerable: true, get: function () { return errors_2.ReadNotFoundError; } });
|
|
72
|
+
Object.defineProperty(exports, "ReadRegistryUnavailableError", { enumerable: true, get: function () { return errors_2.ReadRegistryUnavailableError; } });
|
|
73
|
+
var read_state_1 = require("./read-state");
|
|
74
|
+
Object.defineProperty(exports, "resolveDestination", { enumerable: true, get: function () { return read_state_1.resolveDestination; } });
|
|
75
|
+
Object.defineProperty(exports, "encodeReadQuery", { enumerable: true, get: function () { return read_state_1.encodeReadQuery; } });
|
|
76
|
+
Object.defineProperty(exports, "decodeReadResult", { enumerable: true, get: function () { return read_state_1.decodeReadResult; } });
|
|
77
|
+
Object.defineProperty(exports, "parseReadRequestsFromReceipt", { enumerable: true, get: function () { return read_state_1.parseReadRequestsFromReceipt; } });
|
|
78
|
+
Object.defineProperty(exports, "parseFulfilOutcome", { enumerable: true, get: function () { return read_state_1.parseFulfilOutcome; } });
|
|
79
|
+
Object.defineProperty(exports, "buildReadSpecFromPreflight", { enumerable: true, get: function () { return read_state_1.buildReadSpecFromPreflight; } });
|
|
80
|
+
Object.defineProperty(exports, "validateReadSpec", { enumerable: true, get: function () { return read_state_1.validateReadSpec; } });
|
|
81
|
+
Object.defineProperty(exports, "toCallData", { enumerable: true, get: function () { return read_state_1.toCallData; } });
|
|
82
|
+
Object.defineProperty(exports, "sizeCallbackBudget", { enumerable: true, get: function () { return read_state_1.sizeCallbackBudget; } });
|
|
83
|
+
Object.defineProperty(exports, "inferResultShape", { enumerable: true, get: function () { return read_state_1.inferResultShape; } });
|
|
84
|
+
Object.defineProperty(exports, "toRequestIdHex", { enumerable: true, get: function () { return read_state_1.toRequestIdHex; } });
|
|
85
|
+
Object.defineProperty(exports, "toReadQuery", { enumerable: true, get: function () { return read_state_1.toReadQuery; } });
|
|
86
|
+
var universalCallback_evm_1 = require("./constants/abi/universalCallback.evm");
|
|
87
|
+
Object.defineProperty(exports, "UNIVERSAL_CALLBACK_EVM", { enumerable: true, get: function () { return universalCallback_evm_1.UNIVERSAL_CALLBACK_EVM; } });
|
|
88
|
+
var universalReadRegistry_evm_1 = require("./constants/abi/universalReadRegistry.evm");
|
|
89
|
+
Object.defineProperty(exports, "UNIVERSAL_READ_REGISTRY_EVM", { enumerable: true, get: function () { return universalReadRegistry_evm_1.UNIVERSAL_READ_REGISTRY_EVM; } });
|
|
54
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -219,8 +219,11 @@ async function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
|
219
219
|
const svmFundsToken = burnAmount > BigInt(0)
|
|
220
220
|
? params.funds?.token
|
|
221
221
|
: undefined;
|
|
222
|
-
const
|
|
223
|
-
? svmFundsToken.
|
|
222
|
+
const destinationFundsToken = svmFundsToken
|
|
223
|
+
? (0, route_handlers_1.resolveR2DestinationFundsToken)(svmFundsToken, targetChain, ctx.pushNetwork)
|
|
224
|
+
: undefined;
|
|
225
|
+
const splMintBase58 = destinationFundsToken?.mechanism === 'approve'
|
|
226
|
+
? destinationFundsToken.address
|
|
224
227
|
: undefined;
|
|
225
228
|
let effectiveGasLimit = gasLimit;
|
|
226
229
|
if (prc20Token !== selectors_1.ZERO_ADDRESS) {
|
|
@@ -44,6 +44,12 @@ export declare class PushChainExecutionError extends Error {
|
|
|
44
44
|
decodedError?: DecodedErrorPayload;
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
/** Recovery metadata for a non-atomic Push batch. A pending hash is broadcast but unconfirmed. */
|
|
48
|
+
export declare class PushChainBatchExecutionError extends PushChainExecutionError {
|
|
49
|
+
readonly transactionHashes: `0x${string}`[];
|
|
50
|
+
readonly pendingTransactionHash?: `0x${string}`;
|
|
51
|
+
constructor(message: string, transactionHashes: `0x${string}`[], pendingTransactionHash?: `0x${string}`);
|
|
52
|
+
}
|
|
47
53
|
export type PreflightPathTag = 'R2_EVM' | 'R2_SVM' | 'R3_EVM' | 'R3_SVM' | 'CASCADE';
|
|
48
54
|
export type PreflightShortfallReason = 'NATIVE' | 'PRC20';
|
|
49
55
|
export interface InsufficientUEABalanceErrorOpts {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* callers.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.InsufficientUEABalanceError = exports.PushChainExecutionError = void 0;
|
|
13
|
+
exports.InsufficientUEABalanceError = exports.PushChainBatchExecutionError = exports.PushChainExecutionError = void 0;
|
|
14
14
|
const formatters_1 = require("../../formatters");
|
|
15
15
|
/**
|
|
16
16
|
* Typed error for Route 1 Push Chain tx failures. Thrown by
|
|
@@ -39,6 +39,18 @@ class PushChainExecutionError extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
exports.PushChainExecutionError = PushChainExecutionError;
|
|
42
|
+
/** Recovery metadata for a non-atomic Push batch. A pending hash is broadcast but unconfirmed. */
|
|
43
|
+
class PushChainBatchExecutionError extends PushChainExecutionError {
|
|
44
|
+
transactionHashes;
|
|
45
|
+
pendingTransactionHash;
|
|
46
|
+
constructor(message, transactionHashes, pendingTransactionHash) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = 'PushChainBatchExecutionError';
|
|
49
|
+
this.transactionHashes = [...transactionHashes];
|
|
50
|
+
this.pendingTransactionHash = pendingTransactionHash;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PushChainBatchExecutionError = PushChainBatchExecutionError;
|
|
42
54
|
/**
|
|
43
55
|
* Thrown by `runPreflight` when the UEA cannot cover the required outbound
|
|
44
56
|
* cost. No cosmos tx is submitted on this path — the existing silent-clamp
|
|
@@ -24,3 +24,4 @@ export { rescueFunds } from './rescue';
|
|
|
24
24
|
export { executeFundsOnly } from './execute-funds-only';
|
|
25
25
|
export { executeFundsWithPayload } from './execute-funds-payload';
|
|
26
26
|
export { executeStandardPayload } from './execute-standard';
|
|
27
|
+
export { prepareRead, simulateRead, trackRead, type TrackReadOptions } from './read-state';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.quoteExactOutput = exports.calculateGasAmountFromAmountOutMinETH = exports.calculateNativeAmountForDeposit = exports.queryRescueGasFee = exports.queryOutboundGasFee = exports.ensureErc20Allowance = exports.detectRouteFromUniversalTxData = exports.reconstructProgressEvents = exports.transformToUniversalTxReceipt = exports.waitForInboundPushTx = exports.findChildUtxIdFromExternalTx = exports.INBOUND_MAX_TIMEOUT_MS = exports.INBOUND_INITIAL_WAIT_MS = exports.OUTBOUND_MAX_TIMEOUT_MS = exports.OUTBOUND_POLL_INTERVAL_MS = exports.OUTBOUND_INITIAL_WAIT_MS = exports.waitForAllOutboundTxsV2 = exports.waitForOutboundTx = exports.extractAllUniversalSubTxIds = exports.extractUniversalSubTxIdFromTx = exports.computeUniversalTxId = exports.getSvmGatewayLogIndexFromTx = exports.getSvmProtocolFee = exports.buildSvmUniversalTxRequestFromReq = exports.buildSvmUniversalTxRequest = exports.waitForLockerFeeConfirmation = exports.waitForSvmConfirmationsWithCountdown = exports.waitForEvmConfirmationsWithCountdown = exports.encodeUniversalPayloadSvm = exports.encodeUniversalPayload = exports.signMigrationPayload = exports.signUniversalPayload = exports.computeMigrationHash = exports.computeExecutionHash = exports.buildGatewayPayloadAndGas = exports.buildMulticallPayloadData = exports.buildUniversalTxRequest = exports.SUPPORTED_GATEWAY_CHAINS = exports.fetchOriginChainTransactionForProgress = exports.toExecuteParams = exports.bigintReplacer = exports.validateMainnetConnection = exports.getUniversalGatewayPCAddress = exports.getNativePRC20ForChain = exports.chainFromNamespace = exports.getChainNamespace = exports.getPushChainForNetwork = exports.isPushChain = exports.fireProgressHook = exports.printLog = void 0;
|
|
4
|
-
exports.executeStandardPayload = exports.executeFundsWithPayload = exports.executeFundsOnly = exports.rescueFunds = exports.sendSVMTxWithFunds = exports.createCascadedBuilder = exports.composeCascade = exports.getSegmentType = exports.classifyIntoSegments = exports.buildHopDescriptor = exports.prepareTransaction = exports.buildPayloadForRoute = exports.executeCeaToCea = exports.executeCeaToPushSvm = exports.executeCeaToPush = exports.executeUoaToCeaSvm = exports.executeUoaToCea = exports.executeMultiChain = exports.extractPcTxAndTransform = exports.sendUniversalTx = exports.sendPushTx = exports.transformToUniversalTxResponse = exports.trackTransaction = exports.queryUniversalTxStatusFromGatewayTx = exports.getOriginGatewayContext = exports.lockFee = exports.sendGatewayTokenTxWithFallback = exports.sendGatewayTxWithFallback = exports.toGatewayTokenRequestV1 = exports.toGatewayRequestV1 = exports.migrateCEA = exports.fetchLatestUEAVersion = exports.upgradeAccount = exports.getAccountStatus = exports.fetchUEAVersion = exports.getUeaStatusAndNonce = exports.getUeaNonceForExecution = exports.getUEANonce = exports.computeUEA = exports.computeUEAOffchain = void 0;
|
|
4
|
+
exports.trackRead = exports.simulateRead = exports.prepareRead = exports.executeStandardPayload = exports.executeFundsWithPayload = exports.executeFundsOnly = exports.rescueFunds = exports.sendSVMTxWithFunds = exports.createCascadedBuilder = exports.composeCascade = exports.getSegmentType = exports.classifyIntoSegments = exports.buildHopDescriptor = exports.prepareTransaction = exports.buildPayloadForRoute = exports.executeCeaToCea = exports.executeCeaToPushSvm = exports.executeCeaToPush = exports.executeUoaToCeaSvm = exports.executeUoaToCea = exports.executeMultiChain = exports.extractPcTxAndTransform = exports.sendUniversalTx = exports.sendPushTx = exports.transformToUniversalTxResponse = exports.trackTransaction = exports.queryUniversalTxStatusFromGatewayTx = exports.getOriginGatewayContext = exports.lockFee = exports.sendGatewayTokenTxWithFallback = exports.sendGatewayTxWithFallback = exports.toGatewayTokenRequestV1 = exports.toGatewayRequestV1 = exports.migrateCEA = exports.fetchLatestUEAVersion = exports.upgradeAccount = exports.getAccountStatus = exports.fetchUEAVersion = exports.getUeaStatusAndNonce = exports.getUeaNonceForExecution = exports.getUEANonce = exports.computeUEA = exports.computeUEAOffchain = void 0;
|
|
5
5
|
var context_1 = require("./context");
|
|
6
6
|
Object.defineProperty(exports, "printLog", { enumerable: true, get: function () { return context_1.printLog; } });
|
|
7
7
|
Object.defineProperty(exports, "fireProgressHook", { enumerable: true, get: function () { return context_1.fireProgressHook; } });
|
|
@@ -135,4 +135,9 @@ var execute_funds_payload_1 = require("./execute-funds-payload");
|
|
|
135
135
|
Object.defineProperty(exports, "executeFundsWithPayload", { enumerable: true, get: function () { return execute_funds_payload_1.executeFundsWithPayload; } });
|
|
136
136
|
var execute_standard_1 = require("./execute-standard");
|
|
137
137
|
Object.defineProperty(exports, "executeStandardPayload", { enumerable: true, get: function () { return execute_standard_1.executeStandardPayload; } });
|
|
138
|
+
// === Read State (cross-chain reads) ===
|
|
139
|
+
var read_state_1 = require("./read-state");
|
|
140
|
+
Object.defineProperty(exports, "prepareRead", { enumerable: true, get: function () { return read_state_1.prepareRead; } });
|
|
141
|
+
Object.defineProperty(exports, "simulateRead", { enumerable: true, get: function () { return read_state_1.simulateRead; } });
|
|
142
|
+
Object.defineProperty(exports, "trackRead", { enumerable: true, get: function () { return read_state_1.trackRead; } });
|
|
138
143
|
//# sourceMappingURL=index.js.map
|
|
@@ -32,10 +32,13 @@ async function getIndexedPushTransaction(ctx, txHash, label) {
|
|
|
32
32
|
while (true) {
|
|
33
33
|
try {
|
|
34
34
|
if (!receiptWaited) {
|
|
35
|
-
await ctx.pushClient.publicClient.waitForTransactionReceipt({
|
|
35
|
+
const receipt = await ctx.pushClient.publicClient.waitForTransactionReceipt({
|
|
36
36
|
hash: txHash,
|
|
37
37
|
});
|
|
38
38
|
receiptWaited = true;
|
|
39
|
+
if (receipt.status === 'reverted') {
|
|
40
|
+
throw new errors_1.PushChainExecutionError(`${label} — Push Chain transaction ${txHash} reverted`);
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
return await ctx.pushClient.getTransaction(txHash);
|
|
41
44
|
}
|
|
@@ -116,75 +119,92 @@ async function sendPushTx(ctx, execute, eventBuffer, transformFn) {
|
|
|
116
119
|
blockTag: 'pending',
|
|
117
120
|
});
|
|
118
121
|
let lastTxHash = '0x';
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
nonce
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(0, context_1.printLog)(ctx, `sendPushTx — nonce mismatch on operation ${i + 1}/${calls.length} (retry ${retry + 1}/${MAX_NONCE_RETRIES}), re-fetching nonce`);
|
|
138
|
-
nonce = await ctx.pushClient.publicClient.getTransactionCount({
|
|
139
|
-
address: ctx.universalSigner.account.address,
|
|
140
|
-
blockTag: 'pending',
|
|
122
|
+
// Hashes of the calls that were mined successfully, in order. On a later
|
|
123
|
+
// failure they ride on the thrown error (`err.transactionHashes`) so the caller
|
|
124
|
+
// can resume whatever those calls committed — the batch is not atomic.
|
|
125
|
+
const transactionHashes = [];
|
|
126
|
+
let pendingTransactionHash;
|
|
127
|
+
try {
|
|
128
|
+
for (let i = 0; i < calls.length; i++) {
|
|
129
|
+
const call = calls[i];
|
|
130
|
+
let txSent = false;
|
|
131
|
+
for (let retry = 0; retry < MAX_NONCE_RETRIES && !txSent; retry++) {
|
|
132
|
+
try {
|
|
133
|
+
(0, context_1.printLog)(ctx, `sendPushTx — executing multicall operation ${i + 1}/${calls.length} to: ${call.to} (nonce: ${nonce})`);
|
|
134
|
+
lastTxHash = await ctx.pushClient.sendTransaction({
|
|
135
|
+
to: call.to,
|
|
136
|
+
data: (call.data || '0x'),
|
|
137
|
+
value: call.value,
|
|
138
|
+
signer: ctx.universalSigner,
|
|
139
|
+
nonce,
|
|
141
140
|
});
|
|
141
|
+
txSent = true;
|
|
142
|
+
pendingTransactionHash = lastTxHash;
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
catch (err) {
|
|
145
|
+
const msg = err?.message || err?.details || '';
|
|
146
|
+
if (msg.includes('invalid nonce') || msg.includes('invalid sequence')) {
|
|
147
|
+
(0, context_1.printLog)(ctx, `sendPushTx — nonce mismatch on operation ${i + 1}/${calls.length} (retry ${retry + 1}/${MAX_NONCE_RETRIES}), re-fetching nonce`);
|
|
148
|
+
nonce = await ctx.pushClient.publicClient.getTransactionCount({
|
|
149
|
+
address: ctx.universalSigner.account.address,
|
|
150
|
+
blockTag: 'pending',
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
throw err;
|
|
155
|
+
}
|
|
145
156
|
}
|
|
146
157
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
throw new Error(`sendPushTx — multicall operation ${i + 1}/${calls.length} failed after ${MAX_NONCE_RETRIES} nonce retries`);
|
|
150
|
-
}
|
|
151
|
-
const receipt = await ctx.pushClient.publicClient.waitForTransactionReceipt({
|
|
152
|
-
hash: lastTxHash,
|
|
153
|
-
});
|
|
154
|
-
if (receipt.status === 'reverted') {
|
|
155
|
-
// Simulate the failed call to extract the revert reason
|
|
156
|
-
let revertReason = 'unknown';
|
|
157
|
-
try {
|
|
158
|
-
await ctx.pushClient.publicClient.call({
|
|
159
|
-
to: call.to,
|
|
160
|
-
data: (call.data || '0x'),
|
|
161
|
-
value: call.value,
|
|
162
|
-
account: ctx.universalSigner.account.address,
|
|
163
|
-
blockNumber: receipt.blockNumber,
|
|
164
|
-
});
|
|
158
|
+
if (!txSent) {
|
|
159
|
+
throw new Error(`sendPushTx — multicall operation ${i + 1}/${calls.length} failed after ${MAX_NONCE_RETRIES} nonce retries`);
|
|
165
160
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
161
|
+
const receipt = await ctx.pushClient.publicClient.waitForTransactionReceipt({
|
|
162
|
+
hash: lastTxHash,
|
|
163
|
+
});
|
|
164
|
+
if (receipt.status === 'reverted') {
|
|
165
|
+
pendingTransactionHash = undefined;
|
|
166
|
+
// Simulate the failed call to extract the revert reason
|
|
167
|
+
let revertReason = 'unknown';
|
|
168
|
+
try {
|
|
169
|
+
await ctx.pushClient.publicClient.call({
|
|
170
|
+
to: call.to,
|
|
171
|
+
data: (call.data || '0x'),
|
|
172
|
+
value: call.value,
|
|
173
|
+
account: ctx.universalSigner.account.address,
|
|
174
|
+
blockNumber: receipt.blockNumber,
|
|
175
|
+
});
|
|
174
176
|
}
|
|
177
|
+
catch (simErr) {
|
|
178
|
+
// viem decodes common revert reasons into shortMessage
|
|
179
|
+
revertReason =
|
|
180
|
+
simErr?.shortMessage || simErr?.cause?.reason || simErr?.cause?.message || simErr?.message || String(simErr);
|
|
181
|
+
// Also log the raw revert data if available
|
|
182
|
+
const revertData = simErr?.cause?.data || simErr?.data;
|
|
183
|
+
if (revertData) {
|
|
184
|
+
revertReason += ` [data: ${revertData}]`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
(0, context_1.printLog)(ctx, `sendPushTx — multicall operation ${i + 1}/${calls.length} reverted (to: ${call.to}, txHash: ${lastTxHash}, revertReason: ${revertReason})`);
|
|
188
|
+
throw new Error(`sendPushTx — multicall operation ${i + 1}/${calls.length} reverted (to: ${call.to}, txHash: ${lastTxHash}, revertReason: ${revertReason})`);
|
|
175
189
|
}
|
|
176
|
-
|
|
177
|
-
|
|
190
|
+
transactionHashes.push(lastTxHash);
|
|
191
|
+
pendingTransactionHash = undefined;
|
|
192
|
+
(0, context_1.printLog)(ctx, `sendPushTx — operation ${i + 1}/${calls.length} confirmed in block ${receipt.blockNumber}`);
|
|
193
|
+
nonce++;
|
|
178
194
|
}
|
|
179
|
-
|
|
180
|
-
|
|
195
|
+
const txResponse = await getIndexedPushTransaction(ctx, lastTxHash, 'sendPushTx');
|
|
196
|
+
// Sequential fallback: each call was a separate tx, so the batch is NOT
|
|
197
|
+
// atomic (an earlier call can be committed while a later one reverts).
|
|
198
|
+
const resp = await transformFn(txResponse, eventBuffer);
|
|
199
|
+
resp.atomic = false;
|
|
200
|
+
resp.transactionHashes = transactionHashes;
|
|
201
|
+
return resp;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
// Preserve recovery data across receipt waits, nonce refresh, indexing and
|
|
205
|
+
// response construction, not only errors raised by sendTransaction().
|
|
206
|
+
throw new errors_1.PushChainBatchExecutionError((0, formatters_1.normalizePublicErrorMessage)(error), transactionHashes, pendingTransactionHash);
|
|
181
207
|
}
|
|
182
|
-
const txResponse = await getIndexedPushTransaction(ctx, lastTxHash, 'sendPushTx');
|
|
183
|
-
// Sequential fallback: each call was a separate tx, so the batch is NOT
|
|
184
|
-
// atomic (an earlier call can be committed while a later one reverts).
|
|
185
|
-
const resp = await transformFn(txResponse, eventBuffer);
|
|
186
|
-
resp.atomic = false;
|
|
187
|
-
return resp;
|
|
188
208
|
}
|
|
189
209
|
const txHash = await ctx.pushClient.sendTransaction({
|
|
190
210
|
to: execute.to,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-state delegators. Thin: they bind an OrchestratorContext to the pure
|
|
3
|
+
* `read-state/` module and add nothing else.
|
|
4
|
+
*/
|
|
5
|
+
import type { Address, Hex } from 'viem';
|
|
6
|
+
import type { BuildReadSpecParams, PreparedRead, ReadLifecycleOptions, SimulateReadResult, UniversalReadResponse } from '../../read-state/read-state.types';
|
|
7
|
+
import type { ProgressEvent } from '../../progress-hook/progress-hook.types';
|
|
8
|
+
import { type OrchestratorContext } from './context';
|
|
9
|
+
export declare function prepareRead(ctx: OrchestratorContext, params: BuildReadSpecParams, progressHook?: (e: ProgressEvent) => void): Promise<PreparedRead>;
|
|
10
|
+
export declare function simulateRead(ctx: OrchestratorContext, prepared: PreparedRead, opts: {
|
|
11
|
+
appContract: Address;
|
|
12
|
+
callbackSelector: Hex;
|
|
13
|
+
staleAfterMs?: number;
|
|
14
|
+
}): Promise<SimulateReadResult>;
|
|
15
|
+
export type TrackReadOptions = ReadLifecycleOptions & {
|
|
16
|
+
/** Per-call hook, additive with the init-time one (deduped by reference). */
|
|
17
|
+
progressHook?: (e: ProgressEvent) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function trackRead(ctx: OrchestratorContext, ref: {
|
|
20
|
+
txHash: Hex;
|
|
21
|
+
}, opts?: TrackReadOptions): Promise<UniversalReadResponse[]>;
|
|
22
|
+
export declare function trackRead(ctx: OrchestratorContext, ref: {
|
|
23
|
+
requestId: Hex | bigint;
|
|
24
|
+
}, opts?: TrackReadOptions): Promise<UniversalReadResponse>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareRead = prepareRead;
|
|
4
|
+
exports.simulateRead = simulateRead;
|
|
5
|
+
exports.trackRead = trackRead;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const spec_builder_1 = require("../../read-state/spec-builder");
|
|
8
|
+
const read_tracker_1 = require("../../read-state/read-tracker");
|
|
9
|
+
const progress_hook_1 = tslib_1.__importDefault(require("../../progress-hook/progress-hook"));
|
|
10
|
+
const context_1 = require("./context");
|
|
11
|
+
const uea_manager_1 = require("./uea-manager");
|
|
12
|
+
function depsFrom(ctx) {
|
|
13
|
+
let defaultRefundTo;
|
|
14
|
+
try {
|
|
15
|
+
// The signer's Push-side account: its UEA for an external origin, itself on Push.
|
|
16
|
+
defaultRefundTo = (0, uea_manager_1.computeUEAOffchain)(ctx);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
defaultRefundTo = undefined; // read-only clients without a resolvable account: refundTo becomes required
|
|
20
|
+
}
|
|
21
|
+
return { pushClient: ctx.pushClient, pushNetwork: ctx.pushNetwork, defaultRefundTo };
|
|
22
|
+
}
|
|
23
|
+
function prepareRead(ctx, params, progressHook) {
|
|
24
|
+
return (0, spec_builder_1.prepareRead)({ ...depsFrom(ctx), emit: trackDepsFrom(ctx, progressHook).emit }, params);
|
|
25
|
+
}
|
|
26
|
+
function simulateRead(ctx, prepared, opts) {
|
|
27
|
+
return (0, spec_builder_1.simulateRead)(depsFrom(ctx), prepared, opts);
|
|
28
|
+
}
|
|
29
|
+
function trackDepsFrom(ctx, perCall) {
|
|
30
|
+
const extra = perCall && perCall !== ctx.progressHook ? perCall : undefined;
|
|
31
|
+
return {
|
|
32
|
+
pushClient: ctx.pushClient,
|
|
33
|
+
pushNetwork: ctx.pushNetwork,
|
|
34
|
+
// READ-TX ids are a separate band: fireProgressHook never suppresses them (context.ts R1 set).
|
|
35
|
+
emit: (hookId, ...args) => {
|
|
36
|
+
(0, context_1.fireProgressHook)(ctx, hookId, ...args);
|
|
37
|
+
if (extra)
|
|
38
|
+
extra(progress_hook_1.default[hookId](...args));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function trackRead(ctx, ref, opts = {}) {
|
|
43
|
+
const { progressHook, ...lifecycle } = opts;
|
|
44
|
+
const deps = trackDepsFrom(ctx, progressHook);
|
|
45
|
+
return 'txHash' in ref ? (0, read_tracker_1.trackRead)(deps, ref, lifecycle) : (0, read_tracker_1.trackRead)(deps, ref, lifecycle);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=read-state.js.map
|
|
@@ -861,7 +861,12 @@ async function executeUoaToCeaSvm(ctx, params, target, executeFn) {
|
|
|
861
861
|
const svmFundsToken = burnAmount > BigInt(0)
|
|
862
862
|
? params.funds?.token
|
|
863
863
|
: undefined;
|
|
864
|
-
const
|
|
864
|
+
const destinationFundsToken = svmFundsToken
|
|
865
|
+
? resolveR2DestinationFundsToken(svmFundsToken, targetChain, ctx.pushNetwork)
|
|
866
|
+
: undefined;
|
|
867
|
+
const splMintBase58 = destinationFundsToken?.mechanism === 'approve'
|
|
868
|
+
? destinationFundsToken.address
|
|
869
|
+
: undefined;
|
|
865
870
|
if (prc20Token !== selectors_1.ZERO_ADDRESS) {
|
|
866
871
|
(0, context_1.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_01, targetChain);
|
|
867
872
|
try {
|
|
@@ -11,6 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const web3_js_1 = require("@solana/web3.js");
|
|
12
12
|
const viem_1 = require("viem");
|
|
13
13
|
const universalGatewayV0_json_1 = tslib_1.__importDefault(require("../../constants/abi/universalGatewayV0.json"));
|
|
14
|
+
const svm_events_1 = require("../../universal-tx-detector/svm-events");
|
|
14
15
|
// ============================================================================
|
|
15
16
|
// SVM Request Builders
|
|
16
17
|
// ============================================================================
|
|
@@ -144,6 +145,29 @@ function isPC20EventBody(decoded) {
|
|
|
144
145
|
* position, so it survives a change in emission order.
|
|
145
146
|
*/
|
|
146
147
|
function getSvmGatewayLogIndexFromTx(txResp, preferPC20 = false) {
|
|
148
|
+
const cpiPayloads = (0, svm_events_1.getSvmEventCpiPayloads)(txResp, universalGatewayV0_json_1.default.address);
|
|
149
|
+
if (cpiPayloads.length > 0) {
|
|
150
|
+
let lastMatchIndex = -1;
|
|
151
|
+
let pc20MatchIndex = -1;
|
|
152
|
+
let matchCount = 0;
|
|
153
|
+
for (const { base64Data, eventIndex } of cpiPayloads) {
|
|
154
|
+
const decoded = new Uint8Array(Buffer.from(base64Data, 'base64'));
|
|
155
|
+
const discriminatorHex = (0, viem_1.bytesToHex)(decoded.slice(0, 8)).slice(2);
|
|
156
|
+
if (discriminatorHex !== SVM_GATEWAY_EVENT_DISCRIMINATOR)
|
|
157
|
+
continue;
|
|
158
|
+
matchCount++;
|
|
159
|
+
lastMatchIndex = eventIndex;
|
|
160
|
+
if (preferPC20 && pc20MatchIndex === -1 && isPC20EventBody(decoded)) {
|
|
161
|
+
pc20MatchIndex = eventIndex;
|
|
162
|
+
}
|
|
163
|
+
if (!preferPC20 && matchCount === 2)
|
|
164
|
+
return eventIndex;
|
|
165
|
+
}
|
|
166
|
+
if (preferPC20 && pc20MatchIndex !== -1)
|
|
167
|
+
return pc20MatchIndex;
|
|
168
|
+
if (lastMatchIndex !== -1)
|
|
169
|
+
return lastMatchIndex;
|
|
170
|
+
}
|
|
147
171
|
const logs = (txResp?.meta?.logMessages || []);
|
|
148
172
|
if (!Array.isArray(logs) || logs.length === 0)
|
|
149
173
|
return 0;
|
|
@@ -6,6 +6,10 @@ import { PushClient } from '../push-client/push-client';
|
|
|
6
6
|
import type { UniversalAccount, UniversalSigner } from '../universal/universal.types';
|
|
7
7
|
import { ExecuteParams, UniversalExecuteParams, PreparedUniversalTx, CascadedTxResponse, CascadeExecutionOptions, TransactionExecutionOptions, RescueFundsParams } from './orchestrator.types';
|
|
8
8
|
import { TransactionRoute } from './route-detector';
|
|
9
|
+
import { type TrackReadOptions } from './internals';
|
|
10
|
+
import type { BuildReadSpecParams, PreparedRead, SimulateReadResult, UniversalReadResponse } from '../read-state/read-state.types';
|
|
11
|
+
import type { Address, Hex } from 'viem';
|
|
12
|
+
type ProgressHook = (progress: ProgressEvent) => void;
|
|
9
13
|
export declare class Orchestrator {
|
|
10
14
|
private readonly universalSigner;
|
|
11
15
|
private pushNetwork;
|
|
@@ -56,6 +60,27 @@ export declare class Orchestrator {
|
|
|
56
60
|
* @returns Transaction response
|
|
57
61
|
*/
|
|
58
62
|
migrateCEA(chain: CHAIN): Promise<UniversalTxResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Build a validated cross-chain ReadSpec (preflight + envelope + fee/budget) for the
|
|
65
|
+
* caller to splice into its own contract call. Works in read-only mode.
|
|
66
|
+
*/
|
|
67
|
+
prepareRead(params: BuildReadSpecParams, progressHook?: ProgressHook): Promise<PreparedRead>;
|
|
68
|
+
revalidateRead(prepared: PreparedRead): Promise<void>;
|
|
69
|
+
/** Current native Push balance of the account that will fund read requests. */
|
|
70
|
+
getReadBalance(): Promise<bigint>;
|
|
71
|
+
/** eth_call requestExternalReadSelf as the app contract; decodes contract errors. */
|
|
72
|
+
simulateRead(prepared: PreparedRead, opts: {
|
|
73
|
+
appContract: Address;
|
|
74
|
+
callbackSelector: Hex;
|
|
75
|
+
staleAfterMs?: number;
|
|
76
|
+
}): Promise<SimulateReadResult>;
|
|
77
|
+
/** Resume a read by the Push tx that requested it (array) or by requestId (single). */
|
|
78
|
+
trackRead(ref: {
|
|
79
|
+
txHash: Hex;
|
|
80
|
+
}, opts?: TrackReadOptions): Promise<UniversalReadResponse[]>;
|
|
81
|
+
trackRead(ref: {
|
|
82
|
+
requestId: Hex | bigint;
|
|
83
|
+
}, opts?: TrackReadOptions): Promise<UniversalReadResponse>;
|
|
59
84
|
/**
|
|
60
85
|
* Rescue stuck funds on a source chain.
|
|
61
86
|
* When a CEA-to-Push inbound transaction fails, tokens get locked in the
|
|
@@ -149,3 +174,4 @@ export declare class Orchestrator {
|
|
|
149
174
|
to: MoveableToken | undefined;
|
|
150
175
|
}): Promise<ConversionQuote>;
|
|
151
176
|
}
|
|
177
|
+
export {};
|