@faremeter/wallet-solana-squads 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,19 +27,18 @@ pnpm install @faremeter/wallet-solana-squads
27
27
 
28
28
  Creates a Squads multisig wallet for Solana.
29
29
 
30
- Wraps the Squads SDK to create proposals, gather approvals, and execute
31
- vault transactions through a multisig workflow.
30
+ Wraps the Squads SDK (still on
32
31
 
33
- | Function | Type |
34
- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
- | `createSquadsWallet` | `(network: string, connection: Connection, keypair: Keypair, multisigPda: PublicKey, squadMember: Keypair) => Promise<{ network: string; publicKey: PublicKey; buildTransaction: (instructions: TransactionInstruction[]) => Promise<...>; }>` |
32
+ | Function | Type |
33
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `createSquadsWallet` | `(network: string, connection: Connection, keypair: Keypair, multisigPda: PublicKey, squadMember: Keypair) => Promise<{ network: string; publicKey: Address; buildTransaction: (instructions: readonly Instruction<...>[], lifetimeConstraint: { ...; }) => Promise<...>; }>` |
36
35
 
37
36
  Parameters:
38
37
 
39
38
  - `network`: - Solana network identifier.
40
- - `connection`: - Solana RPC connection.
39
+ - `connection`: - Solana RPC connection (v1).
41
40
  - `keypair`: - Admin keypair for creating and signing proposals.
42
- - `multisigPda`: - Program-derived address of the Squads multisig account.
41
+ - `multisigPda`: - Program-derived address of the Squads multisig.
43
42
  - `squadMember`: - Additional squad member keypair for approval quorum.
44
43
 
45
44
  Returns:
@@ -3,24 +3,38 @@
3
3
  * @sidebarTitle Wallet Squads
4
4
  * @description Squads multisig wallet integration for Solana
5
5
  * @packageDocumentation
6
+ *
7
+ * NOTE: This package retains @solana/web3.js v1 as a direct dependency
8
+ * because @sqds/multisig has no @solana/kit-compatible version. It
9
+ * exposes a kit-typed Wallet bridge so Faremeter callers can stay on
10
+ * the kit-native payment-solana/exact flow. A future kit
11
+ * reimplementation of the Squads instruction builders is a follow-up.
6
12
  */
7
- import { type Connection, type Keypair, type PublicKey, type TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
13
+ import { type Connection, type Keypair, type PublicKey } from "@solana/web3.js";
14
+ import { type Address, type Blockhash, type Instruction, type Transaction as KitTransaction } from "@solana/kit";
8
15
  /**
9
16
  * Creates a Squads multisig wallet for Solana.
10
17
  *
11
- * Wraps the Squads SDK to create proposals, gather approvals, and execute
12
- * vault transactions through a multisig workflow.
18
+ * Wraps the Squads SDK (still on @solana/web3.js v1 internally) and
19
+ * exposes a kit-typed Wallet via a bridge: callers pass kit
20
+ * `Instruction`s, the package converts them to v1 `TransactionInstruction`s,
21
+ * runs them through the full @sqds/multisig proposal + approve + execute
22
+ * flow, serializes the resulting v1 VersionedTransaction, and decodes
23
+ * the bytes as a kit `Transaction`.
13
24
  *
14
25
  * @param network - Solana network identifier.
15
- * @param connection - Solana RPC connection.
26
+ * @param connection - Solana RPC connection (v1).
16
27
  * @param keypair - Admin keypair for creating and signing proposals.
17
- * @param multisigPda - Program-derived address of the Squads multisig account.
28
+ * @param multisigPda - Program-derived address of the Squads multisig.
18
29
  * @param squadMember - Additional squad member keypair for approval quorum.
19
30
  * @returns A wallet object that builds and executes multisig transactions.
20
31
  */
21
32
  export declare function createSquadsWallet(network: string, connection: Connection, keypair: Keypair, multisigPda: PublicKey, squadMember: Keypair): Promise<{
22
33
  network: string;
23
- publicKey: PublicKey;
24
- buildTransaction: (instructions: TransactionInstruction[]) => Promise<VersionedTransaction>;
34
+ publicKey: Address;
35
+ buildTransaction: (instructions: readonly Instruction[], lifetimeConstraint: {
36
+ blockhash: Blockhash;
37
+ lastValidBlockHeight: bigint;
38
+ }) => Promise<KitTransaction>;
25
39
  }>;
26
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,sBAAsB,EAG3B,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAKzB;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,OAAO;;;qCAMF,sBAAsB,EAAE,KACrC,OAAO,CAAC,oBAAoB,CAAC;GAuHnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,SAAS,EAOf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,IAAI,cAAc,EACnC,MAAM,aAAa,CAAC;AA2BrB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,OAAO;;;qCAQF,SAAS,WAAW,EAAE,sBAChB;QAClB,SAAS,EAAE,SAAS,CAAC;QACrB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,KACA,OAAO,CAAC,cAAc,CAAC;GA2H7B"}
package/dist/src/index.js CHANGED
@@ -3,29 +3,59 @@
3
3
  * @sidebarTitle Wallet Squads
4
4
  * @description Squads multisig wallet integration for Solana
5
5
  * @packageDocumentation
6
+ *
7
+ * NOTE: This package retains @solana/web3.js v1 as a direct dependency
8
+ * because @sqds/multisig has no @solana/kit-compatible version. It
9
+ * exposes a kit-typed Wallet bridge so Faremeter callers can stay on
10
+ * the kit-native payment-solana/exact flow. A future kit
11
+ * reimplementation of the Squads instruction builders is a follow-up.
6
12
  */
7
- import { Transaction, TransactionMessage, VersionedTransaction, sendAndConfirmTransaction, } from "@solana/web3.js";
13
+ import { Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction, sendAndConfirmTransaction, PublicKey as SolanaPublicKey, } from "@solana/web3.js";
14
+ import { AccountRole, address, } from "@solana/kit";
15
+ import { getTransactionDecoder } from "@solana/transactions";
8
16
  import * as multisig from "@sqds/multisig";
9
17
  import bs58 from "bs58";
10
18
  import { logger } from "./logger.js";
19
+ function toV1Instruction(ix) {
20
+ if (!ix.accounts || !ix.data) {
21
+ throw new Error("squads bridge requires instructions with accounts and data");
22
+ }
23
+ return new TransactionInstruction({
24
+ programId: new SolanaPublicKey(ix.programAddress),
25
+ keys: ix.accounts.map((a) => ({
26
+ pubkey: new SolanaPublicKey(a.address),
27
+ isSigner: a.role === AccountRole.WRITABLE_SIGNER ||
28
+ a.role === AccountRole.READONLY_SIGNER,
29
+ isWritable: a.role === AccountRole.WRITABLE_SIGNER ||
30
+ a.role === AccountRole.WRITABLE,
31
+ })),
32
+ data: Buffer.from(ix.data),
33
+ });
34
+ }
11
35
  /**
12
36
  * Creates a Squads multisig wallet for Solana.
13
37
  *
14
- * Wraps the Squads SDK to create proposals, gather approvals, and execute
15
- * vault transactions through a multisig workflow.
38
+ * Wraps the Squads SDK (still on @solana/web3.js v1 internally) and
39
+ * exposes a kit-typed Wallet via a bridge: callers pass kit
40
+ * `Instruction`s, the package converts them to v1 `TransactionInstruction`s,
41
+ * runs them through the full @sqds/multisig proposal + approve + execute
42
+ * flow, serializes the resulting v1 VersionedTransaction, and decodes
43
+ * the bytes as a kit `Transaction`.
16
44
  *
17
45
  * @param network - Solana network identifier.
18
- * @param connection - Solana RPC connection.
46
+ * @param connection - Solana RPC connection (v1).
19
47
  * @param keypair - Admin keypair for creating and signing proposals.
20
- * @param multisigPda - Program-derived address of the Squads multisig account.
48
+ * @param multisigPda - Program-derived address of the Squads multisig.
21
49
  * @param squadMember - Additional squad member keypair for approval quorum.
22
50
  * @returns A wallet object that builds and executes multisig transactions.
23
51
  */
24
52
  export async function createSquadsWallet(network, connection, keypair, multisigPda, squadMember) {
53
+ const publicKey = address(keypair.publicKey.toBase58());
25
54
  return {
26
55
  network,
27
- publicKey: keypair.publicKey,
28
- buildTransaction: async (instructions) => {
56
+ publicKey,
57
+ buildTransaction: async (instructions, lifetimeConstraint) => {
58
+ const v1Instructions = instructions.map(toV1Instruction);
29
59
  const [vaultPda] = multisig.getVaultPda({
30
60
  multisigPda,
31
61
  index: 0,
@@ -33,11 +63,10 @@ export async function createSquadsWallet(network, connection, keypair, multisigP
33
63
  const multisigInfo = await multisig.accounts.Multisig.fromAccountAddress(connection, multisigPda);
34
64
  const currentTransactionIndex = Number(multisigInfo.transactionIndex);
35
65
  const newTransactionIndex = BigInt(currentTransactionIndex + 1);
36
- const recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
37
66
  const testTransferMessage = new TransactionMessage({
38
67
  payerKey: vaultPda,
39
- recentBlockhash,
40
- instructions,
68
+ recentBlockhash: lifetimeConstraint.blockhash,
69
+ instructions: v1Instructions,
41
70
  });
42
71
  const createVaultInstruction = multisig.instructions.vaultTransactionCreate({
43
72
  multisigPda,
@@ -84,13 +113,17 @@ export async function createSquadsWallet(network, connection, keypair, multisigP
84
113
  payerKey: keypair.publicKey,
85
114
  recentBlockhash: blockhash,
86
115
  }).compileToV0Message();
87
- const tx = new VersionedTransaction(message);
88
- tx.sign([keypair]);
89
- if (tx.signatures[0] === undefined) {
116
+ const v1Tx = new VersionedTransaction(message);
117
+ v1Tx.sign([keypair]);
118
+ if (v1Tx.signatures[0] === undefined) {
90
119
  throw new Error("vault transaction is undefined");
91
120
  }
92
- logger.info(`Execute vault transaction signature: ${bs58.encode(tx.signatures[0])}`);
93
- return tx;
121
+ logger.info(`Execute vault transaction signature: ${bs58.encode(v1Tx.signatures[0])}`);
122
+ // Bridge the v1 VersionedTransaction back to a kit Transaction by
123
+ // serializing to wire bytes and running them through the kit
124
+ // Transaction decoder.
125
+ const wireBytes = v1Tx.serialize();
126
+ return getTransactionDecoder().decode(wireBytes);
94
127
  },
95
128
  };
96
129
  }