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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ABIDataTypes } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { BaseContractProperty } from '../abi/BaseContractProperty.js';
|
|
3
|
+
import { BitcoinAbiTypes } from '../abi/BitcoinAbiTypes.js';
|
|
4
|
+
import { BaseContractProperties } from '../abi/interfaces/BaseContractProperties.js';
|
|
5
|
+
import { BitcoinInterfaceAbi } from '../abi/interfaces/BitcoinInterfaceAbi.js';
|
|
6
|
+
import { BitcoinAddressLike } from '../common/CommonTypes.js';
|
|
7
|
+
import { CallResult } from '../contracts/CallResult.js';
|
|
8
|
+
import { getContract } from '../contracts/Contract.js';
|
|
9
|
+
import { JSONRpcProvider } from '../providers/JSONRpcProvider.js';
|
|
10
|
+
|
|
11
|
+
const provider: JSONRpcProvider = new JSONRpcProvider('https://testnet.opnet.org');
|
|
12
|
+
|
|
13
|
+
interface TestContract extends BaseContractProperties {
|
|
14
|
+
giveFreeMoney(bool: true): Promise<BaseContractProperty>;
|
|
15
|
+
|
|
16
|
+
balanceOf(address: BitcoinAddressLike): Promise<BaseContractProperty>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
const abi: BitcoinInterfaceAbi = [
|
|
21
|
+
{
|
|
22
|
+
name: 'balanceOf',
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
name: 'address',
|
|
26
|
+
type: ABIDataTypes.ADDRESS,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
outputs: [
|
|
30
|
+
{
|
|
31
|
+
name: 'balance',
|
|
32
|
+
type: ABIDataTypes.UINT256,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
type: BitcoinAbiTypes.Function,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const contract: TestContract = getContract<TestContract>(
|
|
40
|
+
'tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a',
|
|
41
|
+
abi,
|
|
42
|
+
provider,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// 13sBQqJdnAdc7v5tnX3ifYqAMoFX79VfLy
|
|
46
|
+
const res: CallResult = (await contract.balanceOf(
|
|
47
|
+
'bc1p134a291b21a4ef28c961daee77a75e81cd7c0f00733a152930f76746a3e9',
|
|
48
|
+
)) as CallResult;
|
|
49
|
+
|
|
50
|
+
console.log('Balance:', res.decoded);
|
|
51
|
+
})();
|
|
@@ -1,54 +1,52 @@
|
|
|
1
|
-
import { JSONRpcProvider } from '../providers/JSONRpcProvider.js';
|
|
2
|
-
|
|
3
|
-
const provider: JSONRpcProvider = new JSONRpcProvider('https://testnet.opnet.org');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const blockNumber = await provider.getBlockNumber();
|
|
7
|
-
console.log('Current network height:', blockNumber);
|
|
8
|
-
|
|
9
|
-
const block = await provider.getBlock(2810101n, true);
|
|
10
|
-
console.log('Block ->', block.transactions[2]);
|
|
11
|
-
|
|
12
|
-
const balance = await provider.getBalance('tb1qcfszz8dcvsz9mcp70ezw5zy2r3ydr0cfz60d3t');
|
|
13
|
-
console.log('Balance out:', balance);
|
|
14
|
-
|
|
15
|
-
const utxos = await provider.getUXTOs('tb1qcfszz8dcvsz9mcp70ezw5zy2r3ydr0cfz60d3t');
|
|
16
|
-
console.log('UTXOs:', utxos);
|
|
17
|
-
|
|
18
|
-
const transaction = await provider.getTransaction(
|
|
19
|
-
'63e77ba9fa4262b3d4d0d9d97fa8a7359534606c3f3af096284662e3f619f374',
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
console.log('Transaction:', transaction);
|
|
23
|
-
|
|
24
|
-
const receipt = await provider.getTransactionReceipt(
|
|
25
|
-
'63e77ba9fa4262b3d4d0d9d97fa8a7359534606c3f3af096284662e3f619f374',
|
|
26
|
-
);
|
|
27
|
-
console.log('Receipt:', receipt);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
console.log('Call result:', callResult);
|
|
54
|
-
})();
|
|
1
|
+
import { JSONRpcProvider } from '../providers/JSONRpcProvider.js';
|
|
2
|
+
|
|
3
|
+
const provider: JSONRpcProvider = new JSONRpcProvider('https://testnet.opnet.org');
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
const blockNumber = await provider.getBlockNumber();
|
|
7
|
+
console.log('Current network height:', blockNumber);
|
|
8
|
+
|
|
9
|
+
const block = await provider.getBlock(2810101n, true);
|
|
10
|
+
console.log('Block ->', block.transactions[2]);
|
|
11
|
+
|
|
12
|
+
const balance = await provider.getBalance('tb1qcfszz8dcvsz9mcp70ezw5zy2r3ydr0cfz60d3t');
|
|
13
|
+
console.log('Balance out:', balance);
|
|
14
|
+
|
|
15
|
+
const utxos = await provider.getUXTOs('tb1qcfszz8dcvsz9mcp70ezw5zy2r3ydr0cfz60d3t');
|
|
16
|
+
console.log('UTXOs:', utxos);
|
|
17
|
+
|
|
18
|
+
const transaction = await provider.getTransaction(
|
|
19
|
+
'63e77ba9fa4262b3d4d0d9d97fa8a7359534606c3f3af096284662e3f619f374',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
console.log('Transaction:', transaction);
|
|
23
|
+
|
|
24
|
+
const receipt = await provider.getTransactionReceipt(
|
|
25
|
+
'63e77ba9fa4262b3d4d0d9d97fa8a7359534606c3f3af096284662e3f619f374',
|
|
26
|
+
);
|
|
27
|
+
console.log('Receipt:', receipt);
|
|
28
|
+
|
|
29
|
+
const net = await provider.getNetwork();
|
|
30
|
+
console.log(net);
|
|
31
|
+
|
|
32
|
+
const code = await provider.getCode(
|
|
33
|
+
'tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
console.log('Code:', code);
|
|
37
|
+
|
|
38
|
+
const pointerValue = await provider.getStorageAt(
|
|
39
|
+
'tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a',
|
|
40
|
+
'EXLK/QhEQMI5d9DrthLvozT+UcDQ7WuSPaz7g8GV3AQ=',
|
|
41
|
+
true,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
console.log('Pointer value:', pointerValue);
|
|
45
|
+
|
|
46
|
+
const callResult = await provider.call(
|
|
47
|
+
'tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a',
|
|
48
|
+
'82d62f3d3133734251714a646e416463377635746e583369665971414d6f4658373956664c79000000000000000000000000000000000000000000000000000000000000',
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log('Call result:', callResult);
|
|
52
|
+
})();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"constant": true,
|
|
4
|
+
"inputs": [],
|
|
5
|
+
"name": "name",
|
|
6
|
+
"outputs": [
|
|
7
|
+
{
|
|
8
|
+
"name": "",
|
|
9
|
+
"type": "string"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"type": "function"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"anonymous": false,
|
|
16
|
+
"inputs": [
|
|
17
|
+
{
|
|
18
|
+
"indexed": true,
|
|
19
|
+
"name": "src",
|
|
20
|
+
"type": "address"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"indexed": false,
|
|
24
|
+
"name": "wad",
|
|
25
|
+
"type": "uint256"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"name": "Withdrawal",
|
|
29
|
+
"type": "event"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
import { BufferHelper } from '@btc-vision/bsi-binary';
|
|
2
|
-
import { IStorageValue } from './interfaces/IStorageValue.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
1
|
+
import { BufferHelper } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { IStorageValue } from './interfaces/IStorageValue.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description This class is used represent a stored value.
|
|
6
|
+
* @class StoredValue
|
|
7
|
+
* @category Storage
|
|
8
|
+
*/
|
|
9
|
+
export class StoredValue implements IStorageValue {
|
|
10
|
+
public readonly pointer: bigint;
|
|
11
|
+
public readonly value: Buffer;
|
|
12
|
+
|
|
13
|
+
public readonly height: bigint;
|
|
14
|
+
public readonly proofs: string[];
|
|
15
|
+
|
|
16
|
+
constructor(iStoredValue: IStorageValue) {
|
|
17
|
+
this.pointer =
|
|
18
|
+
typeof iStoredValue.pointer === 'string'
|
|
19
|
+
? this.base64ToBigInt(iStoredValue.pointer)
|
|
20
|
+
: iStoredValue.pointer;
|
|
21
|
+
|
|
22
|
+
if (iStoredValue.value instanceof Buffer) {
|
|
23
|
+
this.value = iStoredValue.value;
|
|
24
|
+
} else {
|
|
25
|
+
this.value = Buffer.from(iStoredValue.value, 'base64');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.height = BigInt(iStoredValue.height);
|
|
29
|
+
this.proofs = iStoredValue.proofs || [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private base64ToBigInt(base64: string): bigint {
|
|
33
|
+
return BufferHelper.uint8ArrayToPointer(Buffer.from(base64, 'base64'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { BigNumberish } from 'ethers';
|
|
2
|
-
import { PointerLike } from '../../common/CommonTypes.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { BigNumberish } from 'ethers';
|
|
2
|
+
import { PointerLike } from '../../common/CommonTypes.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description This interface is used to represent a stored value.
|
|
6
|
+
* @interface IStorageValue
|
|
7
|
+
* @category Storage
|
|
8
|
+
*/
|
|
9
|
+
export interface IStorageValue {
|
|
10
|
+
readonly pointer: PointerLike;
|
|
11
|
+
readonly value: string | Buffer;
|
|
12
|
+
|
|
13
|
+
readonly height: BigNumberish;
|
|
14
|
+
readonly proofs?: string[];
|
|
15
|
+
}
|
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
-
import { IDeploymentTransaction } from './interfaces/ITransaction.js';
|
|
3
|
-
import { TransactionBase } from './Transaction.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
public readonly
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
public readonly
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
+
import { IDeploymentTransaction } from './interfaces/ITransaction.js';
|
|
3
|
+
import { TransactionBase } from './Transaction.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description This class is used to provide a deployment transaction.
|
|
7
|
+
* @class DeploymentTransaction
|
|
8
|
+
* @category Transactions
|
|
9
|
+
*/
|
|
10
|
+
export class DeploymentTransaction
|
|
11
|
+
extends TransactionBase<OPNetTransactionTypes.Deployment>
|
|
12
|
+
implements IDeploymentTransaction
|
|
13
|
+
{
|
|
14
|
+
public readonly contractAddress: string;
|
|
15
|
+
public readonly virtualAddress: string;
|
|
16
|
+
|
|
17
|
+
public readonly bytecode: Buffer;
|
|
18
|
+
public readonly wasCompressed: boolean;
|
|
19
|
+
|
|
20
|
+
public readonly deployerPubKey: Buffer;
|
|
21
|
+
public readonly deployerAddress: string;
|
|
22
|
+
|
|
23
|
+
public readonly contractSeed: Buffer;
|
|
24
|
+
public readonly contractSaltHash: Buffer;
|
|
25
|
+
|
|
26
|
+
constructor(transaction: IDeploymentTransaction) {
|
|
27
|
+
super(transaction);
|
|
28
|
+
|
|
29
|
+
this.contractAddress = transaction.contractAddress;
|
|
30
|
+
this.virtualAddress = transaction.virtualAddress;
|
|
31
|
+
|
|
32
|
+
this.bytecode = Buffer.from(transaction.bytecode as string, 'base64');
|
|
33
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
34
|
+
|
|
35
|
+
this.deployerPubKey = Buffer.from(transaction.deployerPubKey as string, 'base64');
|
|
36
|
+
this.deployerAddress = transaction.deployerAddress;
|
|
37
|
+
|
|
38
|
+
this.contractSeed = Buffer.from(transaction.contractSeed as string, 'base64');
|
|
39
|
+
this.contractSaltHash = Buffer.from(transaction.contractSaltHash as string, 'base64');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
-
import { IGenericTransaction } from './interfaces/ITransaction.js';
|
|
3
|
-
import { TransactionBase } from './Transaction.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
+
import { IGenericTransaction } from './interfaces/ITransaction.js';
|
|
3
|
+
import { TransactionBase } from './Transaction.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description This class is used to create a generic transaction.
|
|
7
|
+
* @class GenericTransaction
|
|
8
|
+
* @extends {TransactionBase<OPNetTransactionTypes.Generic>}
|
|
9
|
+
* @implements {IGenericTransaction}
|
|
10
|
+
* @category Transactions
|
|
11
|
+
*/
|
|
12
|
+
export class GenericTransaction
|
|
13
|
+
extends TransactionBase<OPNetTransactionTypes.Generic>
|
|
14
|
+
implements IGenericTransaction
|
|
15
|
+
{
|
|
16
|
+
constructor(transaction: IGenericTransaction) {
|
|
17
|
+
super(transaction);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
-
import { Buffer } from 'buffer';
|
|
3
|
-
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
-
import { IInteractionTransaction } from './interfaces/ITransaction.js';
|
|
5
|
-
import { TransactionBase } from './Transaction.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
public readonly
|
|
17
|
-
public readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
public readonly
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
+
import { IInteractionTransaction } from './interfaces/ITransaction.js';
|
|
5
|
+
import { TransactionBase } from './Transaction.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Interaction transaction.
|
|
9
|
+
* @category Transactions
|
|
10
|
+
*/
|
|
11
|
+
export class InteractionTransaction
|
|
12
|
+
extends TransactionBase<OPNetTransactionTypes.Interaction>
|
|
13
|
+
implements IInteractionTransaction
|
|
14
|
+
{
|
|
15
|
+
public readonly calldata: Buffer;
|
|
16
|
+
public readonly senderPubKeyHash: Buffer;
|
|
17
|
+
public readonly contractSecret: Buffer;
|
|
18
|
+
public readonly interactionPubKey: Buffer;
|
|
19
|
+
|
|
20
|
+
public readonly wasCompressed: boolean;
|
|
21
|
+
public readonly events: NetEvent[];
|
|
22
|
+
|
|
23
|
+
public readonly receipt?: Buffer;
|
|
24
|
+
|
|
25
|
+
public readonly receiptProofs?: string[];
|
|
26
|
+
|
|
27
|
+
constructor(transaction: IInteractionTransaction) {
|
|
28
|
+
super(transaction);
|
|
29
|
+
|
|
30
|
+
this.calldata = Buffer.from(transaction.calldata as string, 'base64');
|
|
31
|
+
this.senderPubKeyHash = Buffer.from(transaction.senderPubKeyHash as string, 'base64');
|
|
32
|
+
this.contractSecret = Buffer.from(transaction.contractSecret as string, 'base64');
|
|
33
|
+
this.interactionPubKey = Buffer.from(transaction.interactionPubKey as string, 'base64');
|
|
34
|
+
|
|
35
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
36
|
+
|
|
37
|
+
this.events = transaction.events;
|
|
38
|
+
this.receipt = transaction.receipt
|
|
39
|
+
? Buffer.from(transaction.receipt as string, 'base64')
|
|
40
|
+
: undefined;
|
|
41
|
+
|
|
42
|
+
this.receiptProofs = transaction.receiptProofs;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -4,6 +4,14 @@ import { ITransactionBase } from './interfaces/ITransaction.js';
|
|
|
4
4
|
import { TransactionInput } from './TransactionInput.js';
|
|
5
5
|
import { ITransactionOutput, TransactionOutput } from './TransactionOutput.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @description This class is used to provide a base transaction.
|
|
9
|
+
* @class Transaction
|
|
10
|
+
* @implements {ITransactionBase<T>}
|
|
11
|
+
* @template T
|
|
12
|
+
* @category Transactions
|
|
13
|
+
* @abstract
|
|
14
|
+
*/
|
|
7
15
|
export abstract class TransactionBase<T extends OPNetTransactionTypes>
|
|
8
16
|
implements ITransactionBase<T>
|
|
9
17
|
{
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ScriptSig } from '@btc-vision/bsi-bitcoin-rpc';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Transaction input interface
|
|
5
|
+
* @category ITransactions
|
|
6
|
+
*/
|
|
3
7
|
export interface ITransactionInput {
|
|
4
8
|
readonly originalTransactionId: string | undefined;
|
|
5
9
|
readonly outputTransactionIndex: number | undefined;
|
|
@@ -10,6 +14,10 @@ export interface ITransactionInput {
|
|
|
10
14
|
readonly transactionInWitness?: string[];
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Transaction input
|
|
19
|
+
* @category ITransactions
|
|
20
|
+
*/
|
|
13
21
|
export class TransactionInput implements ITransactionInput {
|
|
14
22
|
public readonly originalTransactionId: string | undefined;
|
|
15
23
|
public readonly outputTransactionIndex: number | undefined;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ScriptPubKey } from '@btc-vision/bsi-bitcoin-rpc';
|
|
2
2
|
import { script } from 'bitcoinjs-lib';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Transaction output interface
|
|
6
|
+
* @category ITransactions
|
|
7
|
+
*/
|
|
4
8
|
export interface ITransactionOutput {
|
|
5
9
|
readonly index: number;
|
|
6
10
|
readonly scriptPubKey: {
|
|
@@ -12,6 +16,10 @@ export interface ITransactionOutput {
|
|
|
12
16
|
readonly value: string;
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Transaction output
|
|
21
|
+
* @category Transactions
|
|
22
|
+
*/
|
|
15
23
|
export class TransactionOutput {
|
|
16
24
|
public readonly value: bigint;
|
|
17
25
|
public readonly index: number;
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
-
import { DeploymentTransaction } from './DeploymentTransaction.js';
|
|
3
|
-
import { GenericTransaction } from './GenericTransaction.js';
|
|
4
|
-
import { InteractionTransaction } from './InteractionTransaction.js';
|
|
5
|
-
import {
|
|
6
|
-
IDeploymentTransaction,
|
|
7
|
-
IGenericTransaction,
|
|
8
|
-
IInteractionTransaction,
|
|
9
|
-
ITransaction,
|
|
10
|
-
} from './interfaces/ITransaction.js';
|
|
11
|
-
import { TransactionBase } from './Transaction.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case OPNetTransactionTypes.
|
|
38
|
-
return new
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
+
import { DeploymentTransaction } from './DeploymentTransaction.js';
|
|
3
|
+
import { GenericTransaction } from './GenericTransaction.js';
|
|
4
|
+
import { InteractionTransaction } from './InteractionTransaction.js';
|
|
5
|
+
import {
|
|
6
|
+
IDeploymentTransaction,
|
|
7
|
+
IGenericTransaction,
|
|
8
|
+
IInteractionTransaction,
|
|
9
|
+
ITransaction,
|
|
10
|
+
} from './interfaces/ITransaction.js';
|
|
11
|
+
import { TransactionBase } from './Transaction.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Transaction parser
|
|
15
|
+
* @category Transactions
|
|
16
|
+
*/
|
|
17
|
+
export class TransactionParser {
|
|
18
|
+
public static parseTransactions(
|
|
19
|
+
transactions: ITransaction[],
|
|
20
|
+
): TransactionBase<OPNetTransactionTypes>[] {
|
|
21
|
+
if (!transactions) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const transactionArray: TransactionBase<OPNetTransactionTypes>[] = [];
|
|
26
|
+
for (let transaction of transactions) {
|
|
27
|
+
transactionArray.push(this.parseTransaction(transaction));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return transactionArray;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public static parseTransaction(
|
|
34
|
+
transaction: ITransaction,
|
|
35
|
+
): TransactionBase<OPNetTransactionTypes> {
|
|
36
|
+
switch (transaction.OPNetType) {
|
|
37
|
+
case OPNetTransactionTypes.Generic:
|
|
38
|
+
return new GenericTransaction(transaction as IGenericTransaction);
|
|
39
|
+
case OPNetTransactionTypes.Interaction:
|
|
40
|
+
return new InteractionTransaction(transaction as IInteractionTransaction);
|
|
41
|
+
case OPNetTransactionTypes.Deployment:
|
|
42
|
+
return new DeploymentTransaction(transaction as IDeploymentTransaction);
|
|
43
|
+
default:
|
|
44
|
+
throw new Error('Unknown transaction type');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|