@pushchain/core 5.1.3 → 5.1.4-alpha.1

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.
Files changed (131) hide show
  1. package/package.json +29 -6
  2. package/src/lib/constants/abi/prc20.evm.d.ts +22 -2
  3. package/src/lib/constants/abi/prc20.evm.js +11 -3
  4. package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +59 -0
  5. package/src/lib/constants/abi/universalGatewayPC.evm.js +26 -0
  6. package/src/lib/constants/chain.d.ts +4 -0
  7. package/src/lib/constants/chain.js +6 -2
  8. package/src/lib/index.d.ts +2 -2
  9. package/src/lib/internal/bs58.d.ts +2 -0
  10. package/src/lib/internal/bs58.js +7 -0
  11. package/src/lib/orchestrator/cea-utils.d.ts +0 -9
  12. package/src/lib/orchestrator/cea-utils.js +15 -4
  13. package/src/lib/orchestrator/internals/account-manager.d.ts +16 -0
  14. package/src/lib/orchestrator/internals/account-manager.js +191 -0
  15. package/src/lib/orchestrator/internals/cascade.d.ts +23 -0
  16. package/src/lib/orchestrator/internals/cascade.js +945 -0
  17. package/src/lib/orchestrator/internals/confirmation.d.ts +9 -0
  18. package/src/lib/orchestrator/internals/confirmation.js +123 -0
  19. package/src/lib/orchestrator/internals/context.d.ts +38 -0
  20. package/src/lib/orchestrator/internals/context.js +49 -0
  21. package/src/lib/orchestrator/internals/execute-funds-only.d.ts +11 -0
  22. package/src/lib/orchestrator/internals/execute-funds-only.js +219 -0
  23. package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +11 -0
  24. package/src/lib/orchestrator/internals/execute-funds-payload.js +222 -0
  25. package/src/lib/orchestrator/internals/execute-standard.d.ts +13 -0
  26. package/src/lib/orchestrator/internals/execute-standard.js +225 -0
  27. package/src/lib/orchestrator/internals/gas-calculator.d.ts +38 -0
  28. package/src/lib/orchestrator/internals/gas-calculator.js +424 -0
  29. package/src/lib/orchestrator/internals/gateway-client.d.ts +24 -0
  30. package/src/lib/orchestrator/internals/gateway-client.js +191 -0
  31. package/src/lib/orchestrator/internals/helpers.d.ts +26 -0
  32. package/src/lib/orchestrator/internals/helpers.js +181 -0
  33. package/src/lib/orchestrator/internals/index.d.ts +24 -0
  34. package/src/lib/orchestrator/internals/index.js +132 -0
  35. package/src/lib/orchestrator/internals/outbound-sync.d.ts +49 -0
  36. package/src/lib/orchestrator/internals/outbound-sync.js +357 -0
  37. package/src/lib/orchestrator/internals/outbound-tracker.d.ts +8 -0
  38. package/src/lib/orchestrator/internals/outbound-tracker.js +64 -0
  39. package/src/lib/orchestrator/internals/payload-builder.d.ts +24 -0
  40. package/src/lib/orchestrator/internals/payload-builder.js +178 -0
  41. package/src/lib/orchestrator/internals/push-chain-tx.d.ts +32 -0
  42. package/src/lib/orchestrator/internals/push-chain-tx.js +207 -0
  43. package/src/lib/orchestrator/internals/quote.d.ts +9 -0
  44. package/src/lib/orchestrator/internals/quote.js +114 -0
  45. package/src/lib/orchestrator/internals/rescue.d.ts +20 -0
  46. package/src/lib/orchestrator/internals/rescue.js +112 -0
  47. package/src/lib/orchestrator/internals/response-builder.d.ts +26 -0
  48. package/src/lib/orchestrator/internals/response-builder.js +504 -0
  49. package/src/lib/orchestrator/internals/route-handlers.d.ts +77 -0
  50. package/src/lib/orchestrator/internals/route-handlers.js +1192 -0
  51. package/src/lib/orchestrator/internals/signing.d.ts +27 -0
  52. package/src/lib/orchestrator/internals/signing.js +258 -0
  53. package/src/lib/orchestrator/internals/svm-bridge.d.ts +21 -0
  54. package/src/lib/orchestrator/internals/svm-bridge.js +122 -0
  55. package/src/lib/orchestrator/internals/svm-helpers.d.ts +35 -0
  56. package/src/lib/orchestrator/internals/svm-helpers.js +143 -0
  57. package/src/lib/orchestrator/internals/tx-transformer.d.ts +12 -0
  58. package/src/lib/orchestrator/internals/tx-transformer.js +120 -0
  59. package/src/lib/orchestrator/internals/uea-manager.d.ts +17 -0
  60. package/src/lib/orchestrator/internals/uea-manager.js +164 -0
  61. package/src/lib/orchestrator/orchestrator.d.ts +33 -431
  62. package/src/lib/orchestrator/orchestrator.js +124 -6125
  63. package/src/lib/orchestrator/orchestrator.types.d.ts +11 -10
  64. package/src/lib/orchestrator/payload-builders.js +34 -8
  65. package/src/lib/price-fetch/price-fetch.js +19 -7
  66. package/src/lib/push-chain/push-chain.d.ts +6 -0
  67. package/src/lib/push-chain/push-chain.js +10 -2
  68. package/src/lib/push-client/push-client.d.ts +3 -0
  69. package/src/lib/push-client/push-client.js +21 -31
  70. package/src/lib/universal/account/account.d.ts +35 -16
  71. package/src/lib/universal/account/account.js +298 -16
  72. package/src/lib/universal/signer/signer.d.ts +2 -3
  73. package/src/lib/universal/signer/signer.js +65 -115
  74. package/src/lib/universal/universal.types.d.ts +41 -0
  75. package/src/lib/utils.d.ts +7 -2
  76. package/src/lib/utils.js +65 -34
  77. package/src/lib/vm-client/evm-client.js +3 -11
  78. package/src/lib/vm-client/svm-client.d.ts +0 -4
  79. package/src/lib/vm-client/svm-client.js +2 -8
  80. package/src/index.js.map +0 -1
  81. package/src/lib/cache/cache.js.map +0 -1
  82. package/src/lib/constants/abi/cea.evm.js.map +0 -1
  83. package/src/lib/constants/abi/ceaFactory.evm.js.map +0 -1
  84. package/src/lib/constants/abi/erc20.evm.js.map +0 -1
  85. package/src/lib/constants/abi/factoryV1.js.map +0 -1
  86. package/src/lib/constants/abi/feeLocker.evm.js.map +0 -1
  87. package/src/lib/constants/abi/index.js.map +0 -1
  88. package/src/lib/constants/abi/prc20.evm.js.map +0 -1
  89. package/src/lib/constants/abi/uea-factory.js.map +0 -1
  90. package/src/lib/constants/abi/uea.evm.js.map +0 -1
  91. package/src/lib/constants/abi/uea.svm.js.map +0 -1
  92. package/src/lib/constants/abi/universalGateway.evm.js.map +0 -1
  93. package/src/lib/constants/abi/universalGatewayPC.evm.js.map +0 -1
  94. package/src/lib/constants/abi/universalGatewayV0.evm.js.map +0 -1
  95. package/src/lib/constants/chain.js.map +0 -1
  96. package/src/lib/constants/enums.js.map +0 -1
  97. package/src/lib/constants/index.js.map +0 -1
  98. package/src/lib/constants/selectors.js.map +0 -1
  99. package/src/lib/constants/tokens.js.map +0 -1
  100. package/src/lib/generated/uexecutor/v1/query.js.map +0 -1
  101. package/src/lib/generated/uexecutor/v1/types.js.map +0 -1
  102. package/src/lib/generated/uexecutor/v2/index.js.map +0 -1
  103. package/src/lib/generated/uexecutor/v2/query.js.map +0 -1
  104. package/src/lib/generated/uexecutor/v2/types.js.map +0 -1
  105. package/src/lib/generated/v1/tx.js.map +0 -1
  106. package/src/lib/index.js.map +0 -1
  107. package/src/lib/internal/buffer.js.map +0 -1
  108. package/src/lib/internal/global-buffer-polyfill.js.map +0 -1
  109. package/src/lib/orchestrator/cea-utils.js.map +0 -1
  110. package/src/lib/orchestrator/orchestrator.js.map +0 -1
  111. package/src/lib/orchestrator/orchestrator.types.js.map +0 -1
  112. package/src/lib/orchestrator/payload-builders.js.map +0 -1
  113. package/src/lib/orchestrator/route-detector.js.map +0 -1
  114. package/src/lib/price-fetch/price-fetch.js.map +0 -1
  115. package/src/lib/progress-hook/progress-hook.js.map +0 -1
  116. package/src/lib/progress-hook/progress-hook.types.js.map +0 -1
  117. package/src/lib/push-chain/helpers/abis.js.map +0 -1
  118. package/src/lib/push-chain/helpers/addresses.js.map +0 -1
  119. package/src/lib/push-chain/push-chain.js.map +0 -1
  120. package/src/lib/push-client/push-client.js.map +0 -1
  121. package/src/lib/push-client/push-client.types.js.map +0 -1
  122. package/src/lib/universal/account/account.js.map +0 -1
  123. package/src/lib/universal/account/index.js.map +0 -1
  124. package/src/lib/universal/signer/index.js.map +0 -1
  125. package/src/lib/universal/signer/signer.js.map +0 -1
  126. package/src/lib/universal/signer/signer.types.js.map +0 -1
  127. package/src/lib/universal/universal.types.js.map +0 -1
  128. package/src/lib/utils.js.map +0 -1
  129. package/src/lib/vm-client/evm-client.js.map +0 -1
  130. package/src/lib/vm-client/svm-client.js.map +0 -1
  131. package/src/lib/vm-client/vm-client.types.js.map +0 -1
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Transaction response/receipt transformation and progress reconstruction,
4
+ * extracted from Orchestrator.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.transformToUniversalTxReceipt = transformToUniversalTxReceipt;
8
+ exports.reconstructProgressEvents = reconstructProgressEvents;
9
+ exports.detectRouteFromUniversalTxData = detectRouteFromUniversalTxData;
10
+ const tslib_1 = require("tslib");
11
+ const chain_1 = require("../../constants/chain");
12
+ const enums_1 = require("../../constants/enums");
13
+ const types_1 = require("../../generated/uexecutor/v1/types");
14
+ const progress_hook_1 = tslib_1.__importDefault(require("../../progress-hook/progress-hook"));
15
+ const progress_hook_types_1 = require("../../progress-hook/progress-hook.types");
16
+ const route_detector_1 = require("../route-detector");
17
+ // ============================================================================
18
+ // Receipt Transform
19
+ // ============================================================================
20
+ function transformToUniversalTxReceipt(receipt, originalTxResponse) {
21
+ return {
22
+ hash: receipt.transactionHash,
23
+ blockNumber: receipt.blockNumber,
24
+ blockHash: receipt.blockHash,
25
+ transactionIndex: receipt.transactionIndex,
26
+ from: originalTxResponse.from,
27
+ to: originalTxResponse.to,
28
+ contractAddress: receipt.contractAddress || null,
29
+ gasPrice: originalTxResponse.gasPrice || BigInt(0),
30
+ gasUsed: receipt.gasUsed,
31
+ cumulativeGasUsed: receipt.cumulativeGasUsed,
32
+ logs: receipt.logs || [],
33
+ logsBloom: receipt.logsBloom || '0x',
34
+ status: receipt.status === 'success' ? 1 : 0,
35
+ raw: originalTxResponse.raw || {
36
+ from: originalTxResponse.from,
37
+ to: originalTxResponse.to,
38
+ },
39
+ };
40
+ }
41
+ // ============================================================================
42
+ // Progress Event Reconstruction
43
+ // ============================================================================
44
+ function reconstructProgressEvents(universalTxResponse, universalTxData) {
45
+ var _a;
46
+ const events = [];
47
+ const originParts = universalTxResponse.origin.split(':');
48
+ const chainNamespace = originParts.length >= 2 ? `${originParts[0]}:${originParts[1]}` : originParts[0];
49
+ const originAddress = originParts.length >= 3 ? originParts[2] : universalTxResponse.from;
50
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_01](chainNamespace, originAddress));
51
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_01]());
52
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_02](universalTxResponse.gasLimit));
53
+ const pushChainIds = [
54
+ chain_1.CHAIN_INFO[enums_1.CHAIN.PUSH_MAINNET].chainId,
55
+ chain_1.CHAIN_INFO[enums_1.CHAIN.PUSH_TESTNET_DONUT].chainId,
56
+ chain_1.CHAIN_INFO[enums_1.CHAIN.PUSH_LOCALNET].chainId,
57
+ ];
58
+ const isPushOrigin = pushChainIds.some((id) => chainNamespace.includes(`eip155:${id}`));
59
+ if (!isPushOrigin) {
60
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_01]());
61
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_02](universalTxResponse.from, true));
62
+ }
63
+ const inboundTx = universalTxData === null || universalTxData === void 0 ? void 0 : universalTxData.inboundTx;
64
+ const hasFundsFlow = inboundTx && BigInt(inboundTx.amount || '0') > BigInt(0);
65
+ if (!isPushOrigin) {
66
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_02]());
67
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_03]());
68
+ }
69
+ if (hasFundsFlow && inboundTx) {
70
+ const amount = BigInt(inboundTx.amount);
71
+ const decimals = 18;
72
+ const symbol = 'TOKEN';
73
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_01](amount, decimals, symbol));
74
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_02](inboundTx.txHash, amount, decimals, symbol));
75
+ const confirmations = 1;
76
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03](confirmations));
77
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03_02](confirmations, confirmations));
78
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_04]());
79
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_05]());
80
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_06](amount, decimals, symbol));
81
+ }
82
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_07]());
83
+ const pcTx = (_a = universalTxData === null || universalTxData === void 0 ? void 0 : universalTxData.pcTx) === null || _a === void 0 ? void 0 : _a[0];
84
+ const isOutboundFailed = (universalTxData === null || universalTxData === void 0 ? void 0 : universalTxData.universalStatus) === types_1.UniversalTxStatus.OUTBOUND_FAILED;
85
+ const isPcFailed = (pcTx === null || pcTx === void 0 ? void 0 : pcTx.status) === 'FAILED';
86
+ const isFailed = isPcFailed || isOutboundFailed;
87
+ if (isFailed) {
88
+ const errorMsg = isOutboundFailed
89
+ ? 'Outbound transaction failed (status: OUTBOUND_FAILED)'
90
+ : ((pcTx === null || pcTx === void 0 ? void 0 : pcTx.errorMsg) || 'Unknown error');
91
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_02](errorMsg));
92
+ }
93
+ else {
94
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_01]([universalTxResponse]));
95
+ }
96
+ return events;
97
+ }
98
+ // ============================================================================
99
+ // Route Detection from V2 Data
100
+ // ============================================================================
101
+ function detectRouteFromUniversalTxData(universalTxData) {
102
+ if (!universalTxData)
103
+ return undefined;
104
+ const hasOutbound = universalTxData.outboundTx.length > 0;
105
+ const hasInbound = !!universalTxData.inboundTx;
106
+ const statusIndicatesOutbound = [
107
+ types_1.UniversalTxStatus.OUTBOUND_PENDING,
108
+ types_1.UniversalTxStatus.OUTBOUND_SUCCESS,
109
+ types_1.UniversalTxStatus.OUTBOUND_FAILED,
110
+ ].includes(universalTxData.universalStatus);
111
+ if (hasOutbound || statusIndicatesOutbound) {
112
+ return hasInbound
113
+ ? route_detector_1.TransactionRoute.CEA_TO_CEA
114
+ : route_detector_1.TransactionRoute.UOA_TO_CEA;
115
+ }
116
+ if (hasInbound)
117
+ return route_detector_1.TransactionRoute.CEA_TO_PUSH;
118
+ return route_detector_1.TransactionRoute.UOA_TO_PUSH;
119
+ }
120
+ //# sourceMappingURL=tx-transformer.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * UEA (Universal Executor Account) lifecycle functions extracted from Orchestrator.
3
+ * Covers: compute, nonce, version, deployment status.
4
+ */
5
+ import type { OrchestratorContext } from './context';
6
+ export declare function computeUEAOffchain(ctx: OrchestratorContext): `0x${string}`;
7
+ export declare function computeUEA(ctx: OrchestratorContext): Promise<{
8
+ address: `0x${string}`;
9
+ deployed: boolean;
10
+ }>;
11
+ export declare function getUEANonce(ctx: OrchestratorContext, address: `0x${string}`): Promise<bigint>;
12
+ export declare function getUeaNonceForExecution(ctx: OrchestratorContext): Promise<bigint>;
13
+ export declare function getUeaStatusAndNonce(ctx: OrchestratorContext): Promise<{
14
+ deployed: boolean;
15
+ nonce: bigint;
16
+ }>;
17
+ export declare function fetchUEAVersion(ctx: OrchestratorContext): Promise<string>;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /**
3
+ * UEA (Universal Executor Account) lifecycle functions extracted from Orchestrator.
4
+ * Covers: compute, nonce, version, deployment status.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.computeUEAOffchain = computeUEAOffchain;
8
+ exports.computeUEA = computeUEA;
9
+ exports.getUEANonce = getUEANonce;
10
+ exports.getUeaNonceForExecution = getUeaNonceForExecution;
11
+ exports.getUeaStatusAndNonce = getUeaStatusAndNonce;
12
+ exports.fetchUEAVersion = fetchUEAVersion;
13
+ const tslib_1 = require("tslib");
14
+ const bs58_1 = require("../../internal/bs58");
15
+ const viem_1 = require("viem");
16
+ const factoryV1_1 = require("../../constants/abi/factoryV1");
17
+ const uea_svm_1 = require("../../constants/abi/uea.svm");
18
+ const uea_evm_1 = require("../../constants/abi/uea.evm");
19
+ const chain_1 = require("../../constants/chain");
20
+ const enums_1 = require("../../constants/enums");
21
+ const helpers_1 = require("./helpers");
22
+ // ============================================================================
23
+ // Offline UEA Address Computation (CREATE2)
24
+ // ============================================================================
25
+ function computeUEAOffchain(ctx) {
26
+ const { chain, address } = ctx.universalSigner.account;
27
+ const { vm, chainId } = chain_1.CHAIN_INFO[chain];
28
+ if ((0, helpers_1.isPushChain)(chain)) {
29
+ return address;
30
+ }
31
+ let ownerKey;
32
+ if (vm === enums_1.VM.EVM) {
33
+ ownerKey = address;
34
+ }
35
+ else if (vm === enums_1.VM.SVM) {
36
+ ownerKey = (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)));
37
+ }
38
+ else {
39
+ throw new Error(`Unsupported VM type: ${vm}`);
40
+ }
41
+ const encodedAccountId = (0, viem_1.encodeAbiParameters)([
42
+ {
43
+ type: 'tuple',
44
+ components: [
45
+ { name: 'chainNamespace', type: 'string' },
46
+ { name: 'chainId', type: 'string' },
47
+ { name: 'owner', type: 'bytes' },
48
+ ],
49
+ },
50
+ ], [{ chainNamespace: chain_1.VM_NAMESPACE[vm], chainId, owner: ownerKey }]);
51
+ const salt = (0, viem_1.keccak256)(encodedAccountId);
52
+ const minimalProxyRuntimeCode = ('0x3d602d80600a3d3981f3' +
53
+ '363d3d373d3d3d363d73' +
54
+ chain_1.UEA_PROXY[ctx.pushNetwork].toLowerCase().replace(/^0x/, '') +
55
+ '5af43d82803e903d91602b57fd5bf3');
56
+ const initCodeHash = (0, viem_1.keccak256)(minimalProxyRuntimeCode);
57
+ return (0, viem_1.getCreate2Address)({
58
+ from: ctx.pushClient.pushChainInfo.factoryAddress,
59
+ salt,
60
+ bytecodeHash: initCodeHash,
61
+ });
62
+ }
63
+ // ============================================================================
64
+ // On-chain UEA Computation
65
+ // ============================================================================
66
+ function computeUEA(ctx) {
67
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
68
+ const { chain, address } = ctx.universalSigner.account;
69
+ const { vm, chainId } = chain_1.CHAIN_INFO[chain];
70
+ if ((0, helpers_1.isPushChain)(chain)) {
71
+ throw new Error('UEA cannot be computed for a Push Chain Address');
72
+ }
73
+ const computedAddress = yield ctx.pushClient.readContract({
74
+ address: ctx.pushClient.pushChainInfo.factoryAddress,
75
+ abi: factoryV1_1.FACTORY_V1,
76
+ functionName: 'computeUEA',
77
+ args: [
78
+ {
79
+ chainNamespace: chain_1.VM_NAMESPACE[vm],
80
+ chainId,
81
+ owner: vm === enums_1.VM.EVM
82
+ ? address
83
+ : vm === enums_1.VM.SVM
84
+ ? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
85
+ : address,
86
+ },
87
+ ],
88
+ });
89
+ const byteCode = yield ctx.pushClient.publicClient.getCode({
90
+ address: computedAddress,
91
+ });
92
+ return { address: computedAddress, deployed: byteCode !== undefined };
93
+ });
94
+ }
95
+ // ============================================================================
96
+ // UEA Nonce
97
+ // ============================================================================
98
+ function getUEANonce(ctx, address) {
99
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
+ const chain = ctx.universalSigner.account.chain;
101
+ const { vm } = chain_1.CHAIN_INFO[chain];
102
+ switch (vm) {
103
+ case enums_1.VM.EVM:
104
+ return ctx.pushClient.readContract({
105
+ address,
106
+ abi: uea_evm_1.UEA_EVM,
107
+ functionName: 'nonce',
108
+ });
109
+ case enums_1.VM.SVM:
110
+ return ctx.pushClient.readContract({
111
+ address,
112
+ abi: uea_svm_1.UEA_SVM,
113
+ functionName: 'nonce',
114
+ });
115
+ default:
116
+ throw new Error(`Unsupported VM type: ${vm}`);
117
+ }
118
+ });
119
+ }
120
+ function getUeaNonceForExecution(ctx) {
121
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
122
+ const UEA = computeUEAOffchain(ctx);
123
+ const code = yield ctx.pushClient.publicClient.getCode({ address: UEA });
124
+ return code !== undefined ? yield getUEANonce(ctx, UEA) : BigInt(0);
125
+ });
126
+ }
127
+ function getUeaStatusAndNonce(ctx) {
128
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
129
+ const UEA = computeUEAOffchain(ctx);
130
+ const code = yield ctx.pushClient.publicClient.getCode({ address: UEA });
131
+ const deployed = code !== undefined;
132
+ const nonce = deployed ? yield getUEANonce(ctx, UEA) : BigInt(0);
133
+ return { deployed, nonce };
134
+ });
135
+ }
136
+ // ============================================================================
137
+ // UEA Version
138
+ // ============================================================================
139
+ function fetchUEAVersion(ctx) {
140
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
141
+ if (ctx.ueaVersionCache) {
142
+ return ctx.ueaVersionCache;
143
+ }
144
+ const chain = ctx.universalSigner.account.chain;
145
+ const { vm } = chain_1.CHAIN_INFO[chain];
146
+ const abi = vm === enums_1.VM.EVM ? uea_evm_1.UEA_EVM : uea_svm_1.UEA_SVM;
147
+ const predictedUEA = computeUEAOffchain(ctx);
148
+ const code = yield ctx.pushClient.publicClient.getCode({
149
+ address: predictedUEA,
150
+ });
151
+ if (code === undefined) {
152
+ ctx.ueaVersionCache = '0.1.0';
153
+ return '0.1.0';
154
+ }
155
+ const version = yield ctx.pushClient.readContract({
156
+ address: predictedUEA,
157
+ abi,
158
+ functionName: 'VERSION',
159
+ });
160
+ ctx.ueaVersionCache = version;
161
+ return version;
162
+ });
163
+ }
164
+ //# sourceMappingURL=uea-manager.js.map