@revibase/core 0.3.2 → 0.3.3
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 +88 -37
- package/dist/index.cjs +2 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Core types and helpers for Revibase multi-wallet: transfer intents and custom vault-paid transactions (sync or Jito bundles).
|
|
4
4
|
|
|
5
|
-
**Contents:** [Create user](#create-a-user-account) → [Create wallet](#create-a-wallet) → [Transfer intents](#transfer-intents)
|
|
5
|
+
**Contents:** [Create user](#create-a-user-account) → [Create wallet](#create-a-wallet) → [Transfer intents](#transfer-intents) → [Custom transactions](#custom-transactions-sync-vs-bundle) (sync or Jito).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -105,13 +105,21 @@ const walletAddress = await getWalletAddressFromSettings(settings);
|
|
|
105
105
|
|
|
106
106
|
Use `settings`, `compressed`, and (optionally) `walletAddress` in the following steps.
|
|
107
107
|
|
|
108
|
-
### 2.
|
|
108
|
+
### 2. Transaction manager signer (when required)
|
|
109
|
+
|
|
110
|
+
If the wallet uses a [transaction manager](https://github.com/Revibase/multi-wallet/tree/main/packages/transaction-manager) member, add its signer for the native/SPL steps below and for [custom transactions](#custom-transactions-sync-vs-bundle). The manager’s HTTPS URL is stored on-chain on that member’s user account.
|
|
111
|
+
|
|
112
|
+
1. After you have `settingsAccount`, call `retrieveTransactionManager(memberAddress, settingsAccount)`. It returns **`null`** when the member already has Initiate, Vote, and Execute (no transaction manager signer is required). Otherwise it returns **`{ transactionManagerAddress, userAddressTreeIndex }`** — then load the user account with `fetchUserAccountData(transactionManagerAddress, userAddressTreeIndex)` and read `transactionManagerUrl` (a Gill `Option`: use it when `__option === "Some"` via `.value`).
|
|
113
|
+
2. Call `createTransactionManagerSigner({ address, url, authResponses?, transactionMessageBytes?, onPendingApprovalsCallback?, onPendingApprovalsSuccess?, abortController?, opts? })` to obtain a `TransactionSigner`.
|
|
114
|
+
|
|
115
|
+
### 3. Native SOL transfer
|
|
109
116
|
|
|
110
117
|
```ts
|
|
111
118
|
import {
|
|
119
|
+
createTransactionManagerSigner,
|
|
120
|
+
fetchUserAccountData,
|
|
112
121
|
nativeTransferIntent,
|
|
113
122
|
retrieveTransactionManager,
|
|
114
|
-
getSignedTransactionManager,
|
|
115
123
|
} from "@revibase/core";
|
|
116
124
|
import type { TransactionSigner } from "gill";
|
|
117
125
|
|
|
@@ -119,18 +127,27 @@ declare const payer: TransactionSigner;
|
|
|
119
127
|
declare const memberSigner: TransactionSigner;
|
|
120
128
|
declare const destination: string;
|
|
121
129
|
|
|
122
|
-
// For wallets with a transaction manager, add its signer. See
|
|
130
|
+
// For wallets with a transaction manager, add its signer. See [step 2](#2-transaction-manager-signer-when-required).
|
|
123
131
|
const tmResult = retrieveTransactionManager(
|
|
124
132
|
memberSigner.address.toString(),
|
|
125
133
|
settingsAccount,
|
|
126
134
|
);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
let transactionManagerSigner: TransactionSigner | null = null;
|
|
136
|
+
if (tmResult !== null) {
|
|
137
|
+
const userAccountData = await fetchUserAccountData(
|
|
138
|
+
tmResult.transactionManagerAddress,
|
|
139
|
+
tmResult.userAddressTreeIndex,
|
|
140
|
+
);
|
|
141
|
+
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"Transaction manager endpoint is missing for this account",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
transactionManagerSigner = createTransactionManagerSigner({
|
|
147
|
+
address: tmResult.transactionManagerAddress,
|
|
148
|
+
url: userAccountData.transactionManagerUrl.value,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
134
151
|
|
|
135
152
|
const instructions = await nativeTransferIntent({
|
|
136
153
|
settings,
|
|
@@ -146,13 +163,14 @@ const instructions = await nativeTransferIntent({
|
|
|
146
163
|
// Build tx from instructions with prepareTransactionMessage (or similar), then send.
|
|
147
164
|
```
|
|
148
165
|
|
|
149
|
-
###
|
|
166
|
+
### 4. SPL / Token-2022 transfer
|
|
150
167
|
|
|
151
168
|
```ts
|
|
152
169
|
import {
|
|
153
|
-
|
|
170
|
+
createTransactionManagerSigner,
|
|
171
|
+
fetchUserAccountData,
|
|
154
172
|
retrieveTransactionManager,
|
|
155
|
-
|
|
173
|
+
tokenTransferIntent,
|
|
156
174
|
} from "@revibase/core";
|
|
157
175
|
import type { Address, TransactionSigner } from "gill";
|
|
158
176
|
import { TOKEN_2022_PROGRAM_ADDRESS } from "gill/programs";
|
|
@@ -166,13 +184,20 @@ const tmResult = retrieveTransactionManager(
|
|
|
166
184
|
memberSigner.address.toString(),
|
|
167
185
|
settingsAccount,
|
|
168
186
|
);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
187
|
+
let transactionManagerSigner: TransactionSigner | null = null;
|
|
188
|
+
if (tmResult !== null) {
|
|
189
|
+
const userAccountData = await fetchUserAccountData(
|
|
190
|
+
tmResult.transactionManagerAddress,
|
|
191
|
+
tmResult.userAddressTreeIndex,
|
|
192
|
+
);
|
|
193
|
+
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
194
|
+
throw new Error("Transaction manager endpoint is missing for this account");
|
|
195
|
+
}
|
|
196
|
+
transactionManagerSigner = createTransactionManagerSigner({
|
|
197
|
+
address: tmResult.transactionManagerAddress,
|
|
198
|
+
url: userAccountData.transactionManagerUrl.value,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
176
201
|
|
|
177
202
|
const instructions = await tokenTransferIntent({
|
|
178
203
|
settings,
|
|
@@ -203,11 +228,12 @@ Prerequisite: `settings`, `compressed`, `walletAddress`, and `settingsAccount` f
|
|
|
203
228
|
|
|
204
229
|
```ts
|
|
205
230
|
import {
|
|
231
|
+
createTransactionManagerSigner,
|
|
232
|
+
fetchUserAccountData,
|
|
206
233
|
prepareTransactionMessage,
|
|
207
234
|
prepareTransactionSync,
|
|
208
235
|
signAndSendTransaction,
|
|
209
236
|
retrieveTransactionManager,
|
|
210
|
-
getSignedTransactionManager,
|
|
211
237
|
} from "@revibase/core";
|
|
212
238
|
import {
|
|
213
239
|
createNoopSigner,
|
|
@@ -234,13 +260,25 @@ const transactionMessageBytes = prepareTransactionMessage({
|
|
|
234
260
|
addressesByLookupTableAddress: addressLookups,
|
|
235
261
|
});
|
|
236
262
|
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
263
|
+
const tmResult = retrieveTransactionManager(
|
|
264
|
+
memberSigner.address.toString(),
|
|
265
|
+
settingsAccount,
|
|
266
|
+
);
|
|
267
|
+
let transactionManagerSigner: TransactionSigner | null = null;
|
|
268
|
+
if (tmResult !== null) {
|
|
269
|
+
const userAccountData = await fetchUserAccountData(
|
|
270
|
+
tmResult.transactionManagerAddress,
|
|
271
|
+
tmResult.userAddressTreeIndex,
|
|
272
|
+
);
|
|
273
|
+
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
274
|
+
throw new Error("Transaction manager endpoint is missing for this account");
|
|
275
|
+
}
|
|
276
|
+
transactionManagerSigner = createTransactionManagerSigner({
|
|
277
|
+
address: tmResult.transactionManagerAddress,
|
|
278
|
+
url: userAccountData.transactionManagerUrl.value,
|
|
279
|
+
transactionMessageBytes,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
244
282
|
|
|
245
283
|
const details = await prepareTransactionSync({
|
|
246
284
|
compressed,
|
|
@@ -261,12 +299,13 @@ const signature = await signAndSendTransaction(details);
|
|
|
261
299
|
|
|
262
300
|
```ts
|
|
263
301
|
import {
|
|
302
|
+
createTransactionManagerSigner,
|
|
303
|
+
fetchUserAccountData,
|
|
264
304
|
prepareTransactionMessage,
|
|
265
305
|
prepareTransactionBundle,
|
|
266
306
|
signAndSendBundledTransactions,
|
|
267
307
|
pollJitoBundleConfirmation,
|
|
268
308
|
retrieveTransactionManager,
|
|
269
|
-
getSignedTransactionManager,
|
|
270
309
|
} from "@revibase/core";
|
|
271
310
|
import {
|
|
272
311
|
createNoopSigner,
|
|
@@ -292,13 +331,25 @@ const transactionMessageBytes = prepareTransactionMessage({
|
|
|
292
331
|
addressesByLookupTableAddress: addressLookups,
|
|
293
332
|
});
|
|
294
333
|
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
334
|
+
const tmResult = retrieveTransactionManager(
|
|
335
|
+
memberSigner.address.toString(),
|
|
336
|
+
settingsAccount,
|
|
337
|
+
);
|
|
338
|
+
let transactionManagerSigner: TransactionSigner | null = null;
|
|
339
|
+
if (tmResult !== null) {
|
|
340
|
+
const userAccountData = await fetchUserAccountData(
|
|
341
|
+
tmResult.transactionManagerAddress,
|
|
342
|
+
tmResult.userAddressTreeIndex,
|
|
343
|
+
);
|
|
344
|
+
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
345
|
+
throw new Error("Transaction manager endpoint is missing for this account");
|
|
346
|
+
}
|
|
347
|
+
transactionManagerSigner = createTransactionManagerSigner({
|
|
348
|
+
address: tmResult.transactionManagerAddress,
|
|
349
|
+
url: userAccountData.transactionManagerUrl.value,
|
|
350
|
+
transactionMessageBytes,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
302
353
|
|
|
303
354
|
const bundle = await prepareTransactionBundle({
|
|
304
355
|
payer,
|