@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/chains/cardano/cip30/buildCoseStructures.d.ts +1 -1
  3. package/dist/chains/cardano/cip30/buildCoseStructures.js +2 -2
  4. package/dist/chains/cardano/cip30/buildCoseStructures.js.map +1 -1
  5. package/dist/chains/cardano/config.d.ts +31 -0
  6. package/dist/chains/cardano/config.d.ts.map +1 -1
  7. package/dist/chains/cardano/config.js +31 -0
  8. package/dist/chains/cardano/config.js.map +1 -1
  9. package/dist/chains/cosmos/cosmosHrp.d.ts +39 -0
  10. package/dist/chains/cosmos/cosmosHrp.d.ts.map +1 -0
  11. package/dist/chains/cosmos/cosmosHrp.js +65 -0
  12. package/dist/chains/cosmos/cosmosHrp.js.map +1 -0
  13. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts +1 -1
  14. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts.map +1 -1
  15. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js +1 -1
  16. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js.map +1 -1
  17. package/dist/security/tokenTransferGuards.d.ts +78 -0
  18. package/dist/security/tokenTransferGuards.d.ts.map +1 -0
  19. package/dist/security/tokenTransferGuards.js +203 -0
  20. package/dist/security/tokenTransferGuards.js.map +1 -0
  21. package/dist/swap/general/GeneralSwapProvider.d.ts +1 -1
  22. package/dist/swap/general/GeneralSwapProvider.d.ts.map +1 -1
  23. package/dist/swap/general/GeneralSwapProvider.js +2 -1
  24. package/dist/swap/general/GeneralSwapProvider.js.map +1 -1
  25. package/dist/swap/general/GeneralSwapQuote.d.ts +13 -1
  26. package/dist/swap/general/GeneralSwapQuote.d.ts.map +1 -1
  27. package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.d.ts +12 -0
  28. package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.d.ts.map +1 -0
  29. package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.js +136 -0
  30. package/dist/swap/general/ruji/api/getRujiTradeSwapQuote.js.map +1 -0
  31. package/dist/swap/general/ruji/config.d.ts +16 -0
  32. package/dist/swap/general/ruji/config.d.ts.map +1 -0
  33. package/dist/swap/general/ruji/config.js +19 -0
  34. package/dist/swap/general/ruji/config.js.map +1 -0
  35. package/dist/swap/keysign/getSwapDestinationAddress.d.ts.map +1 -1
  36. package/dist/swap/keysign/getSwapDestinationAddress.js +1 -0
  37. package/dist/swap/keysign/getSwapDestinationAddress.js.map +1 -1
  38. package/dist/swap/quote/SwapQuote.d.ts +2 -0
  39. package/dist/swap/quote/SwapQuote.d.ts.map +1 -1
  40. package/dist/swap/quote/findSwapQuote.d.ts +4 -4
  41. package/dist/swap/quote/findSwapQuote.d.ts.map +1 -1
  42. package/dist/swap/quote/findSwapQuote.js +153 -19
  43. package/dist/swap/quote/findSwapQuote.js.map +1 -1
  44. package/dist/swap/quote/getSwapQuoteSafetyFingerprint.d.ts +2 -1
  45. package/dist/swap/quote/getSwapQuoteSafetyFingerprint.d.ts.map +1 -1
  46. package/dist/swap/quote/getSwapQuoteSafetyFingerprint.js +2 -1
  47. package/dist/swap/quote/getSwapQuoteSafetyFingerprint.js.map +1 -1
  48. package/dist/swap/swapEnabledChains.d.ts.map +1 -1
  49. package/dist/swap/swapEnabledChains.js +2 -0
  50. package/dist/swap/swapEnabledChains.js.map +1 -1
  51. package/dist/swap/utils/getSwapExplorerUrl/index.d.ts +2 -2
  52. package/dist/swap/utils/getSwapExplorerUrl/index.d.ts.map +1 -1
  53. package/dist/swap/utils/getSwapExplorerUrl/index.js +2 -1
  54. package/dist/swap/utils/getSwapExplorerUrl/index.js.map +1 -1
  55. package/dist/tx/status/resolvers/ton.d.ts +6 -0
  56. package/dist/tx/status/resolvers/ton.d.ts.map +1 -1
  57. package/dist/tx/status/resolvers/ton.js +39 -10
  58. package/dist/tx/status/resolvers/ton.js.map +1 -1
  59. package/package.json +22 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @vultisig/core-chain
2
2
 
