@revibase/core 0.3.3 → 0.4.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 +43 -14
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -37
- package/dist/index.d.ts +4 -37
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
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) → [Custom transactions](#custom-transactions-sync-vs-bundle) (sync or
|
|
5
|
+
**Contents:** [Initialize](#initialize) → [Create user](#create-a-user-account) → [Create wallet](#create-a-wallet) → [Transfer intents](#transfer-intents) → [Custom transactions](#custom-transactions-sync-vs-chunked-bundle) (sync or chunked).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Initialize
|
|
10
|
+
|
|
11
|
+
Call `initialize()` once before using helpers that rely on shared RPC clients (for example `getSolanaRpc()` or compressed account helpers).
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { initialize } from "@revibase/core";
|
|
15
|
+
|
|
16
|
+
initialize({
|
|
17
|
+
rpcEndpoint: "https://api.mainnet-beta.solana.com",
|
|
18
|
+
// proverEndpoint?: string;
|
|
19
|
+
// compressionApiEndpoint?: string;
|
|
20
|
+
});
|
|
21
|
+
```
|
|
6
22
|
|
|
7
23
|
---
|
|
8
24
|
|
|
@@ -139,9 +155,7 @@ if (tmResult !== null) {
|
|
|
139
155
|
tmResult.userAddressTreeIndex,
|
|
140
156
|
);
|
|
141
157
|
if (userAccountData.transactionManagerUrl.__option === "None") {
|
|
142
|
-
throw new Error(
|
|
143
|
-
"Transaction manager endpoint is missing for this account",
|
|
144
|
-
);
|
|
158
|
+
throw new Error("Transaction manager endpoint is missing for this account");
|
|
145
159
|
}
|
|
146
160
|
transactionManagerSigner = createTransactionManagerSigner({
|
|
147
161
|
address: tmResult.transactionManagerAddress,
|
|
@@ -217,10 +231,12 @@ const instructions = await tokenTransferIntent({
|
|
|
217
231
|
|
|
218
232
|
---
|
|
219
233
|
|
|
220
|
-
## Custom transactions (sync vs bundle)
|
|
234
|
+
## Custom transactions (sync vs chunked bundle)
|
|
221
235
|
|
|
222
|
-
- **Small tx size** → **sync**: `prepareTransactionMessage` → `prepareTransactionSync` →
|
|
223
|
-
- **Larger tx size** → **
|
|
236
|
+
- **Small tx size** → **sync**: `prepareTransactionMessage` → `prepareTransactionSync` → send
|
|
237
|
+
- **Larger tx size** → **chunked bundle**: `prepareTransactionMessage` → `prepareTransactionBundle` → send the returned transactions in order
|
|
238
|
+
|
|
239
|
+
In both cases, use `getSendAndConfirmTransaction()` (after `initialize()`) or your own Gill client to send.
|
|
224
240
|
|
|
225
241
|
Prerequisite: `settings`, `compressed`, `walletAddress`, and `settingsAccount` from [Resolve settings and compressed flag](#1-resolve-settings-and-compressed-flag).
|
|
226
242
|
|
|
@@ -230,9 +246,9 @@ Prerequisite: `settings`, `compressed`, `walletAddress`, and `settingsAccount` f
|
|
|
230
246
|
import {
|
|
231
247
|
createTransactionManagerSigner,
|
|
232
248
|
fetchUserAccountData,
|
|
249
|
+
getSendAndConfirmTransaction,
|
|
233
250
|
prepareTransactionMessage,
|
|
234
251
|
prepareTransactionSync,
|
|
235
|
-
signAndSendTransaction,
|
|
236
252
|
retrieveTransactionManager,
|
|
237
253
|
} from "@revibase/core";
|
|
238
254
|
import {
|
|
@@ -292,19 +308,25 @@ const details = await prepareTransactionSync({
|
|
|
292
308
|
addressesByLookupTableAddress: addressLookups,
|
|
293
309
|
});
|
|
294
310
|
|
|
295
|
-
const
|
|
311
|
+
const sendAndConfirm = getSendAndConfirmTransaction();
|
|
312
|
+
const signature = await sendAndConfirm({
|
|
313
|
+
payer: details.payer,
|
|
314
|
+
instructions: details.instructions,
|
|
315
|
+
addressesByLookupTableAddress: details.addressesByLookupTableAddress,
|
|
316
|
+
});
|
|
296
317
|
```
|
|
297
318
|
|
|
298
|
-
###
|
|
319
|
+
### Chunked bundle: prepareTransactionBundle
|
|
320
|
+
|
|
321
|
+
`prepareTransactionBundle()` returns multiple `TransactionDetails` objects (create buffer → extend buffer chunks → approvals → execute). Submit them in order.
|
|
299
322
|
|
|
300
323
|
```ts
|
|
301
324
|
import {
|
|
302
325
|
createTransactionManagerSigner,
|
|
303
326
|
fetchUserAccountData,
|
|
327
|
+
getSendAndConfirmTransaction,
|
|
304
328
|
prepareTransactionMessage,
|
|
305
329
|
prepareTransactionBundle,
|
|
306
|
-
signAndSendBundledTransactions,
|
|
307
|
-
pollJitoBundleConfirmation,
|
|
308
330
|
retrieveTransactionManager,
|
|
309
331
|
} from "@revibase/core";
|
|
310
332
|
import {
|
|
@@ -362,6 +384,13 @@ const bundle = await prepareTransactionBundle({
|
|
|
362
384
|
jitoBundlesTipAmount: 10_000, // optional, lamports
|
|
363
385
|
});
|
|
364
386
|
|
|
365
|
-
const
|
|
366
|
-
|
|
387
|
+
const sendAndConfirm = getSendAndConfirmTransaction();
|
|
388
|
+
let lastSignature: string | undefined;
|
|
389
|
+
for (const tx of bundle) {
|
|
390
|
+
lastSignature = await sendAndConfirm({
|
|
391
|
+
payer: tx.payer,
|
|
392
|
+
instructions: tx.instructions,
|
|
393
|
+
addressesByLookupTableAddress: tx.addressesByLookupTableAddress,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
367
396
|
```
|