@vultisig/core-mpc 1.13.0 → 1.14.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 (41) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/dist/chains/cosmos/qbtc/QBTCHelper.js +4 -3
  3. package/dist/chains/cosmos/qbtc/QBTCHelper.js.map +1 -1
  4. package/dist/chains/cosmos/qbtc/QBTCTx.js +1 -1
  5. package/dist/chains/cosmos/qbtc/QBTCTx.js.map +1 -1
  6. package/dist/keysign/chainSpecific/resolvers/cosmos/index.d.ts.map +1 -1
  7. package/dist/keysign/chainSpecific/resolvers/cosmos/index.js +71 -10
  8. package/dist/keysign/chainSpecific/resolvers/cosmos/index.js.map +1 -1
  9. package/dist/keysign/chainSpecific/resolvers/sui/index.d.ts.map +1 -1
  10. package/dist/keysign/chainSpecific/resolvers/sui/index.js +62 -64
  11. package/dist/keysign/chainSpecific/resolvers/sui/index.js.map +1 -1
  12. package/dist/keysign/chainSpecific/resolvers/sui/refine.d.ts.map +1 -1
  13. package/dist/keysign/chainSpecific/resolvers/sui/refine.js +14 -4
  14. package/dist/keysign/chainSpecific/resolvers/sui/refine.js.map +1 -1
  15. package/dist/keysign/chainSpecific/resolvers/tron/energyPrice.d.ts +4 -3
  16. package/dist/keysign/chainSpecific/resolvers/tron/energyPrice.d.ts.map +1 -1
  17. package/dist/keysign/chainSpecific/resolvers/tron/energyPrice.js +11 -5
  18. package/dist/keysign/chainSpecific/resolvers/tron/energyPrice.js.map +1 -1
  19. package/dist/keysign/chainSpecific/resolvers/tron/fee.d.ts +11 -0
  20. package/dist/keysign/chainSpecific/resolvers/tron/fee.d.ts.map +1 -1
  21. package/dist/keysign/chainSpecific/resolvers/tron/fee.js +43 -19
  22. package/dist/keysign/chainSpecific/resolvers/tron/fee.js.map +1 -1
  23. package/dist/keysign/fee/resolvers/cosmos.d.ts +5 -3
  24. package/dist/keysign/fee/resolvers/cosmos.d.ts.map +1 -1
  25. package/dist/keysign/fee/resolvers/cosmos.js +8 -21
  26. package/dist/keysign/fee/resolvers/cosmos.js.map +1 -1
  27. package/dist/keysign/fee/resolvers/tron.d.ts.map +1 -1
  28. package/dist/keysign/fee/resolvers/tron.js +11 -2
  29. package/dist/keysign/fee/resolvers/tron.js.map +1 -1
  30. package/dist/keysign/signingInputs/resolvers/cosmos/index.d.ts.map +1 -1
  31. package/dist/keysign/signingInputs/resolvers/cosmos/index.js +24 -15
  32. package/dist/keysign/signingInputs/resolvers/cosmos/index.js.map +1 -1
  33. package/dist/keysign/swap/buildLimitSwapKeysignPayload.d.ts +22 -6
  34. package/dist/keysign/swap/buildLimitSwapKeysignPayload.d.ts.map +1 -1
  35. package/dist/keysign/swap/buildLimitSwapKeysignPayload.js +22 -4
  36. package/dist/keysign/swap/buildLimitSwapKeysignPayload.js.map +1 -1
  37. package/dist/keysign/swap/getKeysignLimitSwapOrder.d.ts +41 -0
  38. package/dist/keysign/swap/getKeysignLimitSwapOrder.d.ts.map +1 -0
  39. package/dist/keysign/swap/getKeysignLimitSwapOrder.js +50 -0
  40. package/dist/keysign/swap/getKeysignLimitSwapOrder.js.map +1 -0
  41. package/package.json +9 -4
