@pushchain/core 6.0.20 → 6.0.22
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 +67 -0
- package/package.json +8 -2
- package/src/lib/cache/cache.js +2 -0
- package/src/lib/constants/abi/erc20.evm.d.ts +30 -0
- package/src/lib/constants/abi/erc20.evm.js +21 -0
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +7 -1
- package/src/lib/constants/abi/pc20.evm.d.ts +192 -0
- package/src/lib/constants/abi/pc20.evm.js +134 -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 +3 -0
- package/src/lib/index.js +21 -3
- package/src/lib/internal/buffer.js +1 -2
- package/src/lib/orchestrator/cea-utils.js +89 -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 +176 -0
- package/src/lib/orchestrator/internals/pc20/export.js +431 -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 +185 -0
- package/src/lib/orchestrator/internals/pc20/resolver.js +649 -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 -329
- 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 +1522 -1176
- 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.js +306 -294
- 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
|
@@ -72,14 +72,13 @@ exports.UniversalAccountId = {
|
|
|
72
72
|
return message;
|
|
73
73
|
},
|
|
74
74
|
create(base) {
|
|
75
|
-
return exports.UniversalAccountId.fromPartial(base
|
|
75
|
+
return exports.UniversalAccountId.fromPartial(base ?? {});
|
|
76
76
|
},
|
|
77
77
|
fromPartial(object) {
|
|
78
|
-
var _a, _b, _c;
|
|
79
78
|
const message = createBaseUniversalAccountId();
|
|
80
|
-
message.chainNamespace =
|
|
81
|
-
message.chainId =
|
|
82
|
-
message.owner =
|
|
79
|
+
message.chainNamespace = object.chainNamespace ?? "";
|
|
80
|
+
message.chainId = object.chainId ?? "";
|
|
81
|
+
message.owner = object.owner ?? "";
|
|
83
82
|
return message;
|
|
84
83
|
},
|
|
85
84
|
};
|
|
@@ -136,16 +135,15 @@ exports.MsgDeployUEA = {
|
|
|
136
135
|
return message;
|
|
137
136
|
},
|
|
138
137
|
create(base) {
|
|
139
|
-
return exports.MsgDeployUEA.fromPartial(base
|
|
138
|
+
return exports.MsgDeployUEA.fromPartial(base ?? {});
|
|
140
139
|
},
|
|
141
140
|
fromPartial(object) {
|
|
142
|
-
var _a, _b;
|
|
143
141
|
const message = createBaseMsgDeployUEA();
|
|
144
|
-
message.signer =
|
|
142
|
+
message.signer = object.signer ?? "";
|
|
145
143
|
message.universalAccountId = (object.universalAccountId !== undefined && object.universalAccountId !== null)
|
|
146
144
|
? exports.UniversalAccountId.fromPartial(object.universalAccountId)
|
|
147
145
|
: undefined;
|
|
148
|
-
message.txHash =
|
|
146
|
+
message.txHash = object.txHash ?? "";
|
|
149
147
|
return message;
|
|
150
148
|
},
|
|
151
149
|
};
|
|
@@ -202,16 +200,15 @@ exports.MsgMintPC = {
|
|
|
202
200
|
return message;
|
|
203
201
|
},
|
|
204
202
|
create(base) {
|
|
205
|
-
return exports.MsgMintPC.fromPartial(base
|
|
203
|
+
return exports.MsgMintPC.fromPartial(base ?? {});
|
|
206
204
|
},
|
|
207
205
|
fromPartial(object) {
|
|
208
|
-
var _a, _b;
|
|
209
206
|
const message = createBaseMsgMintPC();
|
|
210
|
-
message.signer =
|
|
207
|
+
message.signer = object.signer ?? "";
|
|
211
208
|
message.universalAccountId = (object.universalAccountId !== undefined && object.universalAccountId !== null)
|
|
212
209
|
? exports.UniversalAccountId.fromPartial(object.universalAccountId)
|
|
213
210
|
: undefined;
|
|
214
|
-
message.txHash =
|
|
211
|
+
message.txHash = object.txHash ?? "";
|
|
215
212
|
return message;
|
|
216
213
|
},
|
|
217
214
|
};
|
|
@@ -338,20 +335,19 @@ exports.UniversalPayload = {
|
|
|
338
335
|
return message;
|
|
339
336
|
},
|
|
340
337
|
create(base) {
|
|
341
|
-
return exports.UniversalPayload.fromPartial(base
|
|
338
|
+
return exports.UniversalPayload.fromPartial(base ?? {});
|
|
342
339
|
},
|
|
343
340
|
fromPartial(object) {
|
|
344
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
345
341
|
const message = createBaseUniversalPayload();
|
|
346
|
-
message.to =
|
|
347
|
-
message.value =
|
|
348
|
-
message.data =
|
|
349
|
-
message.gasLimit =
|
|
350
|
-
message.maxFeePerGas =
|
|
351
|
-
message.maxPriorityFeePerGas =
|
|
352
|
-
message.nonce =
|
|
353
|
-
message.deadline =
|
|
354
|
-
message.vType =
|
|
342
|
+
message.to = object.to ?? "";
|
|
343
|
+
message.value = object.value ?? "";
|
|
344
|
+
message.data = object.data ?? "";
|
|
345
|
+
message.gasLimit = object.gasLimit ?? "";
|
|
346
|
+
message.maxFeePerGas = object.maxFeePerGas ?? "";
|
|
347
|
+
message.maxPriorityFeePerGas = object.maxPriorityFeePerGas ?? "";
|
|
348
|
+
message.nonce = object.nonce ?? "";
|
|
349
|
+
message.deadline = object.deadline ?? "";
|
|
350
|
+
message.vType = object.vType ?? 0;
|
|
355
351
|
return message;
|
|
356
352
|
},
|
|
357
353
|
};
|
|
@@ -418,19 +414,18 @@ exports.MsgExecutePayload = {
|
|
|
418
414
|
return message;
|
|
419
415
|
},
|
|
420
416
|
create(base) {
|
|
421
|
-
return exports.MsgExecutePayload.fromPartial(base
|
|
417
|
+
return exports.MsgExecutePayload.fromPartial(base ?? {});
|
|
422
418
|
},
|
|
423
419
|
fromPartial(object) {
|
|
424
|
-
var _a, _b;
|
|
425
420
|
const message = createBaseMsgExecutePayload();
|
|
426
|
-
message.signer =
|
|
421
|
+
message.signer = object.signer ?? "";
|
|
427
422
|
message.universalAccountId = (object.universalAccountId !== undefined && object.universalAccountId !== null)
|
|
428
423
|
? exports.UniversalAccountId.fromPartial(object.universalAccountId)
|
|
429
424
|
: undefined;
|
|
430
425
|
message.universalPayload = (object.universalPayload !== undefined && object.universalPayload !== null)
|
|
431
426
|
? exports.UniversalPayload.fromPartial(object.universalPayload)
|
|
432
427
|
: undefined;
|
|
433
|
-
message.verificationData =
|
|
428
|
+
message.verificationData = object.verificationData ?? "";
|
|
434
429
|
return message;
|
|
435
430
|
},
|
|
436
431
|
};
|
|
@@ -487,14 +482,13 @@ exports.MigrationPayload = {
|
|
|
487
482
|
return message;
|
|
488
483
|
},
|
|
489
484
|
create(base) {
|
|
490
|
-
return exports.MigrationPayload.fromPartial(base
|
|
485
|
+
return exports.MigrationPayload.fromPartial(base ?? {});
|
|
491
486
|
},
|
|
492
487
|
fromPartial(object) {
|
|
493
|
-
var _a, _b, _c;
|
|
494
488
|
const message = createBaseMigrationPayload();
|
|
495
|
-
message.migration =
|
|
496
|
-
message.nonce =
|
|
497
|
-
message.deadline =
|
|
489
|
+
message.migration = object.migration ?? "";
|
|
490
|
+
message.nonce = object.nonce ?? "";
|
|
491
|
+
message.deadline = object.deadline ?? "";
|
|
498
492
|
return message;
|
|
499
493
|
},
|
|
500
494
|
};
|
|
@@ -561,19 +555,18 @@ exports.MsgMigrateUEA = {
|
|
|
561
555
|
return message;
|
|
562
556
|
},
|
|
563
557
|
create(base) {
|
|
564
|
-
return exports.MsgMigrateUEA.fromPartial(base
|
|
558
|
+
return exports.MsgMigrateUEA.fromPartial(base ?? {});
|
|
565
559
|
},
|
|
566
560
|
fromPartial(object) {
|
|
567
|
-
var _a, _b;
|
|
568
561
|
const message = createBaseMsgMigrateUEA();
|
|
569
|
-
message.signer =
|
|
562
|
+
message.signer = object.signer ?? "";
|
|
570
563
|
message.universalAccountId = (object.universalAccountId !== undefined && object.universalAccountId !== null)
|
|
571
564
|
? exports.UniversalAccountId.fromPartial(object.universalAccountId)
|
|
572
565
|
: undefined;
|
|
573
566
|
message.migrationPayload = (object.migrationPayload !== undefined && object.migrationPayload !== null)
|
|
574
567
|
? exports.MigrationPayload.fromPartial(object.migrationPayload)
|
|
575
568
|
: undefined;
|
|
576
|
-
message.signature =
|
|
569
|
+
message.signature = object.signature ?? "";
|
|
577
570
|
return message;
|
|
578
571
|
},
|
|
579
572
|
};
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { PushChain } from './push-chain/push-chain';
|
|
2
2
|
export type { ConversionQuote } from './constants/tokens';
|
|
3
3
|
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, SignAuthorizationParams, SignedAuthorization, DerivedExecutorAccount, ResolvedAccount, ResolvedControllerAccounts, AccountType, AccountRole, } from './universal/universal.types';
|
|
4
|
+
export type { PC20TokenReference, FundsToken, PC20RegistryEntry, PC20AddressResult, } from './orchestrator/orchestrator.types';
|
|
5
|
+
export { isPC20Reference } from './orchestrator/orchestrator.types';
|
|
6
|
+
export { PC20Error, InvalidPC20AddressError, PC20TokenChainMismatchError, PC20WrapperNotRegisteredError, PC20RegistryMismatchError, PC20FactoryMismatchError, InvalidPC20MetadataError, PC20ExpectedButPRC20Error, PC20AmbiguousAddressError, UnsupportedPC20DestinationError, InsufficientPC20BalanceError, PC20UnknownChainNamespaceError, PC20WrapperPredictionUnavailableError, PC20ExportRevertedError, PC20UnsafeEmptyPayloadError, } from './orchestrator/internals/pc20/errors';
|
|
4
7
|
export type { ChainTarget, ChainSource, UniversalTo, TransactionRouteType, UniversalExecuteParams, UniversalOutboundTxRequest, PreparedUniversalTx, CascadedTxResponse, CascadeHopInfo, CascadeTrackOptions, CascadeProgressEvent, CascadeCompletionResult, MultiChainTxResponse, OutboundTxDetails, WaitForOutboundOptions, SvmGatewayAccountMeta, SvmExecutePayloadFields, AccountStatus, UEAStatus, RescueFundsParams, } from './orchestrator/orchestrator.types';
|
|
5
8
|
export { parseUEAVersion } from './orchestrator/orchestrator.types';
|
|
6
9
|
export { TransactionRoute, detectRoute, isChainTarget } from './orchestrator/route-detector';
|
package/src/lib/index.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PushChain = 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 = void 0;
|
|
3
|
+
exports.PushChain = 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 = void 0;
|
|
4
4
|
const push_chain_1 = require("./push-chain/push-chain");
|
|
5
5
|
Object.defineProperty(exports, "PushChain", { enumerable: true, get: function () { return push_chain_1.PushChain; } });
|
|
6
|
-
// UEA version utility
|
|
7
6
|
var orchestrator_types_1 = require("./orchestrator/orchestrator.types");
|
|
8
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "isPC20Reference", { enumerable: true, get: function () { return orchestrator_types_1.isPC20Reference; } });
|
|
8
|
+
var errors_1 = require("./orchestrator/internals/pc20/errors");
|
|
9
|
+
Object.defineProperty(exports, "PC20Error", { enumerable: true, get: function () { return errors_1.PC20Error; } });
|
|
10
|
+
Object.defineProperty(exports, "InvalidPC20AddressError", { enumerable: true, get: function () { return errors_1.InvalidPC20AddressError; } });
|
|
11
|
+
Object.defineProperty(exports, "PC20TokenChainMismatchError", { enumerable: true, get: function () { return errors_1.PC20TokenChainMismatchError; } });
|
|
12
|
+
Object.defineProperty(exports, "PC20WrapperNotRegisteredError", { enumerable: true, get: function () { return errors_1.PC20WrapperNotRegisteredError; } });
|
|
13
|
+
Object.defineProperty(exports, "PC20RegistryMismatchError", { enumerable: true, get: function () { return errors_1.PC20RegistryMismatchError; } });
|
|
14
|
+
Object.defineProperty(exports, "PC20FactoryMismatchError", { enumerable: true, get: function () { return errors_1.PC20FactoryMismatchError; } });
|
|
15
|
+
Object.defineProperty(exports, "InvalidPC20MetadataError", { enumerable: true, get: function () { return errors_1.InvalidPC20MetadataError; } });
|
|
16
|
+
Object.defineProperty(exports, "PC20ExpectedButPRC20Error", { enumerable: true, get: function () { return errors_1.PC20ExpectedButPRC20Error; } });
|
|
17
|
+
Object.defineProperty(exports, "PC20AmbiguousAddressError", { enumerable: true, get: function () { return errors_1.PC20AmbiguousAddressError; } });
|
|
18
|
+
Object.defineProperty(exports, "UnsupportedPC20DestinationError", { enumerable: true, get: function () { return errors_1.UnsupportedPC20DestinationError; } });
|
|
19
|
+
Object.defineProperty(exports, "InsufficientPC20BalanceError", { enumerable: true, get: function () { return errors_1.InsufficientPC20BalanceError; } });
|
|
20
|
+
Object.defineProperty(exports, "PC20UnknownChainNamespaceError", { enumerable: true, get: function () { return errors_1.PC20UnknownChainNamespaceError; } });
|
|
21
|
+
Object.defineProperty(exports, "PC20WrapperPredictionUnavailableError", { enumerable: true, get: function () { return errors_1.PC20WrapperPredictionUnavailableError; } });
|
|
22
|
+
Object.defineProperty(exports, "PC20ExportRevertedError", { enumerable: true, get: function () { return errors_1.PC20ExportRevertedError; } });
|
|
23
|
+
Object.defineProperty(exports, "PC20UnsafeEmptyPayloadError", { enumerable: true, get: function () { return errors_1.PC20UnsafeEmptyPayloadError; } });
|
|
24
|
+
// UEA version utility
|
|
25
|
+
var orchestrator_types_2 = require("./orchestrator/orchestrator.types");
|
|
26
|
+
Object.defineProperty(exports, "parseUEAVersion", { enumerable: true, get: function () { return orchestrator_types_2.parseUEAVersion; } });
|
|
9
27
|
// Route detection utilities
|
|
10
28
|
var route_detector_1 = require("./orchestrator/route-detector");
|
|
11
29
|
Object.defineProperty(exports, "TransactionRoute", { enumerable: true, get: function () { return route_detector_1.TransactionRoute; } });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Buffer = void 0;
|
|
5
4
|
const buffer_1 = require("buffer");
|
|
6
|
-
exports.Buffer =
|
|
5
|
+
exports.Buffer = globalThis.Buffer ?? buffer_1.Buffer;
|
|
7
6
|
//# sourceMappingURL=buffer.js.map
|
|
@@ -12,7 +12,6 @@ exports.chainSupportsCEA = chainSupportsCEA;
|
|
|
12
12
|
exports.chainSupportsOutbound = chainSupportsOutbound;
|
|
13
13
|
exports.getCEAFactoryAddress = getCEAFactoryAddress;
|
|
14
14
|
exports.getAllCEAAddresses = getAllCEAAddresses;
|
|
15
|
-
const tslib_1 = require("tslib");
|
|
16
15
|
const viem_1 = require("viem");
|
|
17
16
|
const chains_1 = require("viem/chains");
|
|
18
17
|
const enums_1 = require("../constants/enums");
|
|
@@ -37,6 +36,22 @@ function getViemChain(chain) {
|
|
|
37
36
|
}
|
|
38
37
|
return viemChain;
|
|
39
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Transport for a CEAFactory read.
|
|
41
|
+
*
|
|
42
|
+
* `http(undefined)` falls back to the *viem* chain's default endpoint, which for
|
|
43
|
+
* `sepolia` is `https://sepolia.drpc.org` — a paid-plan host that answers every
|
|
44
|
+
* request with HTTP 400 ("chain is not available on free plan"). That silently
|
|
45
|
+
* broke every CEA derivation that did not pass an explicit rpcUrl, and no caller
|
|
46
|
+
* passes one. Use the SDK's own `CHAIN_INFO[].defaultRPC` list instead, wrapped in
|
|
47
|
+
* `fallback` so one dead endpoint rotates to the next.
|
|
48
|
+
*/
|
|
49
|
+
function ceaTransport(chain, rpcUrl) {
|
|
50
|
+
if (rpcUrl)
|
|
51
|
+
return (0, viem_1.http)(rpcUrl);
|
|
52
|
+
const rpcs = chain_1.CHAIN_INFO[chain]?.defaultRPC ?? [];
|
|
53
|
+
return rpcs.length > 0 ? (0, viem_1.fallback)(rpcs.map((url) => (0, viem_1.http)(url))) : (0, viem_1.http)();
|
|
54
|
+
}
|
|
40
55
|
/**
|
|
41
56
|
* Get CEA address for a UEA on a specific chain
|
|
42
57
|
*
|
|
@@ -49,33 +64,31 @@ function getViemChain(chain) {
|
|
|
49
64
|
// Cache CEA address per UEA+chain — address is deterministic (CREATE2), but
|
|
50
65
|
// isDeployed can change during execution so we always re-fetch it.
|
|
51
66
|
const ceaAddressCache = new Map();
|
|
52
|
-
function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
args: [ueaAddress],
|
|
75
|
-
});
|
|
76
|
-
ceaAddressCache.set(cacheKey, cea);
|
|
77
|
-
return { cea, isDeployed };
|
|
67
|
+
async function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
68
|
+
const cacheKey = `${ueaAddress.toLowerCase()}:${chain}`;
|
|
69
|
+
const cachedAddress = ceaAddressCache.get(cacheKey);
|
|
70
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
71
|
+
if (!factoryAddress) {
|
|
72
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
73
|
+
}
|
|
74
|
+
const viemChain = getViemChain(chain);
|
|
75
|
+
const client = (0, viem_1.createPublicClient)({
|
|
76
|
+
chain: viemChain,
|
|
77
|
+
transport: ceaTransport(chain, rpcUrl),
|
|
78
|
+
});
|
|
79
|
+
if (cachedAddress) {
|
|
80
|
+
// Address is cached — only re-check deployment status
|
|
81
|
+
const code = await client.getCode({ address: cachedAddress });
|
|
82
|
+
return { cea: cachedAddress, isDeployed: code !== undefined && code !== '0x' };
|
|
83
|
+
}
|
|
84
|
+
const [cea, isDeployed] = await client.readContract({
|
|
85
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
86
|
+
address: factoryAddress,
|
|
87
|
+
functionName: 'getCEAForPushAccount',
|
|
88
|
+
args: [ueaAddress],
|
|
78
89
|
});
|
|
90
|
+
ceaAddressCache.set(cacheKey, cea);
|
|
91
|
+
return { cea, isDeployed };
|
|
79
92
|
}
|
|
80
93
|
/**
|
|
81
94
|
* Get Push Account (UEA) address for a CEA on a specific chain
|
|
@@ -86,25 +99,23 @@ function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
|
86
99
|
* @returns Push account address on Push Chain
|
|
87
100
|
* @throws Error if chain doesn't have CEAFactory
|
|
88
101
|
*/
|
|
89
|
-
function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
args: [ceaAddress],
|
|
105
|
-
});
|
|
106
|
-
return uea;
|
|
102
|
+
async function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
103
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
104
|
+
if (!factoryAddress) {
|
|
105
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
106
|
+
}
|
|
107
|
+
const viemChain = getViemChain(chain);
|
|
108
|
+
const client = (0, viem_1.createPublicClient)({
|
|
109
|
+
chain: viemChain,
|
|
110
|
+
transport: ceaTransport(chain, rpcUrl),
|
|
111
|
+
});
|
|
112
|
+
const uea = await client.readContract({
|
|
113
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
114
|
+
address: factoryAddress,
|
|
115
|
+
functionName: 'getPushAccountForCEA',
|
|
116
|
+
args: [ceaAddress],
|
|
107
117
|
});
|
|
118
|
+
return uea;
|
|
108
119
|
}
|
|
109
120
|
/**
|
|
110
121
|
* Check if an address is a CEA on a specific chain
|
|
@@ -115,23 +126,21 @@ function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
|
115
126
|
* @returns True if address is a CEA deployed by the factory
|
|
116
127
|
* @throws Error if chain doesn't have CEAFactory
|
|
117
128
|
*/
|
|
118
|
-
function isCEA(address, chain, rpcUrl) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
args: [address],
|
|
134
|
-
});
|
|
129
|
+
async function isCEA(address, chain, rpcUrl) {
|
|
130
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
131
|
+
if (!factoryAddress) {
|
|
132
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
133
|
+
}
|
|
134
|
+
const viemChain = getViemChain(chain);
|
|
135
|
+
const client = (0, viem_1.createPublicClient)({
|
|
136
|
+
chain: viemChain,
|
|
137
|
+
transport: ceaTransport(chain, rpcUrl),
|
|
138
|
+
});
|
|
139
|
+
return client.readContract({
|
|
140
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
141
|
+
address: factoryAddress,
|
|
142
|
+
functionName: 'isCEA',
|
|
143
|
+
args: [address],
|
|
135
144
|
});
|
|
136
145
|
}
|
|
137
146
|
/**
|
|
@@ -152,8 +161,7 @@ function chainSupportsCEA(chain) {
|
|
|
152
161
|
* @returns True if outbound transactions are supported
|
|
153
162
|
*/
|
|
154
163
|
function chainSupportsOutbound(chain) {
|
|
155
|
-
|
|
156
|
-
if (((_a = chain_1.CHAIN_INFO[chain]) === null || _a === void 0 ? void 0 : _a.vm) === enums_1.VM.SVM) {
|
|
164
|
+
if (chain_1.CHAIN_INFO[chain]?.vm === enums_1.VM.SVM) {
|
|
157
165
|
return true; // SVM uses gateway program, not CEA
|
|
158
166
|
}
|
|
159
167
|
return chain_1.CEA_FACTORY_ADDRESSES[chain] !== undefined;
|
|
@@ -174,24 +182,22 @@ function getCEAFactoryAddress(chain) {
|
|
|
174
182
|
* @param rpcUrls - Optional custom RPC URLs per chain
|
|
175
183
|
* @returns Array of CEA addresses per chain
|
|
176
184
|
*/
|
|
177
|
-
function getAllCEAAddresses(ueaAddress, rpcUrls) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return results;
|
|
195
|
-
});
|
|
185
|
+
async function getAllCEAAddresses(ueaAddress, rpcUrls) {
|
|
186
|
+
const chains = Object.keys(chain_1.CEA_FACTORY_ADDRESSES);
|
|
187
|
+
const results = await Promise.all(chains.map(async (chain) => {
|
|
188
|
+
try {
|
|
189
|
+
const { cea, isDeployed } = await getCEAAddress(ueaAddress, chain, rpcUrls?.[chain]);
|
|
190
|
+
return { chain, cea, isDeployed };
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return {
|
|
194
|
+
chain,
|
|
195
|
+
cea: '0x0000000000000000000000000000000000000000',
|
|
196
|
+
isDeployed: false,
|
|
197
|
+
error: error instanceof Error ? error.message : String(error),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
return results;
|
|
196
202
|
}
|
|
197
203
|
//# sourceMappingURL=cea-utils.js.map
|