@omnity/ree-client-ts-sdk 0.3.2 → 0.3.4
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 +56 -42
- package/dist/index.d.ts +16 -1
- package/dist/ree-sdk.cjs.js +43 -43
- package/dist/ree-sdk.es.js +3359 -3312
- package/package.json +1 -1
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
|
},
|
|
@@ -116,12 +117,13 @@ const transaction = await client.createTransaction({
|
|
|
116
117
|
// Intention 1: Deposit BTC to Pool 1
|
|
117
118
|
transaction.addIntention({
|
|
118
119
|
poolAddress: "bc1p...pool1",
|
|
120
|
+
poolUtxos: [],
|
|
119
121
|
inputCoins: [
|
|
120
122
|
{
|
|
121
123
|
// Deposit 0.0005 BTC
|
|
122
|
-
coin: {
|
|
123
|
-
id: "0:0",
|
|
124
|
-
value: BigInt(50000)
|
|
124
|
+
coin: {
|
|
125
|
+
id: "0:0",
|
|
126
|
+
value: BigInt(50000),
|
|
125
127
|
},
|
|
126
128
|
from: paymentAddress,
|
|
127
129
|
},
|
|
@@ -134,12 +136,13 @@ transaction.addIntention({
|
|
|
134
136
|
// Intention 2: Swap runes between pools
|
|
135
137
|
transaction.addIntention({
|
|
136
138
|
poolAddress: "bc1q...pool2",
|
|
139
|
+
poolUtxos: [],
|
|
137
140
|
inputCoins: [
|
|
138
141
|
{
|
|
139
142
|
// Send 500 of rune A,
|
|
140
|
-
coin: {
|
|
141
|
-
id: "840000:3",
|
|
142
|
-
value: BigInt(500)
|
|
143
|
+
coin: {
|
|
144
|
+
id: "840000:3",
|
|
145
|
+
value: BigInt(500),
|
|
143
146
|
},
|
|
144
147
|
from: address,
|
|
145
148
|
},
|
|
@@ -147,9 +150,9 @@ transaction.addIntention({
|
|
|
147
150
|
outputCoins: [
|
|
148
151
|
{
|
|
149
152
|
// Receive 250 of rune B,
|
|
150
|
-
coin: {
|
|
151
|
-
id: "840000:5",
|
|
152
|
-
value: BigInt(250)
|
|
153
|
+
coin: {
|
|
154
|
+
id: "840000:5",
|
|
155
|
+
value: BigInt(250),
|
|
153
156
|
},
|
|
154
157
|
to: address,
|
|
155
158
|
},
|
|
@@ -195,16 +198,17 @@ function WalletComponent() {
|
|
|
195
198
|
// Add multiple intentions
|
|
196
199
|
tx.addIntention({
|
|
197
200
|
poolAddress: "pool1",
|
|
201
|
+
poolUtxos: [],
|
|
198
202
|
inputCoins: [{
|
|
199
|
-
coin: {
|
|
200
|
-
id: "0:0",
|
|
201
|
-
value: BigInt(100000)
|
|
203
|
+
coin: {
|
|
204
|
+
id: "0:0",
|
|
205
|
+
value: BigInt(100000)
|
|
202
206
|
},
|
|
203
207
|
from: paymentAddress
|
|
204
208
|
}],
|
|
205
209
|
outputCoins: [
|
|
206
|
-
coint: {
|
|
207
|
-
id: "840000:3",
|
|
210
|
+
coint: {
|
|
211
|
+
id: "840000:3",
|
|
208
212
|
value: BigInt(1000)
|
|
209
213
|
},
|
|
210
214
|
to: address
|
|
@@ -215,17 +219,18 @@ function WalletComponent() {
|
|
|
215
219
|
|
|
216
220
|
tx.addIntention({
|
|
217
221
|
poolAddress: "pool2",
|
|
222
|
+
poolUtxos: [],
|
|
218
223
|
inputCoins: [{
|
|
219
|
-
coin: {
|
|
220
|
-
id: "840000:3",
|
|
221
|
-
value: BigInt(500)
|
|
224
|
+
coin: {
|
|
225
|
+
id: "840000:3",
|
|
226
|
+
value: BigInt(500)
|
|
222
227
|
},
|
|
223
228
|
from: address
|
|
224
229
|
}],
|
|
225
230
|
outputCoins: [{
|
|
226
|
-
coin: {
|
|
227
|
-
id: "0:0",
|
|
228
|
-
value: BigInt(50000)
|
|
231
|
+
coin: {
|
|
232
|
+
id: "0:0",
|
|
233
|
+
value: BigInt(50000)
|
|
229
234
|
},
|
|
230
235
|
to: paymentAddress
|
|
231
236
|
}],
|
|
@@ -282,13 +287,16 @@ function MyComponent({ children }) {
|
|
|
282
287
|
|
|
283
288
|
tx.addIntention({
|
|
284
289
|
poolAddress: "bc1q...",
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
poolUtxos: [],
|
|
291
|
+
inputCoins: [
|
|
292
|
+
{
|
|
293
|
+
coin: {
|
|
294
|
+
id: "0:0",
|
|
295
|
+
value: depositBtcAmount,
|
|
296
|
+
},
|
|
297
|
+
from: paymentAddress,
|
|
289
298
|
},
|
|
290
|
-
|
|
291
|
-
}],
|
|
299
|
+
],
|
|
292
300
|
outputCoins: [],
|
|
293
301
|
action: "deposit",
|
|
294
302
|
nonce: depositOffer.nonce,
|
|
@@ -377,20 +385,28 @@ Transaction builder for Bitcoin and Rune transactions with multi-intention suppo
|
|
|
377
385
|
|
|
378
386
|
```typescript
|
|
379
387
|
interface Intention {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
388
|
+
// Target pool address
|
|
389
|
+
poolAddress: string;
|
|
390
|
+
// the UTXOs obtained through the pool’s pre methods
|
|
391
|
+
poolUtxos?: [];
|
|
392
|
+
// Coins being sent to the pool
|
|
393
|
+
inputCoins: InputCoin[];
|
|
394
|
+
// Coins expected from the pool
|
|
395
|
+
outputCoins: InputCoin[];
|
|
396
|
+
// Action type (swap, deposit, withdraw, etc.)
|
|
397
|
+
action: string;
|
|
398
|
+
// Optional action parameters
|
|
399
|
+
actionParams?: string;
|
|
400
|
+
// Unique nonce for the intention
|
|
401
|
+
nonce: bigint;
|
|
386
402
|
}
|
|
387
403
|
|
|
388
404
|
type CoinBalance = {
|
|
389
405
|
id: string; // Coin ID ("0:0" for BTC, "840000:3" for runes)
|
|
390
406
|
value: bigint; // Amount in smallest unit
|
|
391
|
-
}
|
|
407
|
+
};
|
|
392
408
|
|
|
393
|
-
|
|
409
|
+
type InputCoin = {
|
|
394
410
|
coin: CoinBalance;
|
|
395
411
|
from: string;
|
|
396
412
|
};
|
|
@@ -399,7 +415,6 @@ type OutputCoin = {
|
|
|
399
415
|
coin: CoinBalance;
|
|
400
416
|
to: string;
|
|
401
417
|
};
|
|
402
|
-
|
|
403
418
|
```
|
|
404
419
|
|
|
405
420
|
### Multi-Intention Transaction Benefits
|
|
@@ -559,4 +574,3 @@ enum Network {
|
|
|
559
574
|
Testnet = "testnet",
|
|
560
575
|
}
|
|
561
576
|
```
|
|
562
|
-
|
package/dist/index.d.ts
CHANGED
|
@@ -47,10 +47,22 @@ 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>;
|
|
53
63
|
|
|
64
|
+
declare function getUtxoProof(utxos: Utxo[], network: Network): Promise<number[] | null>;
|
|
65
|
+
|
|
54
66
|
declare function hexToBytes(hex: string): Uint8Array;
|
|
55
67
|
|
|
56
68
|
export declare type InputCoin = {
|
|
@@ -64,6 +76,7 @@ export declare type Intention = {
|
|
|
64
76
|
action: string;
|
|
65
77
|
actionParams?: string;
|
|
66
78
|
poolAddress: string;
|
|
79
|
+
poolUtxos?: Utxo[];
|
|
67
80
|
nonce: bigint;
|
|
68
81
|
};
|
|
69
82
|
|
|
@@ -593,7 +606,9 @@ export declare namespace utils {
|
|
|
593
606
|
bytesToHex,
|
|
594
607
|
toBitcoinNetwork,
|
|
595
608
|
getScriptByAddress,
|
|
596
|
-
getAddressType
|
|
609
|
+
getAddressType,
|
|
610
|
+
formatPoolUtxo,
|
|
611
|
+
getUtxoProof
|
|
597
612
|
}
|
|
598
613
|
}
|
|
599
614
|
|