opnet 1.0.13 → 1.0.15
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/CONTRIBUTING.md +71 -0
- package/README.md +6 -7
- package/browser/_version.d.ts +1 -1
- package/browser/abi/BaseContractProperty.d.ts +3 -0
- package/browser/abi/BitcoinAbiTypes.d.ts +4 -0
- package/browser/abi/BitcoinInterface.d.ts +9 -0
- package/browser/abi/interfaces/BaseContractProperties.d.ts +4 -0
- package/browser/abi/interfaces/BitcoinAbiValue.d.ts +5 -0
- package/browser/abi/interfaces/BitcoinInterfaceAbi.d.ts +11 -0
- package/browser/bitcoin/UTXOs.d.ts +1 -6
- package/browser/bitcoin/interfaces/IUTXO.d.ts +7 -0
- package/browser/common/CommonTypes.d.ts +1 -0
- package/browser/contracts/CallResult.d.ts +6 -3
- package/browser/contracts/Contract.d.ts +28 -0
- package/browser/contracts/interfaces/ICallResult.d.ts +2 -3
- package/browser/contracts/interfaces/IContract.d.ts +4 -0
- package/browser/crypto/crypto-browser.d.ts +7 -0
- package/browser/index.js +1 -1
- package/browser/opnet.d.ts +11 -0
- package/browser/scripts/testContract.d.ts +1 -0
- package/browser/scripts/testMethods.d.ts +1 -0
- package/browser/utils/BitcoinUtils.d.ts +4 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/BaseContractProperty.d.ts +3 -0
- package/build/abi/BaseContractProperty.js +1 -0
- package/build/abi/BitcoinAbiTypes.d.ts +4 -0
- package/build/abi/BitcoinAbiTypes.js +5 -0
- package/build/abi/BitcoinInterface.d.ts +9 -0
- package/build/abi/BitcoinInterface.js +45 -0
- package/build/abi/BitcoinInterfaceAbi.d.ts +3 -0
- package/build/abi/BitcoinInterfaceAbi.js +1 -0
- package/build/abi/enums/ParamTypes.d.ts +0 -0
- package/build/abi/enums/ParamTypes.js +1 -0
- package/build/abi/interface/BitcoinInterface.d.ts +6 -0
- package/build/abi/interface/BitcoinInterface.js +12 -0
- package/build/abi/interface/BitcoinInterfaceAbi.d.ts +3 -0
- package/build/abi/interface/BitcoinInterfaceAbi.js +1 -0
- package/build/abi/interfaces/BaseContractProperties.d.ts +4 -0
- package/build/abi/interfaces/BaseContractProperties.js +1 -0
- package/build/abi/interfaces/BaseContractProperty.d.ts +2 -0
- package/build/abi/interfaces/BaseContractProperty.js +1 -0
- package/build/abi/interfaces/BitcoinAbiInput.d.ts +5 -0
- package/build/abi/interfaces/BitcoinAbiInput.js +1 -0
- package/build/abi/interfaces/BitcoinAbiValue.d.ts +5 -0
- package/build/abi/interfaces/BitcoinAbiValue.js +1 -0
- package/build/abi/interfaces/BitcoinInterfaceAbi.d.ts +11 -0
- package/build/abi/interfaces/BitcoinInterfaceAbi.js +1 -0
- package/build/bitcoin/UTXOs.d.ts +1 -6
- package/build/bitcoin/interfaces/IUTXO.d.ts +7 -0
- package/build/bitcoin/interfaces/IUTXO.js +1 -0
- package/build/common/CommonTypes.d.ts +1 -0
- package/build/contracts/CallResult.d.ts +6 -3
- package/build/contracts/CallResult.js +9 -2
- package/build/contracts/Contract.d.ts +28 -0
- package/build/contracts/Contract.js +206 -0
- package/build/contracts/interfaces/ICallResult.d.ts +2 -3
- package/build/contracts/interfaces/IContract.d.ts +4 -0
- package/build/contracts/interfaces/IContract.js +1 -0
- package/build/interface/BitcoinInterface.d.ts +6 -0
- package/build/interface/BitcoinInterface.js +12 -0
- package/build/interface/BitcoinInterfaceAbi.d.ts +3 -0
- package/build/interface/BitcoinInterfaceAbi.js +1 -0
- package/build/interface/Interface.d.ts +2 -0
- package/build/interface/Interface.js +2 -0
- package/build/interface.d.ts +0 -0
- package/build/interface.js +1 -0
- package/build/opnet.d.ts +11 -0
- package/build/opnet.js +11 -0
- package/build/scripts/test.js +12 -0
- package/build/scripts/testContract.d.ts +1 -0
- package/build/scripts/testContract.js +28 -0
- package/build/scripts/testMethods.d.ts +1 -0
- package/build/scripts/testMethods.js +24 -0
- package/build/utils/BitcoinUtils.d.ts +4 -0
- package/build/utils/BitcoinUtils.js +7 -0
- package/cjs/_version.d.ts +1 -0
- package/cjs/_version.js +4 -0
- package/cjs/abi/BaseContractProperty.d.ts +3 -0
- package/cjs/abi/BaseContractProperty.js +2 -0
- package/cjs/abi/BitcoinAbiTypes.d.ts +4 -0
- package/cjs/abi/BitcoinAbiTypes.js +8 -0
- package/cjs/abi/BitcoinInterface.d.ts +9 -0
- package/cjs/abi/BitcoinInterface.js +49 -0
- package/cjs/abi/interfaces/BaseContractProperties.d.ts +4 -0
- package/cjs/abi/interfaces/BaseContractProperties.js +2 -0
- package/cjs/abi/interfaces/BitcoinAbiValue.d.ts +5 -0
- package/cjs/abi/interfaces/BitcoinAbiValue.js +2 -0
- package/cjs/abi/interfaces/BitcoinInterfaceAbi.d.ts +11 -0
- package/cjs/abi/interfaces/BitcoinInterfaceAbi.js +2 -0
- package/cjs/bitcoin/BitcoinAddress.d.ts +20 -0
- package/cjs/bitcoin/BitcoinAddress.js +116 -0
- package/cjs/bitcoin/UTXOs.d.ts +15 -0
- package/cjs/bitcoin/UTXOs.js +16 -0
- package/cjs/block/Block.d.ts +2 -3
- package/cjs/block/Block.js +3 -28
- package/cjs/block/interfaces/IBlock.d.ts +28 -0
- package/cjs/block/interfaces/IBlock.js +2 -0
- package/cjs/common/CommonTypes.d.ts +4 -0
- package/cjs/common/CommonTypes.js +2 -0
- package/cjs/contracts/CallResult.d.ts +13 -0
- package/cjs/contracts/CallResult.js +25 -0
- package/cjs/contracts/Contract.d.ts +28 -0
- package/cjs/contracts/Contract.js +212 -0
- package/cjs/contracts/ContractData.d.ts +15 -0
- package/cjs/contracts/ContractData.js +36 -0
- package/cjs/contracts/interfaces/IAccessList.d.ts +6 -0
- package/cjs/contracts/interfaces/IAccessList.js +2 -0
- package/cjs/contracts/interfaces/ICallResult.d.ts +11 -0
- package/cjs/contracts/interfaces/ICallResult.js +2 -0
- package/cjs/contracts/interfaces/IContract.d.ts +4 -0
- package/cjs/contracts/interfaces/IContract.js +2 -0
- package/cjs/contracts/interfaces/IRawContract.d.ts +13 -0
- package/cjs/contracts/interfaces/IRawContract.js +2 -0
- package/cjs/crypto/crypto.d.ts +2 -0
- package/cjs/crypto/crypto.js +8 -0
- package/cjs/index.d.ts +3 -11
- package/cjs/index.js +16 -11
- package/cjs/opnet.d.ts +36 -0
- package/cjs/opnet.js +54 -0
- package/cjs/providers/AbstractRpcProvider.d.ts +34 -0
- package/cjs/providers/AbstractRpcProvider.js +161 -0
- package/cjs/providers/JSONRpcProvider.d.ts +5 -9
- package/cjs/providers/JSONRpcProvider.js +4 -29
- package/cjs/providers/WebsocketRpcProvider.d.ts +8 -0
- package/cjs/providers/WebsocketRpcProvider.js +27 -0
- package/cjs/scripts/testContract.d.ts +1 -0
- package/cjs/scripts/testContract.js +30 -0
- package/cjs/scripts/testMethods.d.ts +1 -0
- package/cjs/scripts/testMethods.js +26 -0
- package/cjs/serialize/BigInt.d.ts +6 -0
- package/cjs/serialize/BigInt.js +5 -0
- package/cjs/storage/StoredValue.d.ts +10 -0
- package/cjs/storage/StoredValue.js +28 -0
- package/cjs/storage/interfaces/IStorageValue.d.ts +9 -0
- package/cjs/storage/interfaces/IStorageValue.js +2 -0
- package/cjs/transactions/DeploymentTransaction.d.ts +10 -1
- package/cjs/transactions/DeploymentTransaction.js +16 -0
- package/cjs/transactions/GenericTransaction.d.ts +1 -1
- package/cjs/transactions/InteractionTransaction.d.ts +1 -1
- package/cjs/transactions/Transaction.d.ts +1 -1
- package/cjs/transactions/Transaction.js +1 -1
- package/cjs/transactions/TransactionParser.d.ts +7 -0
- package/cjs/transactions/TransactionParser.js +32 -0
- package/cjs/transactions/TransactionReceipt.d.ts +10 -0
- package/cjs/transactions/TransactionReceipt.js +16 -0
- package/cjs/transactions/interfaces/ITransaction.d.ts +39 -0
- package/cjs/transactions/interfaces/ITransaction.js +2 -0
- package/cjs/transactions/interfaces/ITransactionReceipt.d.ts +8 -0
- package/cjs/transactions/interfaces/ITransactionReceipt.js +2 -0
- package/cjs/utils/BitcoinUtils.d.ts +4 -0
- package/cjs/utils/BitcoinUtils.js +14 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AbstractRpcProvider.html +15 -15
- package/docs/classes/BaseContract.html +187 -0
- package/docs/classes/BitcoinAddress.html +5 -2
- package/docs/classes/BitcoinInterface.html +182 -0
- package/docs/classes/BitcoinUtils.html +183 -0
- package/docs/classes/Block.html +5 -3
- package/docs/classes/CallResult.html +6 -2
- package/docs/classes/ContractData.html +4 -2
- package/docs/classes/DeploymentTransaction.html +4 -2
- package/docs/classes/GenericTransaction.html +4 -2
- package/docs/classes/IBaseContract.html +192 -0
- package/docs/classes/InteractionTransaction.html +3 -2
- package/docs/classes/JSONRpcProvider.html +14 -14
- package/docs/classes/StoredValue.html +4 -2
- package/docs/classes/TransactionBase.html +4 -2
- package/docs/classes/TransactionInput.html +3 -2
- package/docs/classes/TransactionOutput.html +3 -2
- package/docs/classes/TransactionParser.html +3 -2
- package/docs/classes/TransactionReceipt.html +3 -2
- package/docs/classes/UTXO.html +4 -2
- package/docs/classes/WebSocketRpcProvider.html +14 -14
- package/docs/enums/ABIDataTypes.html +183 -0
- package/docs/enums/BitcoinAbiTypes.html +178 -0
- package/docs/enums/OPNetTransactionTypes.html +2 -2
- package/docs/functions/getContract.html +180 -0
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +4 -5
- package/docs/interfaces/BaseContractProperties.html +176 -0
- package/docs/interfaces/BitcoinAbiValue.html +180 -0
- package/docs/interfaces/BitcoinInterfaceAbiBase.html +182 -0
- package/docs/interfaces/IAccessList.html +3 -1
- package/docs/interfaces/IAccessListItem.html +3 -1
- package/docs/interfaces/IBlock.html +5 -3
- package/docs/interfaces/IBlockCommon.html +5 -3
- package/docs/interfaces/ICallRequestError.html +4 -2
- package/docs/interfaces/ICallResultData.html +4 -2
- package/docs/interfaces/IContract.html +177 -0
- package/docs/interfaces/IDeploymentTransaction.html +4 -2
- package/docs/interfaces/IGenericTransaction.html +4 -2
- package/docs/interfaces/IInteractionTransaction.html +4 -2
- package/docs/interfaces/IRawContract.html +5 -2
- package/docs/interfaces/IStorageValue.html +4 -2
- package/docs/interfaces/ITransactionBase.html +4 -2
- package/docs/interfaces/ITransactionInput.html +3 -2
- package/docs/interfaces/ITransactionOutput.html +3 -2
- package/docs/interfaces/ITransactionReceipt.html +4 -2
- package/docs/interfaces/IUTXO.html +4 -2
- package/docs/modules.html +38 -24
- package/docs/types/BaseContractProperty.html +176 -0
- package/docs/types/BitcoinAddressLike.html +1 -1
- package/docs/types/BitcoinInterfaceAbi.html +174 -0
- package/docs/types/BlockHeaderChecksumProof.html +1 -1
- package/docs/types/DecodedCallResult.html +174 -0
- package/docs/types/ICallResult.html +2 -1
- package/docs/types/ITransaction.html +2 -1
- package/docs/types/PointerLike.html +1 -1
- package/docs/types/UTXOs.html +3 -1
- package/docs/variables/version.html +1 -1
- package/package.json +6 -4
- package/src/_version.ts +1 -1
- package/src/abi/BaseContractProperty.ts +8 -0
- package/src/abi/BitcoinAbiTypes.ts +9 -0
- package/src/abi/BitcoinInterface.ts +63 -0
- package/src/abi/interfaces/BaseContractProperties.ts +9 -0
- package/src/abi/interfaces/BitcoinAbiValue.ts +18 -0
- package/src/abi/interfaces/BitcoinInterfaceAbi.ts +19 -0
- package/src/bitcoin/BitcoinAddress.ts +5 -0
- package/src/bitcoin/UTXOs.ts +28 -26
- package/src/bitcoin/interfaces/IUTXO.ts +12 -0
- package/src/block/Block.ts +5 -0
- package/src/block/interfaces/IBlock.ts +46 -38
- package/src/common/CommonTypes.ts +16 -4
- package/src/contracts/CallResult.ts +34 -20
- package/src/contracts/Contract.ts +321 -0
- package/src/contracts/ContractData.ts +46 -41
- package/src/contracts/interfaces/IAccessList.ts +17 -7
- package/src/contracts/interfaces/ICallResult.ts +29 -15
- package/src/contracts/interfaces/IContract.ts +10 -0
- package/src/contracts/interfaces/IRawContract.ts +17 -12
- package/src/crypto/crypto-browser.js +71 -60
- package/src/opnet.ts +17 -0
- package/src/providers/AbstractRpcProvider.ts +352 -351
- package/src/scripts/testContract.ts +51 -0
- package/src/scripts/{test.ts → testMethods.ts} +52 -54
- package/src/scripts/test_abi.json +31 -0
- package/src/storage/StoredValue.ts +35 -30
- package/src/storage/interfaces/IStorageValue.ts +15 -10
- package/src/transactions/DeploymentTransaction.ts +41 -36
- package/src/transactions/GenericTransaction.ts +19 -12
- package/src/transactions/InteractionTransaction.ts +44 -40
- package/src/transactions/Transaction.ts +8 -0
- package/src/transactions/TransactionInput.ts +8 -0
- package/src/transactions/TransactionOutput.ts +8 -0
- package/src/transactions/TransactionParser.ts +47 -43
- package/src/transactions/TransactionReceipt.ts +22 -18
- package/src/transactions/interfaces/ITransaction.ts +78 -52
- package/src/transactions/interfaces/ITransactionReceipt.ts +14 -9
- package/src/utils/BitcoinUtils.ts +22 -0
- package/webpack.config.js +71 -75
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
-
import { ITransactionReceipt } from './interfaces/ITransactionReceipt.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
public readonly
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { ITransactionReceipt } from './interfaces/ITransactionReceipt.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Transaction receipt
|
|
6
|
+
* @category Transactions
|
|
7
|
+
*/
|
|
8
|
+
export class TransactionReceipt implements ITransactionReceipt {
|
|
9
|
+
public readonly receipt: Buffer | null;
|
|
10
|
+
public readonly receiptProofs: string[];
|
|
11
|
+
public readonly events: NetEvent[];
|
|
12
|
+
|
|
13
|
+
public readonly revert?: Buffer;
|
|
14
|
+
|
|
15
|
+
constructor(receipt: ITransactionReceipt) {
|
|
16
|
+
this.receipt = receipt.receipt ? Buffer.from(receipt.receipt as string, 'base64') : null;
|
|
17
|
+
this.receiptProofs = receipt.receiptProofs || [];
|
|
18
|
+
this.events = receipt.events || [];
|
|
19
|
+
|
|
20
|
+
this.revert = receipt.revert ? Buffer.from(receipt.revert as string, 'base64') : undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,52 +1,78 @@
|
|
|
1
|
-
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
-
import { BigNumberish } from 'ethers';
|
|
3
|
-
import { OPNetTransactionTypes } from '../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
-
import { ITransactionInput, TransactionInput } from '../TransactionInput.js';
|
|
5
|
-
import { ITransactionOutput, TransactionOutput } from '../TransactionOutput.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
readonly wasCompressed: boolean;
|
|
46
|
-
|
|
47
|
-
readonly
|
|
48
|
-
readonly
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { BigNumberish } from 'ethers';
|
|
3
|
+
import { OPNetTransactionTypes } from '../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
+
import { ITransactionInput, TransactionInput } from '../TransactionInput.js';
|
|
5
|
+
import { ITransactionOutput, TransactionOutput } from '../TransactionOutput.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @description This interface represents the base of a transaction.
|
|
9
|
+
* @interface ITransactionBase
|
|
10
|
+
* @template T
|
|
11
|
+
* @category ITransactions
|
|
12
|
+
*/
|
|
13
|
+
export interface ITransactionBase<T extends OPNetTransactionTypes> {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly hash: string;
|
|
16
|
+
|
|
17
|
+
readonly index: number; // Mark the order of the transaction in the block
|
|
18
|
+
|
|
19
|
+
readonly burnedBitcoin: string | BigNumberish;
|
|
20
|
+
readonly revert?: string | Buffer;
|
|
21
|
+
|
|
22
|
+
readonly inputs: ITransactionInput[] | TransactionInput[];
|
|
23
|
+
readonly outputs: ITransactionOutput[] | TransactionOutput[];
|
|
24
|
+
|
|
25
|
+
readonly OPNetType: T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @description This interface represents a generic transaction.
|
|
30
|
+
* @interface IGenericTransaction
|
|
31
|
+
* @category ITransactions
|
|
32
|
+
*/
|
|
33
|
+
export interface IGenericTransaction extends ITransactionBase<OPNetTransactionTypes.Generic> {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @description This interface represents a deployment transaction.
|
|
37
|
+
* @interface IDeploymentTransaction
|
|
38
|
+
* @category ITransactions
|
|
39
|
+
*/
|
|
40
|
+
export interface IDeploymentTransaction extends ITransactionBase<OPNetTransactionTypes.Deployment> {
|
|
41
|
+
readonly contractAddress: string;
|
|
42
|
+
readonly virtualAddress: string;
|
|
43
|
+
|
|
44
|
+
readonly bytecode: Buffer | string;
|
|
45
|
+
readonly wasCompressed: boolean;
|
|
46
|
+
|
|
47
|
+
readonly deployerPubKey: Buffer | string;
|
|
48
|
+
readonly deployerAddress: string;
|
|
49
|
+
|
|
50
|
+
readonly contractSeed: Buffer | string;
|
|
51
|
+
readonly contractSaltHash: Buffer | string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @description This interface represents an interaction transaction.
|
|
56
|
+
* @interface IInteractionTransaction
|
|
57
|
+
* @category ITransactions
|
|
58
|
+
*/
|
|
59
|
+
export interface IInteractionTransaction
|
|
60
|
+
extends ITransactionBase<OPNetTransactionTypes.Interaction> {
|
|
61
|
+
readonly calldata: string | Buffer;
|
|
62
|
+
readonly senderPubKeyHash: string | Buffer;
|
|
63
|
+
readonly contractSecret: string | Buffer;
|
|
64
|
+
readonly interactionPubKey: string | Buffer;
|
|
65
|
+
|
|
66
|
+
readonly wasCompressed: boolean;
|
|
67
|
+
|
|
68
|
+
readonly events: NetEvent[];
|
|
69
|
+
readonly receipt?: string | Buffer;
|
|
70
|
+
readonly receiptProofs?: string[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @description This type represents a transaction.
|
|
75
|
+
* @type ITransaction
|
|
76
|
+
* @category ITransactions
|
|
77
|
+
*/
|
|
78
|
+
export type ITransaction = IDeploymentTransaction | IInteractionTransaction | IGenericTransaction;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description This interface represents a transaction receipt.
|
|
5
|
+
* @interface ITransactionReceipt
|
|
6
|
+
* @category ITransactions
|
|
7
|
+
*/
|
|
8
|
+
export interface ITransactionReceipt {
|
|
9
|
+
readonly receipt: string | null | Buffer;
|
|
10
|
+
readonly receiptProofs: string[];
|
|
11
|
+
readonly events: NetEvent[];
|
|
12
|
+
|
|
13
|
+
readonly revert?: string | Buffer;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { BigNumberish } from 'ethers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Bitcoin Utilities
|
|
6
|
+
* @description This class is used to provide utility functions for Bitcoin.
|
|
7
|
+
* @class BitcoinUtils
|
|
8
|
+
* @category Utils
|
|
9
|
+
*/
|
|
10
|
+
export class BitcoinUtils {
|
|
11
|
+
/**
|
|
12
|
+
* Get Satoshis or any other unit, bitcoin by default.
|
|
13
|
+
* @description This function is used to format a value in satoshis to Bitcoin.
|
|
14
|
+
* @param value Value in satoshis or any other unit
|
|
15
|
+
* @param decimals Default is 8
|
|
16
|
+
*/
|
|
17
|
+
public static formatUnits(value: BigNumberish, decimals: number = 8): string {
|
|
18
|
+
const bn: BigNumber = new BigNumber(value.toString());
|
|
19
|
+
|
|
20
|
+
return bn.dividedBy(new BigNumber(10).pow(decimals)).toString();
|
|
21
|
+
}
|
|
22
|
+
}
|
package/webpack.config.js
CHANGED
|
@@ -1,75 +1,71 @@
|
|
|
1
|
-
import webpack from 'webpack';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
mode: 'production',
|
|
5
|
-
entry: './src/index.ts',
|
|
6
|
-
watch: false,
|
|
7
|
-
output: {
|
|
8
|
-
filename: 'index.js',
|
|
9
|
-
path: import.meta.dirname + '/browser',
|
|
10
|
-
libraryTarget: 'module',
|
|
11
|
-
},
|
|
12
|
-
node: {
|
|
13
|
-
__dirname: false,
|
|
14
|
-
},
|
|
15
|
-
experiments: {
|
|
16
|
-
outputModule: true,
|
|
17
|
-
asyncWebAssembly: true,
|
|
18
|
-
syncWebAssembly: true,
|
|
19
|
-
},
|
|
20
|
-
resolve: {
|
|
21
|
-
extensionAlias: {
|
|
22
|
-
'.js': ['.js', '.ts'],
|
|
23
|
-
},
|
|
24
|
-
modules: ['.', 'node_modules'],
|
|
25
|
-
extensions: ['.*', '.js', '.jsx', '.tsx', '.ts', '.wasm'],
|
|
26
|
-
fallback: {
|
|
27
|
-
buffer: import.meta.resolve('buffer/'),
|
|
28
|
-
|
|
29
|
-
assert: import.meta.resolve('assert/'),
|
|
30
|
-
crypto: import.meta.resolve('./src/crypto/crypto-browser.js'),
|
|
31
|
-
http: import.meta.resolve('stream-http/'),
|
|
32
|
-
https: import.meta.resolve('https-browserify/'),
|
|
33
|
-
os: import.meta.resolve('os-browserify/browser/'),
|
|
34
|
-
stream: import.meta.resolve('stream-browserify'),
|
|
35
|
-
process: import.meta.resolve('process/browser'),
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
cache: false,
|
|
39
|
-
module: {
|
|
40
|
-
rules: [
|
|
41
|
-
{
|
|
42
|
-
test: /\.(js|jsx|tsx|ts)$/,
|
|
43
|
-
exclude: /node_modules/,
|
|
44
|
-
resolve: {
|
|
45
|
-
fullySpecified: false,
|
|
46
|
-
},
|
|
47
|
-
use: [
|
|
48
|
-
{
|
|
49
|
-
loader: 'babel-loader',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
loader: 'ts-loader',
|
|
53
|
-
options: {
|
|
54
|
-
configFile: 'tsconfig.webpack.json',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
optimization: {
|
|
62
|
-
usedExports: true,
|
|
63
|
-
},
|
|
64
|
-
plugins: [
|
|
65
|
-
new webpack.ProvidePlugin({
|
|
66
|
-
Buffer: ['buffer', 'Buffer'],
|
|
67
|
-
process: 'process/browser',
|
|
68
|
-
stream: 'stream-browserify',
|
|
69
|
-
}),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
excludeAliases: ['console', 'buffer'],
|
|
73
|
-
}),*/
|
|
74
|
-
],
|
|
75
|
-
};
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './src/index.ts',
|
|
6
|
+
watch: false,
|
|
7
|
+
output: {
|
|
8
|
+
filename: 'index.js',
|
|
9
|
+
path: import.meta.dirname + '/browser',
|
|
10
|
+
libraryTarget: 'module',
|
|
11
|
+
},
|
|
12
|
+
node: {
|
|
13
|
+
__dirname: false,
|
|
14
|
+
},
|
|
15
|
+
experiments: {
|
|
16
|
+
outputModule: true,
|
|
17
|
+
asyncWebAssembly: true,
|
|
18
|
+
syncWebAssembly: true,
|
|
19
|
+
},
|
|
20
|
+
resolve: {
|
|
21
|
+
extensionAlias: {
|
|
22
|
+
'.js': ['.js', '.ts'],
|
|
23
|
+
},
|
|
24
|
+
modules: ['.', 'node_modules'],
|
|
25
|
+
extensions: ['.*', '.js', '.jsx', '.tsx', '.ts', '.wasm'],
|
|
26
|
+
fallback: {
|
|
27
|
+
buffer: import.meta.resolve('buffer/'),
|
|
28
|
+
|
|
29
|
+
assert: import.meta.resolve('assert/'),
|
|
30
|
+
crypto: import.meta.resolve('./src/crypto/crypto-browser.js'),
|
|
31
|
+
http: import.meta.resolve('stream-http/'),
|
|
32
|
+
https: import.meta.resolve('https-browserify/'),
|
|
33
|
+
os: import.meta.resolve('os-browserify/browser/'),
|
|
34
|
+
stream: import.meta.resolve('stream-browserify'),
|
|
35
|
+
process: import.meta.resolve('process/browser'),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
cache: false,
|
|
39
|
+
module: {
|
|
40
|
+
rules: [
|
|
41
|
+
{
|
|
42
|
+
test: /\.(js|jsx|tsx|ts)$/,
|
|
43
|
+
exclude: /node_modules/,
|
|
44
|
+
resolve: {
|
|
45
|
+
fullySpecified: false,
|
|
46
|
+
},
|
|
47
|
+
use: [
|
|
48
|
+
{
|
|
49
|
+
loader: 'babel-loader',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
loader: 'ts-loader',
|
|
53
|
+
options: {
|
|
54
|
+
configFile: 'tsconfig.webpack.json',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
optimization: {
|
|
62
|
+
usedExports: true,
|
|
63
|
+
},
|
|
64
|
+
plugins: [
|
|
65
|
+
new webpack.ProvidePlugin({
|
|
66
|
+
Buffer: ['buffer', 'Buffer'],
|
|
67
|
+
process: 'process/browser',
|
|
68
|
+
stream: 'stream-browserify',
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
};
|