@vultisig/core-chain 2.21.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/chains/solana/staking/tx/buildUnsignedStakingTx.d.ts +27 -0
- package/dist/chains/solana/staking/tx/buildUnsignedStakingTx.d.ts.map +1 -0
- package/dist/chains/solana/staking/tx/buildUnsignedStakingTx.js +92 -0
- package/dist/chains/solana/staking/tx/buildUnsignedStakingTx.js.map +1 -0
- package/dist/chains/solana/staking/tx/stakingPayload.d.ts +44 -0
- package/dist/chains/solana/staking/tx/stakingPayload.d.ts.map +1 -0
- package/dist/chains/solana/staking/tx/stakingPayload.js +9 -0
- package/dist/chains/solana/staking/tx/stakingPayload.js.map +1 -0
- package/dist/tx/broadcast/resolvers/solana.d.ts.map +1 -1
- package/dist/tx/broadcast/resolvers/solana.js +27 -1
- package/dist/tx/broadcast/resolvers/solana.js.map +1 -1
- package/package.json +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @vultisig/core-chain
|
|
2
2
|
|
|
3
|
+
## 2.22.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6302825`](https://github.com/vultisig/vultisig-sdk/commit/63028250c7a17bf165046f0bb0c2263354dab66a)]:
|
|
8
|
+
- @vultisig/lib-utils@0.10.4
|
|
9
|
+
|
|
10
|
+
## 2.22.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#915](https://github.com/vultisig/vultisig-sdk/pull/915) [`4941508`](https://github.com/vultisig/vultisig-sdk/commit/4941508f5002e1251b5cc1cbc08ed0ebc379646a) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - feat(solana): native-staking transaction builder (byte-parity)
|
|
15
|
+
|
|
16
|
+
Phase 3 of Solana native staking. Adds the signing core for the delegate flow
|
|
17
|
+
(and the proto for the later unstake / withdraw / move-stake ops) under
|
|
18
|
+
`@vultisig/core-chain/chains/solana/staking/tx`:
|
|
19
|
+
|
|
20
|
+
- `stakingPayload` — discriminated staking-op intent (delegate / unstake /
|
|
21
|
+
withdraw / move-stake deactivate + redelegate sub-steps).
|
|
22
|
+
- `buildUnsignedStakingTx` — maps a payload to the wallet-core Solana stake
|
|
23
|
+
proto (`delegateStakeTransaction` derives the stake account; move-redelegate
|
|
24
|
+
sets it explicitly), compiles a zero-signature envelope via
|
|
25
|
+
`TransactionCompiler`, and returns it base64-encoded. This is the MPC
|
|
26
|
+
byte-parity contract: the initiating device builds these bytes once (pinning
|
|
27
|
+
the recent blockhash + the derived stake-account address) and relays them via
|
|
28
|
+
`signSolana.rawTransactions`, so every co-signer signs the identical message.
|
|
29
|
+
|
|
30
|
+
Adds `long` to core-chain deps (Long-typed proto amount fields). Byte-parity
|
|
31
|
+
tests build delegate / deactivate / withdraw / move-redelegate txs against real
|
|
32
|
+
wallet-core, decode them back, and assert determinism.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#916](https://github.com/vultisig/vultisig-sdk/pull/916) [`17fcbc0`](https://github.com/vultisig/vultisig-sdk/commit/17fcbc0acf983959be7faaf4ab789b4268a83c31) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - Solana broadcast: surface the on-chain rejection reason. When `sendTransaction` is rejected at preflight, the RPC returns the actionable detail in `data.err` / `data.logs` (the program logs), which web3.js exposes via `SendTransactionError.logs` while leaving the bare `.message` ("failed to send transaction") uninformative. The broadcast resolver now folds those program logs into the thrown error's message (preserving the original error as `cause`), so consumers reading the top-level message see _why_ the network rejected the transaction — "insufficient lamports", a custom program error, a failed instruction — instead of just that it failed.
|
|
37
|
+
|
|
3
38
|
## 2.21.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WalletCore } from '@trustwallet/wallet-core';
|
|
2
|
+
import { SolanaStakingPayload } from './stakingPayload.js';
|
|
3
|
+
type BuildUnsignedStakingTxInput = {
|
|
4
|
+
walletCore: WalletCore;
|
|
5
|
+
payload: SolanaStakingPayload;
|
|
6
|
+
/** The signer's Solana address (fee payer / stake authority). */
|
|
7
|
+
sender: string;
|
|
8
|
+
/** The signer's ed25519 public key, hex-encoded. */
|
|
9
|
+
hexPublicKey: string;
|
|
10
|
+
recentBlockHash: string;
|
|
11
|
+
priorityFeePrice: bigint;
|
|
12
|
+
priorityFeeLimit: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compiles the unsigned staking transaction (zero-signature envelope) and
|
|
16
|
+
* returns it base64-encoded. This is the byte-parity contract for native
|
|
17
|
+
* staking: the initiating device builds these bytes once — pinning the recent
|
|
18
|
+
* blockhash and the wallet-core-derived stake-account address — and relays them
|
|
19
|
+
* via `SignSolana.rawTransactions`. Every co-signing device then signs the
|
|
20
|
+
* IDENTICAL message bytes through the raw-transaction path, so no device
|
|
21
|
+
* rebuilds the input from a non-round-tripped staking payload.
|
|
22
|
+
*
|
|
23
|
+
* Port of iOS `SolanaHelper.buildStakingUnsignedTransaction`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const buildUnsignedStakingTx: ({ walletCore, payload, sender, hexPublicKey, recentBlockHash, priorityFeePrice, priorityFeeLimit, }: BuildUnsignedStakingTxInput) => string;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=buildUnsignedStakingTx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUnsignedStakingTx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/solana/staking/tx/buildUnsignedStakingTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAIzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,KAAK,2BAA2B,GAAG;IACjC,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,oBAAoB,CAAA;IAC7B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAiDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAI,qGAQpC,2BAA2B,KAAG,MAuChC,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { TW } from '@trustwallet/wallet-core';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import Long from 'long';
|
|
4
|
+
const toLong = (value) => Long.fromString(value.toString());
|
|
5
|
+
/**
|
|
6
|
+
* Maps a staking payload to the wallet-core `SigningInput` transaction-type
|
|
7
|
+
* oneof:
|
|
8
|
+
* - delegate: `delegateStakeTransaction` (stake account omitted →
|
|
9
|
+
* wallet-core derives it; emits create+initialize+
|
|
10
|
+
* delegate in one tx)
|
|
11
|
+
* - unstake / move-deactivate: `deactivateStakeTransaction` (existing account)
|
|
12
|
+
* - withdraw: `withdrawTransaction` (existing account + amount)
|
|
13
|
+
* - move-redelegate: `delegateStakeTransaction` with the existing account
|
|
14
|
+
* set EXPLICITLY (re-delegate, don't derive a new one)
|
|
15
|
+
*/
|
|
16
|
+
const transactionTypeFields = (payload) => {
|
|
17
|
+
switch (payload.op) {
|
|
18
|
+
case 'delegate':
|
|
19
|
+
return {
|
|
20
|
+
delegateStakeTransaction: TW.Solana.Proto.DelegateStake.create({
|
|
21
|
+
validatorPubkey: payload.votePubkey,
|
|
22
|
+
value: toLong(payload.lamports),
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
case 'unstake':
|
|
26
|
+
case 'moveStakeDeactivate':
|
|
27
|
+
return {
|
|
28
|
+
deactivateStakeTransaction: TW.Solana.Proto.DeactivateStake.create({
|
|
29
|
+
stakeAccount: payload.stakeAccount,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
case 'withdraw':
|
|
33
|
+
return {
|
|
34
|
+
withdrawTransaction: TW.Solana.Proto.WithdrawStake.create({
|
|
35
|
+
stakeAccount: payload.stakeAccount,
|
|
36
|
+
value: toLong(payload.lamports),
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
case 'moveStakeRedelegate':
|
|
40
|
+
return {
|
|
41
|
+
delegateStakeTransaction: TW.Solana.Proto.DelegateStake.create({
|
|
42
|
+
validatorPubkey: payload.votePubkey,
|
|
43
|
+
value: toLong(payload.lamports),
|
|
44
|
+
stakeAccount: payload.stakeAccount,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Compiles the unsigned staking transaction (zero-signature envelope) and
|
|
51
|
+
* returns it base64-encoded. This is the byte-parity contract for native
|
|
52
|
+
* staking: the initiating device builds these bytes once — pinning the recent
|
|
53
|
+
* blockhash and the wallet-core-derived stake-account address — and relays them
|
|
54
|
+
* via `SignSolana.rawTransactions`. Every co-signing device then signs the
|
|
55
|
+
* IDENTICAL message bytes through the raw-transaction path, so no device
|
|
56
|
+
* rebuilds the input from a non-round-tripped staking payload.
|
|
57
|
+
*
|
|
58
|
+
* Port of iOS `SolanaHelper.buildStakingUnsignedTransaction`.
|
|
59
|
+
*/
|
|
60
|
+
export const buildUnsignedStakingTx = ({ walletCore, payload, sender, hexPublicKey, recentBlockHash, priorityFeePrice, priorityFeeLimit, }) => {
|
|
61
|
+
const input = TW.Solana.Proto.SigningInput.create({
|
|
62
|
+
v0Msg: true,
|
|
63
|
+
recentBlockhash: recentBlockHash,
|
|
64
|
+
sender,
|
|
65
|
+
priorityFeePrice: TW.Solana.Proto.PriorityFeePrice.create({
|
|
66
|
+
price: toLong(priorityFeePrice),
|
|
67
|
+
}),
|
|
68
|
+
priorityFeeLimit: TW.Solana.Proto.PriorityFeeLimit.create({
|
|
69
|
+
limit: priorityFeeLimit,
|
|
70
|
+
}),
|
|
71
|
+
...transactionTypeFields(payload),
|
|
72
|
+
});
|
|
73
|
+
const inputData = TW.Solana.Proto.SigningInput.encode(input).finish();
|
|
74
|
+
// Compile a zero-signature envelope: a single 64-byte zero signature plus the
|
|
75
|
+
// signer's public key, exactly as iOS does. The compiler assembles the wire
|
|
76
|
+
// message with the placeholder signature; peers re-sign the relayed bytes.
|
|
77
|
+
const signatures = walletCore.DataVector.create();
|
|
78
|
+
signatures.add(new Uint8Array(64));
|
|
79
|
+
const publicKeys = walletCore.DataVector.create();
|
|
80
|
+
publicKeys.add(Buffer.from(hexPublicKey, 'hex'));
|
|
81
|
+
const compiled = walletCore.TransactionCompiler.compileWithSignatures(walletCore.CoinType.solana, inputData, signatures, publicKeys);
|
|
82
|
+
const output = TW.Solana.Proto.SigningOutput.decode(compiled);
|
|
83
|
+
if (output.errorMessage) {
|
|
84
|
+
throw new Error(`solana staking compile failed: ${output.errorMessage}`);
|
|
85
|
+
}
|
|
86
|
+
// WalletCore emits base58 (the signing input never sets `txEncoding`).
|
|
87
|
+
// Normalize to base64 — the encoding `SignSolana.rawTransactions` and the
|
|
88
|
+
// raw-signing path consume.
|
|
89
|
+
const txBytes = walletCore.Base58.decodeNoCheck(output.encoded);
|
|
90
|
+
return Buffer.from(txBytes).toString('base64');
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=buildUnsignedStakingTx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUnsignedStakingTx.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/solana/staking/tx/buildUnsignedStakingTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAA;AAgBvB,MAAM,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,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7D,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;IAC1E,CAAC;IAED,uEAAuE;IACvE,0EAA0E;IAC1E,4BAA4B;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAChD,CAAC,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carries the Solana staking-operation intent from the build-keysign step into
|
|
3
|
+
* the byte-parity unsigned-tx builder (wallet-core's Solana stake proto:
|
|
4
|
+
* delegate / deactivate / withdraw / move-stake).
|
|
5
|
+
*
|
|
6
|
+
* A move-stake (redelegate A → B) is a guided, multi-transaction, cross-epoch
|
|
7
|
+
* flow — Solana has no native redelegate. It decomposes into discrete sub-steps
|
|
8
|
+
* mapped onto existing wallet-core primitives so the cross-device byte-parity
|
|
9
|
+
* guarantee holds:
|
|
10
|
+
* - `moveStakeDeactivate` → DeactivateStake on the moved account (byte-
|
|
11
|
+
* identical to a plain unstake); begins the ~1-epoch cooldown.
|
|
12
|
+
* - `moveStakeRedelegate` → DelegateStake the now-inactive moved account to
|
|
13
|
+
* validator B, with the existing `stakeAccount` set EXPLICITLY (a fresh
|
|
14
|
+
* delegate omits it so wallet-core derives a new account).
|
|
15
|
+
* - The Stake-program `Split` instruction (a partial move) is not exposed by
|
|
16
|
+
* wallet-core's high-level Solana proto, so only whole-account moves are
|
|
17
|
+
* supported.
|
|
18
|
+
*
|
|
19
|
+
* Port of iOS `SolanaStakingPayload`.
|
|
20
|
+
*/
|
|
21
|
+
export type SolanaStakingPayload = {
|
|
22
|
+
op: 'delegate';
|
|
23
|
+
votePubkey: string;
|
|
24
|
+
lamports: bigint;
|
|
25
|
+
} | {
|
|
26
|
+
op: 'unstake';
|
|
27
|
+
stakeAccount: string;
|
|
28
|
+
} | {
|
|
29
|
+
op: 'withdraw';
|
|
30
|
+
stakeAccount: string;
|
|
31
|
+
lamports: bigint;
|
|
32
|
+
} | {
|
|
33
|
+
op: 'moveStakeDeactivate';
|
|
34
|
+
stakeAccount: string;
|
|
35
|
+
} | {
|
|
36
|
+
op: 'moveStakeRedelegate';
|
|
37
|
+
stakeAccount: string;
|
|
38
|
+
votePubkey: string;
|
|
39
|
+
lamports: bigint;
|
|
40
|
+
};
|
|
41
|
+
/** Discriminant union of every Solana staking op type. */
|
|
42
|
+
export declare const solanaStakingOps: readonly ["delegate", "unstake", "withdraw", "moveStakeDeactivate", "moveStakeRedelegate"];
|
|
43
|
+
export type SolanaStakingOp = (typeof solanaStakingOps)[number];
|
|
44
|
+
//# sourceMappingURL=stakingPayload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stakingPayload.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/solana/staking/tx/stakingPayload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,EAAE,EAAE,qBAAqB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD;IACE,EAAE,EAAE,qBAAqB,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAEL,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,4FAMnB,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stakingPayload.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/solana/staking/tx/stakingPayload.ts"],"names":[],"mappings":"AAgCA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU;IACV,SAAS;IACT,UAAU;IACV,qBAAqB;IACrB,qBAAqB;CACb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/tx/broadcast/resolvers/solana.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/tx/broadcast/resolvers/solana.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAMvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AA2BjD,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,UAAU,CAAC,MAAM,CA+CpE,CAAA"}
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
import { SendTransactionError } from '@solana/web3.js';
|
|
1
2
|
import { getSolanaClient } from '@vultisig/core-chain/chains/solana/client';
|
|
2
3
|
import { sendJitoTransaction } from '@vultisig/core-chain/chains/solana/jito';
|
|
3
4
|
import { isInError } from '@vultisig/lib-utils/error/isInError';
|
|
4
5
|
import base58 from 'bs58';
|
|
5
6
|
import { verifyBroadcastByHash } from '../verifyBroadcastByHash.js';
|
|
7
|
+
/**
|
|
8
|
+
* Hoists the on-chain rejection reason into a Solana send error's message.
|
|
9
|
+
*
|
|
10
|
+
* On a preflight rejection the RPC returns the actionable detail in
|
|
11
|
+
* `data.err` / `data.logs` (the program logs), which `web3.js` exposes via
|
|
12
|
+
* `SendTransactionError.logs`. The bare `.message` ("failed to send
|
|
13
|
+
* transaction") hides it, so any consumer reading only the top-level message
|
|
14
|
+
* loses the reason. Fold the program logs into the message — preserving the
|
|
15
|
+
* original error as `cause` — so the real reason ("insufficient lamports",
|
|
16
|
+
* "custom program error: 0x1", a failed instruction) reaches the surface.
|
|
17
|
+
*/
|
|
18
|
+
const withSolanaBroadcastReason = (error) => {
|
|
19
|
+
if (!(error instanceof SendTransactionError)) {
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
const { logs } = error;
|
|
23
|
+
if (!logs || logs.length === 0) {
|
|
24
|
+
return error;
|
|
25
|
+
}
|
|
26
|
+
return new Error([error.message, ...logs].join('\n'), { cause: error });
|
|
27
|
+
};
|
|
6
28
|
export const broadcastSolanaTx = async ({ chain, tx }) => {
|
|
7
29
|
const rawTransaction = base58.decode(tx.encoded);
|
|
8
30
|
// Try JITO first for MEV protection, but still relay through standard RPC.
|
|
@@ -44,7 +66,11 @@ export const broadcastSolanaTx = async ({ chain, tx }) => {
|
|
|
44
66
|
if (isInError(error, 'already been processed', 'AlreadyProcessed')) {
|
|
45
67
|
return;
|
|
46
68
|
}
|
|
47
|
-
await verifyBroadcastByHash({
|
|
69
|
+
await verifyBroadcastByHash({
|
|
70
|
+
chain,
|
|
71
|
+
tx,
|
|
72
|
+
error: withSolanaBroadcastReason(error),
|
|
73
|
+
});
|
|
48
74
|
}
|
|
49
75
|
};
|
|
50
76
|
//# sourceMappingURL=solana.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/tx/broadcast/resolvers/solana.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../../../../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CAAA;IAC1F,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,kBAAkB,CAAC,cAAc,EAAE;YAC9C,aAAa,EAAE,KAAK;YACpB,mBAAmB,EAAE,WAAW;SACjC,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,sEAAsE;QACtE,oEAAoE;QACpE,oEAAoE;QACpE,wEAAwE;QACxE,EAAE;QACF,wEAAwE;QACxE,0EAA0E;QAC1E,0EAA0E;QAC1E,gEAAgE;QAChE,sEAAsE;QACtE,yEAAyE;QACzE,0EAA0E;QAC1E,wEAAwE;QACxE,2EAA2E;QAC3E,2DAA2D;QAC3D,uEAAuE;QACvE,uEAAuE;QACvE,mEAAmE;QACnE,IAAI,SAAS,CAAC,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,CAAC,EAAE,CAAC;YACnE,OAAM;QACR,CAAC;QACD,MAAM,qBAAqB,CAAC;YAC1B,KAAK;YACL,EAAE;YACF,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAC;SACxC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vultisig/core-chain",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "Blockchain chain logic shared across Vultisig clients",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -720,6 +720,16 @@
|
|
|
720
720
|
"import": "./dist/chains/solana/staking/rpc.js",
|
|
721
721
|
"default": "./dist/chains/solana/staking/rpc.js"
|
|
722
722
|
},
|
|
723
|
+
"./chains/solana/staking/tx/buildUnsignedStakingTx": {
|
|
724
|
+
"types": "./dist/chains/solana/staking/tx/buildUnsignedStakingTx.d.ts",
|
|
725
|
+
"import": "./dist/chains/solana/staking/tx/buildUnsignedStakingTx.js",
|
|
726
|
+
"default": "./dist/chains/solana/staking/tx/buildUnsignedStakingTx.js"
|
|
727
|
+
},
|
|
728
|
+
"./chains/solana/staking/tx/stakingPayload": {
|
|
729
|
+
"types": "./dist/chains/solana/staking/tx/stakingPayload.d.ts",
|
|
730
|
+
"import": "./dist/chains/solana/staking/tx/stakingPayload.js",
|
|
731
|
+
"default": "./dist/chains/solana/staking/tx/stakingPayload.js"
|
|
732
|
+
},
|
|
723
733
|
"./chains/sui/buildTransactionFromJson": {
|
|
724
734
|
"types": "./dist/chains/sui/buildTransactionFromJson.d.ts",
|
|
725
735
|
"import": "./dist/chains/sui/buildTransactionFromJson.js",
|
|
@@ -2020,7 +2030,7 @@
|
|
|
2020
2030
|
"@ton/crypto": "^3.3.0",
|
|
2021
2031
|
"@trustwallet/wallet-core": "^4.6.15",
|
|
2022
2032
|
"@vultisig/core-config": "0.9.1",
|
|
2023
|
-
"@vultisig/lib-utils": "0.10.
|
|
2033
|
+
"@vultisig/lib-utils": "0.10.4",
|
|
2024
2034
|
"bip32": "^5.0.1",
|
|
2025
2035
|
"bitcoinjs-lib": "^7.0.1",
|
|
2026
2036
|
"bs58": "^6.0.0",
|
|
@@ -2028,6 +2038,7 @@
|
|
|
2028
2038
|
"cbor-x": "^1.6.4",
|
|
2029
2039
|
"date-fns": "^4.4.0",
|
|
2030
2040
|
"ethers": "^6.17.0",
|
|
2041
|
+
"long": "^5.3.2",
|
|
2031
2042
|
"tiny-secp256k1": "^2.2.4",
|
|
2032
2043
|
"viem": "^2.53.1",
|
|
2033
2044
|
"xrpl": "^5.0.0"
|