@vultisig/core-mpc 2.1.0 → 3.0.0
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 +91 -0
- package/dist/keysign/chainSpecific/KeysignChainSpecific.d.ts +0 -1
- package/dist/keysign/chainSpecific/KeysignChainSpecific.d.ts.map +1 -1
- package/dist/keysign/chainSpecific/KeysignChainSpecific.js +0 -1
- package/dist/keysign/chainSpecific/KeysignChainSpecific.js.map +1 -1
- package/dist/keysign/chainSpecific/resolver.d.ts +9 -0
- package/dist/keysign/chainSpecific/resolver.d.ts.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/cardano.js +2 -2
- package/dist/keysign/chainSpecific/resolvers/cardano.js.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/ripple.d.ts.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/ripple.js +16 -4
- package/dist/keysign/chainSpecific/resolvers/ripple.js.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/ton/index.d.ts +7 -0
- package/dist/keysign/chainSpecific/resolvers/ton/index.d.ts.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/ton/index.js +42 -24
- package/dist/keysign/chainSpecific/resolvers/ton/index.js.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/tron/index.d.ts +18 -0
- package/dist/keysign/chainSpecific/resolvers/tron/index.d.ts.map +1 -1
- package/dist/keysign/chainSpecific/resolvers/tron/index.js +66 -7
- package/dist/keysign/chainSpecific/resolvers/tron/index.js.map +1 -1
- package/dist/keysign/error.d.ts +1 -1
- package/dist/keysign/error.d.ts.map +1 -1
- package/dist/keysign/error.js.map +1 -1
- package/dist/keysign/send/build.d.ts +8 -1
- package/dist/keysign/send/build.d.ts.map +1 -1
- package/dist/keysign/send/build.js +46 -1
- package/dist/keysign/send/build.js.map +1 -1
- package/dist/keysign/signingInputs/resolvers/cosmos/index.d.ts +11 -0
- package/dist/keysign/signingInputs/resolvers/cosmos/index.d.ts.map +1 -1
- package/dist/keysign/signingInputs/resolvers/cosmos/index.js +4 -1
- package/dist/keysign/signingInputs/resolvers/cosmos/index.js.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ripple.d.ts.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ripple.js +55 -17
- package/dist/keysign/signingInputs/resolvers/ripple.js.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/index.d.ts.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/index.js +10 -5
- package/dist/keysign/signingInputs/resolvers/ton/index.js.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/jetton.d.ts +6 -0
- package/dist/keysign/signingInputs/resolvers/ton/jetton.d.ts.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/jetton.js +25 -5
- package/dist/keysign/signingInputs/resolvers/ton/jetton.js.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/native.d.ts +31 -4
- package/dist/keysign/signingInputs/resolvers/ton/native.d.ts.map +1 -1
- package/dist/keysign/signingInputs/resolvers/ton/native.js +38 -27
- package/dist/keysign/signingInputs/resolvers/ton/native.js.map +1 -1
- package/dist/keysign/utils/isRippleTrustSet.d.ts +8 -23
- package/dist/keysign/utils/isRippleTrustSet.d.ts.map +1 -1
- package/dist/keysign/utils/isRippleTrustSet.js +15 -24
- package/dist/keysign/utils/isRippleTrustSet.js.map +1 -1
- package/dist/types/vultisig/keysign/v1/blockchain_specific_pb.d.ts +9 -1
- package/dist/types/vultisig/keysign/v1/blockchain_specific_pb.d.ts.map +1 -1
- package/dist/types/vultisig/keysign/v1/blockchain_specific_pb.js +9 -1
- package/dist/types/vultisig/keysign/v1/blockchain_specific_pb.js.map +1 -1
- package/dist/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb.d.ts +4 -384
- package/dist/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb.d.ts.map +1 -1
- package/dist/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb.js +5 -76
- package/dist/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
1
|
# @vultisig/core-mpc
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#2237](https://github.com/vultisig/vultisig-sdk/pull/2237) [`7d4c116`](https://github.com/vultisig/vultisig-sdk/commit/7d4c116cc7a940e96abf075790c4a387edd03987) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - Remove Kujira (KUJI) chain support. Kujira wound down in 2025 and every RPC/LCD endpoint the SDK shipped for it is now dead (the polkachu hosts no longer resolve; publicnode 404s), so balances, sends, swaps, staking and governance on Kujira cannot function.
|
|
8
|
+
|
|
9
|
+
`Chain.Kujira` / `CosmosChain.Kujira` are removed from the chain union, along with the Kujira entries in the chain registry, cosmos RPC/LCD/fee/gas/memo tables, SwapKit + Skip + native-swap routing, the Kujira token list, IBC chain-id mapping, governance config and address derivation.
|
|
10
|
+
|
|
11
|
+
The IBC tables in `tools/prep/ibcTransfer.ts` are keyed by raw chain-ID rather than the `Chain` enum, so they are cleared explicitly: `kaiyo-1` is dropped from `IBC_CHAIN_REVISION` and the `osmosis-1/channel-259` route from `IBC_CHANNEL_DEST`. `supportedIbcDestinationsFrom('osmosis-1')` no longer advertises `kaiyo-1`, and `resolveSourceChannelByDestChain('osmosis-1', 'kaiyo-1')` returns `null`.
|
|
12
|
+
|
|
13
|
+
`COSMOS_CHAIN_ID_HRP` keeps its `kaiyo-1` → `kujira` entry: it is a pure bech32-prefix lookup that makes nothing routable, and it is still needed to decode historic `kujira1…` addresses.
|
|
14
|
+
|
|
15
|
+
The `chains/cosmos/thor/kujira-merge` module is intentionally **kept**: it describes the six Kujira-origin tokens (KUJI, rKUJI, FUZN, NSTK, WINK, LVN) that migrated onto THORChain as `thor.*` secured assets, plus their IBC representations on Cosmos Hub and Osmosis. Those assets are unaffected and keep resolving.
|
|
16
|
+
|
|
17
|
+
Consumers holding a persisted `Chain.Kujira` value must drop it — the symbol no longer type-checks.
|
|
18
|
+
|
|
19
|
+
- [#2298](https://github.com/vultisig/vultisig-sdk/pull/2298) [`1716a79`](https://github.com/vultisig/vultisig-sdk/commit/1716a7946bf617ff16f8bb15f33b279efbb4a87d) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): one correct comment validator, run before the user signs
|
|
20
|
+
|
|
21
|
+
TON comment length was checked against a fixed 123 bytes wherever it was checked at all. That number is right for a native transfer, where the comment is the message body's own cell, and wrong for a jetton transfer, where the comment rides inline in the transfer body's `forward_payload` and shares one 1023-bit cell with the opcode, query id, amount, both addresses and the forward amount. The real jetton cap is roughly 34–39 bytes and SHRINKS as the amount grows, because `VarUInteger 16` widens a byte at a time. Anything above it reached WalletCore, which refuses to pack the cell and fails the keysign with a bare "Internal error" — after the user had reviewed and approved the transaction. Memos are load-bearing on TON; an exchange deposit without the right one loses the funds.
|
|
22
|
+
|
|
23
|
+
New `@vultisig/core-chain/chains/ton/comment` owns the rule for both shapes: `tonNativeCommentMaxBytes`, `getTonJettonCommentMaxBytes({ amount, isActiveDestination })`, `getTonCommentMaxBytes` for a send form that wants to count down against the real limit, and `validateTonComment`. The amount-dependent widths are measured by encoding them, not predicted, and a test drives real WalletCore at each cap and one byte past it to prove the two agree.
|
|
24
|
+
|
|
25
|
+
`buildSendKeysignPayload` now validates the memo at the end of the build, where the final signed amount and `isActiveDestination` are both known, and raises a non-retryable `BuildKeysignPayloadError('ton-memo-too-long')`. That moves the failure from keysign to the point where the payload is assembled — the verify screen — for every consumer, with no client-side change. The signing-input resolvers still validate, so a payload built by another device or an older client cannot get an unpackable comment signed here either.
|
|
26
|
+
|
|
27
|
+
**Breaking:** `validateTonComment` is no longer exported from `@vultisig/core-mpc/keysign/signingInputs/resolvers/ton/native`, and takes `{ memo, jetton? }` instead of a bare string. Import it from `@vultisig/core-chain/chains/ton/comment`. `validateTonMemo` in the SDK's TON surface keeps its signature and gains an optional second argument for jetton context.
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#2316](https://github.com/vultisig/vultisig-sdk/pull/2316) [`b19c5d5`](https://github.com/vultisig/vultisig-sdk/commit/b19c5d56f4d00d92493f8da74ff80d92b1d87c68) Thanks [@rcoderdev](https://github.com/rcoderdev)! - Add exact XRP Ledger issued-currency Payments and authoritative delivered-amount receipts for XRP, issued currencies, and MPTs while preserving native XRP and explicit TrustSet behavior.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [#2282](https://github.com/vultisig/vultisig-sdk/pull/2282) [`a711b6c`](https://github.com/vultisig/vultisig-sdk/commit/a711b6ca8a8a7ae39d0efbb1c919b23b6538a1b8) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): derive each dApp message's bounce flag from its own destination
|
|
36
|
+
|
|
37
|
+
A dApp `signTon` batch stamped every message with the single wallet-level `TonSpecific.bounceable`, which the chain-specific resolver computes from the first message's destination alone. The bounce bit a message declares lives in its own address tag — `EQ…`/`kQ…` bounceable, `UQ…`/`0Q…` not, a raw `workchain:hex` address none — so a batch with mixed destinations, or a first destination that is not yet deployed, signed the wrong bit on some of its messages, and a co-signer deriving the flag per address computed a different hash for the same payload.
|
|
38
|
+
|
|
39
|
+
Each dApp message now takes the flag from its own destination (`getTonMessageBounceable` in `@vultisig/core-chain/chains/ton/messageBounce`); a raw `workchain:hex` address carries no tag, so it defaults to bounceable — an already-deployed contract must refund a rejection — unless the message carries `stateInit`, the deployment case whose destination has no code yet to bounce from. Every raw spelling WalletCore signs counts as the same account here: leading zeros, an explicit sign and a `0x`-prefixed hash all name one address and compile to one pre-image, so `00:<hash>` cannot be signed non-bounceable while `0:<hash>` is signed bounceable. App-initiated single sends are unchanged and keep the wallet-level flag and the nominator-pool override.
|
|
40
|
+
|
|
41
|
+
The bounce bit is part of the signed body, so TON signing hashes move for dApp batches whose destinations do not all share the first message's flag. Co-signers must apply the same per-message rule.
|
|
42
|
+
|
|
43
|
+
- [#2255](https://github.com/vultisig/vultisig-sdk/pull/2255) [`ef6a8bb`](https://github.com/vultisig/vultisig-sdk/commit/ef6a8bb0007c6576179e5a8cb10aa47820075b57) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): send swap deposits bounceable so a rejected deposit is refunded
|
|
44
|
+
|
|
45
|
+
TON transfers were marked bounceable only when the destination string started with `E`. Swap providers hand back deposit addresses in the `UQ…` (non-bounceable) form, so every TON swap deposit went out non-bounceable — and a router or escrow contract that rejects a message (expired quote, paused pool, closed route) _absorbs_ a non-bounceable transfer instead of returning it. The funds were gone.
|
|
46
|
+
|
|
47
|
+
Swap deposits are now always sent bounceable. The prefix check is replaced by a real read of the address's bounce tag, so raw `0:hex` destinations — which declare no bounceability at all and which the prefix check silently treated as non-bounceable — default to bounceable, the safe side for anything that might be a contract. Sends to an undeployed account stay non-bounceable, since such an account cannot accept a bounceable message, and an explicit `UQ…` destination is still honoured.
|
|
48
|
+
|
|
49
|
+
Adds `getTonAddressBounceability` to `@vultisig/core-chain/chains/ton/address`.
|
|
50
|
+
|
|
51
|
+
- [#2318](https://github.com/vultisig/vultisig-sdk/pull/2318) [`26a83ed`](https://github.com/vultisig/vultisig-sdk/commit/26a83ed417c9543f9c92d28cbb1bd35f0f914817) Thanks [@rcoderdev](https://github.com/rcoderdev)! - Fix TRON transaction lifecycle safety across fee preparation, status polling, and broadcast. Native TRX bandwidth estimates now measure the WalletCore-serialized signed transaction including memo bytes, default transaction times use the fetched block timestamp, expired raw transactions terminate polling, and successful broadcasts must return the deterministic local transaction hash.
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [[`1b3fb49`](https://github.com/vultisig/vultisig-sdk/commit/1b3fb498ad3f78b84b92b9f09b41fe8956fc5e9a), [`7d4c116`](https://github.com/vultisig/vultisig-sdk/commit/7d4c116cc7a940e96abf075790c4a387edd03987), [`7b65284`](https://github.com/vultisig/vultisig-sdk/commit/7b65284f7fe73f538283a201a416efdbbda0830c), [`1716a79`](https://github.com/vultisig/vultisig-sdk/commit/1716a7946bf617ff16f8bb15f33b279efbb4a87d), [`a711b6c`](https://github.com/vultisig/vultisig-sdk/commit/a711b6ca8a8a7ae39d0efbb1c919b23b6538a1b8), [`ef6a8bb`](https://github.com/vultisig/vultisig-sdk/commit/ef6a8bb0007c6576179e5a8cb10aa47820075b57), [`26a83ed`](https://github.com/vultisig/vultisig-sdk/commit/26a83ed417c9543f9c92d28cbb1bd35f0f914817), [`b19c5d5`](https://github.com/vultisig/vultisig-sdk/commit/b19c5d56f4d00d92493f8da74ff80d92b1d87c68)]:
|
|
54
|
+
- @vultisig/core-chain@5.0.0
|
|
55
|
+
|
|
56
|
+
## 2.1.1
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- [#2297](https://github.com/vultisig/vultisig-sdk/pull/2297) [`c0eafeb`](https://github.com/vultisig/vultisig-sdk/commit/c0eafeb12df42cffa70ef6951c081a74383e5fa2) Thanks [@rcoderdev](https://github.com/rcoderdev)! - Make the SDK package graph explicit and acyclic. Shared Bitcoin signing protobuf schemas now live in `@vultisig/mpc-types`, `@vultisig/core-mpc` preserves its existing schema subpath as a compatibility export, and SDK builds resolve the declared core packages through their published export maps.
|
|
61
|
+
|
|
62
|
+
- [#2006](https://github.com/vultisig/vultisig-sdk/pull/2006) [`3d40017`](https://github.com/vultisig/vultisig-sdk/commit/3d400171facf1107472e827c4ef48d7dd99843f1) Thanks [@gomesalexandre](https://github.com/gomesalexandre)! - Throw a domain error naming both unresolved chains when `getThorchainDepositAsset` can't resolve a native-swap chain id, instead of failing with a bare `Cannot read properties of undefined (reading 'toUpperCase')` TypeError on the secured-asset path (and silently building an invalid `chain: undefined` proto on the unsecured path). Also adds test coverage for the previously-untested CIP-8/CIP-30 `buildCoseStructures` CBOR encoders.
|
|
63
|
+
|
|
64
|
+
- [#2252](https://github.com/vultisig/vultisig-sdk/pull/2252) [`ef252e4`](https://github.com/vultisig/vultisig-sdk/commit/ef252e40b590a6cad9f303f7aba743c617442f90) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): stop hiding action-phase failures on sends and in status
|
|
65
|
+
|
|
66
|
+
Every TON send OR'd `IGNORE_ACTION_PHASE_ERRORS` into the wallet contract's send mode, which tells the contract to skip an outgoing transfer it cannot carry out instead of failing. The transaction then landed un-aborted with the seqno consumed and nothing moved, and the status resolver — which read only `aborted` and `compute_ph.exit_code` — reported it as confirmed. The user was told a transfer succeeded while the funds never left.
|
|
67
|
+
|
|
68
|
+
The flag is now dropped from native, MAX, dApp `signTon`, and Jetton sends (both the WalletCore and the React Native builders), and `getTonTxStatus` reads the action phase (`success`, `no_funds`, `result_code`, `skipped_actions`) alongside the compute phase. A transaction the indexer knows but has not yet described stays pending instead of counting as success.
|
|
69
|
+
|
|
70
|
+
Dropping the flag changes the signed body, so TON signing hashes move. Clients must upgrade together: a co-signer on an older build derives a different hash and the keysign fails. The mobile and cross-encoder golden corpora are re-recorded to the new values.
|
|
71
|
+
|
|
72
|
+
- [#2280](https://github.com/vultisig/vultisig-sdk/pull/2280) [`4e23e92`](https://github.com/vultisig/vultisig-sdk/commit/4e23e9205310e46564bc1782b57499b2a39d7a5f) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): refuse to build a Jetton transfer when the sender jetton wallet cannot be resolved
|
|
73
|
+
|
|
74
|
+
A Jetton transfer is a message to the sender's _own_ jetton wallet, and that address was resolved with a swallowed failure: `TonSpecific.jettonAddress` starts as `''`, a failed lookup left it `''`, and `''` is not null or undefined, so every presence check downstream waved it through. The result was a signable transaction whose destination was the empty string — a failed network lookup producing a broadcastable transfer that moves nothing.
|
|
75
|
+
|
|
76
|
+
The chain-specific resolver now throws when the lookup fails or comes back blank, keeping the underlying failure as the error's `cause`. It stays a plain `Error` rather than a `BuildKeysignPayloadError` because an RPC timeout or indexer lag is retryable, not bad user input.
|
|
77
|
+
|
|
78
|
+
`buildJettonTransfer` rejects a blank jetton wallet address as well, so a payload built elsewhere — an older client, another device in a keysign — cannot get a destination-less transfer signed here either.
|
|
79
|
+
|
|
80
|
+
- [#2256](https://github.com/vultisig/vultisig-sdk/pull/2256) [`4561c65`](https://github.com/vultisig/vultisig-sdk/commit/4561c6584f62fa78d17546bcc119e31b6ea665cb) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(ton): a MAX send signs the amount it displayed, and MAX is no longer guessed
|
|
81
|
+
|
|
82
|
+
A TON MAX send showed the user `balance - fee` and then signed something else: `amount = 0` under `ATTACH_ALL_CONTRACT_BALANCE`, which tells the wallet contract to sweep whatever the balance happens to be when the transaction executes. Worse, nothing marked a send as MAX — it was inferred from `amount + fee >= balance`, so an ordinary send that landed near the balance was silently upgraded to a full-balance sweep.
|
|
83
|
+
|
|
84
|
+
The signing path now always signs `keysignPayload.toAmount` under `PAY_FEES_SEPARATELY`, for MAX and ordinary sends alike; a MAX send is just `balance - fee` as an ordinary amount, and that fee is the reserve the send mode draws on. The signed bytes no longer depend on the flag at all.
|
|
85
|
+
|
|
86
|
+
`sendMaxAmount` becomes an explicit input threaded from the caller (`prepareSendTx` / `prepareSendTxFromKeys` / `buildSendKeysignPayload` → `getChainSpecific`), defaulting to `false`, and is recorded in `TonSpecific` as description rather than instruction. Removing the inference also drops a balance lookup from every TON send.
|
|
87
|
+
|
|
88
|
+
TON MAX sends that previously relied on the sweep to cover an amount larger than `balance - fee` will now fail on chain instead of moving more than was shown. Callers should pass the displayed `balance - fee` as `amount` and set `sendMaxAmount: true` alongside it.
|
|
89
|
+
|
|
90
|
+
- Updated dependencies [[`c0eafeb`](https://github.com/vultisig/vultisig-sdk/commit/c0eafeb12df42cffa70ef6951c081a74383e5fa2), [`ef252e4`](https://github.com/vultisig/vultisig-sdk/commit/ef252e40b590a6cad9f303f7aba743c617442f90), [`bfe0292`](https://github.com/vultisig/vultisig-sdk/commit/bfe0292e3876fb7acc7044bac1b544c27aba8919), [`acd0b2e`](https://github.com/vultisig/vultisig-sdk/commit/acd0b2eaa882669a399fb378e51244ed4199ee47)]:
|
|
91
|
+
- @vultisig/mpc-types@0.3.0
|
|
92
|
+
- @vultisig/core-chain@4.1.1
|
|
93
|
+
|
|
3
94
|
## 2.1.0
|
|
4
95
|
|
|
5
96
|
### Minor Changes
|
|
@@ -28,7 +28,6 @@ export declare const chainSpecificRecord: {
|
|
|
28
28
|
readonly Cosmos: "cosmosSpecific";
|
|
29
29
|
readonly Osmosis: "cosmosSpecific";
|
|
30
30
|
readonly Dydx: "cosmosSpecific";
|
|
31
|
-
readonly Kujira: "cosmosSpecific";
|
|
32
31
|
readonly Terra: "cosmosSpecific";
|
|
33
32
|
readonly TerraClassic: "cosmosSpecific";
|
|
34
33
|
readonly Noble: "cosmosSpecific";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeysignChainSpecific.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/chainSpecific/KeysignChainSpecific.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iEAAiE,CAAA;AAGhG,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAAA;AAExH,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;AAElE,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"KeysignChainSpecific.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/chainSpecific/KeysignChainSpecific.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iEAAiE,CAAA;AAGhG,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAAA;AAExH,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;AAElE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD2B,CAAA;AAE3D,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,uBAAuB,EAC1E,oBAAoB,cAAc,CAAC,oBAAoB,CAAC,EACxD,cAAc,CAAC,KACd,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,OAAO,CAMpD,CAAA"}
|
|
@@ -24,7 +24,6 @@ export const chainSpecificRecord = {
|
|
|
24
24
|
[Chain.Cosmos]: 'cosmosSpecific',
|
|
25
25
|
[Chain.Osmosis]: 'cosmosSpecific',
|
|
26
26
|
[Chain.Dydx]: 'cosmosSpecific',
|
|
27
|
-
[Chain.Kujira]: 'cosmosSpecific',
|
|
28
27
|
[Chain.Terra]: 'cosmosSpecific',
|
|
29
28
|
[Chain.TerraClassic]: 'cosmosSpecific',
|
|
30
29
|
[Chain.Noble]: 'cosmosSpecific',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeysignChainSpecific.js","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/chainSpecific/KeysignChainSpecific.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAM3F,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,kBAAkB;IACpC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,kBAAkB;IACrC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,kBAAkB;IAChC,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,kBAAkB;IACvC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,kBAAkB;IAC/B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,kBAAkB;IACjC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,kBAAkB;IACpC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,kBAAkB;IACpC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,kBAAkB;IACnC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAClC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAClC,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,kBAAkB;IACvC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,kBAAkB;IAC/B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,kBAAkB;IAErC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,cAAc;IAC/B,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,cAAc;IACnC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cAAc;IAChC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cAAc;IAChC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc;IAC5B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,cAAc;IAE7B,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB;IAChC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,gBAAgB;IACjC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,gBAAgB;IAC9B,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"KeysignChainSpecific.js","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/chainSpecific/KeysignChainSpecific.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,0BAA0B,EAAE,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,KAAK,CAAC,KAAK,CAAC,EAAE,gBAAgB;IAC/B,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,gBAAgB;IACtC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,gBAAgB;IAC/B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,gBAAgB;IAE/B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,mBAAmB;IAEtC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,cAAc;IAEjC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,gBAAgB;IAE7B,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB;IAEhC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,kBAAkB;IAEpC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,kBAAkB;IAErC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,aAAa;IAE1B,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB;IAEhC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc;IAE5B,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS;IAE1B,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,gBAAgB;CAC2B,CAAA;AAE3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,kBAAwD,EACxD,YAAe,EACsC,EAAE;IACvD,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,0BAA0B,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAQ,CAAA;AAC7F,CAAC,CAAA"}
|
|
@@ -13,6 +13,12 @@ export type GetChainSpecificInput<C extends KeysignChainSpecificKey = KeysignCha
|
|
|
13
13
|
walletCore: WalletCore;
|
|
14
14
|
/** XRPL DestinationTag, carried in RippleSpecific for Ripple payments. */
|
|
15
15
|
destinationTag?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the caller's UI offered this as a MAX send, carried in TonSpecific.
|
|
18
|
+
* Must come from the flow that drew the button — inferring it from the amount
|
|
19
|
+
* mislabels an ordinary send that happens to sit close to the balance.
|
|
20
|
+
*/
|
|
21
|
+
sendMaxAmount?: boolean;
|
|
16
22
|
} & (C extends 'ethereumSpecific' ? {
|
|
17
23
|
feeSettings?: FeeSettings<'evm'>;
|
|
18
24
|
thirdPartyGasLimitEstimation?: bigint;
|
|
@@ -34,6 +40,9 @@ export type GetChainSpecificInput<C extends KeysignChainSpecificKey = KeysignCha
|
|
|
34
40
|
refBlockBytesHex?: string;
|
|
35
41
|
refBlockHashHex?: string;
|
|
36
42
|
thirdPartyGasLimitEstimation?: bigint;
|
|
43
|
+
} : C extends 'rippleSpecific' ? {
|
|
44
|
+
/** Explicit send intent overrides the legacy issuer-address TrustSet inference. */
|
|
45
|
+
transactionType?: TransactionType.RIPPLE_PAYMENT | TransactionType.RIPPLE_TRUST_SET;
|
|
37
46
|
} : {});
|
|
38
47
|
export type GetChainSpecificResolver<C extends KeysignChainSpecificKey = KeysignChainSpecificKey> = Resolver<GetChainSpecificInput<C>, Promise<ValueForCase<C>>>;
|
|
39
48
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/chainSpecific/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qEAAqE,CAAA;AAC1G,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,oBAAoB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S,CAAC,EAAE,OAAO,CAAA;CACpB,GACD,CAAC,SAAS,mBAAmB,GAC3B;IACE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC,GACD,CAAC,SAAS,cAAc,GACtB;IACE,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,GACD,CAAC,SAAS,cAAc,GACtB;IACE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAA;CACtC,GACD,CAAC,SAAS,gBAAgB,GACxB;IACE,mFAAmF;IACnF,eAAe,CAAC,EAAE,eAAe,CAAC,cAAc,GAAG,eAAe,CAAC,gBAAgB,CAAA;CACpF,GACD,EAAE,CAAC,CAAA;AAEnB,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,IAAI,QAAQ,CAC1G,qBAAqB,CAAC,CAAC,CAAC,EACxB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CACzB,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { create } from '@bufbuild/protobuf';
|
|
|
2
2
|
import { Chain } from '@vultisig/core-chain/Chain';
|
|
3
3
|
import { getCardanoCurrentSlot } from '@vultisig/core-chain/chains/cardano/client/currentSlot';
|
|
4
4
|
import { cardanoDefaultFee } from '@vultisig/core-chain/chains/cardano/config';
|
|
5
|
-
import {
|
|
5
|
+
import { getCardanoSendTtl } from '@vultisig/core-chain/chains/cardano/config';
|
|
6
6
|
import { getPreSigningOutput } from '@vultisig/core-mpc/keysign/preSigningOutput';
|
|
7
7
|
import { CardanoChainSpecificSchema } from '@vultisig/core-mpc/types/vultisig/keysign/v1/blockchain_specific_pb';
|
|
8
8
|
import { bigIntSum } from '@vultisig/lib-utils/bigint/bigIntSum';
|
|
@@ -54,7 +54,7 @@ const estimateCardanoByteFee = async ({ keysignPayload, walletCore, ttl, sendMax
|
|
|
54
54
|
export const getCardanoChainSpecific = async ({ keysignPayload, walletCore }) => {
|
|
55
55
|
const amount = getKeysignAmount(keysignPayload);
|
|
56
56
|
const currentSlot = await getCardanoCurrentSlot();
|
|
57
|
-
const ttl = currentSlot
|
|
57
|
+
const ttl = getCardanoSendTtl(currentSlot);
|
|
58
58
|
const utxoInfo = keysignPayload.utxoInfo;
|
|
59
59
|
const balance = bigIntSum(utxoInfo.map(({ amount }) => amount));
|
|
60
60
|
const sendMaxAmount = amount ? balance === amount : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardano.js","sourceRoot":"","sources":["../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/cardano.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qEAAqE,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAChE,OAAO,EAAE,EAAE,EAAmB,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAA;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG/D,8DAA8D;AAC9D,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,eAAe,GA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G,mBAAmB,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACxF,MAAM,WAAW,GACf,eAAe,GAAG,MAAM,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;YACzG,eAAe,CAAA;QAEjB,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,OAAO,GAAG,WAAW,CAAA;IACvB,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAwC,KAAK,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,EAAE;IACnH,MAAM,MAAM,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAA;IAE/C,MAAM,WAAW,GAAG,MAAM,qBAAqB,EAAE,CAAA;IACjD,MAAM,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"cardano.js","sourceRoot":"","sources":["../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/cardano.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qEAAqE,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAChE,OAAO,EAAE,EAAE,EAAmB,MAAM,0BAA0B,CAA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BAAsB,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAA;IAEhG,OAAO,MAAM,CAAC,0BAA0B,EAAE;QACxC,GAAG;QACH,aAAa;QACb,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripple.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ripple.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAOtD,eAAO,MAAM,2BAA2B,GAAI,oBAAoB,MAAM,GAAG,SAAS,KAAG,MAMpF,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,wBAAwB,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ripple.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ripple.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAOtD,eAAO,MAAM,2BAA2B,GAAI,oBAAoB,MAAM,GAAG,SAAS,KAAG,MAMpF,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,wBAAwB,CAAC,gBAAgB,CA6G7E,CAAA"}
|
|
@@ -20,7 +20,7 @@ export const getRippleLastLedgerSequence = (ledgerCurrentIndex) => {
|
|
|
20
20
|
}
|
|
21
21
|
return BigInt(ledgerCurrentIndex + lastLedgerSequenceOffset);
|
|
22
22
|
};
|
|
23
|
-
export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, }) => {
|
|
23
|
+
export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, transactionType, }) => {
|
|
24
24
|
const coin = getKeysignCoin(keysignPayload);
|
|
25
25
|
const { address } = coin;
|
|
26
26
|
// A dApp-supplied transaction (OfferCreate, OfferCancel, …) carries no
|
|
@@ -32,6 +32,11 @@ export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, }
|
|
|
32
32
|
destinationTag,
|
|
33
33
|
memo: keysignPayload.memo,
|
|
34
34
|
});
|
|
35
|
+
// Preserve existing trust-line callers, but an ordinary send explicitly
|
|
36
|
+
// selects Payment: sending tokens back to their issuer is also a Payment.
|
|
37
|
+
const isTrustSet = transactionType === undefined
|
|
38
|
+
? originatesRippleTrustSet(keysignPayload)
|
|
39
|
+
: transactionType === TransactionType.RIPPLE_TRUST_SET;
|
|
35
40
|
const [senderAccount, networkInfo, destinationAccountResult] = await Promise.all([
|
|
36
41
|
getRippleAccountInfo(address),
|
|
37
42
|
getRippleNetworkInfo(),
|
|
@@ -54,7 +59,7 @@ export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, }
|
|
|
54
59
|
// XRP Ledger rejects a Payment to an account with lsfRequireDestTag when no
|
|
55
60
|
// tag is present. Fail closed on lookup errors other than an unfunded
|
|
56
61
|
// destination: without an account object there is no RequireDestTag flag.
|
|
57
|
-
if (toAddress && destinationAccountResult !== undefined && !
|
|
62
|
+
if (toAddress && destinationAccountResult !== undefined && !isTrustSet && effectiveDestinationTag === undefined) {
|
|
58
63
|
if ('error' in destinationAccountResult) {
|
|
59
64
|
if (!destinationUnfunded) {
|
|
60
65
|
// This lookup can fail transiently, so keep it retryable. Only
|
|
@@ -67,6 +72,10 @@ export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, }
|
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
if (destinationUnfunded) {
|
|
75
|
+
if (!keysignPayload.coin?.isNativeToken) {
|
|
76
|
+
throw new Error(`Cannot send an XRP issued currency to ${toAddress}: the destination account is not activated. ` +
|
|
77
|
+
'Activate it with the XRP base reserve before sending tokens.');
|
|
78
|
+
}
|
|
70
79
|
const toAmount = BigInt(shouldBePresent(keysignPayload.toAmount));
|
|
71
80
|
if (toAmount < BigInt(reserve_base)) {
|
|
72
81
|
throw new Error(`Cannot send to XRP account ${toAddress}: it is not yet activated, and XRPL requires the ` +
|
|
@@ -85,14 +94,17 @@ export const getRippleChainSpecific = async ({ keysignPayload, destinationTag, }
|
|
|
85
94
|
// Only genuine originations are declared. Stamping a token send would make
|
|
86
95
|
// every signer agree to build a TrustSet from it, which is worse than the
|
|
87
96
|
// divergence: the ceremony completes over an operation nobody asked for.
|
|
88
|
-
const isTrustSet = originatesRippleTrustSet(keysignPayload);
|
|
89
97
|
return create(RippleSpecificSchema, {
|
|
90
98
|
sequence: BigInt(account_data.Sequence),
|
|
91
99
|
lastLedgerSequence: getRippleLastLedgerSequence(ledgerCurrentIndex),
|
|
92
100
|
// Fee is the network fee only — the reserve rides on the Payment amount.
|
|
93
101
|
gas: networkFee,
|
|
94
102
|
...(effectiveDestinationTag !== undefined ? { destinationTag: effectiveDestinationTag } : {}),
|
|
95
|
-
...(isTrustSet
|
|
103
|
+
...(isTrustSet
|
|
104
|
+
? { transactionType: TransactionType.RIPPLE_TRUST_SET }
|
|
105
|
+
: transactionType === TransactionType.RIPPLE_PAYMENT
|
|
106
|
+
? { transactionType: TransactionType.RIPPLE_PAYMENT }
|
|
107
|
+
: {}),
|
|
96
108
|
});
|
|
97
109
|
};
|
|
98
110
|
//# sourceMappingURL=ripple.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ripple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AACtF,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,qEAAqE,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,SAAS,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CAAC,YAAY,CAAC,QAAQ,CAAC;QACvC,kBAAkB,EAAE,2BAA2B,CAAC,kBAAkB,CAAC;QACnE,yEAAyE;QACzE,GAAG,EAAE,UAAU;QACf,GAAG,CAAC,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7F,GAAG,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,gBAAgB,EAAE;YACvD,CAAC,CAAC,eAAe,KAAK,eAAe,CAAC,cAAc;gBAClD,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,cAAc,EAAE;gBACrD,CAAC,CAAC,EAAE,CAAC;KACV,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { GetChainSpecificResolver } from '../../resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the TON-specific keysign fields: the sender's seqno, an expiry, whether the
|
|
4
|
+
* transfer bounces on rejection, and — for Jettons — the sender's Jetton wallet and
|
|
5
|
+
* whether the destination is deployed. `sendMaxAmount` is recorded from the caller
|
|
6
|
+
* rather than inferred, so an ordinary send that happens to sit close to the balance is
|
|
7
|
+
* not relabelled a MAX send.
|
|
8
|
+
*/
|
|
2
9
|
export declare const getTonChainSpecific: GetChainSpecificResolver<'tonSpecific'>;
|
|
3
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ton/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ton/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAIzD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,wBAAwB,CAAC,aAAa,CAwFvE,CAAA"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { create } from '@bufbuild/protobuf';
|
|
2
2
|
import { getTonAccountInfo } from '@vultisig/core-chain/chains/ton/account/getTonAccountInfo';
|
|
3
|
+
import { getTonAddressBounceability } from '@vultisig/core-chain/chains/ton/address';
|
|
3
4
|
import { getJettonWalletAddress, getTonWalletState } from '@vultisig/core-chain/chains/ton/api';
|
|
4
|
-
import { getCoinBalance } from '@vultisig/core-chain/coin/balance';
|
|
5
5
|
import { TonSpecificSchema } from '@vultisig/core-mpc/types/vultisig/keysign/v1/blockchain_specific_pb';
|
|
6
6
|
import { attempt } from '@vultisig/lib-utils/attempt';
|
|
7
|
-
import {
|
|
8
|
-
import { getKeysignAmount } from '../../../utils/getKeysignAmount.js';
|
|
7
|
+
import { getKeysignSwapPayload } from '../../../swap/getKeysignSwapPayload.js';
|
|
9
8
|
import { getKeysignCoin } from '../../../utils/getKeysignCoin.js';
|
|
10
9
|
const tonWalletStateUninitialized = 'uninit';
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the TON-specific keysign fields: the sender's seqno, an expiry, whether the
|
|
12
|
+
* transfer bounces on rejection, and — for Jettons — the sender's Jetton wallet and
|
|
13
|
+
* whether the destination is deployed. `sendMaxAmount` is recorded from the caller
|
|
14
|
+
* rather than inferred, so an ordinary send that happens to sit close to the balance is
|
|
15
|
+
* not relabelled a MAX send.
|
|
16
|
+
*/
|
|
17
|
+
export const getTonChainSpecific = async ({ keysignPayload, sendMaxAmount = false, }) => {
|
|
12
18
|
const coin = getKeysignCoin(keysignPayload);
|
|
13
19
|
const { address } = coin;
|
|
14
20
|
const receiver = keysignPayload.toAddress;
|
|
@@ -23,42 +29,54 @@ export const getTonChainSpecific = async ({ keysignPayload }) => {
|
|
|
23
29
|
// than returning null and crashing this destructure.
|
|
24
30
|
const { account_state } = await getTonAccountInfo(address);
|
|
25
31
|
const sequenceNumber = BigInt(account_state?.seqno ?? 0);
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
// Whether the transfer goes out bounceable, which decides what happens to the funds
|
|
33
|
+
// when the destination rejects the message: a bounceable transfer is refunded, a
|
|
34
|
+
// non-bounceable one is absorbed by the destination and gone.
|
|
35
|
+
const getIsBounceable = async () => {
|
|
36
|
+
if (!receiver) {
|
|
28
37
|
return false;
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
}
|
|
39
|
+
// A swap deposit lands on a router or escrow contract, and there are ordinary
|
|
40
|
+
// reasons for such a contract to reject: an expired quote, a paused pool, a
|
|
41
|
+
// route that closed between quote and broadcast. Those have to come back.
|
|
42
|
+
if (getKeysignSwapPayload(keysignPayload)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// An undeployed account has no code to reject anything, so a bounceable message
|
|
46
|
+
// is simply returned and the transfer never lands. Those must go non-bounceable.
|
|
47
|
+
const { data: walletState } = await attempt(getTonWalletState(receiver));
|
|
48
|
+
if (walletState === tonWalletStateUninitialized) {
|
|
31
49
|
return false;
|
|
32
|
-
const balance = await getCoinBalance(coin);
|
|
33
|
-
const fee = getTonFeeAmount(coin);
|
|
34
|
-
return amount + fee >= balance;
|
|
35
|
-
};
|
|
36
|
-
const getIsBounceable = async () => {
|
|
37
|
-
if (receiver) {
|
|
38
|
-
const { data: walletState } = await attempt(getTonWalletState(receiver));
|
|
39
|
-
const isUninitialized = walletState === tonWalletStateUninitialized;
|
|
40
|
-
if (!isUninitialized && receiver.startsWith('E')) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
// A raw `0:hex` destination declares no intent, so it defaults to bounceable —
|
|
52
|
+
// the safe side for anything that might be a contract. Only an explicit `UQ…`
|
|
53
|
+
// opts out.
|
|
54
|
+
return getTonAddressBounceability(receiver) !== 'nonBounceable';
|
|
45
55
|
};
|
|
46
56
|
const result = create(TonSpecificSchema, {
|
|
47
57
|
sequenceNumber,
|
|
48
58
|
expireAt: BigInt(Math.floor(Date.now() / 1000) + 600),
|
|
49
59
|
bounceable: await getIsBounceable(),
|
|
50
|
-
sendMaxAmount
|
|
60
|
+
sendMaxAmount,
|
|
51
61
|
jettonAddress: '',
|
|
52
62
|
isActiveDestination: false,
|
|
53
63
|
});
|
|
54
64
|
if (coin.id) {
|
|
55
|
-
|
|
65
|
+
// A Jetton transfer is a message to the SENDER's own jetton wallet, so without
|
|
66
|
+
// that address there is no transaction to build. Leaving the empty-string default
|
|
67
|
+
// in place does not stop anything downstream — the signing path's presence check
|
|
68
|
+
// only rejects null/undefined — so a failed lookup would otherwise be signed as a
|
|
69
|
+
// transfer to nowhere. This lookup fails transiently (RPC timeout, indexer lag),
|
|
70
|
+
// so it stays a plain retryable Error rather than a BuildKeysignPayloadError.
|
|
71
|
+
const jettonWallet = await attempt(getJettonWalletAddress({
|
|
56
72
|
ownerAddress: address,
|
|
57
73
|
jettonMasterAddress: coin.id,
|
|
58
74
|
}));
|
|
59
|
-
if (jettonWallet) {
|
|
60
|
-
|
|
75
|
+
if ('error' in jettonWallet || !jettonWallet.data.trim()) {
|
|
76
|
+
throw new Error(`Unable to resolve the ${coin.ticker} jetton wallet owned by ${address}. ` +
|
|
77
|
+
'Refusing to build a Jetton transfer without it.', 'error' in jettonWallet ? { cause: jettonWallet.error } : undefined);
|
|
61
78
|
}
|
|
79
|
+
result.jettonAddress = jettonWallet.data;
|
|
62
80
|
if (receiver) {
|
|
63
81
|
const { data: destWalletState } = await attempt(getTonWalletState(receiver));
|
|
64
82
|
result.isActiveDestination = destWalletState !== tonWalletStateUninitialized;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2DAA2D,CAAA;AAC7F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/ton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2DAA2D,CAAA;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACpF,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qEAAqE,CAAA;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAErD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAG9D,MAAM,2BAA2B,GAAG,QAAQ,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA4C,KAAK,EAAE,EACjF,cAAc,EACd,aAAa,GAAG,KAAK,GACtB,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,cAAc,CAAC,cAAc,CAAC,CAAA;IAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IACxB,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAA;IAEzC,8EAA8E;IAC9E,4EAA4E;IAC5E,+EAA+E;IAC/E,8EAA8E;IAC9E,yEAAyE;IACzE,gEAAgE;IAChE,+EAA+E;IAC/E,6EAA6E;IAC7E,qDAAqD;IACrD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAC1D,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,EAAE,KAAK,IAAI,CAAC,CAAC,CAAA;IAExD,oFAAoF;IAC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AC,IAAI,EAAE,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CACb,yBAAyB,IAAI,CAAC,MAAM,2BAA2B,OAAO,IAAI;gBACxE,iDAAiD,EACnD,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CACpE,CAAA;QACH,CAAC;QAED,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC,IAAI,CAAA;QAExC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAA;YAC5E,MAAM,CAAC,mBAAmB,GAAG,eAAe,KAAK,2BAA2B,CAAA;QAC9E,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { getTronBlockInfo } from '@vultisig/core-chain/chains/tron/getTronBlockInfo';
|
|
2
|
+
import { type WalletCore } from '@trustwallet/wallet-core';
|
|
1
3
|
import { GetChainSpecificResolver } from '../../resolver.js';
|
|
4
|
+
type NativeTronBandwidthInput = {
|
|
5
|
+
walletCore: WalletCore;
|
|
6
|
+
fromAddress: string;
|
|
7
|
+
toAddress: string;
|
|
8
|
+
amount: bigint;
|
|
9
|
+
memo: string;
|
|
10
|
+
blockInfo: Awaited<ReturnType<typeof getTronBlockInfo>>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* TRON charges bandwidth for the serialized signed transaction, not for a
|
|
14
|
+
* fixed transfer template. WalletCore exposes the exact raw_data bytes through
|
|
15
|
+
* its pre-signing output; the remaining signed envelope consists of the
|
|
16
|
+
* length-delimited raw_data field and one 65-byte secp256k1 signature.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getNativeTronBandwidthBytes: ({ walletCore, fromAddress, toAddress, amount, memo, blockInfo, }: NativeTronBandwidthInput) => number;
|
|
2
19
|
export declare const getTronChainSpecific: GetChainSpecificResolver<'tronSpecific'>;
|
|
20
|
+
export {};
|
|
3
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/tron/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/tron/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AAKpF,OAAO,EAAM,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAK9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AA0BzD,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAA;CACxD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,kEAOzC,wBAAwB,KAAG,MAqC7B,CAAA;AAgBD,eAAO,MAAM,oBAAoB,EAAE,wBAAwB,CAAC,cAAc,CAmDzE,CAAA"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
import { create } from '@bufbuild/protobuf';
|
|
2
3
|
import { getTronBlockInfo } from '@vultisig/core-chain/chains/tron/getTronBlockInfo';
|
|
3
4
|
import { getTronAccountResources } from '@vultisig/core-chain/chains/tron/resources/getTronAccountResources';
|
|
4
5
|
import { isFeeCoin } from '@vultisig/core-chain/coin/utils/isFeeCoin';
|
|
5
6
|
import { TronSpecificSchema } from '@vultisig/core-mpc/types/vultisig/keysign/v1/blockchain_specific_pb';
|
|
7
|
+
import { shouldBePresent } from '@vultisig/lib-utils/assert/shouldBePresent';
|
|
8
|
+
import { TW } from '@trustwallet/wallet-core';
|
|
9
|
+
import Long from 'long';
|
|
6
10
|
import { getKeysignAmount } from '../../../utils/getKeysignAmount.js';
|
|
7
11
|
import { getKeysignCoin } from '../../../utils/getKeysignCoin.js';
|
|
8
12
|
import { getTrc20TransferFee } from './fee.js';
|
|
@@ -11,12 +15,60 @@ import { getTrc20TransferFee } from './fee.js';
|
|
|
11
15
|
// sun. 800_000n keeps the pre-existing margin (~2.4× the median signed size)
|
|
12
16
|
// and guards against governance-driven bandwidth price hikes.
|
|
13
17
|
const NATIVE_TRX_SEND_FEE_FALLBACK = 800000n;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const TRON_SIGNATURE_BYTES = 65;
|
|
19
|
+
// java-tron charges one 64-byte transaction-result allowance per contract in
|
|
20
|
+
// addition to the serialized signed transaction bytes. A native transfer has
|
|
21
|
+
// exactly one contract.
|
|
22
|
+
const TRON_TRANSACTION_RESULT_BYTES = 64;
|
|
23
|
+
const getProtoVarintSize = (value) => {
|
|
24
|
+
let size = 1;
|
|
25
|
+
while (value >= 128) {
|
|
26
|
+
value = Math.floor(value / 128);
|
|
27
|
+
size += 1;
|
|
28
|
+
}
|
|
29
|
+
return size;
|
|
30
|
+
};
|
|
31
|
+
const getLengthDelimitedFieldSize = (valueSize) => 1 + getProtoVarintSize(valueSize) + valueSize;
|
|
32
|
+
/**
|
|
33
|
+
* TRON charges bandwidth for the serialized signed transaction, not for a
|
|
34
|
+
* fixed transfer template. WalletCore exposes the exact raw_data bytes through
|
|
35
|
+
* its pre-signing output; the remaining signed envelope consists of the
|
|
36
|
+
* length-delimited raw_data field and one 65-byte secp256k1 signature.
|
|
37
|
+
*/
|
|
38
|
+
export const getNativeTronBandwidthBytes = ({ walletCore, fromAddress, toAddress, amount, memo, blockInfo, }) => {
|
|
39
|
+
const signingInput = TW.Tron.Proto.SigningInput.create({
|
|
40
|
+
transaction: TW.Tron.Proto.Transaction.create({
|
|
41
|
+
transfer: TW.Tron.Proto.TransferContract.create({
|
|
42
|
+
ownerAddress: fromAddress,
|
|
43
|
+
toAddress,
|
|
44
|
+
amount: Long.fromString(amount.toString()),
|
|
45
|
+
}),
|
|
46
|
+
timestamp: Long.fromNumber(blockInfo.timestamp),
|
|
47
|
+
expiration: Long.fromNumber(blockInfo.expiration),
|
|
48
|
+
blockHeader: TW.Tron.Proto.BlockHeader.create({
|
|
49
|
+
timestamp: Long.fromNumber(blockInfo.blockHeaderTimestamp),
|
|
50
|
+
number: Long.fromNumber(blockInfo.blockHeaderNumber),
|
|
51
|
+
version: blockInfo.blockHeaderVersion,
|
|
52
|
+
txTrieRoot: Buffer.from(blockInfo.blockHeaderTxTrieRoot, 'hex'),
|
|
53
|
+
parentHash: Buffer.from(blockInfo.blockHeaderParentHash, 'hex'),
|
|
54
|
+
witnessAddress: Buffer.from(blockInfo.blockHeaderWitnessAddress, 'hex'),
|
|
55
|
+
}),
|
|
56
|
+
memo,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
const preSigningOutput = TW.TxCompiler.Proto.PreSigningOutput.decode(walletCore.TransactionCompiler.preImageHashes(walletCore.CoinType.tron, TW.Tron.Proto.SigningInput.encode(signingInput).finish()));
|
|
60
|
+
if (preSigningOutput.errorMessage) {
|
|
61
|
+
throw new Error(preSigningOutput.errorMessage);
|
|
62
|
+
}
|
|
63
|
+
return (getLengthDelimitedFieldSize(preSigningOutput.data.length) +
|
|
64
|
+
getLengthDelimitedFieldSize(TRON_SIGNATURE_BYTES) +
|
|
65
|
+
TRON_TRANSACTION_RESULT_BYTES);
|
|
66
|
+
};
|
|
67
|
+
const getNativeTronSendFee = async (input) => {
|
|
17
68
|
try {
|
|
18
|
-
const
|
|
19
|
-
|
|
69
|
+
const requiredBandwidth = getNativeTronBandwidthBytes(input);
|
|
70
|
+
const resources = await getTronAccountResources(input.fromAddress);
|
|
71
|
+
if (resources.bandwidth.available >= requiredBandwidth) {
|
|
20
72
|
return 0n;
|
|
21
73
|
}
|
|
22
74
|
return NATIVE_TRX_SEND_FEE_FALLBACK;
|
|
@@ -26,7 +78,7 @@ const getNativeTronSendFee = async (fromAddress) => {
|
|
|
26
78
|
return NATIVE_TRX_SEND_FEE_FALLBACK;
|
|
27
79
|
}
|
|
28
80
|
};
|
|
29
|
-
export const getTronChainSpecific = async ({ keysignPayload, thirdPartyGasLimitEstimation, expiration, timestamp, refBlockBytesHex, refBlockHashHex, }) => {
|
|
81
|
+
export const getTronChainSpecific = async ({ keysignPayload, walletCore, thirdPartyGasLimitEstimation, expiration, timestamp, refBlockBytesHex, refBlockHashHex, }) => {
|
|
30
82
|
const coin = getKeysignCoin(keysignPayload);
|
|
31
83
|
const blockInfo = await getTronBlockInfo({
|
|
32
84
|
expiration,
|
|
@@ -39,7 +91,14 @@ export const getTronChainSpecific = async ({ keysignPayload, thirdPartyGasLimitE
|
|
|
39
91
|
return thirdPartyGasLimitEstimation;
|
|
40
92
|
}
|
|
41
93
|
if (isFeeCoin(coin)) {
|
|
42
|
-
return getNativeTronSendFee(
|
|
94
|
+
return getNativeTronSendFee({
|
|
95
|
+
walletCore,
|
|
96
|
+
fromAddress: shouldBePresent(coin.address),
|
|
97
|
+
toAddress: shouldBePresent(keysignPayload.toAddress),
|
|
98
|
+
amount: getKeysignAmount(keysignPayload),
|
|
99
|
+
memo: keysignPayload.memo ?? '',
|
|
100
|
+
blockInfo,
|
|
101
|
+
});
|
|
43
102
|
}
|
|
44
103
|
return getTrc20TransferFee({
|
|
45
104
|
coin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/core/mpc/keysign/chainSpecific/resolvers/tron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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C,SAAS,CAAC,iBAAiB,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACxD,qBAAqB,EAAE,SAAS,CAAC,qBAAqB;QACtD,qBAAqB,EAAE,SAAS,CAAC,qBAAqB;QACtD,yBAAyB,EAAE,SAAS,CAAC,yBAAyB;QAC9D,aAAa,EAAE,MAAM,gBAAgB,EAAE;KACxC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/keysign/error.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type BuildKeysignPayloadErrorType = 'not-enough-funds' | 'ripple-destination-tag-invalid' | 'ripple-destination-tag-required';
|
|
1
|
+
export type BuildKeysignPayloadErrorType = 'not-enough-funds' | 'ripple-destination-tag-invalid' | 'ripple-destination-tag-required' | 'ton-memo-too-long';
|
|
2
2
|
export declare class BuildKeysignPayloadError extends Error {
|
|
3
3
|
readonly type: BuildKeysignPayloadErrorType;
|
|
4
4
|
constructor(type: BuildKeysignPayloadErrorType, message?: string);
|