@perena/vault-sdk 1.0.19 → 1.0.23
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 +35 -0
- package/dist/index.d.ts +311 -143
- package/dist/index.js +546 -206
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -105,6 +105,41 @@ const plan = await client.tx.executeDeposit.getTx({
|
|
|
105
105
|
const sig = await client.sendTransaction(payer, plan);
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
### Squads proposal routing
|
|
109
|
+
|
|
110
|
+
Browser integrations can map a connected Squads member wallet to a multisig and
|
|
111
|
+
vault index, then use the derived vault PDA while building the instruction:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import {
|
|
115
|
+
prepareVaultTransaction,
|
|
116
|
+
vaultAuthorityForWallet,
|
|
117
|
+
type SquadsWalletRouteConfig,
|
|
118
|
+
} from "@perena/vault-sdk";
|
|
119
|
+
|
|
120
|
+
const routes: SquadsWalletRouteConfig[] = [
|
|
121
|
+
{ wallet: "MEMBER_WALLET", multisigPda: "MULTISIG_PDA", vaultIndex: 0 },
|
|
122
|
+
];
|
|
123
|
+
const authority = vaultAuthorityForWallet(connectedWallet, routes);
|
|
124
|
+
const plan = await client.tx.setVaultConfig.getTx({
|
|
125
|
+
curator: address(authority.toBase58()),
|
|
126
|
+
// ...
|
|
127
|
+
});
|
|
128
|
+
const prepared = await prepareVaultTransaction({
|
|
129
|
+
connection,
|
|
130
|
+
proposer: connectedWallet,
|
|
131
|
+
instructions: plan.instructions.map(fromKitInstruction),
|
|
132
|
+
squadsRoutes: routes,
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
When the wallet is configured, `prepared.transaction` creates a Squads vault
|
|
137
|
+
transaction and proposal. The member signs and submits that outer transaction;
|
|
138
|
+
the multisig must still approve and execute the proposal. When no route matches,
|
|
139
|
+
the helper returns the original instructions as a normal direct transaction.
|
|
140
|
+
The configured member must have Squads' `Initiate` permission, and the vault
|
|
141
|
+
program role must be assigned to the derived Squads vault PDA.
|
|
142
|
+
|
|
108
143
|
`VaultTransactionPlan` contains:
|
|
109
144
|
|
|
110
145
|
- `instructions` — ordered `@solana/kit` instructions (preamble + program ix)
|