@faremeter/wallet-solana-squads 0.1.0 → 0.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.
- package/package.json +6 -3
- package/src/index.ts +0 -148
- package/tsconfig.json +0 -8
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faremeter/wallet-solana-squads",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
8
11
|
"devDependencies": {
|
|
9
12
|
"@eslint/js": "^9.28.0",
|
|
10
13
|
"@tapjs/asserts": "^4.0.1",
|
|
@@ -14,12 +17,12 @@
|
|
|
14
17
|
"typescript": "^5.8.3",
|
|
15
18
|
"typescript-eslint": "^8.34.0",
|
|
16
19
|
"typescript-language-server": "^4.3.4",
|
|
17
|
-
"@faremeter/fetch": "0.1.
|
|
20
|
+
"@faremeter/fetch": "0.1.1"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
23
|
"@solana/web3.js": "^1.98.2",
|
|
21
24
|
"@sqds/multisig": "^2.1.4",
|
|
22
25
|
"bs58": "^6.0.0",
|
|
23
|
-
"@faremeter/types": "^0.1.
|
|
26
|
+
"@faremeter/types": "^0.1.1"
|
|
24
27
|
}
|
|
25
28
|
}
|
package/src/index.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Connection,
|
|
3
|
-
type Keypair,
|
|
4
|
-
type PublicKey,
|
|
5
|
-
type TransactionInstruction,
|
|
6
|
-
Transaction,
|
|
7
|
-
TransactionMessage,
|
|
8
|
-
VersionedTransaction,
|
|
9
|
-
sendAndConfirmTransaction,
|
|
10
|
-
} from "@solana/web3.js";
|
|
11
|
-
import * as multisig from "@sqds/multisig";
|
|
12
|
-
import bs58 from "bs58";
|
|
13
|
-
|
|
14
|
-
export async function createSquadsWallet(
|
|
15
|
-
network: string,
|
|
16
|
-
connection: Connection,
|
|
17
|
-
keypair: Keypair,
|
|
18
|
-
multisigPda: PublicKey,
|
|
19
|
-
squadMember: Keypair,
|
|
20
|
-
) {
|
|
21
|
-
return {
|
|
22
|
-
network,
|
|
23
|
-
publicKey: keypair.publicKey,
|
|
24
|
-
buildTransaction: async (
|
|
25
|
-
instructions: TransactionInstruction[],
|
|
26
|
-
): Promise<VersionedTransaction> => {
|
|
27
|
-
const [vaultPda] = multisig.getVaultPda({
|
|
28
|
-
multisigPda,
|
|
29
|
-
index: 0,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const multisigInfo = await multisig.accounts.Multisig.fromAccountAddress(
|
|
33
|
-
connection,
|
|
34
|
-
multisigPda,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const currentTransactionIndex = Number(multisigInfo.transactionIndex);
|
|
38
|
-
const newTransactionIndex = BigInt(currentTransactionIndex + 1);
|
|
39
|
-
|
|
40
|
-
const recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
41
|
-
|
|
42
|
-
const testTransferMessage = new TransactionMessage({
|
|
43
|
-
payerKey: vaultPda,
|
|
44
|
-
recentBlockhash,
|
|
45
|
-
instructions,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const createVaultInstruction =
|
|
49
|
-
multisig.instructions.vaultTransactionCreate({
|
|
50
|
-
multisigPda,
|
|
51
|
-
transactionIndex: newTransactionIndex,
|
|
52
|
-
creator: keypair.publicKey,
|
|
53
|
-
vaultIndex: 0,
|
|
54
|
-
ephemeralSigners: 0,
|
|
55
|
-
transactionMessage: testTransferMessage,
|
|
56
|
-
memo: "Our first transfer!",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const createVaultTransaction = new Transaction().add(
|
|
60
|
-
createVaultInstruction,
|
|
61
|
-
);
|
|
62
|
-
const createVaultTxSignature = await sendAndConfirmTransaction(
|
|
63
|
-
connection,
|
|
64
|
-
createVaultTransaction,
|
|
65
|
-
[keypair],
|
|
66
|
-
);
|
|
67
|
-
console.log(
|
|
68
|
-
"Create vault transaction with signature",
|
|
69
|
-
createVaultTxSignature,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const createProposalInstruction = multisig.instructions.proposalCreate({
|
|
73
|
-
multisigPda,
|
|
74
|
-
transactionIndex: newTransactionIndex,
|
|
75
|
-
creator: keypair.publicKey,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const createProposalTransaction = new Transaction().add(
|
|
79
|
-
createProposalInstruction,
|
|
80
|
-
);
|
|
81
|
-
const createProposalTxSignature = await sendAndConfirmTransaction(
|
|
82
|
-
connection,
|
|
83
|
-
createProposalTransaction,
|
|
84
|
-
[keypair],
|
|
85
|
-
);
|
|
86
|
-
console.log(
|
|
87
|
-
"Create proposal transaction with signature",
|
|
88
|
-
createProposalTxSignature,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const adminApproveInstruction = multisig.instructions.proposalApprove({
|
|
92
|
-
multisigPda,
|
|
93
|
-
transactionIndex: newTransactionIndex,
|
|
94
|
-
member: keypair.publicKey,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const memberApproveInstruction = multisig.instructions.proposalApprove({
|
|
98
|
-
multisigPda,
|
|
99
|
-
transactionIndex: newTransactionIndex,
|
|
100
|
-
member: squadMember.publicKey,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const approveProposalTransaction = new Transaction().add(
|
|
104
|
-
adminApproveInstruction,
|
|
105
|
-
memberApproveInstruction,
|
|
106
|
-
);
|
|
107
|
-
const approveProposalTxSignature = await sendAndConfirmTransaction(
|
|
108
|
-
connection,
|
|
109
|
-
approveProposalTransaction,
|
|
110
|
-
[keypair, squadMember],
|
|
111
|
-
);
|
|
112
|
-
console.log(
|
|
113
|
-
"Approve vault transaction with signature",
|
|
114
|
-
approveProposalTxSignature,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const { instruction } =
|
|
118
|
-
await multisig.instructions.vaultTransactionExecute({
|
|
119
|
-
connection,
|
|
120
|
-
multisigPda,
|
|
121
|
-
transactionIndex: newTransactionIndex,
|
|
122
|
-
member: keypair.publicKey,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
126
|
-
|
|
127
|
-
const message = new TransactionMessage({
|
|
128
|
-
instructions: [instruction],
|
|
129
|
-
payerKey: keypair.publicKey,
|
|
130
|
-
recentBlockhash: blockhash,
|
|
131
|
-
}).compileToV0Message();
|
|
132
|
-
|
|
133
|
-
const tx = new VersionedTransaction(message);
|
|
134
|
-
tx.sign([keypair]);
|
|
135
|
-
|
|
136
|
-
if (tx.signatures[0] === undefined) {
|
|
137
|
-
throw new Error("vault transaction is undefined");
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
console.log(
|
|
141
|
-
"Execute vault transaction signature",
|
|
142
|
-
bs58.encode(tx.signatures[0]),
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
return tx;
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
}
|