@omnity/ree-client-ts-sdk 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 CHANGED
@@ -75,20 +75,21 @@ const transaction = await client.createTransaction({
75
75
  // Add a single intention (e.g., swap BTC for runes)
76
76
  transaction.addIntention({
77
77
  poolAddress: "bc1p...",
78
+ poolUtxos: [],
78
79
  inputCoins: [
79
80
  {
80
- coin: {
81
- id: "0:0",
82
- value: BigInt(100000)
81
+ coin: {
82
+ id: "0:0",
83
+ value: BigInt(100000),
83
84
  }, // Send 0.001 BTC,
84
85
  from: paymentAddress,
85
86
  },
86
87
  ],
87
88
  outputCoins: [
88
89
  {
89
- coin: {
90
- id: "840000:3",
91
- value: BigInt(1000)
90
+ coin: {
91
+ id: "840000:3",
92
+ value: BigInt(1000),
92
93
  }, // Receive 1000 runes,
93
94
  to: address,
94
95
  },
@@ -119,9 +120,9 @@ transaction.addIntention({
119
120
  inputCoins: [
120
121
  {
121
122
  // Deposit 0.0005 BTC
122
- coin: {
123
- id: "0:0",
124
- value: BigInt(50000)
123
+ coin: {
124
+ id: "0:0",
125
+ value: BigInt(50000),
125
126
  },
126
127
  from: paymentAddress,
127
128
  },
@@ -137,9 +138,9 @@ transaction.addIntention({
137
138
  inputCoins: [
138
139
  {
139
140
  // Send 500 of rune A,
140
- coin: {
141
- id: "840000:3",
142
- value: BigInt(500)
141
+ coin: {
142
+ id: "840000:3",
143
+ value: BigInt(500),
143
144
  },
144
145
  from: address,
145
146
  },
@@ -147,9 +148,9 @@ transaction.addIntention({
147
148
  outputCoins: [
148
149
  {
149
150
  // Receive 250 of rune B,
150
- coin: {
151
- id: "840000:5",
152
- value: BigInt(250)
151
+ coin: {
152
+ id: "840000:5",
153
+ value: BigInt(250),
153
154
  },
154
155
  to: address,
155
156
  },
@@ -196,15 +197,15 @@ function WalletComponent() {
196
197
  tx.addIntention({
197
198
  poolAddress: "pool1",
198
199
  inputCoins: [{
199
- coin: {
200
- id: "0:0",
201
- value: BigInt(100000)
200
+ coin: {
201
+ id: "0:0",
202
+ value: BigInt(100000)
202
203
  },
203
204
  from: paymentAddress
204
205
  }],
205
206
  outputCoins: [
206
- coint: {
207
- id: "840000:3",
207
+ coint: {
208
+ id: "840000:3",
208
209
  value: BigInt(1000)
209
210
  },
210
211
  to: address
@@ -216,16 +217,16 @@ function WalletComponent() {
216
217
  tx.addIntention({
217
218
  poolAddress: "pool2",
218
219
  inputCoins: [{
219
- coin: {
220
- id: "840000:3",
221
- value: BigInt(500)
220
+ coin: {
221
+ id: "840000:3",
222
+ value: BigInt(500)
222
223
  },
223
224
  from: address
224
225
  }],
225
226
  outputCoins: [{
226
- coin: {
227
- id: "0:0",
228
- value: BigInt(50000)
227
+ coin: {
228
+ id: "0:0",
229
+ value: BigInt(50000)
229
230
  },
230
231
  to: paymentAddress
231
232
  }],
@@ -282,13 +283,15 @@ function MyComponent({ children }) {
282
283
 
283
284
  tx.addIntention({
284
285
  poolAddress: "bc1q...",
285
- inputCoins: [{
286
- coin: {
287
- id: "0:0",
288
- value: depositBtcAmount
286
+ inputCoins: [
287
+ {
288
+ coin: {
289
+ id: "0:0",
290
+ value: depositBtcAmount,
291
+ },
292
+ from: paymentAddress,
289
293
  },
290
- from: paymentAddress
291
- }],
294
+ ],
292
295
  outputCoins: [],
293
296
  action: "deposit",
294
297
  nonce: depositOffer.nonce,
@@ -377,20 +380,29 @@ Transaction builder for Bitcoin and Rune transactions with multi-intention suppo
377
380
 
378
381
  ```typescript
379
382
  interface Intention {
380
- poolAddress: string; // Target pool address
381
- inputCoins: InputCoin[]; // Coins being sent to the pool
382
- outputCoins: InputCoin[]; // Coins expected from the pool
383
- action: string; // Action type (swap, deposit, withdraw, etc.)
384
- actionParams?: string; // Optional action parameters
385
- nonce: bigint; // Unique nonce for the intention
383
+ // Target pool address
384
+ poolAddress: string;
385
+ // the UTXOs obtained through the pool’s pre methods
386
+ // if not provided, will be fetched via the maestro API.
387
+ poolUtxos?: [];
388
+ // Coins being sent to the pool
389
+ inputCoins: InputCoin[];
390
+ // Coins expected from the pool
391
+ outputCoins: InputCoin[];
392
+ // Action type (swap, deposit, withdraw, etc.)
393
+ action: string;
394
+ // Optional action parameters
395
+ actionParams?: string;
396
+ // Unique nonce for the intention
397
+ nonce: bigint;
386
398
  }
387
399
 
388
400
  type CoinBalance = {
389
401
  id: string; // Coin ID ("0:0" for BTC, "840000:3" for runes)
390
402
  value: bigint; // Amount in smallest unit
391
- }
403
+ };
392
404
 
393
- type InputCoin = {
405
+ type InputCoin = {
394
406
  coin: CoinBalance;
395
407
  from: string;
396
408
  };
@@ -399,7 +411,6 @@ type OutputCoin = {
399
411
  coin: CoinBalance;
400
412
  to: string;
401
413
  };
402
-
403
414
  ```
404
415
 
405
416
  ### Multi-Intention Transaction Benefits
@@ -559,4 +570,3 @@ enum Network {
559
570
  Testnet = "testnet",
560
571
  }
561
572
  ```
562
-
package/dist/index.d.ts CHANGED
@@ -47,6 +47,16 @@ export declare type Config = {
47
47
  exchangeCanisterId: string;
48
48
  };
49
49
 
50
+ declare function formatPoolUtxo(poolAddress: string, input: {
51
+ coins: [{
52
+ id: string;
53
+ value: bigint;
54
+ }];
55
+ sats: bigint;
56
+ txid: string;
57
+ vout: number;
58
+ }, network: Network): Utxo;
59
+
50
60
  declare function getAddressType(address: string): AddressType;
51
61
 
52
62
  declare function getScriptByAddress(address: string, network?: Network): Uint8Array<ArrayBufferLike>;
@@ -64,6 +74,7 @@ export declare type Intention = {
64
74
  action: string;
65
75
  actionParams?: string;
66
76
  poolAddress: string;
77
+ poolUtxos?: Utxo[];
67
78
  nonce: bigint;
68
79
  };
69
80
 
@@ -593,7 +604,8 @@ export declare namespace utils {
593
604
  bytesToHex,
594
605
  toBitcoinNetwork,
595
606
  getScriptByAddress,
596
- getAddressType
607
+ getAddressType,
608
+ formatPoolUtxo
597
609
  }
598
610
  }
599
611