@vultisig/core-chain 1.4.0 → 1.4.2
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 +15 -0
- package/dist/chains/cosmos/cosmosMsgTypes.d.ts +5 -1
- package/dist/chains/cosmos/cosmosMsgTypes.d.ts.map +1 -1
- package/dist/chains/cosmos/cosmosMsgTypes.js +5 -0
- package/dist/chains/cosmos/cosmosMsgTypes.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts +4 -2
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js +17 -6
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js.map +1 -1
- package/dist/chains/cosmos/staking/lcdQueries.d.ts +117 -0
- package/dist/chains/cosmos/staking/lcdQueries.d.ts.map +1 -0
- package/dist/chains/cosmos/staking/lcdQueries.js +80 -0
- package/dist/chains/cosmos/staking/lcdQueries.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/pools.d.ts +1 -1
- package/dist/chains/cosmos/thor/lp/pools.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/pools.js +1 -1
- package/dist/chains/cosmos/thor/lp/pools.js.map +1 -1
- package/dist/chains/solana/client.d.ts.map +1 -1
- package/dist/chains/solana/client.js +1 -3
- package/dist/chains/solana/client.js.map +1 -1
- package/dist/chains/ton/messageBody/decode.d.ts +42 -0
- package/dist/chains/ton/messageBody/decode.d.ts.map +1 -0
- package/dist/chains/ton/messageBody/decode.js +337 -0
- package/dist/chains/ton/messageBody/decode.js.map +1 -0
- package/dist/chains/ton/messageBody/knownRouters.d.ts +19 -0
- package/dist/chains/ton/messageBody/knownRouters.d.ts.map +1 -0
- package/dist/chains/ton/messageBody/knownRouters.js +179 -0
- package/dist/chains/ton/messageBody/knownRouters.js.map +1 -0
- package/dist/chains/ton/messageBody/opcodes.d.ts +23 -0
- package/dist/chains/ton/messageBody/opcodes.d.ts.map +1 -0
- package/dist/chains/ton/messageBody/opcodes.js +22 -0
- package/dist/chains/ton/messageBody/opcodes.js.map +1 -0
- package/dist/chains/ton/messageBody/types.d.ts +50 -0
- package/dist/chains/ton/messageBody/types.d.ts.map +1 -0
- package/dist/chains/ton/messageBody/types.js +2 -0
- package/dist/chains/ton/messageBody/types.js.map +1 -0
- package/dist/coin/balance/resolvers/polkadot.d.ts.map +1 -1
- package/dist/coin/balance/resolvers/polkadot.js +72 -6
- package/dist/coin/balance/resolvers/polkadot.js.map +1 -1
- package/dist/publicKey/ecdsa/derivePublicKey.d.ts.map +1 -1
- package/dist/publicKey/ecdsa/derivePublicKey.js +6 -0
- package/dist/publicKey/ecdsa/derivePublicKey.js.map +1 -1
- package/dist/security/blockaid/tx/simulation/api/core.d.ts.map +1 -1
- package/dist/security/blockaid/tx/simulation/api/core.js +30 -29
- package/dist/security/blockaid/tx/simulation/api/core.js.map +1 -1
- package/package.json +31 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @vultisig/core-chain
|
|
2
2
|
|
|
3
|
+
## 1.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`a3a331a`](https://github.com/vultisig/vultisig-sdk/commit/a3a331a875ebc6868b11c6901c8ed99dde51a4ff)]:
|
|
8
|
+
- @vultisig/lib-utils@0.10.0
|
|
9
|
+
|
|
10
|
+
## 1.4.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#342](https://github.com/vultisig/vultisig-sdk/pull/342) [`77410fb`](https://github.com/vultisig/vultisig-sdk/commit/77410fb28f53dd558f05e5634aadba6a9547ee0f) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - fix(security/blockaid): pair swap diffs across all asset diffs in EVM simulations
|
|
15
|
+
|
|
16
|
+
`parseBlockaidEvmSimulation` previously destructured only `assetDiffs[0]` and `assetDiffs[1]`. For router-mediated flows like `permitAndCall`, Blockaid returns three diffs with the user's `in` side at `assetDiffs[2]` and an empty intermediate leg at `assetDiffs[1]`, causing the parser to bail and the simulation hero to render nothing. The parser now scans all diffs for the user-side `out` and `in` legs (preferring an in-asset different from the out-asset), matching the iOS `BlockaidSimulationParser` behaviour.
|
|
17
|
+
|
|
3
18
|
## 1.4.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -9,6 +9,10 @@ export declare enum CosmosMsgType {
|
|
|
9
9
|
THORCHAIN_MSG_DEPOSIT_URL = "/types.MsgDeposit",
|
|
10
10
|
THORCHAIN_MSG_LEAVE_POOL = "thorchain/MsgLeavePool",
|
|
11
11
|
THORCHAIN_MSG_LEAVE_POOL_URL = "/thorchain.v1.MsgLeavePool",
|
|
12
|
-
THORCHAIN_MSG_SEND_URL = "/types.MsgSend"
|
|
12
|
+
THORCHAIN_MSG_SEND_URL = "/types.MsgSend",
|
|
13
|
+
MSG_DELEGATE_URL = "/cosmos.staking.v1beta1.MsgDelegate",
|
|
14
|
+
MSG_UNDELEGATE_URL = "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
15
|
+
MSG_BEGIN_REDELEGATE_URL = "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
|
16
|
+
MSG_WITHDRAW_DELEGATOR_REWARD_URL = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=cosmosMsgTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosMsgTypes.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosMsgTypes.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,QAAQ,uBAAuB;IAC/B,kBAAkB,sBAAsB;IACxC,oBAAoB,4BAA4B;IAChD,wBAAwB,yCAAyC;IACjE,gBAAgB,8CAA8C;IAC9D,YAAY,iCAAiC;IAC7C,qBAAqB,yBAAyB;IAC9C,yBAAyB,sBAAsB;IAC/C,wBAAwB,2BAA2B;IACnD,4BAA4B,+BAA+B;IAC3D,sBAAsB,mBAAmB;
|
|
1
|
+
{"version":3,"file":"cosmosMsgTypes.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosMsgTypes.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,QAAQ,uBAAuB;IAC/B,kBAAkB,sBAAsB;IACxC,oBAAoB,4BAA4B;IAChD,wBAAwB,yCAAyC;IACjE,gBAAgB,8CAA8C;IAC9D,YAAY,iCAAiC;IAC7C,qBAAqB,yBAAyB;IAC9C,yBAAyB,sBAAsB;IAC/C,wBAAwB,2BAA2B;IACnD,4BAA4B,+BAA+B;IAC3D,sBAAsB,mBAAmB;IAEzC,gBAAgB,wCAAwC;IACxD,kBAAkB,0CAA0C;IAC5D,wBAAwB,+CAA+C;IACvE,iCAAiC,4DAA4D;CAC9F"}
|
|
@@ -11,5 +11,10 @@ export var CosmosMsgType;
|
|
|
11
11
|
CosmosMsgType["THORCHAIN_MSG_LEAVE_POOL"] = "thorchain/MsgLeavePool";
|
|
12
12
|
CosmosMsgType["THORCHAIN_MSG_LEAVE_POOL_URL"] = "/thorchain.v1.MsgLeavePool";
|
|
13
13
|
CosmosMsgType["THORCHAIN_MSG_SEND_URL"] = "/types.MsgSend";
|
|
14
|
+
// cosmos-sdk staking + distribution module (proto direct-sign)
|
|
15
|
+
CosmosMsgType["MSG_DELEGATE_URL"] = "/cosmos.staking.v1beta1.MsgDelegate";
|
|
16
|
+
CosmosMsgType["MSG_UNDELEGATE_URL"] = "/cosmos.staking.v1beta1.MsgUndelegate";
|
|
17
|
+
CosmosMsgType["MSG_BEGIN_REDELEGATE_URL"] = "/cosmos.staking.v1beta1.MsgBeginRedelegate";
|
|
18
|
+
CosmosMsgType["MSG_WITHDRAW_DELEGATOR_REWARD_URL"] = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
|
|
14
19
|
})(CosmosMsgType || (CosmosMsgType = {}));
|
|
15
20
|
//# sourceMappingURL=cosmosMsgTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosMsgTypes.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosMsgTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"cosmosMsgTypes.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosMsgTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAiBX;AAjBD,WAAY,aAAa;IACvB,gDAA+B,CAAA;IAC/B,yDAAwC,CAAA;IACxC,iEAAgD,CAAA;IAChD,kFAAiE,CAAA;IACjE,+EAA8D,CAAA;IAC9D,8DAA6C,CAAA;IAC7C,+DAA8C,CAAA;IAC9C,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,4EAA2D,CAAA;IAC3D,0DAAyC,CAAA;IACzC,+DAA+D;IAC/D,yEAAwD,CAAA;IACxD,6EAA4D,CAAA;IAC5D,wFAAuE,CAAA;IACvE,8GAA6F,CAAA;AAC/F,CAAC,EAjBW,aAAa,KAAb,aAAa,QAiBxB"}
|
|
@@ -22,10 +22,12 @@ type ComputeClaimMessageHashInput = {
|
|
|
22
22
|
* Computes the final MessageHash for the QBTC claim.
|
|
23
23
|
*
|
|
24
24
|
* ```
|
|
25
|
-
* MessageHash = SHA256(
|
|
25
|
+
* MessageHash = SHA256("ecdsa-hash160:" + addressHash + qbtcAddressHash + chainIdHash + "qbtc-claim-v1")
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* The domain-separation prefix must match `ClaimTagECDSAHash160` on the
|
|
29
|
+
* chain (`x/qbtc/zk/message.go`). Schnorr/Taproot claims will use a
|
|
30
|
+
* distinct tag once the chain defines one — see btcq-org/qbtc#148.
|
|
29
31
|
*/
|
|
30
32
|
export declare const computeClaimMessageHash: ({ addressHash, qbtcAddressHash, chainIdHash, circuit, }: ComputeClaimMessageHashInput) => Uint8Array;
|
|
31
33
|
type ComputeAllClaimHashesInput = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeClaimHashes.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/computeClaimHashes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"computeClaimHashes.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/computeClaimHashes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAgB1E;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,gCAGhC;IACD,gBAAgB,EAAE,UAAU,CAAA;IAC5B,OAAO,EAAE,gBAAgB,CAAA;CAC1B,KAAG,UAcH,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,GAAI,aAAa,MAAM,KAAG,UACd,CAAA;AAE/C,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG,UACE,CAAA;AAEvD,KAAK,4BAA4B,GAAG;IAClC,WAAW,EAAE,UAAU,CAAA;IACvB,eAAe,EAAE,UAAU,CAAA;IAC3B,WAAW,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAAI,yDAKrC,4BAA4B,KAAG,UAyCjC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,UAAU,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,UAAU,CAAA;IACvB,eAAe,EAAE,UAAU,CAAA;IAC3B,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,yDAKnC,0BAA0B,KAAG,WAgB/B,CAAA"}
|
|
@@ -3,6 +3,13 @@ import { sha256 } from '@noble/hashes/sha256';
|
|
|
3
3
|
import { btcAddressTypeCircuit } from './BtcAddressType.js';
|
|
4
4
|
import { detectBtcAddressType } from './detectBtcAddressType.js';
|
|
5
5
|
const claimSuffix = 'qbtc-claim-v1';
|
|
6
|
+
/**
|
|
7
|
+
* Domain-separation prefix for the ECDSA + Hash160 claim circuit
|
|
8
|
+
* (`BTCPubKeyOwnershipCircuit` post btcq-org/qbtc#148). Covers P2PKH,
|
|
9
|
+
* P2WPKH, P2SH-P2WPKH, and P2WSH. Must match `ClaimTagECDSAHash160` on the
|
|
10
|
+
* chain side (`x/qbtc/zk/message.go`).
|
|
11
|
+
*/
|
|
12
|
+
const ecdsaHash160Tag = 'ecdsa-hash160:';
|
|
6
13
|
/** Hash160 = RIPEMD160(SHA256(data)), the standard Bitcoin hash. */
|
|
7
14
|
const hash160 = (data) => ripemd160(sha256(data));
|
|
8
15
|
/**
|
|
@@ -28,15 +35,19 @@ export const computeChainIdHash = (chainId) => sha256(new TextEncoder().encode(c
|
|
|
28
35
|
* Computes the final MessageHash for the QBTC claim.
|
|
29
36
|
*
|
|
30
37
|
* ```
|
|
31
|
-
* MessageHash = SHA256(
|
|
38
|
+
* MessageHash = SHA256("ecdsa-hash160:" + addressHash + qbtcAddressHash + chainIdHash + "qbtc-claim-v1")
|
|
32
39
|
* ```
|
|
33
40
|
*
|
|
34
|
-
*
|
|
41
|
+
* The domain-separation prefix must match `ClaimTagECDSAHash160` on the
|
|
42
|
+
* chain (`x/qbtc/zk/message.go`). Schnorr/Taproot claims will use a
|
|
43
|
+
* distinct tag once the chain defines one — see btcq-org/qbtc#148.
|
|
35
44
|
*/
|
|
36
45
|
export const computeClaimMessageHash = ({ addressHash, qbtcAddressHash, chainIdHash, circuit, }) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if (circuit === 'schnorr') {
|
|
47
|
+
throw new Error('Schnorr / Taproot claim circuit is not yet supported on the QBTC chain');
|
|
48
|
+
}
|
|
49
|
+
if (addressHash.length !== 20) {
|
|
50
|
+
throw new Error('addressHash must be 20 bytes for ecdsa-hash160');
|
|
40
51
|
}
|
|
41
52
|
if (qbtcAddressHash.length !== 32) {
|
|
42
53
|
throw new Error('qbtcAddressHash must be 32 bytes');
|
|
@@ -45,7 +56,7 @@ export const computeClaimMessageHash = ({ addressHash, qbtcAddressHash, chainIdH
|
|
|
45
56
|
throw new Error('chainIdHash must be 8 bytes');
|
|
46
57
|
}
|
|
47
58
|
const encoder = new TextEncoder();
|
|
48
|
-
const prefix = encoder.encode(
|
|
59
|
+
const prefix = encoder.encode(ecdsaHash160Tag);
|
|
49
60
|
const suffix = encoder.encode(claimSuffix);
|
|
50
61
|
const message = new Uint8Array(prefix.length +
|
|
51
62
|
addressHash.length +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeClaimHashes.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/computeClaimHashes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,OAAO,EAAE,qBAAqB,EAAoB,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,WAAW,GAAG,eAAe,CAAA;AAEnC,oEAAoE;AACpE,MAAM,OAAO,GAAG,CAAC,IAAgB,EAAc,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AAEzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,gBAAgB,EAChB,OAAO,GAIR,EAAc,EAAE;IACf,IACE,gBAAgB,CAAC,MAAM,KAAK,EAAE;QAC9B,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAC9D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAA;IACH,CAAC;IAED,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAc,EAAE,CACxE,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;AAE/C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAc,EAAE,CAChE,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AASvD
|
|
1
|
+
{"version":3,"file":"computeClaimHashes.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/computeClaimHashes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,OAAO,EAAE,qBAAqB,EAAoB,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM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;IAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC,CAAA;AACxB,CAAC,CAAA;AAgBD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,OAAO,GACoB,EAAe,EAAE;IAC5C,MAAM,WAAW,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,OAAO,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAA;IAElD,MAAM,WAAW,GAAG,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAA;IACrE,MAAM,eAAe,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAA;IAC3D,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAE/C,MAAM,WAAW,GAAG,uBAAuB,CAAC;QAC1C,WAAW;QACX,eAAe;QACf,WAAW;QACX,OAAO;KACR,CAAC,CAAA;IAEF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,CAAA;AAC/D,CAAC,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LCD query helpers for the cosmos-sdk staking + distribution modules.
|
|
3
|
+
*
|
|
4
|
+
* Read-only HTTP fetches against the per-chain `cosmosRpcUrl` (which actually
|
|
5
|
+
* points at the LCD/REST endpoint, despite the dict name). All endpoints are
|
|
6
|
+
* unauthenticated, public, and rate-limited at most by the upstream provider.
|
|
7
|
+
*
|
|
8
|
+
* Generic across every cosmos-sdk chain we support — same paths, just
|
|
9
|
+
* different LCD root. No chain-specific branching.
|
|
10
|
+
*/
|
|
11
|
+
import { IbcEnabledCosmosChain } from '@vultisig/core-chain/Chain';
|
|
12
|
+
export type Coin = {
|
|
13
|
+
denom: string;
|
|
14
|
+
amount: string;
|
|
15
|
+
};
|
|
16
|
+
export type Delegation = {
|
|
17
|
+
/** valoper bech32, e.g. `cosmosvaloper1...` */
|
|
18
|
+
validatorAddress: string;
|
|
19
|
+
/** Current liquid balance currently delegated to this validator */
|
|
20
|
+
balance: Coin;
|
|
21
|
+
/** Raw shares (NOT 1:1 with balance after slashing). String to preserve precision. */
|
|
22
|
+
shares: string;
|
|
23
|
+
};
|
|
24
|
+
export type UnbondingEntry = {
|
|
25
|
+
/** Block height at which the unbonding was initiated */
|
|
26
|
+
creationHeight: string;
|
|
27
|
+
/** ISO-8601 string when this entry completes (becomes spendable) */
|
|
28
|
+
completionTime: string;
|
|
29
|
+
/** Amount in stake denom base units that will be returned */
|
|
30
|
+
initialBalance: string;
|
|
31
|
+
/** Amount remaining after any slashing during the unbonding window */
|
|
32
|
+
balance: string;
|
|
33
|
+
};
|
|
34
|
+
export type UnbondingDelegation = {
|
|
35
|
+
validatorAddress: string;
|
|
36
|
+
entries: UnbondingEntry[];
|
|
37
|
+
};
|
|
38
|
+
export type DelegatorReward = {
|
|
39
|
+
validatorAddress: string;
|
|
40
|
+
/** Per-denom reward (some chains have multi-asset rewards) */
|
|
41
|
+
reward: Coin[];
|
|
42
|
+
};
|
|
43
|
+
export type DelegatorRewardsResponse = {
|
|
44
|
+
rewards: DelegatorReward[];
|
|
45
|
+
total: Coin[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Discriminated by `@type` on the auth/accounts response. We only surface
|
|
49
|
+
* vesting variants the staking module cares about; non-vesting addresses
|
|
50
|
+
* return `null` from `getCosmosVestingAccount`.
|
|
51
|
+
*/
|
|
52
|
+
export type PeriodicVestingAccount = {
|
|
53
|
+
'@type': '/cosmos.vesting.v1beta1.PeriodicVestingAccount';
|
|
54
|
+
base_vesting_account: {
|
|
55
|
+
base_account: {
|
|
56
|
+
address: string;
|
|
57
|
+
account_number: string;
|
|
58
|
+
sequence: string;
|
|
59
|
+
pub_key?: {
|
|
60
|
+
'@type': string;
|
|
61
|
+
key: string;
|
|
62
|
+
} | null;
|
|
63
|
+
};
|
|
64
|
+
original_vesting: Coin[];
|
|
65
|
+
delegated_free: Coin[];
|
|
66
|
+
delegated_vesting: Coin[];
|
|
67
|
+
end_time: string;
|
|
68
|
+
};
|
|
69
|
+
start_time: string;
|
|
70
|
+
vesting_periods: Array<{
|
|
71
|
+
length: string;
|
|
72
|
+
amount: Coin[];
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
export type ContinuousVestingAccount = {
|
|
76
|
+
'@type': '/cosmos.vesting.v1beta1.ContinuousVestingAccount';
|
|
77
|
+
base_vesting_account: PeriodicVestingAccount['base_vesting_account'];
|
|
78
|
+
start_time: string;
|
|
79
|
+
};
|
|
80
|
+
export type DelayedVestingAccount = {
|
|
81
|
+
'@type': '/cosmos.vesting.v1beta1.DelayedVestingAccount';
|
|
82
|
+
base_vesting_account: PeriodicVestingAccount['base_vesting_account'];
|
|
83
|
+
};
|
|
84
|
+
export type VestingAccount = PeriodicVestingAccount | ContinuousVestingAccount | DelayedVestingAccount;
|
|
85
|
+
/**
|
|
86
|
+
* `cosmosRpcUrl` covers all CosmosChain entries (incl THORChain/MayaChain
|
|
87
|
+
* vault-based variants) but the cosmos-sdk staking module endpoints only
|
|
88
|
+
* make sense on `IbcEnabledCosmosChain`. Tighten the type at the boundary
|
|
89
|
+
* so callers can't accidentally hit `/cosmos/staking/...` against a
|
|
90
|
+
* THORChain LCD that doesn't serve it.
|
|
91
|
+
*/
|
|
92
|
+
type StakingChain = (typeof IbcEnabledCosmosChain)[keyof typeof IbcEnabledCosmosChain];
|
|
93
|
+
export declare const getDelegationsUrl: (chain: StakingChain, delegatorAddress: string) => string;
|
|
94
|
+
export declare const getUnbondingDelegationsUrl: (chain: StakingChain, delegatorAddress: string) => string;
|
|
95
|
+
export declare const getDelegatorRewardsUrl: (chain: StakingChain, delegatorAddress: string) => string;
|
|
96
|
+
export declare const getAuthAccountUrl: (chain: StakingChain, address: string) => string;
|
|
97
|
+
type FetchOpts = {
|
|
98
|
+
fetchImpl?: typeof fetch;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
};
|
|
101
|
+
export declare function getCosmosDelegations(chain: StakingChain, delegatorAddress: string, opts?: FetchOpts): Promise<Delegation[]>;
|
|
102
|
+
export declare function getCosmosUnbondingDelegations(chain: StakingChain, delegatorAddress: string, opts?: FetchOpts): Promise<UnbondingDelegation[]>;
|
|
103
|
+
export declare function getCosmosDelegatorRewards(chain: StakingChain, delegatorAddress: string, opts?: FetchOpts): Promise<DelegatorRewardsResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the wrapped vesting account if the address is a vesting account,
|
|
106
|
+
* otherwise null. The auth endpoint always wraps in `BaseAccount` for
|
|
107
|
+
* non-vesting addresses, so we filter by `@type`.
|
|
108
|
+
*
|
|
109
|
+
* Used by callers that need to surface vesting state to the user (e.g.
|
|
110
|
+
* "X LUNA still locked, vesting until 2024-05-26"). NOT used by the staking
|
|
111
|
+
* msg builders — undelegate works on any delegated balance regardless of
|
|
112
|
+
* vesting state, the contract just controls when the unbonded coins become
|
|
113
|
+
* spendable post-21-day window.
|
|
114
|
+
*/
|
|
115
|
+
export declare function getCosmosVestingAccount(chain: StakingChain, address: string, opts?: FetchOpts): Promise<VestingAccount | null>;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=lcdQueries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcdQueries.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/cosmos/staking/lcdQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAQlE,MAAM,MAAM,IAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,MAAM,MAAM,UAAU,GAAG;IACvB,+CAA+C;IAC/C,gBAAgB,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EACxB,IAAI,GAAE,SAAc,GACnB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuBhC;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,YAAY,EACnB,gBAAgB,EAAE,MAAM,EACxB,IAAI,GAAE,SAAc,GACnB,OAAO,CAAC,wBAAwB,CAAC,CAenC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,SAAc,GACnB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAoBhC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { cosmosRpcUrl } from '../cosmosRpcUrl.js';
|
|
2
|
+
export const getDelegationsUrl = (chain, delegatorAddress) => `${cosmosRpcUrl[chain]}/cosmos/staking/v1beta1/delegations/${delegatorAddress}`;
|
|
3
|
+
export const getUnbondingDelegationsUrl = (chain, delegatorAddress) => `${cosmosRpcUrl[chain]}/cosmos/staking/v1beta1/delegators/${delegatorAddress}/unbonding_delegations`;
|
|
4
|
+
export const getDelegatorRewardsUrl = (chain, delegatorAddress) => `${cosmosRpcUrl[chain]}/cosmos/distribution/v1beta1/delegators/${delegatorAddress}/rewards`;
|
|
5
|
+
export const getAuthAccountUrl = (chain, address) => `${cosmosRpcUrl[chain]}/cosmos/auth/v1beta1/accounts/${address}`;
|
|
6
|
+
async function lcdGet(url, opts = {}) {
|
|
7
|
+
const f = opts.fetchImpl ?? fetch;
|
|
8
|
+
const res = await f(url, { signal: opts.signal });
|
|
9
|
+
if (!res.ok) {
|
|
10
|
+
// 404 on `/auth/accounts/{addr}` for an unseen address is a legitimate
|
|
11
|
+
// response shape on some chains. Caller decides what to do with it; we
|
|
12
|
+
// surface the status so they can branch on `error.message.includes('404')`.
|
|
13
|
+
throw new Error(`LCD ${res.status}: ${url}`);
|
|
14
|
+
}
|
|
15
|
+
return (await res.json());
|
|
16
|
+
}
|
|
17
|
+
export async function getCosmosDelegations(chain, delegatorAddress, opts = {}) {
|
|
18
|
+
const raw = await lcdGet(getDelegationsUrl(chain, delegatorAddress), opts);
|
|
19
|
+
return raw.delegation_responses.map(d => ({
|
|
20
|
+
validatorAddress: d.delegation.validator_address,
|
|
21
|
+
balance: d.balance,
|
|
22
|
+
shares: d.delegation.shares,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export async function getCosmosUnbondingDelegations(chain, delegatorAddress, opts = {}) {
|
|
26
|
+
const raw = await lcdGet(getUnbondingDelegationsUrl(chain, delegatorAddress), opts);
|
|
27
|
+
return raw.unbonding_responses.map(u => ({
|
|
28
|
+
validatorAddress: u.validator_address,
|
|
29
|
+
entries: u.entries.map(e => ({
|
|
30
|
+
creationHeight: e.creation_height,
|
|
31
|
+
completionTime: e.completion_time,
|
|
32
|
+
initialBalance: e.initial_balance,
|
|
33
|
+
balance: e.balance,
|
|
34
|
+
})),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
export async function getCosmosDelegatorRewards(chain, delegatorAddress, opts = {}) {
|
|
38
|
+
const raw = await lcdGet(getDelegatorRewardsUrl(chain, delegatorAddress), opts);
|
|
39
|
+
return {
|
|
40
|
+
// `?? []` on both fields: an address with zero unclaimed rewards (rare
|
|
41
|
+
// but valid - e.g. brand-new delegator who hasn't accrued anything yet,
|
|
42
|
+
// or one who claimed in the same block) returns a body where `rewards`
|
|
43
|
+
// (and sometimes `total`) is missing entirely on some chain firmwares.
|
|
44
|
+
// Without the fallback the .map call would throw on undefined.
|
|
45
|
+
rewards: (raw.rewards ?? []).map(r => ({ validatorAddress: r.validator_address, reward: r.reward })),
|
|
46
|
+
total: raw.total ?? [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the wrapped vesting account if the address is a vesting account,
|
|
51
|
+
* otherwise null. The auth endpoint always wraps in `BaseAccount` for
|
|
52
|
+
* non-vesting addresses, so we filter by `@type`.
|
|
53
|
+
*
|
|
54
|
+
* Used by callers that need to surface vesting state to the user (e.g.
|
|
55
|
+
* "X LUNA still locked, vesting until 2024-05-26"). NOT used by the staking
|
|
56
|
+
* msg builders — undelegate works on any delegated balance regardless of
|
|
57
|
+
* vesting state, the contract just controls when the unbonded coins become
|
|
58
|
+
* spendable post-21-day window.
|
|
59
|
+
*/
|
|
60
|
+
export async function getCosmosVestingAccount(chain, address, opts = {}) {
|
|
61
|
+
let raw;
|
|
62
|
+
try {
|
|
63
|
+
raw = await lcdGet(getAuthAccountUrl(chain, address), opts);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
// 404 on a brand-new (zero-tx) address is normal — return null so the
|
|
67
|
+
// caller doesn't have to differentiate "not found" from "not vesting".
|
|
68
|
+
if (e instanceof Error && e.message.startsWith('LCD 404'))
|
|
69
|
+
return null;
|
|
70
|
+
throw e;
|
|
71
|
+
}
|
|
72
|
+
const t = raw.account['@type'];
|
|
73
|
+
if (t === '/cosmos.vesting.v1beta1.PeriodicVestingAccount' ||
|
|
74
|
+
t === '/cosmos.vesting.v1beta1.ContinuousVestingAccount' ||
|
|
75
|
+
t === '/cosmos.vesting.v1beta1.DelayedVestingAccount') {
|
|
76
|
+
return raw.account;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=lcdQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcdQueries.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/cosmos/staking/lcdQueries.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA6F9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAmB,EAAE,gBAAwB,EAAU,EAAE,CACzF,GAAG,YAAY,CAAC,KAAK,CAAC,uCAAuC,gBAAgB,EAAE,CAAA;AAEjF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAmB,EAAE,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;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAmB,EACnB,OAAe,EACf,OAAkB,EAAE;IAGpB,IAAI,GAAQ,CAAA;IACZ,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,MAAM,CAAM,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;IAClE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,sEAAsE;QACtE,uEAAuE;QACvE,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAA;QACtE,MAAM,CAAC,CAAA;IACT,CAAC;IACD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9B,IACE,CAAC,KAAK,gDAAgD;QACtD,CAAC,KAAK,kDAAkD;QACxD,CAAC,KAAK,+CAA+C,EACrD,CAAC;QACD,OAAO,GAAG,CAAC,OAAoC,CAAA;IACjD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Midgard base URL used by every helper in this module. Matches what
|
|
3
3
|
* vultisig-ios and the rujira package use as the default mainnet endpoint.
|
|
4
4
|
*/
|
|
5
|
-
export declare const thorchainMidgardBaseUrl = "https://midgard.
|
|
5
|
+
export declare const thorchainMidgardBaseUrl = "https://midgard.thorchain.network";
|
|
6
6
|
/**
|
|
7
7
|
* Validate a THORChain pool id is in the canonical format.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,sCAAsC,CAAA;AA2B1E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,IAahD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAG5C,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAsBD,MAAM,MAAM,wBAAwB,GAAG;IACrC,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,wBAA6B,KACrC,OAAO,CAAC,oBAAoB,EAAE,CAahC,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { queryUrl } from '@vultisig/lib-utils/query/queryUrl';
|
|
|
3
3
|
* Midgard base URL used by every helper in this module. Matches what
|
|
4
4
|
* vultisig-ios and the rujira package use as the default mainnet endpoint.
|
|
5
5
|
*/
|
|
6
|
-
export const thorchainMidgardBaseUrl = 'https://midgard.
|
|
6
|
+
export const thorchainMidgardBaseUrl = 'https://midgard.thorchain.network';
|
|
7
7
|
/**
|
|
8
8
|
* Canonical THORChain pool-id format: `CHAIN.ASSET` for native assets
|
|
9
9
|
* (e.g. `BTC.BTC`, `ETH.ETH`) or `CHAIN.ASSET-CONTRACT` for ERC-20-style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,GAAG,qCAAqC,CAAA;AAExD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAQ,EAAE;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,8DAA8D,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACvG,CAAA;IACH,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qCAAqC;YAC7E,0EAA0E;YAC1E,+DAA+D,CAClE,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/D,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC,CAAA;AA2BD,MAAM,aAA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CAAA;AAE5C,eAAO,MAAM,YAAY,QAA0B,CAAA;AAEnD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,eAAO,MAAM,YAAY,QAA0B,CAAA;AAEnD,eAAO,MAAM,eAAe,kBAA8C,CAAA"}
|
|
@@ -2,7 +2,5 @@ import { rootApiUrl } from '@vultisig/core-config';
|
|
|
2
2
|
import { memoize } from '@vultisig/lib-utils/memoize';
|
|
3
3
|
import { Connection } from '@solana/web3.js';
|
|
4
4
|
export const solanaRpcUrl = `${rootApiUrl}/solana/`;
|
|
5
|
-
export const getSolanaClient = memoize(() =>
|
|
6
|
-
return new Connection(solanaRpcUrl);
|
|
7
|
-
});
|
|
5
|
+
export const getSolanaClient = memoize(() => new Connection(solanaRpcUrl));
|
|
8
6
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,UAAU,UAAU,CAAA;AAEnD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,UAAU,UAAU,CAAA;AAEnD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TonMessageBodyIntent } from './types.js';
|
|
2
|
+
export declare const tonPayloadToBase64: (payload?: string | null) => string | null;
|
|
3
|
+
/**
|
|
4
|
+
* Input to {@link decodeTonMessageBody}. `outerDestination` is the `to` field
|
|
5
|
+
* of the outgoing TON message (`TonMessage.to` in the keysign payload). It is
|
|
6
|
+
* required to bind opcode-based swap classification to known router contracts.
|
|
7
|
+
*/
|
|
8
|
+
export type DecodeTonMessageBodyInput = {
|
|
9
|
+
payload: string | null | undefined;
|
|
10
|
+
outerDestination: string | null | undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Decode the body BOC of a TON internal message into a structured intent.
|
|
14
|
+
*
|
|
15
|
+
* Accepts the base64 BOC carried in `TonMessage.payload` (Vultisig's keysign
|
|
16
|
+
* payload schema) along with the outer message destination. Returns `null`
|
|
17
|
+
* when the payload is empty, not a parseable BOC, has no opcode header, or
|
|
18
|
+
* carries an opcode this decoder doesn't yet handle — callers should fall
|
|
19
|
+
* back to displaying the raw TON transfer.
|
|
20
|
+
*
|
|
21
|
+
* **Router binding.** Opcodes are contract-local in TON, so an attacker can
|
|
22
|
+
* craft a body whose leading 32 bits collide with a known DEX swap opcode. To
|
|
23
|
+
* prevent the keysign UI from labeling such a body as a "swap":
|
|
24
|
+
*
|
|
25
|
+
* - `DEDUST_NATIVE_SWAP` is dispatched only when `outerDestination` is a
|
|
26
|
+
* known DeDust **native vault** (NOT the factory — the factory only
|
|
27
|
+
* receives `create_vault`/`create_pool` ops; `swap#ea06185d` lives on
|
|
28
|
+
* the per-asset vault contracts per
|
|
29
|
+
* https://docs.dedust.io/reference/tlb-schemes).
|
|
30
|
+
* - `PTON_TRANSFER` (STON.fi v2 TON-side swap) is dispatched only when
|
|
31
|
+
* `outerDestination` is a known STON.fi v2 pTON wallet.
|
|
32
|
+
* - STON.fi v2 jetton-swap detection inside `JETTON_TRANSFER` is gated on
|
|
33
|
+
* the inner `destination` field being a known STON.fi v2 router.
|
|
34
|
+
*
|
|
35
|
+
* DeDust jetton-swap detection is intentionally not provided — DeDust vaults
|
|
36
|
+
* are per-jetton and not statically enumerable.
|
|
37
|
+
*
|
|
38
|
+
* Note: dApps sometimes prefix a jetton transfer body with an empty 32-bit
|
|
39
|
+
* "text comment" header (op = 0). In that case, we look at the next 32 bits.
|
|
40
|
+
*/
|
|
41
|
+
export declare const decodeTonMessageBody: ({ payload: payloadBase64, outerDestination, }: DecodeTonMessageBodyInput) => TonMessageBodyIntent | null;
|
|
42
|
+
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/ton/messageBody/decode.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAiB,MAAM,SAAS,CAAA;AA2B7D,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAOrE,CAAA;AAqRD;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAClC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC5C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,oBAAoB,GAAI,+CAGlC,yBAAyB,KAAG,oBAAoB,GAAG,IA0CrD,CAAA"}
|