@omnity/ree-client-ts-sdk 0.3.3 → 0.3.5
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 +10 -6
- package/dist/index.d.ts +9 -3
- package/dist/ree-sdk.cjs.js +37 -37
- package/dist/ree-sdk.es.js +2923 -2887
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ transaction.addIntention({
|
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// Build and execute
|
|
102
|
-
const psbt = await transaction.build();
|
|
102
|
+
const { psbt } = await transaction.build();
|
|
103
103
|
const signedPsbt = await wallet.signPsbt(psbt);
|
|
104
104
|
const result = await transaction.send(signedPsbt.toHex());
|
|
105
105
|
```
|
|
@@ -117,6 +117,7 @@ const transaction = await client.createTransaction({
|
|
|
117
117
|
// Intention 1: Deposit BTC to Pool 1
|
|
118
118
|
transaction.addIntention({
|
|
119
119
|
poolAddress: "bc1p...pool1",
|
|
120
|
+
poolUtxos: [],
|
|
120
121
|
inputCoins: [
|
|
121
122
|
{
|
|
122
123
|
// Deposit 0.0005 BTC
|
|
@@ -135,6 +136,7 @@ transaction.addIntention({
|
|
|
135
136
|
// Intention 2: Swap runes between pools
|
|
136
137
|
transaction.addIntention({
|
|
137
138
|
poolAddress: "bc1q...pool2",
|
|
139
|
+
poolUtxos: [],
|
|
138
140
|
inputCoins: [
|
|
139
141
|
{
|
|
140
142
|
// Send 500 of rune A,
|
|
@@ -160,7 +162,7 @@ transaction.addIntention({
|
|
|
160
162
|
});
|
|
161
163
|
|
|
162
164
|
// Build and execute the multi-intention transaction
|
|
163
|
-
const psbt = await transaction.build();
|
|
165
|
+
const { psbt } = await transaction.build();
|
|
164
166
|
const signedPsbt = await wallet.signPsbt(psbt);
|
|
165
167
|
const result = await transaction.send(signedPsbt.toHex());
|
|
166
168
|
```
|
|
@@ -196,6 +198,7 @@ function WalletComponent() {
|
|
|
196
198
|
// Add multiple intentions
|
|
197
199
|
tx.addIntention({
|
|
198
200
|
poolAddress: "pool1",
|
|
201
|
+
poolUtxos: [],
|
|
199
202
|
inputCoins: [{
|
|
200
203
|
coin: {
|
|
201
204
|
id: "0:0",
|
|
@@ -216,6 +219,7 @@ function WalletComponent() {
|
|
|
216
219
|
|
|
217
220
|
tx.addIntention({
|
|
218
221
|
poolAddress: "pool2",
|
|
222
|
+
poolUtxos: [],
|
|
219
223
|
inputCoins: [{
|
|
220
224
|
coin: {
|
|
221
225
|
id: "840000:3",
|
|
@@ -234,7 +238,7 @@ function WalletComponent() {
|
|
|
234
238
|
nonce: BigInt(Date.now() + 1),
|
|
235
239
|
});
|
|
236
240
|
|
|
237
|
-
const psbt = await tx.build();
|
|
241
|
+
const { psbt } = await tx.build();
|
|
238
242
|
// Sign and send...
|
|
239
243
|
};
|
|
240
244
|
|
|
@@ -283,6 +287,7 @@ function MyComponent({ children }) {
|
|
|
283
287
|
|
|
284
288
|
tx.addIntention({
|
|
285
289
|
poolAddress: "bc1q...",
|
|
290
|
+
poolUtxos: [],
|
|
286
291
|
inputCoins: [
|
|
287
292
|
{
|
|
288
293
|
coin: {
|
|
@@ -297,7 +302,7 @@ function MyComponent({ children }) {
|
|
|
297
302
|
nonce: depositOffer.nonce,
|
|
298
303
|
});
|
|
299
304
|
|
|
300
|
-
const psbt = await tx.build();
|
|
305
|
+
const { psbt } = await tx.build();
|
|
301
306
|
|
|
302
307
|
const signedPsbt = await signPsbt(psbt);
|
|
303
308
|
const txid = await tx.send(signedPsbt.toHex());
|
|
@@ -373,7 +378,7 @@ Transaction builder for Bitcoin and Rune transactions with multi-intention suppo
|
|
|
373
378
|
#### Methods
|
|
374
379
|
|
|
375
380
|
- `addIntention(intention: Intention): void` - Add an intention to the transaction
|
|
376
|
-
- `build(): Promise<bitcoin.Psbt>` - Build the PSBT with all intentions
|
|
381
|
+
- `build(): Promise<{ psbt: bitcoin.Psbt, txid: string }>` - Build the PSBT with all intentions
|
|
377
382
|
- `send(signedPsbtHex: string): Promise<any>` - Submit the signed transaction
|
|
378
383
|
|
|
379
384
|
#### Intention Structure
|
|
@@ -383,7 +388,6 @@ interface Intention {
|
|
|
383
388
|
// Target pool address
|
|
384
389
|
poolAddress: string;
|
|
385
390
|
// the UTXOs obtained through the pool’s pre methods
|
|
386
|
-
// if not provided, will be fetched via the maestro API.
|
|
387
391
|
poolUtxos?: [];
|
|
388
392
|
// Coins being sent to the pool
|
|
389
393
|
inputCoins: InputCoin[];
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ declare function getAddressType(address: string): AddressType;
|
|
|
61
61
|
|
|
62
62
|
declare function getScriptByAddress(address: string, network?: Network): Uint8Array<ArrayBufferLike>;
|
|
63
63
|
|
|
64
|
+
declare function getUtxoProof(utxos: Utxo[], network: Network): Promise<number[] | null>;
|
|
65
|
+
|
|
64
66
|
declare function hexToBytes(hex: string): Uint8Array;
|
|
65
67
|
|
|
66
68
|
export declare type InputCoin = {
|
|
@@ -471,11 +473,14 @@ export declare class Transaction {
|
|
|
471
473
|
* @example
|
|
472
474
|
* ```typescript
|
|
473
475
|
* // After adding intentions
|
|
474
|
-
* const psbt = await transaction.build();
|
|
476
|
+
* const { psbt, txid } = await transaction.build();
|
|
475
477
|
* const signedPsbt = await wallet.signPsbt(psbt);
|
|
476
478
|
* ```
|
|
477
479
|
*/
|
|
478
|
-
build(): Promise<
|
|
480
|
+
build(): Promise<{
|
|
481
|
+
psbt: bitcoin.Psbt;
|
|
482
|
+
txid: string;
|
|
483
|
+
}>;
|
|
479
484
|
/**
|
|
480
485
|
* Submit the signed transaction to the orchestrator for execution
|
|
481
486
|
* This method sends the signed PSBT along with the intention set to the orchestrator canister
|
|
@@ -605,7 +610,8 @@ export declare namespace utils {
|
|
|
605
610
|
toBitcoinNetwork,
|
|
606
611
|
getScriptByAddress,
|
|
607
612
|
getAddressType,
|
|
608
|
-
formatPoolUtxo
|
|
613
|
+
formatPoolUtxo,
|
|
614
|
+
getUtxoProof
|
|
609
615
|
}
|
|
610
616
|
}
|
|
611
617
|
|