opnet 1.0.21 → 1.0.22
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/contracts/ContractData.d.ts +5 -3
- package/browser/contracts/interfaces/IRawContract.d.ts +5 -3
- package/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +2 -0
- package/browser/interfaces/opnet/OPNetTransactionTypes.d.ts +4 -1
- package/browser/opnet.d.ts +11 -6
- package/browser/providers/AbstractRpcProvider.d.ts +1 -1
- package/browser/scripts/testMethodsReg.d.ts +1 -0
- package/browser/transactions/Transaction.d.ts +4 -3
- package/browser/transactions/decoders/DeploymentTransaction.d.ts +17 -0
- package/browser/transactions/decoders/GenericTransaction.d.ts +6 -0
- package/browser/transactions/decoders/InteractionTransaction.d.ts +15 -0
- package/browser/transactions/decoders/WrapTransaction.d.ts +15 -0
- package/browser/transactions/interfaces/ITransaction.d.ts +8 -27
- package/browser/transactions/interfaces/transactions/ICommonTransaction.d.ts +7 -0
- package/browser/transactions/interfaces/transactions/IDeploymentTransaction.d.ts +13 -0
- package/browser/transactions/interfaces/transactions/IInteractionTransaction.d.ts +14 -0
- package/browser/transactions/interfaces/transactions/IWrapTransaction.d.ts +10 -0
- package/browser/transactions/metadata/TransactionInput.d.ts +16 -0
- package/browser/transactions/metadata/TransactionOutput.d.ts +19 -0
- package/browser/transactions/metadata/TransactionReceipt.d.ts +11 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/contracts/ContractData.d.ts +5 -3
- package/build/contracts/ContractData.js +2 -0
- package/build/contracts/interfaces/IRawContract.d.ts +5 -3
- package/build/interfaces/opnet/OPNetTransactionTypes.d.ts +4 -1
- package/build/interfaces/opnet/OPNetTransactionTypes.js +2 -0
- package/build/opnet.d.ts +11 -6
- package/build/opnet.js +11 -6
- package/build/providers/AbstractRpcProvider.d.ts +1 -1
- package/build/providers/AbstractRpcProvider.js +1 -1
- package/build/scripts/testMethods.js +1 -1
- package/build/scripts/testMethodsReg.d.ts +1 -0
- package/build/scripts/testMethodsReg.js +10 -0
- package/build/transactions/Transaction.d.ts +4 -3
- package/build/transactions/Transaction.js +5 -3
- package/build/transactions/TransactionParser.js +8 -4
- package/build/transactions/decoders/DeploymentTransaction.d.ts +17 -0
- package/build/transactions/decoders/DeploymentTransaction.js +26 -0
- package/build/transactions/decoders/GenericTransaction.d.ts +6 -0
- package/build/transactions/decoders/GenericTransaction.js +6 -0
- package/build/transactions/decoders/InteractionTransaction.d.ts +15 -0
- package/build/transactions/decoders/InteractionTransaction.js +21 -0
- package/build/transactions/decoders/WrapInteractionTransaction.d.ts +15 -0
- package/build/transactions/decoders/WrapInteractionTransaction.js +21 -0
- package/build/transactions/decoders/WrapTransaction.d.ts +15 -0
- package/build/transactions/decoders/WrapTransaction.js +30 -0
- package/build/transactions/interfaces/ITransaction.d.ts +8 -27
- package/build/transactions/interfaces/IWrapTransaction.d.ts +3 -0
- package/build/transactions/interfaces/IWrapTransaction.js +1 -0
- package/build/transactions/interfaces/transactions/ICommonTransaction.d.ts +7 -0
- package/build/transactions/interfaces/transactions/ICommonTransaction.js +1 -0
- package/build/transactions/interfaces/transactions/IDeploymentTransaction.d.ts +13 -0
- package/build/transactions/interfaces/transactions/IDeploymentTransaction.js +1 -0
- package/build/transactions/interfaces/transactions/IInteractionTransaction.d.ts +14 -0
- package/build/transactions/interfaces/transactions/IInteractionTransaction.js +1 -0
- package/build/transactions/interfaces/transactions/IWrapTransaction.d.ts +10 -0
- package/build/transactions/interfaces/transactions/IWrapTransaction.js +1 -0
- package/build/transactions/metadata/TransactionInput.d.ts +16 -0
- package/build/transactions/metadata/TransactionInput.js +14 -0
- package/build/transactions/metadata/TransactionOutput.d.ts +19 -0
- package/build/transactions/metadata/TransactionOutput.js +16 -0
- package/build/transactions/metadata/TransactionReceipt.d.ts +11 -0
- package/build/transactions/metadata/TransactionReceipt.js +53 -0
- package/build/transactions/types/DeploymentTransaction.d.ts +16 -0
- package/build/transactions/types/DeploymentTransaction.js +24 -0
- package/build/transactions/types/GenericTransaction.d.ts +6 -0
- package/build/transactions/types/GenericTransaction.js +6 -0
- package/build/transactions/types/InteractionTransaction.d.ts +15 -0
- package/build/transactions/types/InteractionTransaction.js +21 -0
- package/cjs/_version.d.ts +1 -1
- package/cjs/_version.js +1 -1
- package/cjs/block/interfaces/BlockWitness.d.ts +11 -0
- package/cjs/block/interfaces/BlockWitness.js +2 -0
- package/cjs/contracts/Contract.d.ts +3 -1
- package/cjs/contracts/Contract.js +18 -12
- package/cjs/contracts/interfaces/IContract.d.ts +3 -1
- package/cjs/generator/WrappedGenerationParameters.d.ts +9 -0
- package/cjs/generator/WrappedGenerationParameters.js +18 -0
- package/cjs/opnet.d.ts +6 -1
- package/cjs/opnet.js +6 -1
- package/cjs/providers/AbstractRpcProvider.d.ts +8 -0
- package/cjs/providers/AbstractRpcProvider.js +63 -0
- package/cjs/providers/interfaces/Generate.d.ts +19 -0
- package/cjs/providers/interfaces/Generate.js +7 -0
- package/cjs/providers/interfaces/ReorgInformation.d.ts +5 -0
- package/cjs/providers/interfaces/ReorgInformation.js +2 -0
- package/cjs/scripts/ITestContract.d.ts +2 -2
- package/cjs/scripts/ITestContract.js +2 -2
- package/cjs/scripts/testContract.js +1 -1
- package/cjs/scripts/testMethods.js +8 -15
- package/cjs/transactions/TransactionReceipt.d.ts +3 -3
- package/cjs/transactions/TransactionReceipt.js +35 -16
- package/cjs/transactions/interfaces/BroadcastedTransaction.d.ts +7 -0
- package/cjs/transactions/interfaces/BroadcastedTransaction.js +2 -0
- package/cjs/transactions/interfaces/ITransaction.d.ts +2 -3
- package/cjs/transactions/interfaces/ITransactionReceipt.d.ts +9 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AbstractRpcProvider.html +18 -18
- package/docs/classes/BaseContract.html +7 -7
- package/docs/classes/BitcoinAddress.html +2 -2
- package/docs/classes/BitcoinInterface.html +2 -2
- package/docs/classes/BitcoinUtils.html +2 -2
- package/docs/classes/Block.html +3 -3
- package/docs/classes/CallResult.html +2 -2
- package/docs/classes/ContractData.html +3 -2
- package/docs/classes/DeploymentTransaction.html +26 -22
- package/docs/classes/GenericTransaction.html +15 -13
- package/docs/classes/IBaseContract.html +7 -7
- package/docs/classes/InteractionTransaction.html +22 -20
- package/docs/classes/JSONRpcProvider.html +17 -17
- package/docs/classes/OPNetEvent.html +2 -2
- package/docs/classes/StoredValue.html +2 -2
- package/docs/classes/TransactionBase.html +15 -13
- package/docs/classes/TransactionInput.html +2 -2
- package/docs/classes/TransactionOutput.html +2 -2
- package/docs/classes/TransactionParser.html +2 -2
- package/docs/classes/TransactionReceipt.html +7 -7
- package/docs/classes/UTXO.html +2 -2
- package/docs/classes/WebSocketRpcProvider.html +17 -17
- package/docs/classes/WrapTransaction.html +229 -0
- package/docs/classes/WrappedGeneration.html +7 -7
- package/docs/enums/BitcoinAbiTypes.html +2 -2
- package/docs/enums/GenerateTarget.html +2 -2
- package/docs/enums/OPNetTransactionTypes.html +4 -2
- package/docs/functions/getContract.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/BaseContractProperties.html +2 -2
- package/docs/interfaces/BitcoinAbiValue.html +3 -3
- package/docs/interfaces/BitcoinInterfaceAbiBase.html +2 -2
- package/docs/interfaces/BroadcastedTransaction.html +6 -6
- package/docs/interfaces/ContractEvents.html +1 -1
- package/docs/interfaces/EventBaseData.html +2 -2
- package/docs/interfaces/FunctionBaseData.html +2 -2
- package/docs/interfaces/GenerationConstraints.html +7 -7
- package/docs/interfaces/IAccessList.html +1 -1
- package/docs/interfaces/IAccessListItem.html +1 -1
- package/docs/interfaces/IBlock.html +3 -3
- package/docs/interfaces/IBlockCommon.html +3 -3
- package/docs/interfaces/IBlockWitness.html +2 -2
- package/docs/interfaces/IBlockWitnessAPI.html +2 -2
- package/docs/interfaces/ICallRequestError.html +2 -2
- package/docs/interfaces/ICallResultData.html +2 -2
- package/docs/interfaces/ICommonTransaction.html +17 -15
- package/docs/interfaces/IContract.html +2 -2
- package/docs/interfaces/IDecodedEvent.html +2 -2
- package/docs/interfaces/IDeploymentTransaction.html +26 -22
- package/docs/interfaces/IGenericTransaction.html +14 -12
- package/docs/interfaces/IInteractionTransaction.html +22 -20
- package/docs/interfaces/IRawContract.html +3 -2
- package/docs/interfaces/IRawContractEvents.html +1 -1
- package/docs/interfaces/IStorageValue.html +2 -2
- package/docs/interfaces/ITransactionBase.html +14 -12
- package/docs/interfaces/ITransactionInput.html +2 -2
- package/docs/interfaces/ITransactionOutput.html +2 -2
- package/docs/interfaces/ITransactionReceipt.html +5 -5
- package/docs/interfaces/IUTXO.html +2 -2
- package/docs/interfaces/IWrapTransaction.html +228 -0
- package/docs/interfaces/NetEventDocument.html +5 -5
- package/docs/interfaces/ReorgInformation.html +2 -2
- package/docs/interfaces/WrappedGenerationParameters.html +6 -6
- package/docs/modules.html +3 -0
- package/docs/types/BaseContractProperty.html +1 -1
- package/docs/types/BitcoinAddressLike.html +1 -1
- package/docs/types/BitcoinInterfaceAbi.html +1 -1
- package/docs/types/BlockHeaderChecksumProof.html +1 -1
- package/docs/types/BlockWitnesses.html +1 -1
- package/docs/types/ContractDecodedObjectResult.html +1 -1
- package/docs/types/DecodedCallResult.html +1 -1
- package/docs/types/DecodedOutput.html +1 -1
- package/docs/types/GenerationParameters.html +1 -1
- package/docs/types/ICallResult.html +1 -1
- package/docs/types/ITransaction.html +2 -2
- package/docs/types/InteractionType.html +174 -0
- package/docs/types/PointerLike.html +1 -1
- package/docs/types/RawContractEvents.html +1 -1
- package/docs/types/UTXOs.html +1 -1
- package/docs/variables/version.html +1 -1
- package/package.json +6 -5
- package/src/_version.ts +1 -1
- package/src/contracts/ContractData.ts +11 -3
- package/src/contracts/interfaces/IRawContract.ts +7 -3
- package/src/interfaces/opnet/OPNetTransactionTypes.ts +7 -0
- package/src/opnet.ts +13 -6
- package/src/providers/AbstractRpcProvider.ts +1 -1
- package/src/scripts/testMethods.ts +54 -54
- package/src/scripts/testMethodsReg.ts +20 -0
- package/src/transactions/Transaction.ts +10 -3
- package/src/transactions/TransactionParser.ts +13 -10
- package/src/transactions/{DeploymentTransaction.ts → decoders/DeploymentTransaction.ts} +6 -3
- package/src/transactions/{GenericTransaction.ts → decoders/GenericTransaction.ts} +3 -3
- package/src/transactions/{InteractionTransaction.ts → decoders/InteractionTransaction.ts} +4 -4
- package/src/transactions/decoders/WrapTransaction.ts +69 -0
- package/src/transactions/interfaces/ITransaction.ts +16 -107
- package/src/transactions/interfaces/transactions/ICommonTransaction.ts +19 -0
- package/src/transactions/interfaces/transactions/IDeploymentTransaction.ts +50 -0
- package/src/transactions/interfaces/transactions/IInteractionTransaction.ts +50 -0
- package/src/transactions/interfaces/transactions/IWrapTransaction.ts +43 -0
- package/src/transactions/{TransactionReceipt.ts → metadata/TransactionReceipt.ts} +1 -1
- package/tsconfig.webpack.json +8 -0
- /package/src/transactions/{TransactionInput.ts → metadata/TransactionInput.ts} +0 -0
- /package/src/transactions/{TransactionOutput.ts → metadata/TransactionOutput.ts} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { InteractionType } from '../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
+
import { IInteractionTransaction } from '../interfaces/transactions/IInteractionTransaction.js';
|
|
5
|
+
import { TransactionBase } from '../Transaction.js';
|
|
6
|
+
export declare class InteractionTransaction extends TransactionBase<InteractionType> implements IInteractionTransaction {
|
|
7
|
+
readonly calldata: Buffer;
|
|
8
|
+
readonly senderPubKeyHash: Buffer;
|
|
9
|
+
readonly contractSecret: Buffer;
|
|
10
|
+
readonly interactionPubKey: Buffer;
|
|
11
|
+
readonly wasCompressed: boolean;
|
|
12
|
+
readonly from: string;
|
|
13
|
+
readonly contractAddress: string;
|
|
14
|
+
constructor(transaction: IInteractionTransaction);
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
import { TransactionBase } from '../Transaction.js';
|
|
3
|
+
export class InteractionTransaction extends TransactionBase {
|
|
4
|
+
calldata;
|
|
5
|
+
senderPubKeyHash;
|
|
6
|
+
contractSecret;
|
|
7
|
+
interactionPubKey;
|
|
8
|
+
wasCompressed;
|
|
9
|
+
from;
|
|
10
|
+
contractAddress;
|
|
11
|
+
constructor(transaction) {
|
|
12
|
+
super(transaction);
|
|
13
|
+
this.calldata = Buffer.from(transaction.calldata, 'base64');
|
|
14
|
+
this.senderPubKeyHash = Buffer.from(transaction.senderPubKeyHash, 'base64');
|
|
15
|
+
this.contractSecret = Buffer.from(transaction.contractSecret, 'base64');
|
|
16
|
+
this.interactionPubKey = Buffer.from(transaction.interactionPubKey, 'base64');
|
|
17
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
18
|
+
this.from = transaction.from;
|
|
19
|
+
this.contractAddress = transaction.contractAddress;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
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
|
+
export declare class InteractionTransaction extends TransactionBase<OPNetTransactionTypes.Interaction> implements IInteractionTransaction {
|
|
7
|
+
readonly calldata: Buffer;
|
|
8
|
+
readonly senderPubKeyHash: Buffer;
|
|
9
|
+
readonly contractSecret: Buffer;
|
|
10
|
+
readonly interactionPubKey: Buffer;
|
|
11
|
+
readonly wasCompressed: boolean;
|
|
12
|
+
readonly from: string;
|
|
13
|
+
readonly contractAddress: string;
|
|
14
|
+
constructor(transaction: IInteractionTransaction);
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
import { TransactionBase } from '../Transaction.js';
|
|
3
|
+
export class InteractionTransaction extends TransactionBase {
|
|
4
|
+
calldata;
|
|
5
|
+
senderPubKeyHash;
|
|
6
|
+
contractSecret;
|
|
7
|
+
interactionPubKey;
|
|
8
|
+
wasCompressed;
|
|
9
|
+
from;
|
|
10
|
+
contractAddress;
|
|
11
|
+
constructor(transaction) {
|
|
12
|
+
super(transaction);
|
|
13
|
+
this.calldata = Buffer.from(transaction.calldata, 'base64');
|
|
14
|
+
this.senderPubKeyHash = Buffer.from(transaction.senderPubKeyHash, 'base64');
|
|
15
|
+
this.contractSecret = Buffer.from(transaction.contractSecret, 'base64');
|
|
16
|
+
this.interactionPubKey = Buffer.from(transaction.interactionPubKey, 'base64');
|
|
17
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
18
|
+
this.from = transaction.from;
|
|
19
|
+
this.contractAddress = transaction.contractAddress;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EcKeyPair } from '@btc-vision/transaction';
|
|
2
|
+
import { Network } from 'bitcoinjs-lib';
|
|
3
|
+
import { IWrapTransaction } from '../interfaces/transactions/IWrapTransaction.js';
|
|
4
|
+
import { InteractionTransaction } from './InteractionTransaction.js';
|
|
5
|
+
export declare class WrapTransaction extends InteractionTransaction implements IWrapTransaction {
|
|
6
|
+
readonly penalized: boolean;
|
|
7
|
+
readonly wrappingFees: bigint | string;
|
|
8
|
+
readonly depositAmount: bigint | string;
|
|
9
|
+
readonly depositAddress: string;
|
|
10
|
+
readonly vault: string;
|
|
11
|
+
readonly pubKeys: string[];
|
|
12
|
+
readonly minimumSignatures: number;
|
|
13
|
+
constructor(transaction: IWrapTransaction);
|
|
14
|
+
parsedTrustedKeys(trustedKeys: string[], network: Network): EcKeyPair[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EcKeyPair } from '@btc-vision/transaction';
|
|
2
|
+
import { InteractionTransaction } from './InteractionTransaction.js';
|
|
3
|
+
export class WrapTransaction extends InteractionTransaction {
|
|
4
|
+
penalized;
|
|
5
|
+
wrappingFees;
|
|
6
|
+
depositAmount;
|
|
7
|
+
depositAddress;
|
|
8
|
+
vault;
|
|
9
|
+
pubKeys;
|
|
10
|
+
minimumSignatures;
|
|
11
|
+
constructor(transaction) {
|
|
12
|
+
super(transaction);
|
|
13
|
+
this.penalized = transaction.penalized;
|
|
14
|
+
this.wrappingFees = BigInt(transaction.wrappingFees || '0x00') || 0n;
|
|
15
|
+
this.depositAmount = BigInt(transaction.depositAmount || '0x00') || 0n;
|
|
16
|
+
this.depositAddress = transaction.depositAddress;
|
|
17
|
+
this.vault = transaction.vault;
|
|
18
|
+
this.pubKeys = transaction.pubKeys;
|
|
19
|
+
this.minimumSignatures = transaction.minimumSignatures;
|
|
20
|
+
}
|
|
21
|
+
parsedTrustedKeys(trustedKeys, network) {
|
|
22
|
+
if (!trustedKeys) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
return trustedKeys.map((key) => {
|
|
26
|
+
const buffer = Buffer.from(key, 'base64');
|
|
27
|
+
return EcKeyPair.fromPublicKey(buffer, network);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BigNumberish } from 'ethers';
|
|
3
3
|
import { OPNetTransactionTypes } from '../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
4
|
-
import { ITransactionInput, TransactionInput } from '../TransactionInput.js';
|
|
5
|
-
import { ITransactionOutput, TransactionOutput } from '../TransactionOutput.js';
|
|
6
|
-
import {
|
|
4
|
+
import { ITransactionInput, TransactionInput } from '../metadata/TransactionInput.js';
|
|
5
|
+
import { ITransactionOutput, TransactionOutput } from '../metadata/TransactionOutput.js';
|
|
6
|
+
import { ITransactionReceipt } from './ITransactionReceipt.js';
|
|
7
|
+
import { IDeploymentTransaction } from './transactions/IDeploymentTransaction.js';
|
|
8
|
+
import { IInteractionTransaction } from './transactions/IInteractionTransaction.js';
|
|
9
|
+
import { IWrapTransaction } from './transactions/IWrapTransaction.js';
|
|
7
10
|
export interface ITransactionBase<T extends OPNetTransactionTypes> extends ITransactionReceipt {
|
|
8
11
|
readonly id: string;
|
|
9
12
|
readonly hash: string;
|
|
@@ -13,30 +16,8 @@ export interface ITransactionBase<T extends OPNetTransactionTypes> extends ITran
|
|
|
13
16
|
readonly inputs: ITransactionInput[] | TransactionInput[];
|
|
14
17
|
readonly outputs: ITransactionOutput[] | TransactionOutput[];
|
|
15
18
|
readonly OPNetType: T;
|
|
19
|
+
readonly gasUsed: string | bigint;
|
|
16
20
|
}
|
|
17
21
|
export interface IGenericTransaction extends ITransactionBase<OPNetTransactionTypes.Generic> {
|
|
18
22
|
}
|
|
19
|
-
export
|
|
20
|
-
readonly from: string;
|
|
21
|
-
readonly contractAddress: string;
|
|
22
|
-
readonly wasCompressed: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface IDeploymentTransaction extends ICommonTransaction<OPNetTransactionTypes.Deployment> {
|
|
25
|
-
readonly virtualAddress: string;
|
|
26
|
-
readonly bytecode: Buffer | string;
|
|
27
|
-
readonly deployerPubKey: Buffer | string;
|
|
28
|
-
readonly deployerAddress: string;
|
|
29
|
-
readonly contractSeed: Buffer | string;
|
|
30
|
-
readonly contractSaltHash: Buffer | string;
|
|
31
|
-
}
|
|
32
|
-
export interface IInteractionTransaction extends ICommonTransaction<OPNetTransactionTypes.Interaction> {
|
|
33
|
-
readonly calldata: string | Buffer;
|
|
34
|
-
readonly senderPubKeyHash: string | Buffer;
|
|
35
|
-
readonly contractSecret: string | Buffer;
|
|
36
|
-
readonly interactionPubKey: string | Buffer;
|
|
37
|
-
readonly from: string;
|
|
38
|
-
readonly events: ContractEvents;
|
|
39
|
-
readonly receipt?: string | Buffer;
|
|
40
|
-
readonly receiptProofs?: string[];
|
|
41
|
-
}
|
|
42
|
-
export type ITransaction = IDeploymentTransaction | IInteractionTransaction | IGenericTransaction;
|
|
23
|
+
export type ITransaction = IDeploymentTransaction | IInteractionTransaction | IGenericTransaction | IWrapTransaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OPNetTransactionTypes } from '../../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
+
import { ITransactionBase } from '../ITransaction.js';
|
|
3
|
+
export interface ICommonTransaction<T extends OPNetTransactionTypes> extends ITransactionBase<T> {
|
|
4
|
+
readonly from: string;
|
|
5
|
+
readonly contractAddress: string;
|
|
6
|
+
readonly wasCompressed: boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OPNetTransactionTypes } from '../../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
3
|
+
import { ICommonTransaction } from './ICommonTransaction.js';
|
|
4
|
+
export interface IDeploymentTransaction extends ICommonTransaction<OPNetTransactionTypes.Deployment> {
|
|
5
|
+
readonly contractAddress: string;
|
|
6
|
+
readonly p2trAddress: string;
|
|
7
|
+
readonly virtualAddress: string;
|
|
8
|
+
readonly bytecode: Buffer | string;
|
|
9
|
+
readonly deployerPubKey: Buffer | string;
|
|
10
|
+
readonly deployerAddress: string;
|
|
11
|
+
readonly contractSeed: Buffer | string;
|
|
12
|
+
readonly contractSaltHash: Buffer | string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { InteractionType } from '../../../interfaces/opnet/OPNetTransactionTypes.js';
|
|
3
|
+
import { ContractEvents } from '../ITransactionReceipt.js';
|
|
4
|
+
import { ICommonTransaction } from './ICommonTransaction.js';
|
|
5
|
+
export interface IInteractionTransaction extends ICommonTransaction<InteractionType> {
|
|
6
|
+
readonly calldata: string | Buffer;
|
|
7
|
+
readonly senderPubKeyHash: string | Buffer;
|
|
8
|
+
readonly contractSecret: string | Buffer;
|
|
9
|
+
readonly interactionPubKey: string | Buffer;
|
|
10
|
+
readonly from: string;
|
|
11
|
+
readonly events: ContractEvents;
|
|
12
|
+
readonly receipt?: string | Buffer;
|
|
13
|
+
readonly receiptProofs?: string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IInteractionTransaction } from './IInteractionTransaction.js';
|
|
2
|
+
export interface IWrapTransaction extends IInteractionTransaction {
|
|
3
|
+
readonly penalized: boolean;
|
|
4
|
+
readonly wrappingFees: bigint | string;
|
|
5
|
+
readonly depositAmount: bigint | string;
|
|
6
|
+
readonly depositAddress: string;
|
|
7
|
+
readonly vault: string;
|
|
8
|
+
readonly pubKeys: string[];
|
|
9
|
+
readonly minimumSignatures: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ScriptSig } from '@btc-vision/bsi-bitcoin-rpc';
|
|
2
|
+
export interface ITransactionInput {
|
|
3
|
+
readonly originalTransactionId: string | undefined;
|
|
4
|
+
readonly outputTransactionIndex: number | undefined;
|
|
5
|
+
readonly scriptSignature: ScriptSig | undefined;
|
|
6
|
+
readonly sequenceId: number;
|
|
7
|
+
readonly transactionInWitness?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class TransactionInput implements ITransactionInput {
|
|
10
|
+
readonly originalTransactionId: string | undefined;
|
|
11
|
+
readonly outputTransactionIndex: number | undefined;
|
|
12
|
+
readonly scriptSignature: ScriptSig | undefined;
|
|
13
|
+
readonly sequenceId: number;
|
|
14
|
+
readonly transactionInWitness: string[];
|
|
15
|
+
constructor(data: ITransactionInput);
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class TransactionInput {
|
|
2
|
+
originalTransactionId;
|
|
3
|
+
outputTransactionIndex;
|
|
4
|
+
scriptSignature;
|
|
5
|
+
sequenceId;
|
|
6
|
+
transactionInWitness = [];
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.originalTransactionId = data.originalTransactionId;
|
|
9
|
+
this.outputTransactionIndex = data.outputTransactionIndex;
|
|
10
|
+
this.scriptSignature = data.scriptSignature;
|
|
11
|
+
this.sequenceId = data.sequenceId;
|
|
12
|
+
this.transactionInWitness = data.transactionInWitness || [];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ScriptPubKey } from '@btc-vision/bsi-bitcoin-rpc';
|
|
3
|
+
export interface ITransactionOutput {
|
|
4
|
+
readonly index: number;
|
|
5
|
+
readonly scriptPubKey: {
|
|
6
|
+
hex: string;
|
|
7
|
+
addresses?: string[];
|
|
8
|
+
address?: string;
|
|
9
|
+
};
|
|
10
|
+
readonly value: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class TransactionOutput {
|
|
13
|
+
readonly value: bigint;
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly scriptPubKey: ScriptPubKey;
|
|
16
|
+
readonly script: Array<number | Buffer> | null;
|
|
17
|
+
constructor(data: ITransactionOutput);
|
|
18
|
+
private convertValue;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { script } from 'bitcoinjs-lib';
|
|
2
|
+
export class TransactionOutput {
|
|
3
|
+
value;
|
|
4
|
+
index;
|
|
5
|
+
scriptPubKey;
|
|
6
|
+
script;
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.value = this.convertValue(data.value);
|
|
9
|
+
this.index = data.index;
|
|
10
|
+
this.scriptPubKey = data.scriptPubKey;
|
|
11
|
+
this.script = script.decompile(Buffer.from(this.scriptPubKey.hex, 'hex'));
|
|
12
|
+
}
|
|
13
|
+
convertValue(value) {
|
|
14
|
+
return BigInt(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ContractEvents, ITransactionReceipt } from '../interfaces/ITransactionReceipt.js';
|
|
3
|
+
export declare class TransactionReceipt implements ITransactionReceipt {
|
|
4
|
+
readonly receipt?: Buffer;
|
|
5
|
+
readonly receiptProofs: string[];
|
|
6
|
+
readonly events: ContractEvents;
|
|
7
|
+
readonly revert?: Buffer;
|
|
8
|
+
constructor(receipt: ITransactionReceipt);
|
|
9
|
+
private parseEvents;
|
|
10
|
+
private decodeEvent;
|
|
11
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
|
+
export class TransactionReceipt {
|
|
3
|
+
receipt;
|
|
4
|
+
receiptProofs;
|
|
5
|
+
events;
|
|
6
|
+
revert;
|
|
7
|
+
constructor(receipt) {
|
|
8
|
+
this.receipt = receipt.receipt
|
|
9
|
+
? Buffer.from(receipt.receipt, 'base64')
|
|
10
|
+
: undefined;
|
|
11
|
+
this.receiptProofs = receipt.receiptProofs || [];
|
|
12
|
+
this.events = receipt.events ? this.parseEvents(receipt.events) : {};
|
|
13
|
+
this.revert = receipt.revert ? Buffer.from(receipt.revert, 'base64') : undefined;
|
|
14
|
+
}
|
|
15
|
+
parseEvents(events) {
|
|
16
|
+
const parsedEvents = {};
|
|
17
|
+
if (!Array.isArray(events)) {
|
|
18
|
+
for (const [key, value] of Object.entries(events)) {
|
|
19
|
+
parsedEvents[key] = value.map((event) => {
|
|
20
|
+
return this.decodeEvent(event);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const event of events) {
|
|
26
|
+
const parsedEvent = this.decodeEvent(event);
|
|
27
|
+
const contractAddress = event.contractAddress;
|
|
28
|
+
if (!parsedEvents[contractAddress]) {
|
|
29
|
+
parsedEvents[contractAddress] = [];
|
|
30
|
+
}
|
|
31
|
+
parsedEvents[contractAddress].push(parsedEvent);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return parsedEvents;
|
|
35
|
+
}
|
|
36
|
+
decodeEvent(event) {
|
|
37
|
+
let eventData;
|
|
38
|
+
let eventDataSelector;
|
|
39
|
+
if (typeof event.eventData === 'string') {
|
|
40
|
+
eventData = new Uint8Array(Buffer.from(event.eventData, 'base64'));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
eventData = event.eventData;
|
|
44
|
+
}
|
|
45
|
+
if (typeof event.eventDataSelector === 'string') {
|
|
46
|
+
eventDataSelector = BigInt(event.eventDataSelector);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
eventDataSelector = event.eventDataSelector;
|
|
50
|
+
}
|
|
51
|
+
return new NetEvent(event.eventType, eventDataSelector, eventData);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
3
|
+
import { IDeploymentTransaction } from './interfaces/ITransaction.js';
|
|
4
|
+
import { TransactionBase } from './Transaction.js';
|
|
5
|
+
export declare class DeploymentTransaction extends TransactionBase<OPNetTransactionTypes.Deployment> implements IDeploymentTransaction {
|
|
6
|
+
readonly contractAddress: string;
|
|
7
|
+
readonly virtualAddress: string;
|
|
8
|
+
readonly bytecode: Buffer;
|
|
9
|
+
readonly wasCompressed: boolean;
|
|
10
|
+
readonly deployerPubKey: Buffer;
|
|
11
|
+
readonly deployerAddress: string;
|
|
12
|
+
readonly contractSeed: Buffer;
|
|
13
|
+
readonly contractSaltHash: Buffer;
|
|
14
|
+
readonly from: string;
|
|
15
|
+
constructor(transaction: IDeploymentTransaction);
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TransactionBase } from './Transaction.js';
|
|
2
|
+
export class DeploymentTransaction extends TransactionBase {
|
|
3
|
+
contractAddress;
|
|
4
|
+
virtualAddress;
|
|
5
|
+
bytecode;
|
|
6
|
+
wasCompressed;
|
|
7
|
+
deployerPubKey;
|
|
8
|
+
deployerAddress;
|
|
9
|
+
contractSeed;
|
|
10
|
+
contractSaltHash;
|
|
11
|
+
from;
|
|
12
|
+
constructor(transaction) {
|
|
13
|
+
super(transaction);
|
|
14
|
+
this.from = transaction.from;
|
|
15
|
+
this.contractAddress = transaction.contractAddress;
|
|
16
|
+
this.virtualAddress = transaction.virtualAddress;
|
|
17
|
+
this.bytecode = Buffer.from(transaction.bytecode, 'base64');
|
|
18
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
19
|
+
this.deployerPubKey = Buffer.from(transaction.deployerPubKey, 'base64');
|
|
20
|
+
this.deployerAddress = transaction.deployerAddress;
|
|
21
|
+
this.contractSeed = Buffer.from(transaction.contractSeed, 'base64');
|
|
22
|
+
this.contractSaltHash = Buffer.from(transaction.contractSaltHash, 'base64');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes.js';
|
|
2
|
+
import { IGenericTransaction } from './interfaces/ITransaction.js';
|
|
3
|
+
import { TransactionBase } from './Transaction.js';
|
|
4
|
+
export declare class GenericTransaction extends TransactionBase<OPNetTransactionTypes.Generic> implements IGenericTransaction {
|
|
5
|
+
constructor(transaction: IGenericTransaction);
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
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
|
+
export declare class InteractionTransaction extends TransactionBase<OPNetTransactionTypes.Interaction> implements IInteractionTransaction {
|
|
7
|
+
readonly calldata: Buffer;
|
|
8
|
+
readonly senderPubKeyHash: Buffer;
|
|
9
|
+
readonly contractSecret: Buffer;
|
|
10
|
+
readonly interactionPubKey: Buffer;
|
|
11
|
+
readonly wasCompressed: boolean;
|
|
12
|
+
readonly from: string;
|
|
13
|
+
readonly contractAddress: string;
|
|
14
|
+
constructor(transaction: IInteractionTransaction);
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
import { TransactionBase } from './Transaction.js';
|
|
3
|
+
export class InteractionTransaction extends TransactionBase {
|
|
4
|
+
calldata;
|
|
5
|
+
senderPubKeyHash;
|
|
6
|
+
contractSecret;
|
|
7
|
+
interactionPubKey;
|
|
8
|
+
wasCompressed;
|
|
9
|
+
from;
|
|
10
|
+
contractAddress;
|
|
11
|
+
constructor(transaction) {
|
|
12
|
+
super(transaction);
|
|
13
|
+
this.calldata = Buffer.from(transaction.calldata, 'base64');
|
|
14
|
+
this.senderPubKeyHash = Buffer.from(transaction.senderPubKeyHash, 'base64');
|
|
15
|
+
this.contractSecret = Buffer.from(transaction.contractSecret, 'base64');
|
|
16
|
+
this.interactionPubKey = Buffer.from(transaction.interactionPubKey, 'base64');
|
|
17
|
+
this.wasCompressed = transaction.wasCompressed;
|
|
18
|
+
this.from = transaction.from;
|
|
19
|
+
this.contractAddress = transaction.contractAddress;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/cjs/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.21";
|
package/cjs/_version.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IBlockWitnessAPI {
|
|
2
|
+
readonly trusted: boolean;
|
|
3
|
+
readonly signature: string;
|
|
4
|
+
readonly identity?: string;
|
|
5
|
+
readonly opnetPubKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IBlockWitness {
|
|
8
|
+
blockNumber: bigint | string;
|
|
9
|
+
readonly witnesses: IBlockWitnessAPI[];
|
|
10
|
+
}
|
|
11
|
+
export type BlockWitnesses = IBlockWitness[];
|
|
@@ -5,6 +5,7 @@ import { BaseContractProperties } from '../abi/interfaces/BaseContractProperties
|
|
|
5
5
|
import { BitcoinInterfaceAbi } from '../abi/interfaces/BitcoinInterfaceAbi.js';
|
|
6
6
|
import { BitcoinAddressLike, DecodedCallResult } from '../common/CommonTypes.js';
|
|
7
7
|
import { AbstractRpcProvider } from '../providers/AbstractRpcProvider.js';
|
|
8
|
+
import { ContractEvents } from '../transactions/interfaces/ITransactionReceipt.js';
|
|
8
9
|
import { IContract } from './interfaces/IContract.js';
|
|
9
10
|
import { OPNetEvent } from './OPNetEvent.js';
|
|
10
11
|
declare const internal: unique symbol;
|
|
@@ -22,7 +23,8 @@ export declare abstract class IBaseContract<T extends BaseContractProperties> im
|
|
|
22
23
|
readonly [internal]: keyof T | undefined;
|
|
23
24
|
private events;
|
|
24
25
|
protected constructor(address: BitcoinAddressLike, abi: BitcoinInterface | BitcoinInterfaceAbi, provider: AbstractRpcProvider);
|
|
25
|
-
decodeEvents(events: NetEvent[]): OPNetEvent[];
|
|
26
|
+
decodeEvents(events: NetEvent[] | ContractEvents): OPNetEvent[];
|
|
27
|
+
decodeEvent(event: NetEvent): OPNetEvent;
|
|
26
28
|
protected getFunction(name: symbol): BaseContractProperty | undefined | string | number | symbol;
|
|
27
29
|
private defineInternalFunctions;
|
|
28
30
|
private encodeFunctionData;
|
|
@@ -22,21 +22,28 @@ class IBaseContract {
|
|
|
22
22
|
}
|
|
23
23
|
decodeEvents(events) {
|
|
24
24
|
const decodedEvents = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!
|
|
28
|
-
|
|
29
|
-
decodedEvents.push(decodedEvent);
|
|
30
|
-
continue;
|
|
25
|
+
if (!Array.isArray(events)) {
|
|
26
|
+
events = events[this.address.toString()];
|
|
27
|
+
if (!events) {
|
|
28
|
+
return [];
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
decodedEvent.setDecoded(out);
|
|
36
|
-
decodedEvents.push(decodedEvent);
|
|
30
|
+
}
|
|
31
|
+
for (let event of events) {
|
|
32
|
+
decodedEvents.push(this.decodeEvent(event));
|
|
37
33
|
}
|
|
38
34
|
return decodedEvents;
|
|
39
35
|
}
|
|
36
|
+
decodeEvent(event) {
|
|
37
|
+
const eventData = this.events.get(event.eventType);
|
|
38
|
+
if (!eventData || eventData.values.length === 0) {
|
|
39
|
+
return new OPNetEvent_js_1.OPNetEvent(event.eventType, event.eventDataSelector, event.eventData);
|
|
40
|
+
}
|
|
41
|
+
const binaryReader = new bsi_binary_1.BinaryReader(event.eventData);
|
|
42
|
+
const out = this.decodeOutput(eventData.values, binaryReader);
|
|
43
|
+
const decodedEvent = new OPNetEvent_js_1.OPNetEvent(event.eventType, event.eventDataSelector, event.eventData);
|
|
44
|
+
decodedEvent.setDecoded(out);
|
|
45
|
+
return decodedEvent;
|
|
46
|
+
}
|
|
40
47
|
getFunction(name) {
|
|
41
48
|
const key = name;
|
|
42
49
|
return this[key];
|
|
@@ -182,7 +189,6 @@ class IBaseContract {
|
|
|
182
189
|
return async (...args) => {
|
|
183
190
|
const data = this.encodeFunctionData(element, args);
|
|
184
191
|
const buffer = Buffer.from(data.getBuffer());
|
|
185
|
-
console.log(buffer.toString('hex'));
|
|
186
192
|
const response = await this.provider.call(this.address, buffer);
|
|
187
193
|
if ('error' in response) {
|
|
188
194
|
return response;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { NetEvent } from '@btc-vision/bsi-binary';
|
|
2
2
|
import { BitcoinAddressLike } from '../../common/CommonTypes.js';
|
|
3
|
+
import { ContractEvents } from '../../transactions/interfaces/ITransactionReceipt.js';
|
|
3
4
|
import { OPNetEvent } from '../OPNetEvent.js';
|
|
4
5
|
export interface IContract {
|
|
5
6
|
readonly address: BitcoinAddressLike;
|
|
6
|
-
decodeEvents(events: NetEvent[]): OPNetEvent[];
|
|
7
|
+
decodeEvents(events: NetEvent[] | ContractEvents): OPNetEvent[];
|
|
8
|
+
decodeEvent(event: NetEvent): OPNetEvent;
|
|
7
9
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GenerationConstraints, WrappedGenerationParameters } from '../providers/interfaces/Generate.js';
|
|
2
|
+
export declare class WrappedGeneration implements WrappedGenerationParameters {
|
|
3
|
+
readonly constraints: GenerationConstraints;
|
|
4
|
+
readonly entities: string[];
|
|
5
|
+
readonly keys: string[];
|
|
6
|
+
readonly signature: string;
|
|
7
|
+
readonly vault: string;
|
|
8
|
+
constructor(params: WrappedGenerationParameters);
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WrappedGeneration = void 0;
|
|
4
|
+
class WrappedGeneration {
|
|
5
|
+
constraints;
|
|
6
|
+
entities;
|
|
7
|
+
keys;
|
|
8
|
+
signature;
|
|
9
|
+
vault;
|
|
10
|
+
constructor(params) {
|
|
11
|
+
this.constraints = params.constraints;
|
|
12
|
+
this.entities = params.entities;
|
|
13
|
+
this.keys = params.keys;
|
|
14
|
+
this.signature = params.signature;
|
|
15
|
+
this.vault = params.vault;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.WrappedGeneration = WrappedGeneration;
|