opnet 1.0.39 → 1.0.40
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/browser/_version.d.ts +1 -1
- package/browser/index.js +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/shared/json/MOTOSWAP_POOL_ABI.js +0 -2
- package/build/scripts/testMethodsReg.js +4 -12
- package/cjs/_version.d.ts +1 -1
- package/cjs/_version.js +1 -1
- package/cjs/abi/shared/interfaces/IMotoContract.d.ts +6 -0
- package/cjs/abi/shared/interfaces/IMotoContract.js +2 -0
- package/cjs/abi/shared/interfaces/IMotoswapFactoryContract.d.ts +7 -0
- package/cjs/abi/shared/interfaces/IMotoswapFactoryContract.js +2 -0
- package/cjs/abi/shared/interfaces/IMotoswapPoolContract.d.ts +13 -0
- package/cjs/abi/shared/interfaces/IMotoswapPoolContract.js +2 -0
- package/cjs/abi/shared/interfaces/IMotoswapRouterContract.d.ts +15 -0
- package/cjs/abi/shared/interfaces/IMotoswapRouterContract.js +2 -0
- package/cjs/abi/shared/interfaces/IOP_20Contract.d.ts +16 -0
- package/cjs/abi/shared/interfaces/IOP_20Contract.js +2 -0
- package/cjs/abi/shared/interfaces/IOP_NETContract.d.ts +7 -0
- package/cjs/abi/shared/interfaces/IOP_NETContract.js +2 -0
- package/cjs/abi/shared/interfaces/IStackingContract.d.ts +11 -0
- package/cjs/abi/shared/interfaces/IStackingContract.js +2 -0
- package/cjs/abi/shared/interfaces/IWBTCContract.d.ts +8 -0
- package/cjs/abi/shared/interfaces/IWBTCContract.js +2 -0
- package/cjs/abi/shared/json/MOTOSWAP_FACTORY_ABI.d.ts +3 -0
- package/cjs/abi/shared/json/MOTOSWAP_FACTORY_ABI.js +74 -0
- package/cjs/abi/shared/json/MOTOSWAP_POOL_ABI.d.ts +3 -0
- package/cjs/abi/shared/json/MOTOSWAP_POOL_ABI.js +280 -0
- package/cjs/abi/shared/json/MOTOSWAP_ROUTER_ABI.d.ts +2 -0
- package/cjs/abi/shared/json/MOTOSWAP_ROUTER_ABI.js +277 -0
- package/cjs/abi/shared/json/MOTO_TOKEN_ABI.d.ts +2 -0
- package/cjs/abi/shared/json/MOTO_TOKEN_ABI.js +25 -0
- package/cjs/abi/shared/json/OP_20_ABI.d.ts +3 -0
- package/cjs/abi/shared/json/OP_20_ABI.js +259 -0
- package/cjs/abi/shared/json/OP_NET_ABI.d.ts +2 -0
- package/cjs/abi/shared/json/OP_NET_ABI.js +34 -0
- package/cjs/abi/shared/json/STAKING_ABI.d.ts +3 -0
- package/cjs/abi/shared/json/STAKING_ABI.js +132 -0
- package/cjs/abi/shared/json/WBTC_ABI.d.ts +3 -0
- package/cjs/abi/shared/json/WBTC_ABI.js +60 -0
- package/cjs/common/CommonTypes.d.ts +2 -1
- package/cjs/contracts/CallResult.d.ts +6 -2
- package/cjs/contracts/CallResult.js +14 -6
- package/cjs/contracts/Contract.d.ts +8 -4
- package/cjs/contracts/Contract.js +172 -19
- package/cjs/contracts/interfaces/ICallResult.d.ts +1 -0
- package/cjs/contracts/interfaces/IContract.d.ts +3 -0
- package/cjs/opnet.d.ts +18 -0
- package/cjs/opnet.js +18 -0
- package/cjs/providers/AbstractRpcProvider.d.ts +5 -3
- package/cjs/providers/AbstractRpcProvider.js +41 -7
- package/cjs/providers/JSONRpcProvider.d.ts +1 -1
- package/cjs/scripts/testMethods.js +3 -10
- package/cjs/scripts/testMethodsReg.js +6 -8
- package/cjs/scripts/testWBTCContract.d.ts +1 -0
- package/cjs/scripts/testWBTCContract.js +13 -0
- package/cjs/transactions/TransactionParser.js +7 -0
- package/cjs/transactions/decoders/UnwrapTransaction.d.ts +11 -0
- package/cjs/transactions/decoders/UnwrapTransaction.js +33 -0
- package/cjs/transactions/interfaces/transactions/IUnwrapTransaction.d.ts +28 -0
- package/cjs/transactions/interfaces/transactions/IUnwrapTransaction.js +2 -0
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/abi/shared/json/MOTOSWAP_POOL_ABI.ts +0 -4
- package/src/scripts/testMethodsReg.ts +8 -3
package/cjs/opnet.js
CHANGED
|
@@ -63,9 +63,27 @@ __exportStar(require("./providers/interfaces/JSONRpc.js"), exports);
|
|
|
63
63
|
__exportStar(require("./providers/interfaces/JSONRpcMethods.js"), exports);
|
|
64
64
|
__exportStar(require("./providers/interfaces/JSONRpcParams.js"), exports);
|
|
65
65
|
__exportStar(require("./providers/interfaces/JSONRpcResult.js"), exports);
|
|
66
|
+
__exportStar(require("./transactions/decoders/UnwrapTransaction.js"), exports);
|
|
67
|
+
__exportStar(require("./transactions/interfaces/transactions/IUnwrapTransaction.js"), exports);
|
|
66
68
|
__exportStar(require("./common/CommonTypes.js"), exports);
|
|
67
69
|
__exportStar(require("./bitcoin/BitcoinAddress.js"), exports);
|
|
68
70
|
__exportStar(require("./bitcoin/UTXOs.js"), exports);
|
|
69
71
|
__exportStar(require("./bitcoin/interfaces/IUTXO.js"), exports);
|
|
70
72
|
var bsi_binary_1 = require("@btc-vision/bsi-binary");
|
|
71
73
|
Object.defineProperty(exports, "ABIDataTypes", { enumerable: true, get: function () { return bsi_binary_1.ABIDataTypes; } });
|
|
74
|
+
__exportStar(require("./abi/shared/json/OP_20_ABI.js"), exports);
|
|
75
|
+
__exportStar(require("./abi/shared/json/OP_NET_ABI.js"), exports);
|
|
76
|
+
__exportStar(require("./abi/shared/json/WBTC_ABI.js"), exports);
|
|
77
|
+
__exportStar(require("./abi/shared/json/STAKING_ABI.js"), exports);
|
|
78
|
+
__exportStar(require("./abi/shared/json/MOTOSWAP_FACTORY_ABI.js"), exports);
|
|
79
|
+
__exportStar(require("./abi/shared/json/MOTO_TOKEN_ABI.js"), exports);
|
|
80
|
+
__exportStar(require("./abi/shared/json/MOTOSWAP_POOL_ABI.js"), exports);
|
|
81
|
+
__exportStar(require("./abi/shared/json/MOTOSWAP_ROUTER_ABI.js"), exports);
|
|
82
|
+
__exportStar(require("./abi/shared/interfaces/IOP_20Contract.js"), exports);
|
|
83
|
+
__exportStar(require("./abi/shared/interfaces/IOP_NETContract.js"), exports);
|
|
84
|
+
__exportStar(require("./abi/shared/interfaces/IWBTCContract.js"), exports);
|
|
85
|
+
__exportStar(require("./abi/shared/interfaces/IStackingContract.js"), exports);
|
|
86
|
+
__exportStar(require("./abi/shared/interfaces/IMotoswapFactoryContract.js"), exports);
|
|
87
|
+
__exportStar(require("./abi/shared/interfaces/IMotoContract.js"), exports);
|
|
88
|
+
__exportStar(require("./abi/shared/interfaces/IMotoswapPoolContract.js"), exports);
|
|
89
|
+
__exportStar(require("./abi/shared/interfaces/IMotoswapRouterContract.js"), exports);
|
|
@@ -14,7 +14,7 @@ import { BroadcastedTransaction } from '../transactions/interfaces/BroadcastedTr
|
|
|
14
14
|
import { TransactionReceipt } from '../transactions/metadata/TransactionReceipt.js';
|
|
15
15
|
import { TransactionBase } from '../transactions/Transaction.js';
|
|
16
16
|
import { JsonRpcPayload } from './interfaces/JSONRpc.js';
|
|
17
|
-
import { JsonRpcCallResult } from './interfaces/JSONRpcResult.js';
|
|
17
|
+
import { JsonRpcCallResult, JsonRpcResult } from './interfaces/JSONRpcResult.js';
|
|
18
18
|
import { ReorgInformation } from './interfaces/ReorgInformation.js';
|
|
19
19
|
export declare abstract class AbstractRpcProvider {
|
|
20
20
|
private nextId;
|
|
@@ -23,6 +23,7 @@ export declare abstract class AbstractRpcProvider {
|
|
|
23
23
|
protected constructor();
|
|
24
24
|
getBlockNumber(): Promise<bigint>;
|
|
25
25
|
getBlock(blockNumberOrHash: BlockTag, prefetchTxs?: boolean): Promise<Block>;
|
|
26
|
+
getBlocks(blockNumbers: BlockTag[], prefetchTxs?: boolean): Promise<Block[]>;
|
|
26
27
|
getBlockByHash(blockHash: string): Promise<Block>;
|
|
27
28
|
getBalance(addressLike: BitcoinAddressLike): Promise<bigint>;
|
|
28
29
|
getUXTOs(address: BitcoinAddressLike, optimize?: boolean): Promise<unknown>;
|
|
@@ -37,10 +38,11 @@ export declare abstract class AbstractRpcProvider {
|
|
|
37
38
|
getBlockWitness(height?: BigNumberish | -1, trusted?: boolean, limit?: number, page?: number): Promise<BlockWitnesses>;
|
|
38
39
|
getReorg(fromBlock?: BigNumberish, toBlock?: BigNumberish): Promise<ReorgInformation[]>;
|
|
39
40
|
requestTrustedPublicKeyForBitcoinWrapping(amount: BigNumberish): Promise<WrappedGeneration>;
|
|
40
|
-
abstract _send(payload: JsonRpcPayload): Promise<JsonRpcCallResult>;
|
|
41
|
+
abstract _send(payload: JsonRpcPayload | JsonRpcPayload[]): Promise<JsonRpcCallResult>;
|
|
42
|
+
callPayloadSingle(payload: JsonRpcPayload): Promise<JsonRpcResult>;
|
|
43
|
+
callMultiplePayloads(payloads: JsonRpcPayload[]): Promise<JsonRpcCallResult>;
|
|
41
44
|
protected abstract providerUrl(url: string): string;
|
|
42
45
|
private bufferToHex;
|
|
43
46
|
private bigintToBase64;
|
|
44
|
-
private callPayloadSingle;
|
|
45
47
|
private buildJsonRpcPayload;
|
|
46
48
|
}
|
|
@@ -37,6 +37,26 @@ class AbstractRpcProvider {
|
|
|
37
37
|
const result = block.result;
|
|
38
38
|
return new Block_js_1.Block(result);
|
|
39
39
|
}
|
|
40
|
+
async getBlocks(blockNumbers, prefetchTxs = false) {
|
|
41
|
+
const payloads = blockNumbers.map((blockNumber) => {
|
|
42
|
+
return this.buildJsonRpcPayload(JSONRpcMethods_js_1.JSONRpcMethods.GET_BLOCK_BY_NUMBER, [
|
|
43
|
+
blockNumber,
|
|
44
|
+
prefetchTxs,
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
const blocks = await this.callMultiplePayloads(payloads);
|
|
48
|
+
if ('error' in blocks) {
|
|
49
|
+
const error = blocks.error;
|
|
50
|
+
throw new Error(`Error fetching block: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
return blocks.map((block) => {
|
|
53
|
+
if ('error' in block) {
|
|
54
|
+
throw new Error(`Error fetching block: ${block.error}`);
|
|
55
|
+
}
|
|
56
|
+
const result = block.result;
|
|
57
|
+
return new Block_js_1.Block(result);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
40
60
|
async getBlockByHash(blockHash) {
|
|
41
61
|
return await this.getBlock(blockHash);
|
|
42
62
|
}
|
|
@@ -68,6 +88,9 @@ class AbstractRpcProvider {
|
|
|
68
88
|
const payload = this.buildJsonRpcPayload(JSONRpcMethods_js_1.JSONRpcMethods.GET_TRANSACTION_BY_HASH, [txHash]);
|
|
69
89
|
const rawTransaction = await this.callPayloadSingle(payload);
|
|
70
90
|
const result = rawTransaction.result;
|
|
91
|
+
if ('error' in rawTransaction) {
|
|
92
|
+
throw new Error(`Error fetching transaction: ${rawTransaction.error?.message || 'Unknown error'}`);
|
|
93
|
+
}
|
|
71
94
|
return TransactionParser_js_1.TransactionParser.parseTransaction(result);
|
|
72
95
|
}
|
|
73
96
|
async getTransactionReceipt(txHash) {
|
|
@@ -157,7 +180,7 @@ class AbstractRpcProvider {
|
|
|
157
180
|
}
|
|
158
181
|
async sendRawTransaction(tx, psbt) {
|
|
159
182
|
if (!/^[0-9A-Fa-f]+$/.test(tx)) {
|
|
160
|
-
throw new Error('Invalid hex string');
|
|
183
|
+
throw new Error('sendRawTransaction: Invalid hex string');
|
|
161
184
|
}
|
|
162
185
|
const payload = this.buildJsonRpcPayload(JSONRpcMethods_js_1.JSONRpcMethods.BROADCAST_TRANSACTION, [tx, psbt]);
|
|
163
186
|
const rawTx = await this.callPayloadSingle(payload);
|
|
@@ -213,12 +236,6 @@ class AbstractRpcProvider {
|
|
|
213
236
|
const result = rawPublicKey.result;
|
|
214
237
|
return new transaction_1.WrappedGeneration(result);
|
|
215
238
|
}
|
|
216
|
-
bufferToHex(buffer) {
|
|
217
|
-
return buffer.toString('hex');
|
|
218
|
-
}
|
|
219
|
-
bigintToBase64(bigint) {
|
|
220
|
-
return Buffer.from(bsi_binary_1.BufferHelper.pointerToUint8Array(bigint)).toString('base64');
|
|
221
|
-
}
|
|
222
239
|
async callPayloadSingle(payload) {
|
|
223
240
|
const rawData = await this._send(payload);
|
|
224
241
|
if (!rawData.length) {
|
|
@@ -230,6 +247,23 @@ class AbstractRpcProvider {
|
|
|
230
247
|
}
|
|
231
248
|
return data;
|
|
232
249
|
}
|
|
250
|
+
async callMultiplePayloads(payloads) {
|
|
251
|
+
const rawData = (await this._send(payloads));
|
|
252
|
+
if ('error' in rawData) {
|
|
253
|
+
throw new Error(`Error fetching block: ${rawData.error}`);
|
|
254
|
+
}
|
|
255
|
+
const data = rawData.shift();
|
|
256
|
+
if (!data) {
|
|
257
|
+
throw new Error('Block not found');
|
|
258
|
+
}
|
|
259
|
+
return data;
|
|
260
|
+
}
|
|
261
|
+
bufferToHex(buffer) {
|
|
262
|
+
return buffer.toString('hex');
|
|
263
|
+
}
|
|
264
|
+
bigintToBase64(bigint) {
|
|
265
|
+
return Buffer.from(bsi_binary_1.BufferHelper.pointerToUint8Array(bigint)).toString('base64');
|
|
266
|
+
}
|
|
233
267
|
buildJsonRpcPayload(method, params) {
|
|
234
268
|
return {
|
|
235
269
|
method: method,
|
|
@@ -4,6 +4,6 @@ import { JsonRpcCallResult } from './interfaces/JSONRpcResult.js';
|
|
|
4
4
|
export declare class JSONRpcProvider extends AbstractRpcProvider {
|
|
5
5
|
private readonly url;
|
|
6
6
|
constructor(url: string);
|
|
7
|
-
_send(payload: JsonRpcPayload): Promise<JsonRpcCallResult>;
|
|
7
|
+
_send(payload: JsonRpcPayload | JsonRpcPayload[]): Promise<JsonRpcCallResult>;
|
|
8
8
|
protected providerUrl(url: string): string;
|
|
9
9
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Contract_js_1 = require("../contracts/Contract.js");
|
|
4
3
|
const JSONRpcProvider_js_1 = require("../providers/JSONRpcProvider.js");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const myWBTCBalance = await contract.balanceOf('tb1pvajdvghss0tc737z72sq02cga9hd7wvdua9vcqj357a6yqhlhy4seud439');
|
|
9
|
-
if ('error' in myWBTCBalance)
|
|
10
|
-
throw new Error(myWBTCBalance.error);
|
|
11
|
-
console.log('My WBTC balance:', myWBTCBalance.decoded[0]);
|
|
12
|
-
const tx = await provider.getTransaction('4076964e2d70c44562cb4bb8afb074c723e850a7807abc73eb9a33682ec93f44');
|
|
13
|
-
console.log('Transaction:', tx);
|
|
4
|
+
const provider = new JSONRpcProvider_js_1.JSONRpcProvider('http://localhost:9001');
|
|
5
|
+
const tx = await provider.getTransaction('335f66a330ba3cce82c271c1cbe3e9fa35ed6e47aa5d9104049066a2d52269e6');
|
|
6
|
+
console.log(tx);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const transaction_1 = require("@btc-vision/transaction");
|
|
4
|
+
const WBTC_ABI_js_1 = require("../abi/shared/json/WBTC_ABI.js");
|
|
5
|
+
const Contract_js_1 = require("../contracts/Contract.js");
|
|
3
6
|
const JSONRpcProvider_js_1 = require("../providers/JSONRpcProvider.js");
|
|
4
7
|
const provider = new JSONRpcProvider_js_1.JSONRpcProvider('http://localhost:9001');
|
|
5
|
-
(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const c = await provider.getCode('', false);
|
|
9
|
-
console.log(c);
|
|
10
|
-
const d = await provider.getCode('bcrt1qmsx5vpm6yfwtex5ygag0nwktnmj7a48eew2qn0', false);
|
|
11
|
-
console.log(d);
|
|
12
|
-
})();
|
|
8
|
+
const contract = (0, Contract_js_1.getContract)(transaction_1.MOTO_ADDRESS_REGTEST, WBTC_ABI_js_1.WBTC_ABI, provider, 'bcrt1p2m2yz9hae5lkypuf8heh6udnt0tchmxhaftcfslqsr5vrwzh34yqgn6hs6');
|
|
9
|
+
const decimals = contract.encodeCalldata('decimals', []);
|
|
10
|
+
console.log(decimals);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const OP_20_ABI_js_1 = require("../abi/shared/json/OP_20_ABI.js");
|
|
4
|
+
const Contract_js_1 = require("../contracts/Contract.js");
|
|
5
|
+
const JSONRpcProvider_js_1 = require("../providers/JSONRpcProvider.js");
|
|
6
|
+
const provider = new JSONRpcProvider_js_1.JSONRpcProvider('https://regtest.opnet.org');
|
|
7
|
+
const contract = (0, Contract_js_1.getContract)('bcrt1qxeyh0pacdtkqmlna9n254fztp3ptadkkfu6efl', OP_20_ABI_js_1.OP_20_ABI, provider);
|
|
8
|
+
const balanceExample = await contract.balanceOf('bcrt1pyrs3eqwnrmd4ql3nwvx66yzp0wc24xd2t9pf8699ln340pjs7f3sar3tum');
|
|
9
|
+
if ('error' in balanceExample)
|
|
10
|
+
throw new Error('Error in fetching balance');
|
|
11
|
+
console.log('Balance:', balanceExample.decoded);
|
|
12
|
+
const owner = (await contract.owner());
|
|
13
|
+
console.log('Owner:', owner.properties);
|
|
@@ -5,6 +5,7 @@ const OPNetTransactionTypes_js_1 = require("../interfaces/opnet/OPNetTransaction
|
|
|
5
5
|
const DeploymentTransaction_js_1 = require("./decoders/DeploymentTransaction.js");
|
|
6
6
|
const GenericTransaction_js_1 = require("./decoders/GenericTransaction.js");
|
|
7
7
|
const InteractionTransaction_js_1 = require("./decoders/InteractionTransaction.js");
|
|
8
|
+
const UnwrapTransaction_js_1 = require("./decoders/UnwrapTransaction.js");
|
|
8
9
|
const WrapTransaction_js_1 = require("./decoders/WrapTransaction.js");
|
|
9
10
|
class TransactionParser {
|
|
10
11
|
static parseTransactions(transactions) {
|
|
@@ -13,11 +14,15 @@ class TransactionParser {
|
|
|
13
14
|
}
|
|
14
15
|
const transactionArray = [];
|
|
15
16
|
for (let transaction of transactions) {
|
|
17
|
+
if (!transaction)
|
|
18
|
+
throw new Error(`Something went wrong while parsing transactions`);
|
|
16
19
|
transactionArray.push(this.parseTransaction(transaction));
|
|
17
20
|
}
|
|
18
21
|
return transactionArray;
|
|
19
22
|
}
|
|
20
23
|
static parseTransaction(transaction) {
|
|
24
|
+
if (!transaction)
|
|
25
|
+
throw new Error('Transaction is required');
|
|
21
26
|
const opnetType = transaction.OPNetType;
|
|
22
27
|
switch (opnetType) {
|
|
23
28
|
case OPNetTransactionTypes_js_1.OPNetTransactionTypes.Generic:
|
|
@@ -28,6 +33,8 @@ class TransactionParser {
|
|
|
28
33
|
return new DeploymentTransaction_js_1.DeploymentTransaction(transaction);
|
|
29
34
|
case OPNetTransactionTypes_js_1.OPNetTransactionTypes.WrapInteraction:
|
|
30
35
|
return new WrapTransaction_js_1.WrapTransaction(transaction);
|
|
36
|
+
case OPNetTransactionTypes_js_1.OPNetTransactionTypes.UnwrapInteraction:
|
|
37
|
+
return new UnwrapTransaction_js_1.UnwrapTransaction(transaction);
|
|
31
38
|
default:
|
|
32
39
|
throw new Error('Unknown transaction type');
|
|
33
40
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IUnwrapTransaction, ParsedPartialWBTCUTXODocument, UsedUTXO } from '../interfaces/transactions/IUnwrapTransaction.js';
|
|
2
|
+
import { InteractionTransaction } from './InteractionTransaction.js';
|
|
3
|
+
export declare class UnwrapTransaction extends InteractionTransaction implements IUnwrapTransaction {
|
|
4
|
+
readonly authorizedBy: string[];
|
|
5
|
+
readonly usedUTXOs: UsedUTXO[];
|
|
6
|
+
readonly consolidatedVault: ParsedPartialWBTCUTXODocument | undefined;
|
|
7
|
+
readonly unwrapAmount: bigint;
|
|
8
|
+
readonly requestedAmount: bigint;
|
|
9
|
+
constructor(transaction: IUnwrapTransaction);
|
|
10
|
+
private decodePartialWBTCUTXODocument;
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnwrapTransaction = void 0;
|
|
4
|
+
const InteractionTransaction_js_1 = require("./InteractionTransaction.js");
|
|
5
|
+
class UnwrapTransaction extends InteractionTransaction_js_1.InteractionTransaction {
|
|
6
|
+
authorizedBy;
|
|
7
|
+
usedUTXOs;
|
|
8
|
+
consolidatedVault;
|
|
9
|
+
unwrapAmount;
|
|
10
|
+
requestedAmount;
|
|
11
|
+
constructor(transaction) {
|
|
12
|
+
super(transaction);
|
|
13
|
+
this.authorizedBy = transaction.authorizedBy;
|
|
14
|
+
this.usedUTXOs = transaction.usedUTXOs;
|
|
15
|
+
this.consolidatedVault = this.decodePartialWBTCUTXODocument(transaction.consolidatedVault);
|
|
16
|
+
this.unwrapAmount = BigInt(transaction.unwrapAmount);
|
|
17
|
+
this.requestedAmount = BigInt(transaction.requestedAmount);
|
|
18
|
+
}
|
|
19
|
+
decodePartialWBTCUTXODocument(document) {
|
|
20
|
+
if (!document) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
console.log(document);
|
|
24
|
+
return {
|
|
25
|
+
vault: document.vault,
|
|
26
|
+
hash: document.hash,
|
|
27
|
+
value: BigInt(document.value),
|
|
28
|
+
outputIndex: document.outputIndex,
|
|
29
|
+
output: Buffer.from(document.output, 'base64'),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.UnwrapTransaction = UnwrapTransaction;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
3
|
+
import { IInteractionTransaction } from './IInteractionTransaction.js';
|
|
4
|
+
export interface UsedUTXO {
|
|
5
|
+
readonly hash: string;
|
|
6
|
+
readonly outputIndex: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PartialWBTCUTXODocument {
|
|
9
|
+
readonly vault: Address;
|
|
10
|
+
readonly hash: string;
|
|
11
|
+
readonly value: string;
|
|
12
|
+
readonly outputIndex: number;
|
|
13
|
+
readonly output: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ParsedPartialWBTCUTXODocument {
|
|
16
|
+
readonly vault: Address;
|
|
17
|
+
readonly hash: string;
|
|
18
|
+
readonly value: bigint;
|
|
19
|
+
readonly outputIndex: number;
|
|
20
|
+
readonly output: Buffer;
|
|
21
|
+
}
|
|
22
|
+
export interface IUnwrapTransaction extends IInteractionTransaction {
|
|
23
|
+
readonly authorizedBy: string[];
|
|
24
|
+
readonly usedUTXOs: UsedUTXO[];
|
|
25
|
+
readonly consolidatedVault: PartialWBTCUTXODocument | ParsedPartialWBTCUTXODocument | undefined;
|
|
26
|
+
readonly unwrapAmount: bigint | string;
|
|
27
|
+
readonly requestedAmount: bigint | string;
|
|
28
|
+
}
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.40';
|
|
@@ -2,7 +2,6 @@ import { ABIDataTypes } from '@btc-vision/bsi-binary';
|
|
|
2
2
|
import { BitcoinAbiTypes } from '../../BitcoinAbiTypes.js';
|
|
3
3
|
import { BitcoinInterfaceAbi } from '../../interfaces/BitcoinInterfaceAbi.js';
|
|
4
4
|
import { OP_20_ABI } from './OP_20_ABI.js';
|
|
5
|
-
import { OP_NET_ABI } from './OP_NET_ABI.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* @category Events
|
|
@@ -94,9 +93,6 @@ export const MotoSwapPoolEvents: BitcoinInterfaceAbi = [
|
|
|
94
93
|
* @category ABI
|
|
95
94
|
*/
|
|
96
95
|
export const MotoswapPoolAbi: BitcoinInterfaceAbi = [
|
|
97
|
-
// OP_NET
|
|
98
|
-
...OP_NET_ABI,
|
|
99
|
-
|
|
100
96
|
// OP_20
|
|
101
97
|
...OP_20_ABI,
|
|
102
98
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MOTO_ADDRESS_REGTEST } from '@btc-vision/transaction';
|
|
1
2
|
import { IWBTCContract } from '../abi/shared/interfaces/IWBTCContract.js';
|
|
2
3
|
import { WBTC_ABI } from '../abi/shared/json/WBTC_ABI.js';
|
|
3
4
|
import { getContract } from '../contracts/Contract.js';
|
|
@@ -6,12 +7,16 @@ import { JSONRpcProvider } from '../providers/JSONRpcProvider.js';
|
|
|
6
7
|
const provider: JSONRpcProvider = new JSONRpcProvider('http://localhost:9001');
|
|
7
8
|
|
|
8
9
|
const contract: IWBTCContract = getContract<IWBTCContract>(
|
|
9
|
-
|
|
10
|
+
MOTO_ADDRESS_REGTEST,
|
|
10
11
|
WBTC_ABI,
|
|
11
12
|
provider,
|
|
12
13
|
'bcrt1p2m2yz9hae5lkypuf8heh6udnt0tchmxhaftcfslqsr5vrwzh34yqgn6hs6',
|
|
13
14
|
);
|
|
14
15
|
|
|
16
|
+
const decimals = contract.encodeCalldata('decimals', []);
|
|
17
|
+
|
|
18
|
+
console.log(decimals);
|
|
19
|
+
|
|
15
20
|
//const transferCalldata = await contract.transfer(amount, transferToAddress);
|
|
16
21
|
|
|
17
22
|
//if ('error' in transferCalldata) throw transferCalldata.error;
|
|
@@ -31,7 +36,7 @@ console.log(owner);
|
|
|
31
36
|
const name = await contract.name();
|
|
32
37
|
console.log(name);*/
|
|
33
38
|
|
|
34
|
-
for (let i = 0; i < 10; i++) {
|
|
39
|
+
/*for (let i = 0; i < 10; i++) {
|
|
35
40
|
(async () => {
|
|
36
41
|
try {
|
|
37
42
|
const blocks = await provider.getBlocks([1, 2, 3, 4, 5, 6, 7]);
|
|
@@ -40,4 +45,4 @@ for (let i = 0; i < 10; i++) {
|
|
|
40
45
|
console.log((e as Error).message);
|
|
41
46
|
}
|
|
42
47
|
})();
|
|
43
|
-
}
|
|
48
|
+
}*/
|