@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.
- package/package.json +29 -6
- package/src/lib/constants/abi/prc20.evm.d.ts +22 -2
- package/src/lib/constants/abi/prc20.evm.js +11 -3
- package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +59 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.js +26 -0
- package/src/lib/constants/chain.d.ts +4 -0
- package/src/lib/constants/chain.js +6 -2
- package/src/lib/index.d.ts +2 -2
- package/src/lib/internal/bs58.d.ts +2 -0
- package/src/lib/internal/bs58.js +7 -0
- package/src/lib/orchestrator/cea-utils.d.ts +0 -9
- package/src/lib/orchestrator/cea-utils.js +15 -4
- package/src/lib/orchestrator/internals/account-manager.d.ts +16 -0
- package/src/lib/orchestrator/internals/account-manager.js +191 -0
- package/src/lib/orchestrator/internals/cascade.d.ts +23 -0
- package/src/lib/orchestrator/internals/cascade.js +945 -0
- package/src/lib/orchestrator/internals/confirmation.d.ts +9 -0
- package/src/lib/orchestrator/internals/confirmation.js +123 -0
- package/src/lib/orchestrator/internals/context.d.ts +38 -0
- package/src/lib/orchestrator/internals/context.js +49 -0
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +11 -0
- package/src/lib/orchestrator/internals/execute-funds-only.js +219 -0
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +11 -0
- package/src/lib/orchestrator/internals/execute-funds-payload.js +222 -0
- package/src/lib/orchestrator/internals/execute-standard.d.ts +13 -0
- package/src/lib/orchestrator/internals/execute-standard.js +225 -0
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +38 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +424 -0
- package/src/lib/orchestrator/internals/gateway-client.d.ts +24 -0
- package/src/lib/orchestrator/internals/gateway-client.js +191 -0
- package/src/lib/orchestrator/internals/helpers.d.ts +26 -0
- package/src/lib/orchestrator/internals/helpers.js +181 -0
- package/src/lib/orchestrator/internals/index.d.ts +24 -0
- package/src/lib/orchestrator/internals/index.js +132 -0
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +49 -0
- package/src/lib/orchestrator/internals/outbound-sync.js +357 -0
- package/src/lib/orchestrator/internals/outbound-tracker.d.ts +8 -0
- package/src/lib/orchestrator/internals/outbound-tracker.js +64 -0
- package/src/lib/orchestrator/internals/payload-builder.d.ts +24 -0
- package/src/lib/orchestrator/internals/payload-builder.js +178 -0
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +32 -0
- package/src/lib/orchestrator/internals/push-chain-tx.js +207 -0
- package/src/lib/orchestrator/internals/quote.d.ts +9 -0
- package/src/lib/orchestrator/internals/quote.js +114 -0
- package/src/lib/orchestrator/internals/rescue.d.ts +20 -0
- package/src/lib/orchestrator/internals/rescue.js +112 -0
- package/src/lib/orchestrator/internals/response-builder.d.ts +26 -0
- package/src/lib/orchestrator/internals/response-builder.js +504 -0
- package/src/lib/orchestrator/internals/route-handlers.d.ts +77 -0
- package/src/lib/orchestrator/internals/route-handlers.js +1192 -0
- package/src/lib/orchestrator/internals/signing.d.ts +27 -0
- package/src/lib/orchestrator/internals/signing.js +258 -0
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +21 -0
- package/src/lib/orchestrator/internals/svm-bridge.js +122 -0
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +35 -0
- package/src/lib/orchestrator/internals/svm-helpers.js +143 -0
- package/src/lib/orchestrator/internals/tx-transformer.d.ts +12 -0
- package/src/lib/orchestrator/internals/tx-transformer.js +120 -0
- package/src/lib/orchestrator/internals/uea-manager.d.ts +17 -0
- package/src/lib/orchestrator/internals/uea-manager.js +164 -0
- package/src/lib/orchestrator/orchestrator.d.ts +33 -431
- package/src/lib/orchestrator/orchestrator.js +124 -6125
- package/src/lib/orchestrator/orchestrator.types.d.ts +11 -10
- package/src/lib/orchestrator/payload-builders.js +34 -8
- package/src/lib/price-fetch/price-fetch.js +19 -7
- package/src/lib/push-chain/push-chain.d.ts +6 -0
- package/src/lib/push-chain/push-chain.js +10 -2
- package/src/lib/push-client/push-client.d.ts +3 -0
- package/src/lib/push-client/push-client.js +21 -31
- package/src/lib/universal/account/account.d.ts +35 -16
- package/src/lib/universal/account/account.js +298 -16
- package/src/lib/universal/signer/signer.d.ts +2 -3
- package/src/lib/universal/signer/signer.js +65 -115
- package/src/lib/universal/universal.types.d.ts +41 -0
- package/src/lib/utils.d.ts +7 -2
- package/src/lib/utils.js +65 -34
- package/src/lib/vm-client/evm-client.js +3 -11
- package/src/lib/vm-client/svm-client.d.ts +0 -4
- package/src/lib/vm-client/svm-client.js +2 -8
- package/src/index.js.map +0 -1
- package/src/lib/cache/cache.js.map +0 -1
- package/src/lib/constants/abi/cea.evm.js.map +0 -1
- package/src/lib/constants/abi/ceaFactory.evm.js.map +0 -1
- package/src/lib/constants/abi/erc20.evm.js.map +0 -1
- package/src/lib/constants/abi/factoryV1.js.map +0 -1
- package/src/lib/constants/abi/feeLocker.evm.js.map +0 -1
- package/src/lib/constants/abi/index.js.map +0 -1
- package/src/lib/constants/abi/prc20.evm.js.map +0 -1
- package/src/lib/constants/abi/uea-factory.js.map +0 -1
- package/src/lib/constants/abi/uea.evm.js.map +0 -1
- package/src/lib/constants/abi/uea.svm.js.map +0 -1
- package/src/lib/constants/abi/universalGateway.evm.js.map +0 -1
- package/src/lib/constants/abi/universalGatewayPC.evm.js.map +0 -1
- package/src/lib/constants/abi/universalGatewayV0.evm.js.map +0 -1
- package/src/lib/constants/chain.js.map +0 -1
- package/src/lib/constants/enums.js.map +0 -1
- package/src/lib/constants/index.js.map +0 -1
- package/src/lib/constants/selectors.js.map +0 -1
- package/src/lib/constants/tokens.js.map +0 -1
- package/src/lib/generated/uexecutor/v1/query.js.map +0 -1
- package/src/lib/generated/uexecutor/v1/types.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/index.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/query.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/types.js.map +0 -1
- package/src/lib/generated/v1/tx.js.map +0 -1
- package/src/lib/index.js.map +0 -1
- package/src/lib/internal/buffer.js.map +0 -1
- package/src/lib/internal/global-buffer-polyfill.js.map +0 -1
- package/src/lib/orchestrator/cea-utils.js.map +0 -1
- package/src/lib/orchestrator/orchestrator.js.map +0 -1
- package/src/lib/orchestrator/orchestrator.types.js.map +0 -1
- package/src/lib/orchestrator/payload-builders.js.map +0 -1
- package/src/lib/orchestrator/route-detector.js.map +0 -1
- package/src/lib/price-fetch/price-fetch.js.map +0 -1
- package/src/lib/progress-hook/progress-hook.js.map +0 -1
- package/src/lib/progress-hook/progress-hook.types.js.map +0 -1
- package/src/lib/push-chain/helpers/abis.js.map +0 -1
- package/src/lib/push-chain/helpers/addresses.js.map +0 -1
- package/src/lib/push-chain/push-chain.js.map +0 -1
- package/src/lib/push-client/push-client.js.map +0 -1
- package/src/lib/push-client/push-client.types.js.map +0 -1
- package/src/lib/universal/account/account.js.map +0 -1
- package/src/lib/universal/account/index.js.map +0 -1
- package/src/lib/universal/signer/index.js.map +0 -1
- package/src/lib/universal/signer/signer.js.map +0 -1
- package/src/lib/universal/signer/signer.types.js.map +0 -1
- package/src/lib/universal/universal.types.js.map +0 -1
- package/src/lib/utils.js.map +0 -1
- package/src/lib/vm-client/evm-client.js.map +0 -1
- package/src/lib/vm-client/svm-client.js.map +0 -1
- package/src/lib/vm-client/vm-client.types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushchain/core",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4-alpha.1",
|
|
4
4
|
"homepage": "https://push.org",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pushchain",
|
|
@@ -21,20 +21,33 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@bufbuild/protobuf": "^2.0.0",
|
|
24
|
-
"@coral-xyz/anchor": "^0.31.0",
|
|
25
24
|
"@cosmjs/crypto": "0.33.1",
|
|
26
25
|
"@cosmjs/encoding": "0.33.1",
|
|
27
26
|
"@cosmjs/proto-signing": "^0.33.1",
|
|
28
27
|
"@cosmjs/stargate": "^0.33.1",
|
|
29
28
|
"@cosmjs/tendermint-rpc": "0.33.1",
|
|
30
29
|
"@solana/web3.js": "^1.68.0",
|
|
30
|
+
"bs58": "^4.0.0",
|
|
31
31
|
"buffer": "^6.0.3",
|
|
32
32
|
"cosmjs-types": "0.9.0",
|
|
33
|
-
"ethers": "^6.14.3",
|
|
34
|
-
"protobufjs": "7.4.0",
|
|
35
33
|
"tslib": "^2.3.0",
|
|
36
|
-
"
|
|
37
|
-
|
|
34
|
+
"viem": "^2.27.2"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@coral-xyz/anchor": "^0.31.0",
|
|
38
|
+
"ethers": "^6.0.0",
|
|
39
|
+
"tweetnacl": "^1.0.3"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"@coral-xyz/anchor": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"ethers": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"tweetnacl": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
38
51
|
},
|
|
39
52
|
"scripts": {
|
|
40
53
|
"build:proto": "scripts/protoc-generate.sh"
|
|
@@ -42,6 +55,16 @@
|
|
|
42
55
|
"type": "commonjs",
|
|
43
56
|
"main": "./src/index.js",
|
|
44
57
|
"typings": "./src/index.d.ts",
|
|
58
|
+
"sideEffects": [
|
|
59
|
+
"./src/lib/internal/global-buffer-polyfill.*"
|
|
60
|
+
],
|
|
61
|
+
"files": [
|
|
62
|
+
"src/**/*.js",
|
|
63
|
+
"src/**/*.d.ts",
|
|
64
|
+
"src/**/*.json",
|
|
65
|
+
"README.md",
|
|
66
|
+
"CHANGELOG.md"
|
|
67
|
+
],
|
|
45
68
|
"devDependencies": {
|
|
46
69
|
"secp256k1": "^5.0.1",
|
|
47
70
|
"ts-proto": "^2.0.3"
|
|
@@ -144,11 +144,31 @@ export declare const UNIVERSAL_CORE_EVM: readonly [{
|
|
|
144
144
|
}, {
|
|
145
145
|
readonly type: "function";
|
|
146
146
|
readonly name: "getRescueFundsGasLimit";
|
|
147
|
-
readonly inputs: readonly [
|
|
147
|
+
readonly inputs: readonly [{
|
|
148
|
+
readonly name: "_prc20";
|
|
149
|
+
readonly type: "address";
|
|
150
|
+
readonly internalType: "address";
|
|
151
|
+
}];
|
|
148
152
|
readonly outputs: readonly [{
|
|
149
|
-
readonly name: "";
|
|
153
|
+
readonly name: "gasToken";
|
|
154
|
+
readonly type: "address";
|
|
155
|
+
readonly internalType: "address";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "gasFee";
|
|
150
158
|
readonly type: "uint256";
|
|
151
159
|
readonly internalType: "uint256";
|
|
160
|
+
}, {
|
|
161
|
+
readonly name: "rescueGasLimit";
|
|
162
|
+
readonly type: "uint256";
|
|
163
|
+
readonly internalType: "uint256";
|
|
164
|
+
}, {
|
|
165
|
+
readonly name: "gasPrice";
|
|
166
|
+
readonly type: "uint256";
|
|
167
|
+
readonly internalType: "uint256";
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "chainNamespace";
|
|
170
|
+
readonly type: "string";
|
|
171
|
+
readonly internalType: "string";
|
|
152
172
|
}];
|
|
153
173
|
readonly stateMutability: "view";
|
|
154
174
|
}, {
|
|
@@ -96,12 +96,20 @@ exports.UNIVERSAL_CORE_EVM = [
|
|
|
96
96
|
outputs: [{ name: '', type: 'address', internalType: 'address' }],
|
|
97
97
|
stateMutability: 'view',
|
|
98
98
|
},
|
|
99
|
-
// Rescue funds gas limit
|
|
99
|
+
// Rescue funds gas limit (returns gas details for a given PRC-20 token)
|
|
100
100
|
{
|
|
101
101
|
type: 'function',
|
|
102
102
|
name: 'getRescueFundsGasLimit',
|
|
103
|
-
inputs: [
|
|
104
|
-
|
|
103
|
+
inputs: [
|
|
104
|
+
{ name: '_prc20', type: 'address', internalType: 'address' },
|
|
105
|
+
],
|
|
106
|
+
outputs: [
|
|
107
|
+
{ name: 'gasToken', type: 'address', internalType: 'address' },
|
|
108
|
+
{ name: 'gasFee', type: 'uint256', internalType: 'uint256' },
|
|
109
|
+
{ name: 'rescueGasLimit', type: 'uint256', internalType: 'uint256' },
|
|
110
|
+
{ name: 'gasPrice', type: 'uint256', internalType: 'uint256' },
|
|
111
|
+
{ name: 'chainNamespace', type: 'string', internalType: 'string' },
|
|
112
|
+
],
|
|
105
113
|
stateMutability: 'view',
|
|
106
114
|
},
|
|
107
115
|
// Swap and burn gas (gateway-only)
|
|
@@ -137,4 +137,63 @@ export declare const UNIVERSAL_GATEWAY_PC: readonly [{
|
|
|
137
137
|
}];
|
|
138
138
|
readonly stateMutability: "view";
|
|
139
139
|
readonly type: "function";
|
|
140
|
+
}, {
|
|
141
|
+
readonly inputs: readonly [{
|
|
142
|
+
readonly internalType: "bytes32";
|
|
143
|
+
readonly name: "universalTxId";
|
|
144
|
+
readonly type: "bytes32";
|
|
145
|
+
}, {
|
|
146
|
+
readonly internalType: "address";
|
|
147
|
+
readonly name: "prc20";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}];
|
|
150
|
+
readonly name: "rescueFundsOnSourceChain";
|
|
151
|
+
readonly outputs: readonly [];
|
|
152
|
+
readonly stateMutability: "payable";
|
|
153
|
+
readonly type: "function";
|
|
154
|
+
}, {
|
|
155
|
+
readonly anonymous: false;
|
|
156
|
+
readonly inputs: readonly [{
|
|
157
|
+
readonly indexed: true;
|
|
158
|
+
readonly internalType: "bytes32";
|
|
159
|
+
readonly name: "universalTxId";
|
|
160
|
+
readonly type: "bytes32";
|
|
161
|
+
}, {
|
|
162
|
+
readonly indexed: true;
|
|
163
|
+
readonly internalType: "address";
|
|
164
|
+
readonly name: "prc20";
|
|
165
|
+
readonly type: "address";
|
|
166
|
+
}, {
|
|
167
|
+
readonly indexed: false;
|
|
168
|
+
readonly internalType: "string";
|
|
169
|
+
readonly name: "chainNamespace";
|
|
170
|
+
readonly type: "string";
|
|
171
|
+
}, {
|
|
172
|
+
readonly indexed: true;
|
|
173
|
+
readonly internalType: "address";
|
|
174
|
+
readonly name: "sender";
|
|
175
|
+
readonly type: "address";
|
|
176
|
+
}, {
|
|
177
|
+
readonly indexed: false;
|
|
178
|
+
readonly internalType: "uint8";
|
|
179
|
+
readonly name: "txType";
|
|
180
|
+
readonly type: "uint8";
|
|
181
|
+
}, {
|
|
182
|
+
readonly indexed: false;
|
|
183
|
+
readonly internalType: "uint256";
|
|
184
|
+
readonly name: "gasFee";
|
|
185
|
+
readonly type: "uint256";
|
|
186
|
+
}, {
|
|
187
|
+
readonly indexed: false;
|
|
188
|
+
readonly internalType: "uint256";
|
|
189
|
+
readonly name: "gasPrice";
|
|
190
|
+
readonly type: "uint256";
|
|
191
|
+
}, {
|
|
192
|
+
readonly indexed: false;
|
|
193
|
+
readonly internalType: "uint256";
|
|
194
|
+
readonly name: "gasLimit";
|
|
195
|
+
readonly type: "uint256";
|
|
196
|
+
}];
|
|
197
|
+
readonly name: "RescueFundsOnSourceChain";
|
|
198
|
+
readonly type: "event";
|
|
140
199
|
}];
|
|
@@ -66,5 +66,31 @@ exports.UNIVERSAL_GATEWAY_PC = [
|
|
|
66
66
|
stateMutability: 'view',
|
|
67
67
|
type: 'function',
|
|
68
68
|
},
|
|
69
|
+
// Rescue funds on source chain
|
|
70
|
+
{
|
|
71
|
+
inputs: [
|
|
72
|
+
{ internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
73
|
+
{ internalType: 'address', name: 'prc20', type: 'address' },
|
|
74
|
+
],
|
|
75
|
+
name: 'rescueFundsOnSourceChain',
|
|
76
|
+
outputs: [],
|
|
77
|
+
stateMutability: 'payable',
|
|
78
|
+
type: 'function',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
anonymous: false,
|
|
82
|
+
inputs: [
|
|
83
|
+
{ indexed: true, internalType: 'bytes32', name: 'universalTxId', type: 'bytes32' },
|
|
84
|
+
{ indexed: true, internalType: 'address', name: 'prc20', type: 'address' },
|
|
85
|
+
{ indexed: false, internalType: 'string', name: 'chainNamespace', type: 'string' },
|
|
86
|
+
{ indexed: true, internalType: 'address', name: 'sender', type: 'address' },
|
|
87
|
+
{ indexed: false, internalType: 'uint8', name: 'txType', type: 'uint8' },
|
|
88
|
+
{ indexed: false, internalType: 'uint256', name: 'gasFee', type: 'uint256' },
|
|
89
|
+
{ indexed: false, internalType: 'uint256', name: 'gasPrice', type: 'uint256' },
|
|
90
|
+
{ indexed: false, internalType: 'uint256', name: 'gasLimit', type: 'uint256' },
|
|
91
|
+
],
|
|
92
|
+
name: 'RescueFundsOnSourceChain',
|
|
93
|
+
type: 'event',
|
|
94
|
+
},
|
|
69
95
|
];
|
|
70
96
|
//# sourceMappingURL=universalGatewayPC.evm.js.map
|
|
@@ -80,6 +80,10 @@ export declare const PUSH_CHAIN_INFO: Record<CHAIN.PUSH_MAINNET | CHAIN.PUSH_TES
|
|
|
80
80
|
* These are the contracts that handle inbound/outbound universal transactions
|
|
81
81
|
*/
|
|
82
82
|
export declare const UNIVERSAL_GATEWAY_ADDRESSES: Partial<Record<CHAIN, `0x${string}`>>;
|
|
83
|
+
/**
|
|
84
|
+
* Pyth price feed account for SVM gateway gas estimation
|
|
85
|
+
*/
|
|
86
|
+
export declare const SVM_PYTH_PRICE_FEED = "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE";
|
|
83
87
|
/**
|
|
84
88
|
* Vault contract addresses on external chains
|
|
85
89
|
* Vaults hold locked assets for cross-chain operations
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHAIN_EXPLORERS = exports.CEA_FACTORY_ADDRESSES = exports.VAULT_ADDRESSES = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.PUSH_CHAIN_INFO = exports.CHAIN_INFO = exports.SYNTHETIC_PUSH_ERC20 = exports.UEA_MIGRATION = exports.UEA_FACTORY = exports.UEA_PROXY = exports.VM_NAMESPACE = void 0;
|
|
3
|
+
exports.CHAIN_EXPLORERS = exports.CEA_FACTORY_ADDRESSES = exports.VAULT_ADDRESSES = exports.SVM_PYTH_PRICE_FEED = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.PUSH_CHAIN_INFO = exports.CHAIN_INFO = exports.SYNTHETIC_PUSH_ERC20 = exports.UEA_MIGRATION = exports.UEA_FACTORY = exports.UEA_PROXY = exports.VM_NAMESPACE = void 0;
|
|
4
4
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
5
5
|
exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
6
6
|
const enums_1 = require("./enums");
|
|
@@ -292,12 +292,16 @@ exports.PUSH_CHAIN_INFO = {
|
|
|
292
292
|
* These are the contracts that handle inbound/outbound universal transactions
|
|
293
293
|
*/
|
|
294
294
|
exports.UNIVERSAL_GATEWAY_ADDRESSES = {
|
|
295
|
-
[enums_1.CHAIN.ETHEREUM_SEPOLIA]: '
|
|
295
|
+
[enums_1.CHAIN.ETHEREUM_SEPOLIA]: '0x05bD7a3D18324c1F7e216f7fBF2b15985aE5281A',
|
|
296
296
|
[enums_1.CHAIN.BNB_TESTNET]: '0x44aFFC61983F4348DdddB886349eb992C061EaC0',
|
|
297
297
|
// Arbitrum Sepolia and Base Sepolia use same as locker for now
|
|
298
298
|
[enums_1.CHAIN.ARBITRUM_SEPOLIA]: '0x2cd870e0166Ba458dEC615168Fd659AacD795f34',
|
|
299
299
|
[enums_1.CHAIN.BASE_SEPOLIA]: '0xFD4fef1F43aFEc8b5bcdEEc47f35a1431479aC16',
|
|
300
300
|
};
|
|
301
|
+
/**
|
|
302
|
+
* Pyth price feed account for SVM gateway gas estimation
|
|
303
|
+
*/
|
|
304
|
+
exports.SVM_PYTH_PRICE_FEED = '7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE';
|
|
301
305
|
/**
|
|
302
306
|
* Vault contract addresses on external chains
|
|
303
307
|
* Vaults hold locked assets for cross-chain operations
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PushChain } from './push-chain/push-chain';
|
|
2
2
|
export type { ConversionQuote } from './constants/tokens';
|
|
3
|
-
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, } from './universal/universal.types';
|
|
4
|
-
export type { ChainTarget, ChainSource, UniversalTo, TransactionRouteType, UniversalExecuteParams, UniversalOutboundTxRequest, PreparedUniversalTx, CascadedTransactionBuilder, CascadedTxResponse, CascadeHopInfo, CascadeTrackOptions, CascadeProgressEvent, CascadeCompletionResult,
|
|
3
|
+
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, DerivedExecutorAccount, ResolvedAccount, ResolvedControllerAccounts, AccountType, AccountRole, } from './universal/universal.types';
|
|
4
|
+
export type { ChainTarget, ChainSource, UniversalTo, TransactionRouteType, UniversalExecuteParams, UniversalOutboundTxRequest, PreparedUniversalTx, CascadedTransactionBuilder, CascadedTxResponse, CascadeHopInfo, CascadeTrackOptions, CascadeProgressEvent, CascadeCompletionResult, MultiChainTxResponse, OutboundTxDetails, WaitForOutboundOptions, SvmGatewayAccountMeta, SvmExecutePayloadFields, SvmExecuteParams, AccountStatus, UEAStatus, RescueFundsParams, } from './orchestrator/orchestrator.types';
|
|
5
5
|
export { parseUEAVersion } from './orchestrator/orchestrator.types';
|
|
6
6
|
export { TransactionRoute, detectRoute, isChainTarget } from './orchestrator/route-detector';
|
|
7
7
|
export { getCEAAddress, getPushAccountForCEA, isCEA, chainSupportsCEA, chainSupportsOutbound, getCEAFactoryAddress, getAllCEAAddresses, } from './orchestrator/cea-utils';
|
|
@@ -13,15 +13,6 @@ export interface CEAAddressResult {
|
|
|
13
13
|
/** Whether the CEA has been deployed */
|
|
14
14
|
isDeployed: boolean;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Get CEA address for a UEA on a specific chain
|
|
18
|
-
*
|
|
19
|
-
* @param ueaAddress - UEA address on Push Chain
|
|
20
|
-
* @param chain - Target external chain
|
|
21
|
-
* @param rpcUrl - Optional custom RPC URL
|
|
22
|
-
* @returns CEA address and deployment status
|
|
23
|
-
* @throws Error if chain doesn't have CEAFactory
|
|
24
|
-
*/
|
|
25
16
|
export declare function getCEAAddress(ueaAddress: `0x${string}`, chain: CHAIN, rpcUrl?: string): Promise<CEAAddressResult>;
|
|
26
17
|
/**
|
|
27
18
|
* Get Push Account (UEA) address for a CEA on a specific chain
|
|
@@ -17,7 +17,7 @@ const viem_1 = require("viem");
|
|
|
17
17
|
const chains_1 = require("viem/chains");
|
|
18
18
|
const enums_1 = require("../constants/enums");
|
|
19
19
|
const chain_1 = require("../constants/chain");
|
|
20
|
-
const
|
|
20
|
+
const ceaFactory_evm_1 = require("../constants/abi/ceaFactory.evm");
|
|
21
21
|
/**
|
|
22
22
|
* Map CHAIN enum to viem chain object
|
|
23
23
|
*/
|
|
@@ -46,8 +46,13 @@ function getViemChain(chain) {
|
|
|
46
46
|
* @returns CEA address and deployment status
|
|
47
47
|
* @throws Error if chain doesn't have CEAFactory
|
|
48
48
|
*/
|
|
49
|
+
// Cache CEA address per UEA+chain — address is deterministic (CREATE2), but
|
|
50
|
+
// isDeployed can change during execution so we always re-fetch it.
|
|
51
|
+
const ceaAddressCache = new Map();
|
|
49
52
|
function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
50
53
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const cacheKey = `${ueaAddress.toLowerCase()}:${chain}`;
|
|
55
|
+
const cachedAddress = ceaAddressCache.get(cacheKey);
|
|
51
56
|
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
52
57
|
if (!factoryAddress) {
|
|
53
58
|
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
@@ -57,12 +62,18 @@ function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
|
57
62
|
chain: viemChain,
|
|
58
63
|
transport: (0, viem_1.http)(rpcUrl),
|
|
59
64
|
});
|
|
65
|
+
if (cachedAddress) {
|
|
66
|
+
// Address is cached — only re-check deployment status
|
|
67
|
+
const code = yield client.getCode({ address: cachedAddress });
|
|
68
|
+
return { cea: cachedAddress, isDeployed: code !== undefined && code !== '0x' };
|
|
69
|
+
}
|
|
60
70
|
const [cea, isDeployed] = yield client.readContract({
|
|
61
|
-
abi:
|
|
71
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
62
72
|
address: factoryAddress,
|
|
63
73
|
functionName: 'getCEAForPushAccount',
|
|
64
74
|
args: [ueaAddress],
|
|
65
75
|
});
|
|
76
|
+
ceaAddressCache.set(cacheKey, cea);
|
|
66
77
|
return { cea, isDeployed };
|
|
67
78
|
});
|
|
68
79
|
}
|
|
@@ -87,7 +98,7 @@ function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
|
87
98
|
transport: (0, viem_1.http)(rpcUrl),
|
|
88
99
|
});
|
|
89
100
|
const uea = yield client.readContract({
|
|
90
|
-
abi:
|
|
101
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
91
102
|
address: factoryAddress,
|
|
92
103
|
functionName: 'getPushAccountForCEA',
|
|
93
104
|
args: [ceaAddress],
|
|
@@ -116,7 +127,7 @@ function isCEA(address, chain, rpcUrl) {
|
|
|
116
127
|
transport: (0, viem_1.http)(rpcUrl),
|
|
117
128
|
});
|
|
118
129
|
return client.readContract({
|
|
119
|
-
abi:
|
|
130
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
120
131
|
address: factoryAddress,
|
|
121
132
|
functionName: 'isCEA',
|
|
122
133
|
args: [address],
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account management functions extracted from Orchestrator.
|
|
3
|
+
* Covers: getAccountStatus, upgradeAccount, fetchLatestUEAVersion, migrateCEA.
|
|
4
|
+
*/
|
|
5
|
+
import { CHAIN, VM } from '../../constants/enums';
|
|
6
|
+
import { ProgressEvent } from '../../progress-hook/progress-hook.types';
|
|
7
|
+
import { AccountStatus, UniversalTxResponse } from '../orchestrator.types';
|
|
8
|
+
import type { OrchestratorContext } from './context';
|
|
9
|
+
export declare function fetchLatestUEAVersion(ctx: OrchestratorContext, vm: VM): Promise<string>;
|
|
10
|
+
export declare function getAccountStatus(ctx: OrchestratorContext, options?: {
|
|
11
|
+
forceRefresh?: boolean;
|
|
12
|
+
}): Promise<AccountStatus>;
|
|
13
|
+
export declare function upgradeAccount(ctx: OrchestratorContext, options?: {
|
|
14
|
+
progressHook?: (progress: ProgressEvent) => void;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function migrateCEA(ctx: OrchestratorContext, chain: CHAIN, executeFn: (params: any) => Promise<UniversalTxResponse>): Promise<UniversalTxResponse>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Account management functions extracted from Orchestrator.
|
|
4
|
+
* Covers: getAccountStatus, upgradeAccount, fetchLatestUEAVersion, migrateCEA.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.fetchLatestUEAVersion = fetchLatestUEAVersion;
|
|
8
|
+
exports.getAccountStatus = getAccountStatus;
|
|
9
|
+
exports.upgradeAccount = upgradeAccount;
|
|
10
|
+
exports.migrateCEA = migrateCEA;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const bs58_1 = require("../../internal/bs58");
|
|
13
|
+
const viem_1 = require("viem");
|
|
14
|
+
const uea_factory_1 = require("../../constants/abi/uea-factory");
|
|
15
|
+
const chain_1 = require("../../constants/chain");
|
|
16
|
+
const enums_1 = require("../../constants/enums");
|
|
17
|
+
const progress_hook_1 = tslib_1.__importDefault(require("../../progress-hook/progress-hook"));
|
|
18
|
+
const progress_hook_types_1 = require("../../progress-hook/progress-hook.types");
|
|
19
|
+
const orchestrator_types_1 = require("../orchestrator.types");
|
|
20
|
+
const cea_utils_1 = require("../cea-utils");
|
|
21
|
+
const uea_manager_1 = require("./uea-manager");
|
|
22
|
+
const signing_1 = require("./signing");
|
|
23
|
+
const helpers_1 = require("./helpers");
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Fetch Latest UEA Version from Factory
|
|
26
|
+
// ============================================================================
|
|
27
|
+
function fetchLatestUEAVersion(ctx, vm) {
|
|
28
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const factoryAddress = chain_1.UEA_FACTORY[ctx.pushNetwork];
|
|
30
|
+
if (!factoryAddress || factoryAddress === '0xTBD') {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const vmHash = vm === enums_1.VM.EVM
|
|
35
|
+
? (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'string' }], ['EVM']))
|
|
36
|
+
: (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'string' }], ['SVM']));
|
|
37
|
+
return yield ctx.pushClient.readContract({
|
|
38
|
+
address: factoryAddress,
|
|
39
|
+
abi: uea_factory_1.UEA_FACTORY_ABI,
|
|
40
|
+
functionName: 'UEA_VERSION',
|
|
41
|
+
args: [vmHash],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// Account Status
|
|
51
|
+
// ============================================================================
|
|
52
|
+
function getAccountStatus(ctx, options) {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
if (ctx.accountStatusCache && !(options === null || options === void 0 ? void 0 : options.forceRefresh)) {
|
|
55
|
+
return ctx.accountStatusCache;
|
|
56
|
+
}
|
|
57
|
+
const chain = ctx.universalSigner.account.chain;
|
|
58
|
+
const { vm } = chain_1.CHAIN_INFO[chain];
|
|
59
|
+
const { deployed } = yield (0, uea_manager_1.getUeaStatusAndNonce)(ctx);
|
|
60
|
+
if (!deployed) {
|
|
61
|
+
const status = {
|
|
62
|
+
mode: 'signer',
|
|
63
|
+
uea: {
|
|
64
|
+
loaded: true,
|
|
65
|
+
deployed: false,
|
|
66
|
+
version: '',
|
|
67
|
+
minRequiredVersion: '',
|
|
68
|
+
requiresUpgrade: false,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
ctx.accountStatusCache = status;
|
|
72
|
+
return status;
|
|
73
|
+
}
|
|
74
|
+
const [currentVersion, minRequiredVersion] = yield Promise.all([
|
|
75
|
+
(0, uea_manager_1.fetchUEAVersion)(ctx),
|
|
76
|
+
fetchLatestUEAVersion(ctx, vm),
|
|
77
|
+
]);
|
|
78
|
+
const requiresUpgrade = (0, orchestrator_types_1.parseUEAVersion)(currentVersion) < (0, orchestrator_types_1.parseUEAVersion)(minRequiredVersion);
|
|
79
|
+
const status = {
|
|
80
|
+
mode: 'signer',
|
|
81
|
+
uea: {
|
|
82
|
+
loaded: true,
|
|
83
|
+
deployed: true,
|
|
84
|
+
version: currentVersion,
|
|
85
|
+
minRequiredVersion,
|
|
86
|
+
requiresUpgrade,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
ctx.accountStatusCache = status;
|
|
90
|
+
return status;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// UEA Upgrade
|
|
95
|
+
// ============================================================================
|
|
96
|
+
function upgradeAccount(ctx, options) {
|
|
97
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const hook = (options === null || options === void 0 ? void 0 : options.progressHook) || ctx.progressHook;
|
|
99
|
+
const fireHook = (hookId, ...args) => {
|
|
100
|
+
const hookEntry = progress_hook_1.default[hookId];
|
|
101
|
+
if (hookEntry && hook) {
|
|
102
|
+
hook(hookEntry(...args));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01);
|
|
106
|
+
const status = yield getAccountStatus(ctx, { forceRefresh: true });
|
|
107
|
+
if (!status.uea.requiresUpgrade) {
|
|
108
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9903);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_02);
|
|
112
|
+
try {
|
|
113
|
+
const { chain, address } = ctx.universalSigner.account;
|
|
114
|
+
const { vm, chainId } = chain_1.CHAIN_INFO[chain];
|
|
115
|
+
const ueaAddress = (0, uea_manager_1.computeUEAOffchain)(ctx);
|
|
116
|
+
const migrationContractAddress = chain_1.UEA_MIGRATION[ctx.pushNetwork];
|
|
117
|
+
if (!migrationContractAddress || migrationContractAddress === '0xTBD') {
|
|
118
|
+
throw new Error('UEA migration contract address not configured');
|
|
119
|
+
}
|
|
120
|
+
const { nonce } = yield (0, uea_manager_1.getUeaStatusAndNonce)(ctx);
|
|
121
|
+
const deadline = BigInt(9999999999);
|
|
122
|
+
const ueaVersion = status.uea.version || '0.1.0';
|
|
123
|
+
const signatureBytes = yield (0, signing_1.signMigrationPayload)(ctx, {
|
|
124
|
+
migrationContractAddress,
|
|
125
|
+
nonce,
|
|
126
|
+
deadline,
|
|
127
|
+
ueaVersion,
|
|
128
|
+
ueaAddress,
|
|
129
|
+
});
|
|
130
|
+
const signature = (0, viem_1.bytesToHex)(signatureBytes);
|
|
131
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_03);
|
|
132
|
+
const universalAccountId = {
|
|
133
|
+
chainNamespace: chain_1.VM_NAMESPACE[vm],
|
|
134
|
+
chainId,
|
|
135
|
+
owner: vm === enums_1.VM.EVM
|
|
136
|
+
? address
|
|
137
|
+
: vm === enums_1.VM.SVM
|
|
138
|
+
? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
|
|
139
|
+
: address,
|
|
140
|
+
};
|
|
141
|
+
const { cosmosAddress: signer } = ctx.pushClient.getSignerAddress();
|
|
142
|
+
const msg = ctx.pushClient.createMsgMigrateUEA({
|
|
143
|
+
signer,
|
|
144
|
+
universalAccountId,
|
|
145
|
+
migrationPayload: {
|
|
146
|
+
migration: migrationContractAddress,
|
|
147
|
+
nonce: nonce.toString(),
|
|
148
|
+
deadline: deadline.toString(),
|
|
149
|
+
},
|
|
150
|
+
signature,
|
|
151
|
+
});
|
|
152
|
+
const txBody = yield ctx.pushClient.createCosmosTxBody([msg]);
|
|
153
|
+
const txRaw = yield ctx.pushClient.signCosmosTx(txBody);
|
|
154
|
+
const tx = yield ctx.pushClient.broadcastCosmosTx(txRaw);
|
|
155
|
+
if (tx.code !== 0) {
|
|
156
|
+
throw new Error(tx.rawLog || 'UEA migration transaction failed');
|
|
157
|
+
}
|
|
158
|
+
ctx.ueaVersionCache = undefined;
|
|
159
|
+
const updated = yield getAccountStatus(ctx, { forceRefresh: true });
|
|
160
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9901, updated.uea.version);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902);
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// CEA Migration
|
|
170
|
+
// ============================================================================
|
|
171
|
+
function migrateCEA(ctx, chain, executeFn) {
|
|
172
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
var _a;
|
|
174
|
+
if ((0, helpers_1.isPushChain)(chain)) {
|
|
175
|
+
throw new Error('Cannot migrate CEA on Push Chain');
|
|
176
|
+
}
|
|
177
|
+
if (!(0, cea_utils_1.chainSupportsCEA)(chain)) {
|
|
178
|
+
throw new Error(`Chain ${chain} does not support CEA`);
|
|
179
|
+
}
|
|
180
|
+
const ueaAddress = (0, uea_manager_1.computeUEAOffchain)(ctx);
|
|
181
|
+
const { cea, isDeployed } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, chain, (_a = ctx.rpcUrls[chain]) === null || _a === void 0 ? void 0 : _a[0]);
|
|
182
|
+
if (!isDeployed) {
|
|
183
|
+
throw new Error(`CEA not deployed on chain ${chain}. Deploy CEA first.`);
|
|
184
|
+
}
|
|
185
|
+
return executeFn({
|
|
186
|
+
to: { address: cea, chain },
|
|
187
|
+
migration: true,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=account-manager.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cascade composition functions extracted from Orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Covers: prepareTransaction, buildHopDescriptor, classifyIntoSegments,
|
|
5
|
+
* getSegmentType, composeCascade, createCascadedBuilder, createChainedBuilder.
|
|
6
|
+
*/
|
|
7
|
+
import { TransactionRoute } from '../route-detector';
|
|
8
|
+
import type { HopDescriptor, CascadeSegment, CascadeSegmentType, PreparedUniversalTx, CascadedTransactionBuilder, CascadeHopInfo, UniversalTxResponse, UniversalExecuteParams, MultiCall, WaitForOutboundOptions, OutboundTxDetails } from '../orchestrator.types';
|
|
9
|
+
import type { OrchestratorContext } from './context';
|
|
10
|
+
export interface CascadeCallbacks {
|
|
11
|
+
executeFn: (params: any) => Promise<UniversalTxResponse>;
|
|
12
|
+
waitForOutboundTxFn: (hash: string, opts?: WaitForOutboundOptions) => Promise<OutboundTxDetails>;
|
|
13
|
+
waitForAllOutboundTxsFn: (hash: string, hops: CascadeHopInfo[], opts: any) => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
failedAt?: number;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export declare function prepareTransaction(ctx: OrchestratorContext, params: UniversalExecuteParams, callbacks: CascadeCallbacks): Promise<PreparedUniversalTx>;
|
|
19
|
+
export declare function buildHopDescriptor(ctx: OrchestratorContext, params: UniversalExecuteParams, route: TransactionRoute, ueaAddress: `0x${string}`): Promise<HopDescriptor>;
|
|
20
|
+
export declare function classifyIntoSegments(hops: HopDescriptor[]): CascadeSegment[];
|
|
21
|
+
export declare function getSegmentType(route: string): CascadeSegmentType;
|
|
22
|
+
export declare function composeCascade(ctx: OrchestratorContext, segments: CascadeSegment[], ueaAddress: `0x${string}`, ueaBalance?: bigint, ueaNonce?: bigint): MultiCall[];
|
|
23
|
+
export declare function createCascadedBuilder(ctx: OrchestratorContext, preparedTxs: PreparedUniversalTx[], callbacks: CascadeCallbacks): CascadedTransactionBuilder;
|