@vultisig/core-chain 4.0.1 → 4.1.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/CHANGELOG.md +33 -0
- package/dist/chains/cardano/cip30/buildCoseStructures.d.ts +1 -1
- package/dist/chains/cardano/cip30/buildCoseStructures.js +2 -2
- package/dist/chains/cardano/cip30/buildCoseStructures.js.map +1 -1
- package/dist/chains/cardano/config.d.ts +31 -0
- package/dist/chains/cardano/config.d.ts.map +1 -1
- package/dist/chains/cardano/config.js +31 -0
- package/dist/chains/cardano/config.js.map +1 -1
- package/dist/chains/cosmos/cosmosHrp.d.ts +39 -0
- package/dist/chains/cosmos/cosmosHrp.d.ts.map +1 -0
- package/dist/chains/cosmos/cosmosHrp.js +65 -0
- package/dist/chains/cosmos/cosmosHrp.js.map +1 -0
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts +1 -1
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts.map +1 -1
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js +1 -1
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js.map +1 -1
- package/dist/security/tokenTransferGuards.d.ts +78 -0
- package/dist/security/tokenTransferGuards.d.ts.map +1 -0
- package/dist/security/tokenTransferGuards.js +203 -0
- package/dist/security/tokenTransferGuards.js.map +1 -0
- package/dist/swap/general/GeneralSwapProvider.d.ts +1 -1
- package/dist/swap/general/GeneralSwapProvider.d.ts.map +1 -1
- package/dist/swap/general/GeneralSwapProvider.js +2 -1
- package/dist/swap/general/GeneralSwapProvider.js.map +1 -1
- package/dist/swap/general/GeneralSwapQuote.d.ts +13 -1
- package/dist/swap/general/GeneralSwapQuote.d.ts.map +1 -1
- package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.d.ts +12 -0
- package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.d.ts.map +1 -0
- package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.js +136 -0
- package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.js.map +1 -0
- package/dist/swap/general/ruji/config.d.ts +16 -0
- package/dist/swap/general/ruji/config.d.ts.map +1 -0
- package/dist/swap/general/ruji/config.js +19 -0
- package/dist/swap/general/ruji/config.js.map +1 -0
- package/dist/swap/keysign/getSwapDestinationAddress.d.ts.map +1 -1
- package/dist/swap/keysign/getSwapDestinationAddress.js +1 -0
- package/dist/swap/keysign/getSwapDestinationAddress.js.map +1 -1
- package/dist/swap/quote/SwapQuote.d.ts +2 -0
- package/dist/swap/quote/SwapQuote.d.ts.map +1 -1
- package/dist/swap/quote/findSwapQuote.d.ts +4 -4
- package/dist/swap/quote/findSwapQuote.d.ts.map +1 -1
- package/dist/swap/quote/findSwapQuote.js +153 -19
- package/dist/swap/quote/findSwapQuote.js.map +1 -1
- package/dist/swap/quote/getSwapQuoteSafetyFingerprint.d.ts +2 -1
- package/dist/swap/quote/getSwapQuoteSafetyFingerprint.d.ts.map +1 -1
- package/dist/swap/quote/getSwapQuoteSafetyFingerprint.js +2 -1
- package/dist/swap/quote/getSwapQuoteSafetyFingerprint.js.map +1 -1
- package/dist/swap/swapEnabledChains.d.ts.map +1 -1
- package/dist/swap/swapEnabledChains.js +2 -0
- package/dist/swap/swapEnabledChains.js.map +1 -1
- package/dist/swap/utils/getSwapExplorerUrl/index.d.ts +2 -2
- package/dist/swap/utils/getSwapExplorerUrl/index.d.ts.map +1 -1
- package/dist/swap/utils/getSwapExplorerUrl/index.js +2 -1
- package/dist/swap/utils/getSwapExplorerUrl/index.js.map +1 -1
- package/dist/tx/status/resolvers/ton.d.ts +6 -0
- package/dist/tx/status/resolvers/ton.d.ts.map +1 -1
- package/dist/tx/status/resolvers/ton.js +39 -10
- package/dist/tx/status/resolvers/ton.js.map +1 -1
- package/package.json +22 -1
|
@@ -3,6 +3,36 @@ import { chainFeeCoin } from '@vultisig/core-chain/coin/chainFeeCoin';
|
|
|
3
3
|
import { rootApiUrl } from '@vultisig/core-config';
|
|
4
4
|
import { attempt } from '@vultisig/lib-utils/attempt';
|
|
5
5
|
import { queryUrl } from '@vultisig/lib-utils/query/queryUrl';
|
|
6
|
+
/**
|
|
7
|
+
* TVM exit codes 0 and 1 are the success conventions; any other code is a revert.
|
|
8
|
+
* An absent code means the message had no compute phase (a plain transfer to a
|
|
9
|
+
* wallet), which is not a failure.
|
|
10
|
+
*/
|
|
11
|
+
const hasComputePhaseFailed = (computePhase) => {
|
|
12
|
+
const exitCode = computePhase?.exit_code;
|
|
13
|
+
return exitCode !== undefined && exitCode !== 0 && exitCode !== 1;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The action phase is where the wallet contract actually emits the outgoing
|
|
17
|
+
* transfer, so it is where the money moves. A transaction can pass its compute
|
|
18
|
+
* phase and land un-aborted while its action phase moved nothing — the seqno is
|
|
19
|
+
* consumed either way — so this is what separates a real send from a silent
|
|
20
|
+
* no-op. `result_code` is checked alongside `success` because indexers do not
|
|
21
|
+
* always populate both.
|
|
22
|
+
*/
|
|
23
|
+
const hasActionPhaseFailed = (actionPhase) => {
|
|
24
|
+
if (!actionPhase) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const { success, no_funds, result_code, skipped_actions } = actionPhase;
|
|
28
|
+
return success === false || no_funds === true || (result_code ?? 0) !== 0 || (skipped_actions ?? 0) > 0;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a TON transaction by the hash of the external message that carried it.
|
|
32
|
+
* Success requires the transaction to be un-aborted *and* to have cleared both the
|
|
33
|
+
* compute and the action phase; a transaction the indexer knows but hasn't fully
|
|
34
|
+
* described yet stays pending.
|
|
35
|
+
*/
|
|
6
36
|
export const getTonTxStatus = async ({ hash }) => {
|
|
7
37
|
const url = `${rootApiUrl}/ton/v3/transactionsByMessage?msg_hash=${hash}&direction=in&limit=1`;
|
|
8
38
|
const { data: response, error } = await attempt(queryUrl(url));
|
|
@@ -10,16 +40,12 @@ export const getTonTxStatus = async ({ hash }) => {
|
|
|
10
40
|
return { status: 'pending', isKnown: false };
|
|
11
41
|
}
|
|
12
42
|
const tx = response.transactions[0];
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
43
|
+
const { description } = tx;
|
|
44
|
+
if (!description) {
|
|
45
|
+
// Indexed, but the execution details haven't landed yet. Keep polling rather
|
|
46
|
+
// than reading the missing phases as success.
|
|
47
|
+
return { status: 'pending', isKnown: true };
|
|
16
48
|
}
|
|
17
|
-
// Check compute phase exit code
|
|
18
|
-
const exitCode = tx.description?.compute_ph?.exit_code;
|
|
19
|
-
// Exit code 0 or 1 indicates success
|
|
20
|
-
// If no exit code is present (simple transfers), assume success
|
|
21
|
-
const success = exitCode === undefined || exitCode === 0 || exitCode === 1;
|
|
22
|
-
const status = success ? 'success' : 'error';
|
|
23
49
|
const feeCoin = chainFeeCoin[Chain.Ton];
|
|
24
50
|
const feeStr = tx.total_fees;
|
|
25
51
|
const receipt = feeStr != null && feeStr !== ''
|
|
@@ -29,6 +55,9 @@ export const getTonTxStatus = async ({ hash }) => {
|
|
|
29
55
|
feeTicker: feeCoin.ticker,
|
|
30
56
|
}
|
|
31
57
|
: undefined;
|
|
32
|
-
|
|
58
|
+
const failed = description.aborted === true ||
|
|
59
|
+
hasComputePhaseFailed(description.compute_ph) ||
|
|
60
|
+
hasActionPhaseFailed(description.action);
|
|
61
|
+
return { status: failed ? 'error' : 'success', receipt };
|
|
33
62
|
};
|
|
34
63
|
//# sourceMappingURL=ton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/tx/status/resolvers/ton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,E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6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vultisig/core-chain",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Blockchain chain logic shared across Vultisig clients",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -240,6 +240,11 @@
|
|
|
240
240
|
"import": "./dist/chains/cosmos/cosmosGasLimitRecord.js",
|
|
241
241
|
"default": "./dist/chains/cosmos/cosmosGasLimitRecord.js"
|
|
242
242
|
},
|
|
243
|
+
"./chains/cosmos/cosmosHrp": {
|
|
244
|
+
"types": "./dist/chains/cosmos/cosmosHrp.d.ts",
|
|
245
|
+
"import": "./dist/chains/cosmos/cosmosHrp.js",
|
|
246
|
+
"default": "./dist/chains/cosmos/cosmosHrp.js"
|
|
247
|
+
},
|
|
243
248
|
"./chains/cosmos/cosmosMemoCap": {
|
|
244
249
|
"types": "./dist/chains/cosmos/cosmosMemoCap.d.ts",
|
|
245
250
|
"import": "./dist/chains/cosmos/cosmosMemoCap.js",
|
|
@@ -1648,6 +1653,11 @@
|
|
|
1648
1653
|
"import": "./dist/security/dangerousAddresses.js",
|
|
1649
1654
|
"default": "./dist/security/dangerousAddresses.js"
|
|
1650
1655
|
},
|
|
1656
|
+
"./security/tokenTransferGuards": {
|
|
1657
|
+
"types": "./dist/security/tokenTransferGuards.d.ts",
|
|
1658
|
+
"import": "./dist/security/tokenTransferGuards.js",
|
|
1659
|
+
"default": "./dist/security/tokenTransferGuards.js"
|
|
1660
|
+
},
|
|
1651
1661
|
"./signing/SignatureAlgorithm": {
|
|
1652
1662
|
"types": "./dist/signing/SignatureAlgorithm.d.ts",
|
|
1653
1663
|
"import": "./dist/signing/SignatureAlgorithm.js",
|
|
@@ -1853,6 +1863,16 @@
|
|
|
1853
1863
|
"import": "./dist/swap/general/priceImpactGuard.js",
|
|
1854
1864
|
"default": "./dist/swap/general/priceImpactGuard.js"
|
|
1855
1865
|
},
|
|
1866
|
+
"./swap/general/ruji/api/getRujiTradeSwapQuote": {
|
|
1867
|
+
"types": "./dist/swap/general/ruji/api/getRujiTradeSwapQuote.d.ts",
|
|
1868
|
+
"import": "./dist/swap/general/ruji/api/getRujiTradeSwapQuote.js",
|
|
1869
|
+
"default": "./dist/swap/general/ruji/api/getRujiTradeSwapQuote.js"
|
|
1870
|
+
},
|
|
1871
|
+
"./swap/general/ruji/config": {
|
|
1872
|
+
"types": "./dist/swap/general/ruji/config.d.ts",
|
|
1873
|
+
"import": "./dist/swap/general/ruji/config.js",
|
|
1874
|
+
"default": "./dist/swap/general/ruji/config.js"
|
|
1875
|
+
},
|
|
1856
1876
|
"./swap/general/swapkit/api/getSwapKitQuote": {
|
|
1857
1877
|
"types": "./dist/swap/general/swapkit/api/getSwapKitQuote.d.ts",
|
|
1858
1878
|
"import": "./dist/swap/general/swapkit/api/getSwapKitQuote.js",
|
|
@@ -2392,6 +2412,7 @@
|
|
|
2392
2412
|
"@trustwallet/wallet-core": "^4.7.3",
|
|
2393
2413
|
"@vultisig/core-config": "0.9.1",
|
|
2394
2414
|
"@vultisig/lib-utils": "0.10.6",
|
|
2415
|
+
"@vultisig/mpc-types": "0.3.0",
|
|
2395
2416
|
"bip32": "^5.0.1",
|
|
2396
2417
|
"bitcoinjs-lib": "^7.0.1",
|
|
2397
2418
|
"bs58": "^6.0.0",
|