@revibase/core 0.6.1 → 0.7.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 +52 -41
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +429 -1642
- package/dist/index.d.ts +429 -1642
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Core types and helpers for Revibase multi-wallet: transfer intents and custom va
|
|
|
8
8
|
|
|
9
9
|
## Initialize
|
|
10
10
|
|
|
11
|
-
Call `initialize()` once before using helpers that rely on shared RPC clients (for example `getSolanaRpc()`
|
|
11
|
+
Call `initialize()` once before using helpers that rely on shared RPC clients (for example `getSolanaRpc()`).
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
14
|
import { initialize } from "@revibase/core";
|
|
@@ -35,7 +35,7 @@ declare const memberSigner: TransactionSigner;
|
|
|
35
35
|
|
|
36
36
|
const createUserIx = await createUserAccounts({
|
|
37
37
|
payer,
|
|
38
|
-
createUserArgs:
|
|
38
|
+
createUserArgs: { member: memberSigner, role: UserRole.Member },
|
|
39
39
|
});
|
|
40
40
|
// Build a tx with createUserIx; sign with payer + memberSigner, then send.
|
|
41
41
|
```
|
|
@@ -75,16 +75,13 @@ const createWalletIx = await createWallet({
|
|
|
75
75
|
const setWalletAsDelegateIx = await editUserDelegate({
|
|
76
76
|
payer,
|
|
77
77
|
user: memberSigner,
|
|
78
|
-
newDelegate:
|
|
79
|
-
index: globalCounter.data.index,
|
|
80
|
-
settingsAddressTreeIndex: 0,
|
|
81
|
-
},
|
|
78
|
+
newDelegate: Number(globalCounter.data.index),
|
|
82
79
|
});
|
|
83
80
|
|
|
84
81
|
// Build a tx with setWalletAsDelegateIx; sign with payer + memberSigner, then send.
|
|
85
82
|
```
|
|
86
83
|
|
|
87
|
-
After confirmation, use [Resolve
|
|
84
|
+
After confirmation, use [Resolve delegated wallet settings](#1-resolve-delegated-wallet-settings) with this index to get `settings` and `walletAddress` for transfers or custom transactions.
|
|
88
85
|
|
|
89
86
|
---
|
|
90
87
|
|
|
@@ -92,41 +89,46 @@ After confirmation, use [Resolve settings and compressed flag](#1-resolve-settin
|
|
|
92
89
|
|
|
93
90
|
Move SOL or SPL tokens from a multi-wallet via on-chain intent instructions.
|
|
94
91
|
|
|
95
|
-
### 1. Resolve
|
|
92
|
+
### 1. Resolve delegated wallet settings
|
|
96
93
|
|
|
97
|
-
Using the member signer, get the delegated wallet’s settings and
|
|
94
|
+
Using the member signer, get the delegated wallet’s settings PDA and vault address:
|
|
98
95
|
|
|
99
96
|
```ts
|
|
100
97
|
import {
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
fetchSettings,
|
|
99
|
+
fetchUser,
|
|
103
100
|
getSettingsFromIndex,
|
|
101
|
+
getSolanaRpc,
|
|
102
|
+
getUserAddress,
|
|
104
103
|
getWalletAddressFromSettings,
|
|
105
104
|
} from "@revibase/core";
|
|
106
105
|
import type { TransactionSigner } from "gill";
|
|
107
106
|
|
|
108
107
|
declare const memberSigner: TransactionSigner;
|
|
109
108
|
|
|
110
|
-
const user =
|
|
109
|
+
const user = (
|
|
110
|
+
await fetchUser(getSolanaRpc(), await getUserAddress(memberSigner.address))
|
|
111
|
+
).data;
|
|
111
112
|
const delegatedWallet = user.wallets.find((w) => w.isDelegate);
|
|
112
113
|
if (!delegatedWallet)
|
|
113
114
|
throw new Error("memberSigner is not delegated to any wallet");
|
|
114
115
|
|
|
115
116
|
const settingsIndex = delegatedWallet.index;
|
|
116
117
|
const settings = await getSettingsFromIndex(settingsIndex);
|
|
117
|
-
const settingsAccount = await
|
|
118
|
-
const compressed = settingsAccount.isCompressed;
|
|
118
|
+
const settingsAccount = (await fetchSettings(getSolanaRpc(), settings)).data;
|
|
119
119
|
const walletAddress = await getWalletAddressFromSettings(settings);
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
Use `settings`, `
|
|
122
|
+
Use `settings`, `settingsAccount`, and (optionally) `walletAddress` in the following steps.
|
|
123
123
|
|
|
124
124
|
### 2. Native SOL transfer
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
127
|
import {
|
|
128
128
|
createTransactionManagerSigner,
|
|
129
|
-
|
|
129
|
+
fetchUser,
|
|
130
|
+
getSolanaRpc,
|
|
131
|
+
getUserAddress,
|
|
130
132
|
nativeTransferIntent,
|
|
131
133
|
retrieveTransactionManager,
|
|
132
134
|
} from "@revibase/core";
|
|
@@ -143,10 +145,12 @@ const tmResult = retrieveTransactionManager(
|
|
|
143
145
|
);
|
|
144
146
|
let transactionManagerSigner: TransactionSigner | null = null;
|
|
145
147
|
if (tmResult !== null) {
|
|
146
|
-
const userAccountData =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
const userAccountData = (
|
|
149
|
+
await fetchUser(
|
|
150
|
+
getSolanaRpc(),
|
|
151
|
+
await getUserAddress(tmResult.transactionManagerAddress),
|
|
152
|
+
)
|
|
153
|
+
).data;
|
|
150
154
|
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
151
155
|
throw new Error("Transaction manager endpoint is missing for this account");
|
|
152
156
|
}
|
|
@@ -164,8 +168,6 @@ const instructions = await nativeTransferIntent({
|
|
|
164
168
|
memberSigner,
|
|
165
169
|
...(transactionManagerSigner ? [transactionManagerSigner] : []),
|
|
166
170
|
],
|
|
167
|
-
payer,
|
|
168
|
-
compressed,
|
|
169
171
|
});
|
|
170
172
|
// Build tx from instructions with prepareTransactionMessage (or similar), then send.
|
|
171
173
|
```
|
|
@@ -175,7 +177,9 @@ const instructions = await nativeTransferIntent({
|
|
|
175
177
|
```ts
|
|
176
178
|
import {
|
|
177
179
|
createTransactionManagerSigner,
|
|
178
|
-
|
|
180
|
+
fetchUser,
|
|
181
|
+
getSolanaRpc,
|
|
182
|
+
getUserAddress,
|
|
179
183
|
retrieveTransactionManager,
|
|
180
184
|
tokenTransferIntent,
|
|
181
185
|
} from "@revibase/core";
|
|
@@ -193,10 +197,12 @@ const tmResult = retrieveTransactionManager(
|
|
|
193
197
|
);
|
|
194
198
|
let transactionManagerSigner: TransactionSigner | null = null;
|
|
195
199
|
if (tmResult !== null) {
|
|
196
|
-
const userAccountData =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
+
const userAccountData = (
|
|
201
|
+
await fetchUser(
|
|
202
|
+
getSolanaRpc(),
|
|
203
|
+
await getUserAddress(tmResult.transactionManagerAddress),
|
|
204
|
+
)
|
|
205
|
+
).data;
|
|
200
206
|
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
201
207
|
throw new Error("Transaction manager endpoint is missing for this account");
|
|
202
208
|
}
|
|
@@ -217,7 +223,6 @@ const instructions = await tokenTransferIntent({
|
|
|
217
223
|
amount: 1_000_000n,
|
|
218
224
|
mint,
|
|
219
225
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
|
|
220
|
-
compressed,
|
|
221
226
|
});
|
|
222
227
|
// Build tx from instructions, then send. Same signer pattern as native transfer if using a transaction manager.
|
|
223
228
|
```
|
|
@@ -231,15 +236,17 @@ const instructions = await tokenTransferIntent({
|
|
|
231
236
|
|
|
232
237
|
In both cases, use `getSendAndConfirmTransaction()` (after `initialize()`) or your own Gill client to send.
|
|
233
238
|
|
|
234
|
-
Prerequisite: `settings`, `
|
|
239
|
+
Prerequisite: `settings`, `walletAddress`, and `settingsAccount` from [Resolve delegated wallet settings](#1-resolve-delegated-wallet-settings).
|
|
235
240
|
|
|
236
241
|
### Sync: prepareTransactionSync
|
|
237
242
|
|
|
238
243
|
```ts
|
|
239
244
|
import {
|
|
240
245
|
createTransactionManagerSigner,
|
|
241
|
-
|
|
246
|
+
fetchUser,
|
|
242
247
|
getSendAndConfirmTransaction,
|
|
248
|
+
getSolanaRpc,
|
|
249
|
+
getUserAddress,
|
|
243
250
|
prepareTransactionMessage,
|
|
244
251
|
prepareTransactionSync,
|
|
245
252
|
retrieveTransactionManager,
|
|
@@ -275,10 +282,12 @@ const tmResult = retrieveTransactionManager(
|
|
|
275
282
|
);
|
|
276
283
|
let transactionManagerSigner: TransactionSigner | null = null;
|
|
277
284
|
if (tmResult !== null) {
|
|
278
|
-
const userAccountData =
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
const userAccountData = (
|
|
286
|
+
await fetchUser(
|
|
287
|
+
getSolanaRpc(),
|
|
288
|
+
await getUserAddress(tmResult.transactionManagerAddress),
|
|
289
|
+
)
|
|
290
|
+
).data;
|
|
282
291
|
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
283
292
|
throw new Error("Transaction manager endpoint is missing for this account");
|
|
284
293
|
}
|
|
@@ -290,7 +299,6 @@ if (tmResult !== null) {
|
|
|
290
299
|
}
|
|
291
300
|
|
|
292
301
|
const details = await prepareTransactionSync({
|
|
293
|
-
compressed,
|
|
294
302
|
payer,
|
|
295
303
|
settings,
|
|
296
304
|
transactionMessageBytes,
|
|
@@ -316,8 +324,10 @@ const signature = await sendAndConfirm({
|
|
|
316
324
|
```ts
|
|
317
325
|
import {
|
|
318
326
|
createTransactionManagerSigner,
|
|
319
|
-
|
|
327
|
+
fetchUser,
|
|
320
328
|
getSendAndConfirmTransaction,
|
|
329
|
+
getSolanaRpc,
|
|
330
|
+
getUserAddress,
|
|
321
331
|
prepareTransactionMessage,
|
|
322
332
|
prepareTransactionBundle,
|
|
323
333
|
retrieveTransactionManager,
|
|
@@ -352,10 +362,12 @@ const tmResult = retrieveTransactionManager(
|
|
|
352
362
|
);
|
|
353
363
|
let transactionManagerSigner: TransactionSigner | null = null;
|
|
354
364
|
if (tmResult !== null) {
|
|
355
|
-
const userAccountData =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
365
|
+
const userAccountData = (
|
|
366
|
+
await fetchUser(
|
|
367
|
+
getSolanaRpc(),
|
|
368
|
+
await getUserAddress(tmResult.transactionManagerAddress),
|
|
369
|
+
)
|
|
370
|
+
).data;
|
|
359
371
|
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
360
372
|
throw new Error("Transaction manager endpoint is missing for this account");
|
|
361
373
|
}
|
|
@@ -372,7 +384,6 @@ const bundle = await prepareTransactionBundle({
|
|
|
372
384
|
transactionMessageBytes,
|
|
373
385
|
creator: transactionManagerSigner ?? memberSigner,
|
|
374
386
|
executor: transactionManagerSigner ? memberSigner : undefined,
|
|
375
|
-
compressed,
|
|
376
387
|
addressesByLookupTableAddress: addressLookups,
|
|
377
388
|
jitoBundlesTipAmount: 10_000, // optional, lamports
|
|
378
389
|
});
|