@@ -0,0 +1,41 @@
1
+ import { Chain } from '@vultisig/core-chain/Chain';
2
+ import { LimitSwapExpiryHours, ParsedLimitSwapMemo } from '@vultisig/core-chain/swap/native/limitSwapMemo';
3
+ import { KeysignPayload } from '../../types/vultisig/keysign/v1/keysign_message_pb.js';
4
+ export type KeysignLimitSwapOrder = ParsedLimitSwapMemo & {
5
+ /** The buy chain, when the target asset's prefix is one this SDK can route. */
6
+ targetChain?: Chain;
7
+ /**
8
+ * Guaranteed-minimum received, as a decimal string in the target asset's
9
+ * display units. Formatted from the LIM with THORChain's 8 decimals, matching
10
+ * how `toAmountDecimal` is formatted for market swaps.
11
+ */
12
+ minimumReceivedDecimal: string;
13
+ /** The order's resting lifetime, when the interval maps to one this SDK builds. */
14
+ expiryHours?: LimitSwapExpiryHours;
15
+ };
16
+ /**
17
+ * Decode the limit order a keysign payload is about to place, for review.
18
+ *
19
+ * Returns `undefined` for any payload that is not a limit order, so a caller can
20
+ * branch on it directly.
21
+ *
22
+ * **This is how a *joining* device reviews a limit order.** The builder attaches
23
+ * a `swapPayload` only for ERC20 sources — RUNE and native-gas-asset orders are
24
+ * plain deposits — so a co-signer keying off the swap payload alone sees a
25
+ * generic send to an opaque address with an opaque memo, and cannot tell what is
26
+ * being bought, where it pays out, or at what floor.
27
+ *
28
+ * Deriving the terms from `keysignPayload.memo` fixes that uniformly, because
29
+ * the memo is present on every source branch. It is also the *only* trustworthy
30
+ * source: the memo is the exact string THORChain executes, so terms read from it
31
+ * cannot disagree with the order that gets signed. A display field carried
32
+ * alongside the memo can — it is supplied by the initiating device, and a
33
+ * co-signer has no way to tell a mistaken one from a malicious one.
34
+ *
35
+ * Parsing is fail-closed on a malformed memo, but a caller reviewing an
36
+ * arbitrary payload wants "not a limit order" rather than a throw, so a memo
37
+ * that does not parse is reported as not-a-limit-order. Signing still rejects it:
38
+ * `buildLimitSwapKeysignPayload` parses the same memo and throws.
39
+ */
40
+ export declare const getKeysignLimitSwapOrder: ({ memo }: Pick<KeysignPayload, "memo">) => KeysignLimitSwapOrder | undefined;
41
+ //# sourceMappingURL=getKeysignLimitSwapOrder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getKeysignLimitSwapOrder.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/swap/getKeysignLimitSwapOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAEL,oBAAoB,EAGpB,mBAAmB,EAEpB,MAAM,gDAAgD,CAAA;AAIvD,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AASnF,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,GAAG;IACxD,+EAA+E;IAC/E,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAA;IAC9B,mFAAmF;IACnF,WAAW,CAAC,EAAE,oBAAoB,CAAA;CACnC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,GAAI,UAAU,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,qBAAqB,GAAG,SAkBzG,CAAA"}
@@ -0,0 +1,50 @@
1
+ import { fromChainAmountDisplay } from '@vultisig/core-chain/amount/fromChainAmountExact';
2
+ import { Chain } from '@vultisig/core-chain/Chain';
3
+ import { chainFeeCoin } from '@vultisig/core-chain/coin/chainFeeCoin';
4
+ import { limitSwapExpiryHours, getLimitSwapIntervalBlocks, limitSwapMemoPrefix, parseLimitSwapMemo, } from '@vultisig/core-chain/swap/native/limitSwapMemo';
5
+ import { thorchainAssetPrefixToChain } from '@vultisig/core-chain/swap/native/thorchainMemoAsset';
6
+ import { attempt } from '@vultisig/lib-utils/attempt';
7
+ /** THORChain's fixed point for pool amounts, which the memo's LIM is expressed in. */
8
+ const thorchainDecimals = chainFeeCoin[Chain.THORChain].decimals;
9
+ const intervalBlocksToExpiryHours = Object.freeze(Object.fromEntries(limitSwapExpiryHours.map(hours => [getLimitSwapIntervalBlocks(hours), hours])));
10
+ /**
11
+ * Decode the limit order a keysign payload is about to place, for review.
12
+ *
13
+ * Returns `undefined` for any payload that is not a limit order, so a caller can
14
+ * branch on it directly.
15
+ *
16
+ * **This is how a *joining* device reviews a limit order.** The builder attaches
17
+ * a `swapPayload` only for ERC20 sources — RUNE and native-gas-asset orders are
18
+ * plain deposits — so a co-signer keying off the swap payload alone sees a
19
+ * generic send to an opaque address with an opaque memo, and cannot tell what is
20
+ * being bought, where it pays out, or at what floor.
21
+ *
22
+ * Deriving the terms from `keysignPayload.memo` fixes that uniformly, because
23
+ * the memo is present on every source branch. It is also the *only* trustworthy
24
+ * source: the memo is the exact string THORChain executes, so terms read from it
25
+ * cannot disagree with the order that gets signed. A display field carried
26
+ * alongside the memo can — it is supplied by the initiating device, and a
27
+ * co-signer has no way to tell a mistaken one from a malicious one.
28
+ *
29
+ * Parsing is fail-closed on a malformed memo, but a caller reviewing an
30
+ * arbitrary payload wants "not a limit order" rather than a throw, so a memo
31
+ * that does not parse is reported as not-a-limit-order. Signing still rejects it:
32
+ * `buildLimitSwapKeysignPayload` parses the same memo and throws.
33
+ */
34
+ export const getKeysignLimitSwapOrder = ({ memo }) => {
35
+ if (!memo?.startsWith(limitSwapMemoPrefix)) {
36
+ return undefined;
37
+ }
38
+ const parsed = attempt(() => parseLimitSwapMemo(memo));
39
+ if ('error' in parsed) {
40
+ return undefined;
41
+ }
42
+ const { data: order } = parsed;
43
+ return {
44
+ ...order,
45
+ targetChain: thorchainAssetPrefixToChain[order.targetAsset.split('.')[0].toUpperCase()],
46
+ minimumReceivedDecimal: fromChainAmountDisplay(order.limit, thorchainDecimals),
47
+ expiryHours: intervalBlocksToExpiryHours[order.intervalBlocks],
48
+ };
49
+ };
50
+ //# sourceMappingURL=getKeysignLimitSwapOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getKeysignLimitSwapOrder.js","sourceRoot":"","sources":["../../../../../../packages/core/mpc/keysign/swap/getKeysignLimitSwapOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAA;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,OAAO,EACL,oBAAoB,EAEpB,0BAA0B,EAC1B,mBAAmB,EAEnB,kBAAkB,GACnB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAA;AACjG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAIrD,sFAAsF;AACtF,MAAM,iBAAiB,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAA;AAEhE,MAAM,2BAA2B,GAA4D,MAAM,CAAC,MAAM,CACxG,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAClG,CAAA;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAE,IAAI,EAAgC,EAAqC,EAAE;IACpH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACtB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAE9B,OAAO;QACL,GAAG,KAAK;QACR,WAAW,EAAE,2BAA2B,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACvF,sBAAsB,EAAE,sBAAsB,CAAC,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC;QAC9E,WAAW,EAAE,2BAA2B,CAAC,KAAK,CAAC,cAAc,CAAC;KAC/D,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vultisig/core-mpc",
3
- "version": "1.13.0",
3
+ "version": "1.14.1",
4
4
  "description": "MPC, keysign, and vault types shared across Vultisig clients",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -601,6 +601,11 @@