3
+ ## 4.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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.
8
+
9
+ - [#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
10
+
11
+ 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.
12
+
13
+ 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.
14
+
15
+ 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.
16
+
17
+ - [#2093](https://github.com/vultisig/vultisig-sdk/pull/2093) [`bfe0292`](https://github.com/vultisig/vultisig-sdk/commit/bfe0292e3876fb7acc7044bac1b544c27aba8919) Thanks [@gomesalexandre](https://github.com/gomesalexandre)! - Publishes token-transfer / ERC-20-calldata destination safety helpers alongside the existing burn-address guard (`assertSafeDestination`): `assertSafeTokenTransferDestination` (rejects a transfer whose recipient is itself a known token contract — not just its own, any registered token's), `isErc20TransferCalldata`, `decodeErc20Recipient`, `decodeErc20Approve`, and `decodeErc20RecipientFromSig`, all re-exported from `@vultisig/sdk`. Previously only `agent-backend-ts` had this guard family as a private fork; `packages/sdk/src/tools/prep/send.ts`'s inline own-token-contract check is now additionally backed by the registry-based guard (catching sends to a _different_ known token's contract, on top of the existing unconditional self-contract check).
18
+
19
+ - [#2092](https://github.com/vultisig/vultisig-sdk/pull/2092) [`acd0b2e`](https://github.com/vultisig/vultisig-sdk/commit/acd0b2eaa882669a399fb378e51244ed4199ee47) Thanks [@gomesalexandre](https://github.com/gomesalexandre)! - Consolidates four independently-maintained, overlapping Cosmos-family bech32 HRP tables — `tools/cosmos/gov.ts`'s `CHAIN_HRP`, `tools/prep/ibcTransfer.ts`'s `IBC_CHAIN_HRP`, `tools/swap/skip/skipSwap.ts`'s `COSMOS_CHAIN_HRPS`, and `tools/token/resolveContract.ts`'s `CW20_CHAIN_PREFIX` — into a single canonical registry, `COSMOS_CHAIN_ID_HRP`/`getCosmosChainHrp` (`@vultisig/core-chain/chains/cosmos/cosmosHrp`). All four consumers now derive their HRP checks from the same source instead of hand-maintained local copies that could drift from each other. As a side effect, Skip swap address validation now also HRP-checks four chain-ids (`axelar-dojo-1`, `juno-1`, `stargaze-1`, `akashnet-2`) it previously had no entry for and silently skipped — strictly safer, not a behavior change for any chain that was already validated. Deliberately does not touch `utils/addressFormat.ts`'s separate `cosmosHRPByChain`/`cosmosValoperByChain` tables, which are keyed by a different (lowercase chain-tag) space and ported 1:1 from a Go reference for cross-language parity.
20
+
21
+ - Updated dependencies [[`c0eafeb`](https://github.com/vultisig/vultisig-sdk/commit/c0eafeb12df42cffa70ef6951c081a74383e5fa2)]:
22
+ - @vultisig/mpc-types@0.3.0
23
+
24
+ ## 4.1.0
25
+
26
+ ### Minor Changes
27
+
28
+ - [#2234](https://github.com/vultisig/vultisig-sdk/pull/2234) [`0697060`](https://github.com/vultisig/vultisig-sdk/commit/0697060107c7fe1c8ec818d3e0eae01557d9d96f) Thanks [@rcoderdev](https://github.com/rcoderdev)! - Add RUJI Trade quoting and CosmWasm execution for native RUNE and bRUNE swaps through the SDK's normal swap flow.
29
+
30
+ ### Patch Changes
31
+
32
+ - [#2235](https://github.com/vultisig/vultisig-sdk/pull/2235) [`3fff7cf`](https://github.com/vultisig/vultisig-sdk/commit/3fff7cfdfe23d2d5622f7caa87a6f1525329f07e) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(swap): stop reporting a native trading halt when an aggregator could still fill
33
+
34
+ `findSwapQuotes` collapsed a THORChain/MayaChain halt plus a transient aggregator failure into `TradingHalted` for the whole pair, so an ETH→SOL quote surfaced "trading halted" whenever LiFi/SwapKit happened to time out. A halt is scoped to the native protocol that raised it: those aggregators now get one automatic re-attempt, and when they are still unreachable the error reports the transient failure instead of a halt the user cannot retry out of. Halt-only pairs still throw `TradingHalted`.
35
+
3
36
  ## 4.0.1
4
37
 
5
38
  ### Patch Changes
@@ -15,7 +15,7 @@ type BuildCoseSign1Input = {
15
15
  /**
16
16
  * Build and return the full COSE_Sign1 CBOR:
17
17
  *
18
- * [protected: bstr, unprotected: {}, payload: bstr, signature: bstr]
18
+ * [protected: bstr, unprotected: { "hashed": false }, payload: bstr, signature: bstr]
19
19
  *
20
20
  * Also returns the `protectedSerialized` bytes needed to compute the
21
21
  * Sig_structure before signing.
@@ -32,7 +32,7 @@ export const buildSigStructure = (protectedBytes, payload) => cborArray([
32
32
  /**
33
33
  * Build and return the full COSE_Sign1 CBOR:
34
34
  *
35
- * [protected: bstr, unprotected: {}, payload: bstr, signature: bstr]
35
+ * [protected: bstr, unprotected: { "hashed": false }, payload: bstr, signature: bstr]
36
36
  *
37
37
  * Also returns the `protectedSerialized` bytes needed to compute the
38
38
  * Sig_structure before signing.
@@ -41,7 +41,7 @@ export const buildCoseSign1 = ({ addressBytes, payload, signature }) => {
41
41
  const protectedSerialized = buildProtectedHeaders(addressBytes);
42
42
  return cborArray([
43
43
  cborBytes(protectedSerialized),
44
- cborMap([]), // empty unprotected headers
44
+ cborMap([[cborText('hashed'), Uint8Array.of(0xf4)]]), // `false` per RFC 8949 §3.3
45
45
  cborBytes(payload),
46
46
  cborBytes(signature),
47
47
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"buildCoseStructures.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/cardano/cip30/buildCoseStructures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvG;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,CAAC,YAAwB,EAAc,EAAE,CACrE,OAAO,CAAC;IACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC,CAAA;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,cAA0B,EAAE,OAAmB,EAAc,EAAE,CAC/F,SAAS,CAAC;IACR,QAAQ,CAAC,YAAY,CAAC;IACtB,SAAS,CAAC,cAAc,CAAC;IACzB,SAAS,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,qBAAqB;IACnD,SAAS,CAAC,OAAO,CAAC;CACnB,CAAC,CAAA;AAWJ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAuB,EAAc,EAAE;IACtG,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAA;IAC/D,OAAO,SAAS,CAAC;QACf,SAAS,CAAC,mBAAmB,CAAC;QAC9B,OAAO,CAAC,EAAE,CAAC,EAAE,4BAA4B;QACzC,SAAS,CAAC,OAAO,CAAC;QAClB,SAAS,CAAC,SAAS,CAAC;KACrB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,YAAwB,EAAc,EAAE,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAA;AAOtH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,SAAS,EAAqB,EAAc,EAAE,CAC3E,OAAO,CAAC;IACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC,CAAA"}
1
+ {"version":3,"file":"buildCoseStructures.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/cardano/cip30/buildCoseStructures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvG;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,CAAC,YAAwB,EAAc,EAAE,CACrE,OAAO,CAAC;IACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,YAAY,CA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5B,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC,CAAA"}
@@ -1,4 +1,35 @@
1
+ /**
2
+ * Slots added to the current tip to produce a Cardano transaction's TTL.
3
+ *
4
+ * Cardano slots are 1 second, so this is the window during which a built
5
+ * transaction stays valid; past it the node rejects it outright. Read together
6
+ * with {@link cardanoBroadcastTtlSafetyMargin}: the usable window for a signing
7
+ * ceremony is `cardanoSlotOffset - cardanoBroadcastTtlSafetyMargin` seconds,
8
+ * because broadcast refuses anything closer to expiry than the margin.
9
+ *
10
+ * Do not read this constant directly to build a TTL - call
11
+ * {@link getCardanoSendTtl}, so every consumer applies one policy instead of
12
+ * re-deriving it from the raw number.
13
+ */
1
14
  export declare const cardanoSlotOffset = 720;
2
15
  export declare const cardanoDefaultFee = 180000n;
16
+ /**
17
+ * How close to its TTL a Cardano transaction may get before broadcast refuses
18
+ * it. Guards against signing a transaction that expires in flight, which would
19
+ * otherwise surface as an opaque node rejection after the ceremony completed.
20
+ */
3
21
  export declare const cardanoBroadcastTtlSafetyMargin = 60;
22
+ /**
23
+ * The canonical TTL for a Cardano transaction built against `currentSlot`.
24
+ *
25
+ * This is protocol policy, not a per-caller choice: a transaction's validity
26
+ * window has to agree across every consumer that builds, signs or broadcasts
27
+ * one. When a consumer re-derives it locally the two silently diverge, and the
28
+ * same send stays valid for a different length of time depending on which code
29
+ * path produced it - while the broadcast-time freshness guard keeps using this
30
+ * side's numbers to judge it.
31
+ *
32
+ * @param currentSlot - the chain tip the transaction is being built against
33
+ */
34
+ export declare const getCardanoSendTtl: (currentSlot: bigint) => bigint;
4
35
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cardano/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,MAAM,CAAA;AACpC,eAAO,MAAM,iBAAiB,UAAU,CAAA;AACxC,eAAO,MAAM,+BAA+B,KAAK,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cardano/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,iBAAiB,UAAU,CAAA;AAExC;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,MAAiD,CAAA"}
@@ -1,4 +1,35 @@
1
+ /**
2
+ * Slots added to the current tip to produce a Cardano transaction's TTL.
3
+ *
4
+ * Cardano slots are 1 second, so this is the window during which a built
5
+ * transaction stays valid; past it the node rejects it outright. Read together
6
+ * with {@link cardanoBroadcastTtlSafetyMargin}: the usable window for a signing
7
+ * ceremony is `cardanoSlotOffset - cardanoBroadcastTtlSafetyMargin` seconds,
8
+ * because broadcast refuses anything closer to expiry than the margin.
9
+ *
10
+ * Do not read this constant directly to build a TTL - call
11
+ * {@link getCardanoSendTtl}, so every consumer applies one policy instead of
12
+ * re-deriving it from the raw number.
13
+ */
1
14
  export const cardanoSlotOffset = 720;
2
15
  export const cardanoDefaultFee = 180000n;
16
+ /**
17
+ * How close to its TTL a Cardano transaction may get before broadcast refuses
18
+ * it. Guards against signing a transaction that expires in flight, which would
19
+ * otherwise surface as an opaque node rejection after the ceremony completed.
20
+ */
3
21
  export const cardanoBroadcastTtlSafetyMargin = 60;
22
+ /**
23
+ * The canonical TTL for a Cardano transaction built against `currentSlot`.
24
+ *
25
+ * This is protocol policy, not a per-caller choice: a transaction's validity
26
+ * window has to agree across every consumer that builds, signs or broadcasts
27
+ * one. When a consumer re-derives it locally the two silently diverge, and the
28
+ * same send stays valid for a different length of time depending on which code
29
+ * path produced it - while the broadcast-time freshness guard keeps using this
30
+ * side's numbers to judge it.
31
+ *
32
+ * @param currentSlot - the chain tip the transaction is being built against
33
+ */
34
+ export const getCardanoSendTtl = (currentSlot) => currentSlot + BigInt(cardanoSlotOffset);
4
35
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cardano/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACxC,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAA"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cardano/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAEpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { CosmosChain } from '../../Chain.js';
2
+ /**
3
+ * Canonical Cosmos-family bech32 HRP (human-readable prefix), keyed by
4
+ * CHAIN-ID rather than the SDK `Chain` enum, so it covers both:
5
+ *
6
+ * - every first-class Vultisig-supported Cosmos chain (`CosmosChain`,
7
+ * resolvable to an HRP via `getCosmosChainHrp` below), and
8
+ * - IBC/Skip DESTINATION chains that are valid transfer/swap targets but
9
+ * have no wallet/RPC support of their own (e.g. `neutron-1`, `juno-1`,
10
+ * `stargaze-1`) — these have no `CosmosChain` member to key by.
11
+ *
12
+ * Consolidates what were four independently-maintained, overlapping copies
13
+ * (architecture#1787): `tools/cosmos/gov.ts`'s `CHAIN_HRP`, `tools/prep/
14
+ * ibcTransfer.ts`'s `IBC_CHAIN_HRP`, `tools/swap/skip/skipSwap.ts`'s
15
+ * `COSMOS_CHAIN_HRPS`, and `tools/token/resolveContract.ts`'s
16
+ * `CW20_CHAIN_PREFIX`. Every entry below was cross-checked against all four
17
+ * source tables for the chains they had in common — no value differs across
18
+ * copies, so this union is a lossless merge, not a judgment call on which
19
+ * source wins.
20
+ *
21
+ * Deliberately does NOT absorb `utils/addressFormat.ts`'s `cosmosHRPByChain`
22
+ * / `cosmosValoperByChain` — those are keyed by a THIRD, different space
23
+ * (lowercase "canonical chain tag", not chain-id or `Chain` enum), ported
24
+ * 1:1 from a Go reference (`chain_prefix_extractor.go`) for cross-language
25
+ * parity, and cover additional chains (sei, kava, persistence, secret,
26
+ * crescent, qbtc) this registry has no chain-id for. Forcing that table
27
+ * through this one would risk silently breaking Go parity for no
28
+ * consolidation benefit — a real, but separately-scoped, follow-up.
29
+ */
30
+ export declare const COSMOS_CHAIN_ID_HRP: Record<string, string>;
31
+ /**
32
+ * Resolve the bech32 HRP for a first-class Vultisig `CosmosChain`. Throws on
33
+ * a registry gap (a `CosmosChain` member with no HRP entry above) rather
34
+ * than returning `undefined` — that's a bug in this file, not a caller
35
+ * error, and failing loudly here beats a confusing downstream 404/wrong-HRP
36
+ * address match.
37
+ */
38
+ export declare function getCosmosChainHrp(chain: CosmosChain): string;
39
+ //# sourceMappingURL=cosmosHrp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosmosHrp.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosHrp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAmBtD,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAO5D"}
@@ -0,0 +1,65 @@
1
+ import { getCosmosChainId } from './chainInfo.js';
2
+ /**
3
+ * Canonical Cosmos-family bech32 HRP (human-readable prefix), keyed by
4
+ * CHAIN-ID rather than the SDK `Chain` enum, so it covers both:
5
+ *
6
+ * - every first-class Vultisig-supported Cosmos chain (`CosmosChain`,
7
+ * resolvable to an HRP via `getCosmosChainHrp` below), and
8
+ * - IBC/Skip DESTINATION chains that are valid transfer/swap targets but
9
+ * have no wallet/RPC support of their own (e.g. `neutron-1`, `juno-1`,
10
+ * `stargaze-1`) — these have no `CosmosChain` member to key by.
11
+ *
12
+ * Consolidates what were four independently-maintained, overlapping copies
13
+ * (architecture#1787): `tools/cosmos/gov.ts`'s `CHAIN_HRP`, `tools/prep/
14
+ * ibcTransfer.ts`'s `IBC_CHAIN_HRP`, `tools/swap/skip/skipSwap.ts`'s
15
+ * `COSMOS_CHAIN_HRPS`, and `tools/token/resolveContract.ts`'s
16
+ * `CW20_CHAIN_PREFIX`. Every entry below was cross-checked against all four
17
+ * source tables for the chains they had in common — no value differs across
18
+ * copies, so this union is a lossless merge, not a judgment call on which
19
+ * source wins.
20
+ *
21
+ * Deliberately does NOT absorb `utils/addressFormat.ts`'s `cosmosHRPByChain`
22
+ * / `cosmosValoperByChain` — those are keyed by a THIRD, different space
23
+ * (lowercase "canonical chain tag", not chain-id or `Chain` enum), ported
24
+ * 1:1 from a Go reference (`chain_prefix_extractor.go`) for cross-language
25
+ * parity, and cover additional chains (sei, kava, persistence, secret,
26
+ * crescent, qbtc) this registry has no chain-id for. Forcing that table
27
+ * through this one would risk silently breaking Go parity for no
28
+ * consolidation benefit — a real, but separately-scoped, follow-up.
29
+ */
30
+ export const COSMOS_CHAIN_ID_HRP = {
31
+ 'phoenix-1': 'terra',
32
+ 'columbus-5': 'terra',
33
+ 'cosmoshub-4': 'cosmos',
34
+ 'osmosis-1': 'osmo',
35
+ 'kaiyo-1': 'kujira',
36
+ 'neutron-1': 'neutron',
37
+ 'axelar-dojo-1': 'axelar',
38
+ 'injective-1': 'inj',
39
+ 'juno-1': 'juno',
40
+ 'stargaze-1': 'stars',
41
+ 'noble-1': 'noble',
42
+ 'akashnet-2': 'akash',
43
+ 'dydx-mainnet-1': 'dydx',
44
+ 'stride-1': 'stride',
45
+ celestia: 'celestia',
46
+ 'thorchain-1': 'thor',
47
+ 'mayachain-mainnet-v1': 'maya',
48
+ 'agoric-3': 'agoric',
49
+ };
50
+ /**
51
+ * Resolve the bech32 HRP for a first-class Vultisig `CosmosChain`. Throws on
52
+ * a registry gap (a `CosmosChain` member with no HRP entry above) rather
53
+ * than returning `undefined` — that's a bug in this file, not a caller
54
+ * error, and failing loudly here beats a confusing downstream 404/wrong-HRP
55
+ * address match.
56
+ */
57
+ export function getCosmosChainHrp(chain) {
58
+ const chainId = getCosmosChainId(chain);
59
+ const hrp = COSMOS_CHAIN_ID_HRP[chainId];
60
+ if (!hrp) {
61
+ throw new Error(`getCosmosChainHrp: no HRP registered for ${chain} (chainId ${chainId})`);
62
+ }
63
+ return hrp;
64
+ }
65
+ //# sourceMappingURL=cosmosHrp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosmosHrp.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosHrp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,QAAQ;IACnB,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,QAAQ;IACzB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,OAAO;IACrB,SAAS,EAAE,OAAO;IAClB,YAAY,EAAE,OAAO;IACrB,gBAAgB,EAAE,MAAM;IACxB,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,MAAM;IACrB,sBAAsB,EAAE,MAAM;IAC9B,UAAU,EAAE,QAAQ;CACrB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IAClD,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACxC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,4CAA4C,KAAK,aAAa,OAAO,GAAG,CAAC,CAAA;IAC3F,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { SignBitcoin } from '@vultisig/core-mpc/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
1
+ import { SignBitcoin } from '@vultisig/mpc-types/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
2
2
  import { Network, Psbt } from 'bitcoinjs-lib';
3
3
  type BuildSignBitcoinFromPsbtInput = {
4
4
  psbt: Psbt;
@@ -1 +1 @@
1
- {"version":3,"file":"buildSignBitcoinFromPsbt.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEZ,MAAM,+EAA+E,CAAA;AACtF,OAAO,EAAyB,OAAO,EAAqB,IAAI,EAAkC,MAAM,eAAe,CAAA;AAiEvH,KAAK,6BAA6B,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,mCAItC,6BAA6B,KAAG,WA8HlC,CAAA"}
1
+ {"version":3,"file":"buildSignBitcoinFromPsbt.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEZ,MAAM,gFAAgF,CAAA;AACvF,OAAO,EAAyB,OAAO,EAAqB,IAAI,EAAkC,MAAM,eAAe,CAAA;AAiEvH,KAAK,6BAA6B,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,mCAItC,6BAA6B,KAAG,WA8HlC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { create } from '@bufbuild/protobuf';
2
- import { BitcoinInputSchema, BitcoinOutputSchema, SignBitcoinSchema, } from '@vultisig/core-mpc/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
2
+ import { BitcoinInputSchema, BitcoinOutputSchema, SignBitcoinSchema, } from '@vultisig/mpc-types/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
3
3
  import { address as btcAddress, networks, opcodes, script as bscript, Transaction } from 'bitcoinjs-lib';
4
4
  /**
5
5
  * Detect the script type from a scriptPubKey buffer.
@@ -1 +1 @@
1
- {"version":3,"file":"buildSignBitcoinFromPsbt.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,GAClB,MAAM,+EAA+E,CAAA;AACtF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAW,QAAQ,EAAE,OAAO,EAAQ,MAAM,IAAI,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CA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AI,CAAC,QAAQ;QACvB,MAAM;QACN,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA"}
1
+ {"version":3,"file":"buildSignBitcoinFromPsbt.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,GAClB,MAAM,gFAAgF,CAAA;AACvF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAW,QAAQ,EAAE,OAAO,EAAQ,MAAM,IAAI,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAKvH;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,YAAoB,EAAE,YAAyB,EAAc,EAAE;IACvF,iDAAiD;IACjD,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvF,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,wFAAwF;IACxF,IACE,YAAY,CAAC,MAAM,KAAK,EAAE;QAC1B,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,EAAE,CAAC,KAAK,IAAI;QACzB,YAAY,CAAC,EAAE,CAAC,KAAK,IAAI,EACzB,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,8CAA8C;IAC9C,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvF,OAAO,MAAM,CAAA;IACf,CAAC;IACD,gD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,CAAC,mBAAmB,EAAE;YACjC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,aAAa;YACtB,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;YAC3D,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YACpC,QAAQ,EAAE,aAAa,KAAK,EAAE,IAAI,aAAa,KAAK,aAAa;SAClE,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,iBAAiB,EAAE;QAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM;QACN,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Throws when a plain token-transfer `recipient` is itself a known token
3
+ * contract address on `chain` — most commonly the SAME token being sent to
4
+ * its own contract, but also catches a transfer aimed at a different known
5
+ * token's contract.
6
+ *
7
+ * Call this ONLY on plain-transfer recipients (a native/ERC-20 send, or a
8
+ * decoded ERC-20 `transfer` hidden inside an arbitrary contract-call's
9
+ * calldata — see `decodeErc20Recipient` below). `sendingTokenContract` is
10
+ * the contract address of the token actually being sent (`undefined` for a
11
+ * native-coin send, which this guard is a no-op for — there is no "the ETH
12
+ * contract" to accidentally send ETH to).
13
+ */
14
+ export declare function assertSafeTokenTransferDestination(chain: string, recipient: string, sendingTokenContract: string | undefined): void;
15
+ /**
16
+ * True when `data`'s selector is a plain ERC-20 `transfer`/`transferFrom` —
17
+ * the two calldata shapes where the call target IS the token being moved, so
18
+ * a recipient that is itself a known token contract strands the funds and
19
+ * `assertSafeTokenTransferDestination` applies. ERC-721 `safeTransferFrom`
20
+ * deliberately returns false: the 721 standard's on-chain `onERC721Received`
21
+ * check already reverts a transfer to a non-receiver contract, so extending
22
+ * the registry guard there would add false-positive surface without closing
23
+ * a loss path. Every other selector is an arbitrary contract call and stays
24
+ * out of scope.
25
+ */
26
+ export declare function isErc20TransferCalldata(data: string): boolean;
27
+ /**
28
+ * If `data` looks like an ERC-20 `transfer`/`transferFrom` (or the
29
+ * same-shaped ERC-721 `safeTransferFrom`) call, return the decoded recipient
30
+ * address (lower-cased, `0x`-prefixed). Otherwise returns `null`.
31
+ *
32
+ * A contract-call builder that sets `to = <token contract>` + `data =
33
+ * <encoded transfer>` must run this to check the ACTUAL recipient —
34
+ * otherwise a destination guard that only vets the token contract address
35
+ * lets the real recipient slip through unchecked.
36
+ *
37
+ * Calldata layout for `transfer(address,uint256)`:
38
+ * 0x00–0x04 selector (4 bytes)
39
+ * 0x04–0x24 recipient (32-byte padded; address in last 20 bytes)
40
+ * 0x24–0x44 amount
41
+ *
42
+ * For `transferFrom(address,address,uint256)` (ERC-20) and
43
+ * `safeTransferFrom(address,address,uint256[,bytes])` (ERC-721 — same head layout):
44
+ * 0x00–0x04 selector
45
+ * 0x04–0x24 sender
46
+ * 0x24–0x44 recipient
47
+ * 0x44–0x64 amount / tokenId
48
+ */
49
+ export declare function decodeErc20Recipient(data: string): string | null;
50
+ export declare const ERC20_APPROVE_SELECTOR = "0x095ea7b3";
51
+ /**
52
+ * If `data` is an ERC-20 `approve(address spender, uint256 amount)` call,
53
+ * decode the SPENDER (lower-cased, `0x`-prefixed) + the raw allowance
54
+ * amount. Otherwise null. Mirrors `decodeErc20Recipient`'s slot math:
55
+ * spender = first 32-byte slot (bytes 4..36), amount = second slot (bytes
56
+ * 36..68).
57
+ */
58
+ export declare function decodeErc20Approve(data: string): {
59
+ spender: string;
60
+ amount: bigint;
61
+ } | null;
62
+ /**
63
+ * Extract the ERC-20/721 transfer RECIPIENT from a `function_sig` + `args`
64
+ * shape — the alternative to raw ABI-encoded `data` some builders accept
65
+ * (function signature + positional args, ABI-encoded server/caller-side
66
+ * AFTER any pre-dispatch destination guard already ran). Without this, a
67
+ * transfer expressed as `function_sig: "transfer(address,uint256)"` +
68
+ * `args: [<recipient>, <amount>]` has no `data` for `decodeErc20Recipient`
69
+ * to see and a destination guard silently no-ops.
70
+ *
71
+ * Mirrors `decodeErc20Recipient`'s selector→slot mapping on the parsed
72
+ * signature: `transfer(address,uint256)` → `args[0]`;
73
+ * `transferFrom`/`safeTransferFrom(address from,address to,…)` → `args[1]`
74
+ * (the recipient is the SECOND address, never `from`). A non-transfer
75
+ * signature (or one that doesn't match either shape) → `null`.
76
+ */
77
+ export declare function decodeErc20RecipientFromSig(functionSig: unknown, args: unknown): string | null;
78
+ //# sourceMappingURL=tokenTransferGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenTransferGuards.d.ts","sourceRoot":"","sources":["../../../../../packages/core/chain/security/tokenTransferGuards.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,GAAG,SAAS,GACvC,IAAI,CAiBN;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK7D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BhE;AAMD,eAAO,MAAM,sBAAsB,eAAe,CAAA;AAElD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAe3F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuC9F"}
@@ -0,0 +1,203 @@
1
+ import { knownTokensIndex } from '@vultisig/core-chain/coin/knownTokens';
2
+ const EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
3
+ /**
4
+ * Throws when a plain token-transfer `recipient` is itself a known token
5
+ * contract address on `chain` — most commonly the SAME token being sent to
6
+ * its own contract, but also catches a transfer aimed at a different known
7
+ * token's contract.
8
+ *
9
+ * Call this ONLY on plain-transfer recipients (a native/ERC-20 send, or a
10
+ * decoded ERC-20 `transfer` hidden inside an arbitrary contract-call's
11
+ * calldata — see `decodeErc20Recipient` below). `sendingTokenContract` is
12
+ * the contract address of the token actually being sent (`undefined` for a
13
+ * native-coin send, which this guard is a no-op for — there is no "the ETH
14
+ * contract" to accidentally send ETH to).
15
+ */
16
+ export function assertSafeTokenTransferDestination(chain, recipient, sendingTokenContract) {
17
+ if (!sendingTokenContract)
18
+ return;
19
+ const hit = knownTokensIndex[chain]?.[recipient.toLowerCase()];
20
+ if (!hit)
21
+ return;
22
+ const isSameToken = recipient.toLowerCase() === sendingTokenContract.toLowerCase();
23
+ if (isSameToken) {
24
+ throw new Error(`Refusing to build transaction: sending ${hit.ticker} to the ${hit.ticker} token contract ` +
25
+ `(${recipient}) would permanently burn it — the contract cannot credit a balance to itself. ` +
26
+ 'Did you mean to send to a wallet address instead?');
27
+ }
28
+ throw new Error(`Refusing to build transaction: destination ${recipient} is the ${hit.ticker} token contract on ${chain}, ` +
29
+ 'not a wallet — tokens sent to a token contract are permanently unrecoverable. ' +
30
+ 'Did you mean to send to a wallet address instead?');
31
+ }
32
+ // ── ERC-20 calldata recipient decoding ───────────────────────────────────────
33
+ const ERC20_TRANSFER_SELECTOR = '0xa9059cbb';
34
+ const ERC20_TRANSFER_FROM_SELECTOR = '0x23b872dd';
35
+ // ERC-721 safeTransferFrom — same recipient offset as ERC-20 transferFrom
36
+ // (second 32-byte slot). Two overloads; both hit the same decode path:
37
+ // safeTransferFrom(address,address,uint256) → 0x42842e0e (3-arg)
38
+ // safeTransferFrom(address,address,uint256,bytes) → 0xb88d4fde (4-arg, common in wallet SDKs)
39
+ const ERC721_SAFE_TRANSFER_FROM_SELECTOR = '0x42842e0e';
40
+ const ERC721_SAFE_TRANSFER_FROM_BYTES_SELECTOR = '0xb88d4fde';
41
+ /**
42
+ * True when `data`'s selector is a plain ERC-20 `transfer`/`transferFrom` —
43
+ * the two calldata shapes where the call target IS the token being moved, so
44
+ * a recipient that is itself a known token contract strands the funds and
45
+ * `assertSafeTokenTransferDestination` applies. ERC-721 `safeTransferFrom`
46
+ * deliberately returns false: the 721 standard's on-chain `onERC721Received`
47
+ * check already reverts a transfer to a non-receiver contract, so extending
48
+ * the registry guard there would add false-positive surface without closing
49
+ * a loss path. Every other selector is an arbitrary contract call and stays
50
+ * out of scope.
51
+ */
52
+ export function isErc20TransferCalldata(data) {
53
+ if (typeof data !== 'string')
54
+ return false;
55
+ const hex = data.startsWith('0x') ? data : `0x${data}`;
56
+ const selector = hex.slice(0, 10).toLowerCase();
57
+ return selector === ERC20_TRANSFER_SELECTOR || selector === ERC20_TRANSFER_FROM_SELECTOR;
58
+ }
59
+ /**
60
+ * If `data` looks like an ERC-20 `transfer`/`transferFrom` (or the
61
+ * same-shaped ERC-721 `safeTransferFrom`) call, return the decoded recipient
62
+ * address (lower-cased, `0x`-prefixed). Otherwise returns `null`.
63
+ *
64
+ * A contract-call builder that sets `to = <token contract>` + `data =
65
+ * <encoded transfer>` must run this to check the ACTUAL recipient —
66
+ * otherwise a destination guard that only vets the token contract address
67
+ * lets the real recipient slip through unchecked.
68
+ *
69
+ * Calldata layout for `transfer(address,uint256)`:
70
+ * 0x00–0x04 selector (4 bytes)
71
+ * 0x04–0x24 recipient (32-byte padded; address in last 20 bytes)
72
+ * 0x24–0x44 amount
73
+ *
74
+ * For `transferFrom(address,address,uint256)` (ERC-20) and
75
+ * `safeTransferFrom(address,address,uint256[,bytes])` (ERC-721 — same head layout):
76
+ * 0x00–0x04 selector
77
+ * 0x04–0x24 sender
78
+ * 0x24–0x44 recipient
79
+ * 0x44–0x64 amount / tokenId
80
+ */
81
+ export function decodeErc20Recipient(data) {
82
+ if (typeof data !== 'string')
83
+ return null;
84
+ const hex = data.startsWith('0x') ? data : `0x${data}`;
85
+ if (hex.length < 10)
86
+ return null;
87
+ const selector = hex.slice(0, 10).toLowerCase();
88
+ let recipientSliceStart;
89
+ if (selector === ERC20_TRANSFER_SELECTOR) {
90
+ // recipient is at bytes 4..36 → hex chars 10..74, last 40 chars = addr
91
+ recipientSliceStart = 10;
92
+ }
93
+ else if (selector === ERC20_TRANSFER_FROM_SELECTOR ||
94
+ selector === ERC721_SAFE_TRANSFER_FROM_SELECTOR ||
95
+ selector === ERC721_SAFE_TRANSFER_FROM_BYTES_SELECTOR) {
96
+ // recipient is at bytes 36..68 → hex chars 74..138, last 40 chars = addr
97
+ recipientSliceStart = 74;
98
+ }
99
+ else {
100
+ return null;
101
+ }
102
+ const slotEnd = recipientSliceStart + 64;
103
+ if (hex.length < slotEnd)
104
+ return null;
105
+ const slot = hex.slice(recipientSliceStart, slotEnd);
106
+ // Recipient occupies the last 40 hex chars (rightmost 20 bytes) of the slot.
107
+ const addr = `0x${slot.slice(24).toLowerCase()}`;
108
+ if (!EVM_ADDRESS_RE.test(addr))
109
+ return null;
110
+ return addr;
111
+ }
112
+ // ERC-20 approve(address spender, uint256 amount) — 0x095ea7b3. The SPENDER
113
+ // receives spend authority over the owner's tokens; a raw approve built via
114
+ // an arbitrary contract-call path is OPAQUE (no spender decode, no
115
+ // WYSIWYS surface) unless decoded explicitly.
116
+ export const ERC20_APPROVE_SELECTOR = '0x095ea7b3';
117
+ /**
118
+ * If `data` is an ERC-20 `approve(address spender, uint256 amount)` call,
119
+ * decode the SPENDER (lower-cased, `0x`-prefixed) + the raw allowance
120
+ * amount. Otherwise null. Mirrors `decodeErc20Recipient`'s slot math:
121
+ * spender = first 32-byte slot (bytes 4..36), amount = second slot (bytes
122
+ * 36..68).
123
+ */
124
+ export function decodeErc20Approve(data) {
125
+ if (typeof data !== 'string')
126
+ return null;
127
+ const hex = data.startsWith('0x') ? data : `0x${data}`;
128
+ if (hex.slice(0, 10).toLowerCase() !== ERC20_APPROVE_SELECTOR)
129
+ return null;
130
+ // 4-byte selector + 32-byte spender + 32-byte amount = 138 hex chars incl the `0x`.
131
+ if (hex.length < 138)
132
+ return null;
133
+ const spender = `0x${hex.slice(10, 74).slice(24).toLowerCase()}`;
134
+ if (!EVM_ADDRESS_RE.test(spender))
135
+ return null;
136
+ let amount;
137
+ try {
138
+ amount = BigInt(`0x${hex.slice(74, 138)}`);
139
+ }
140
+ catch {
141
+ return null;
142
+ }
143
+ return { spender, amount };
144
+ }
145
+ /**
146
+ * Extract the ERC-20/721 transfer RECIPIENT from a `function_sig` + `args`
147
+ * shape — the alternative to raw ABI-encoded `data` some builders accept
148
+ * (function signature + positional args, ABI-encoded server/caller-side
149
+ * AFTER any pre-dispatch destination guard already ran). Without this, a
150
+ * transfer expressed as `function_sig: "transfer(address,uint256)"` +
151
+ * `args: [<recipient>, <amount>]` has no `data` for `decodeErc20Recipient`
152
+ * to see and a destination guard silently no-ops.
153
+ *
154
+ * Mirrors `decodeErc20Recipient`'s selector→slot mapping on the parsed
155
+ * signature: `transfer(address,uint256)` → `args[0]`;
156
+ * `transferFrom`/`safeTransferFrom(address from,address to,…)` → `args[1]`
157
+ * (the recipient is the SECOND address, never `from`). A non-transfer
158
+ * signature (or one that doesn't match either shape) → `null`.
159
+ */
160
+ export function decodeErc20RecipientFromSig(functionSig, args) {
161
+ if (typeof functionSig !== 'string' || !Array.isArray(args))
162
+ return null;
163
+ // Accept "function transfer(address,uint256)" or "transfer(address,uint256)".
164
+ const m = functionSig
165
+ .replace(/^\s*function\s+/i, '')
166
+ .trim()
167
+ .match(/^(\w+)\s*\(([^)]*)\)$/);
168
+ if (!m)
169
+ return null;
170
+ const name = m[1];
171
+ // Strip any inline arg names ("address to" → "address") so we compare pure types.
172
+ const argTypes = m[2].split(',').map(t => t.trim().split(/\s+/)[0]);
173
+ const isUint256 = (type) => type === 'uint' || type === 'uint256';
174
+ let idx;
175
+ if (name === 'transfer' && argTypes.length === 2 && argTypes[0] === 'address' && isUint256(argTypes[1])) {
176
+ idx = 0; // transfer(address to, uint256 amount) — recipient is the FIRST arg
177
+ }
178
+ else if (name === 'transferFrom' &&
179
+ argTypes.length === 3 &&
180
+ argTypes[0] === 'address' &&
181
+ argTypes[1] === 'address' &&
182
+ isUint256(argTypes[2])) {
183
+ idx = 1; // transferFrom(address from, address to, uint256 amount) — recipient is the SECOND arg
184
+ }
185
+ else if (name === 'safeTransferFrom' &&
186
+ (argTypes.length === 3 || (argTypes.length === 4 && argTypes[3] === 'bytes')) &&
187
+ argTypes[0] === 'address' &&
188
+ argTypes[1] === 'address' &&
189
+ isUint256(argTypes[2])) {
190
+ idx = 1; // ERC-721 safeTransferFrom overloads — recipient is the SECOND arg
191
+ }
192
+ else {
193
+ return null;
194
+ }
195
+ if (args.length !== argTypes.length)
196
+ return null;
197
+ const raw = args[idx];
198
+ if (typeof raw !== 'string')
199
+ return null;
200
+ const addr = raw.trim().toLowerCase();
201
+ return EVM_ADDRESS_RE.test(addr) ? addr : null;
202
+ }
203
+ //# sourceMappingURL=tokenTransferGuards.js.map