601
601
  "import": "./dist/keysign/swap/cowswap/buildCowSwapApprovalSigningInput.js",
602
602
  "default": "./dist/keysign/swap/cowswap/buildCowSwapApprovalSigningInput.js"
603
603
  },
604
+ "./keysign/swap/getKeysignLimitSwapOrder": {
605
+ "types": "./dist/keysign/swap/getKeysignLimitSwapOrder.d.ts",
606
+ "import": "./dist/keysign/swap/getKeysignLimitSwapOrder.js",
607
+ "default": "./dist/keysign/swap/getKeysignLimitSwapOrder.js"
608
+ },
604
609
  "./keysign/swap/getKeysignSwapPayload": {
605
610
  "types": "./dist/keysign/swap/getKeysignSwapPayload.d.ts",
606
611
  "import": "./dist/keysign/swap/getKeysignSwapPayload.js",
@@ -1068,13 +1073,13 @@
1068
1073
  },
1069
1074
  "dependencies": {
1070
1075
  "7z-wasm": "^1.2.0",
1071
- "@bufbuild/protobuf": "^2.12.0",
1076
+ "@bufbuild/protobuf": "^2.13.0",
1072
1077
  "@cosmjs/encoding": "^0.39.0",
1073
- "@mysten/sui": "^2.20.3",
1078
+ "@mysten/sui": "^2.22.1",
1074
1079
  "@noble/hashes": "^1.8.0",
1075
1080
  "@solana/web3.js": "^1.98.4",
1076
1081
  "@trustwallet/wallet-core": "^4.7.0",
1077
- "@vultisig/core-chain": "2.28.0",
1082
+ "@vultisig/core-chain": "2.29.1",
1078
1083
  "@vultisig/core-config": "0.9.1",
1079
1084
  "@vultisig/lib-dkls": "0.9.0",
1080
1085
  "@vultisig/lib-mldsa": "0.9.0",