@btc-vision/transaction 1.0.92 → 1.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/_version.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/transaction/browser/Web3Provider.d.ts +8 -1
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +1 -0
- package/browser/transaction/browser/types/Unisat.d.ts +4 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/generators/builders/DeploymentGeneratorV2.d.ts +13 -0
- package/build/generators/builders/DeploymentGeneratorV2.js +57 -0
- package/build/transaction/browser/Web3Provider.d.ts +8 -1
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +1 -0
- package/build/transaction/browser/extensions/UnisatSigner.js +1 -1
- package/build/transaction/browser/types/Unisat.d.ts +4 -1
- package/build/transaction/browser/types/Unisat.js +4 -1
- package/build/transaction/builders/DeploymentTransactionV2.d.ts +36 -0
- package/build/transaction/builders/DeploymentTransactionV2.js +192 -0
- package/package.json +3 -3
- package/src/_version.ts +1 -1
- package/src/generators/Generator.ts +75 -75
- package/src/transaction/TransactionFactory.ts +544 -544
- package/src/transaction/browser/Web3Provider.ts +17 -2
- package/src/transaction/browser/extensions/UnisatSigner.ts +2 -1
- package/src/transaction/browser/types/Unisat.ts +100 -97
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IDeploymentParameters,
|
|
3
|
+
IInteractionParameters,
|
|
4
|
+
IUnwrapParameters,
|
|
5
|
+
IWrapParameters,
|
|
6
|
+
} from '../interfaces/ITransactionParameters.js';
|
|
2
7
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
8
|
+
import { DeploymentResult, UnwrapResult, WrapResult } from '../TransactionFactory';
|
|
3
9
|
|
|
4
|
-
export type InteractionParametersWithoutSigner = Omit<IInteractionParameters, 'signer'>;
|
|
10
|
+
export type InteractionParametersWithoutSigner = Omit<IInteractionParameters, 'signer'>;
|
|
11
|
+
export type IWrapParametersWithoutSigner = Omit<IWrapParameters, 'signer'>;
|
|
12
|
+
export type IUnwrapParametersSigner = Omit<IUnwrapParameters, 'signer'>;
|
|
13
|
+
export type IDeploymentParametersWithoutSigner = Omit<IDeploymentParameters, 'signer' | 'network'>;
|
|
5
14
|
|
|
6
15
|
export interface BroadcastTransactionOptions {
|
|
7
16
|
raw: string;
|
|
@@ -42,5 +51,11 @@ export interface Web3Provider {
|
|
|
42
51
|
interactionParameters: InteractionParametersWithoutSigner,
|
|
43
52
|
): Promise<[BroadcastedTransaction, BroadcastedTransaction, UTXO[]]>;
|
|
44
53
|
|
|
54
|
+
deployContract(params: IDeploymentParametersWithoutSigner): Promise<DeploymentResult>;
|
|
55
|
+
|
|
45
56
|
broadcast(transactions: BroadcastTransactionOptions[]): Promise<BroadcastedTransaction[]>;
|
|
57
|
+
|
|
58
|
+
wrap(wrapParameters: IWrapParametersWithoutSigner): Promise<WrapResult>;
|
|
59
|
+
|
|
60
|
+
unwrap(unwrapParameters: IUnwrapParametersSigner): Promise<UnwrapResult>;
|
|
46
61
|
}
|
|
@@ -9,6 +9,7 @@ import { TapScriptSig } from 'bip174/src/lib/interfaces.js';
|
|
|
9
9
|
declare global {
|
|
10
10
|
interface Window {
|
|
11
11
|
unisat?: Unisat;
|
|
12
|
+
opnet?: Unisat;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -98,7 +99,7 @@ export class UnisatSigner extends CustomKeypair {
|
|
|
98
99
|
this._network = networks.regtest;
|
|
99
100
|
break;
|
|
100
101
|
default:
|
|
101
|
-
throw new Error(
|
|
102
|
+
throw new Error(`Invalid network: ${network}`);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
const publicKey = await this.unisat.getPublicKey();
|
|
@@ -1,97 +1,100 @@
|
|
|
1
|
-
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
-
import { Web3Provider } from '../Web3Provider.js';
|
|
3
|
-
|
|
4
|
-
export enum UnisatNetwork {
|
|
5
|
-
testnet = 'testnet',
|
|
6
|
-
mainnet = 'livenet',
|
|
7
|
-
regtest = 'regtest',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export enum UnisatChainType {
|
|
11
|
-
BITCOIN_MAINNET = 'BITCOIN_MAINNET',
|
|
12
|
-
BITCOIN_TESTNET = 'BITCOIN_TESTNET',
|
|
13
|
-
|
|
14
|
-
BITCOIN_REGTEST = 'BITCOIN_REGTEST',
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { Web3Provider } from '../Web3Provider.js';
|
|
3
|
+
|
|
4
|
+
export enum UnisatNetwork {
|
|
5
|
+
testnet = 'testnet',
|
|
6
|
+
mainnet = 'livenet',
|
|
7
|
+
regtest = 'regtest',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum UnisatChainType {
|
|
11
|
+
BITCOIN_MAINNET = 'BITCOIN_MAINNET',
|
|
12
|
+
BITCOIN_TESTNET = 'BITCOIN_TESTNET',
|
|
13
|
+
BITCOIN_TESTNET4 = 'BITCOIN_TESTNET4',
|
|
14
|
+
BITCOIN_REGTEST = 'BITCOIN_REGTEST',
|
|
15
|
+
BITCOIN_SIGNET = 'BITCOIN_SIGNET',
|
|
16
|
+
FRACTAL_BITCOIN_MAINNET = 'FRACTAL_BITCOIN_MAINNET',
|
|
17
|
+
FRACTAL_BITCOIN_TESTNET = 'FRACTAL_BITCOIN_TESTNET',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface UnisatChainInfo {
|
|
21
|
+
readonly enum: UnisatChainType;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly network: UnisatNetwork;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Balance {
|
|
27
|
+
readonly confirmed: number;
|
|
28
|
+
readonly unconfirmed: number;
|
|
29
|
+
readonly total: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export enum MessageType {
|
|
33
|
+
ecdsa = 'ecdsa',
|
|
34
|
+
bip322 = 'bip322-simple',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ToSignInputBase {
|
|
38
|
+
readonly index: number;
|
|
39
|
+
readonly sighashTypes?: number[];
|
|
40
|
+
readonly disableTweakSigner?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ToSignInputPublicKey extends ToSignInputBase {
|
|
44
|
+
readonly publicKey: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ToSignInputAddress extends ToSignInputBase {
|
|
48
|
+
readonly address: Address;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type ToSignInput = ToSignInputPublicKey | ToSignInputAddress;
|
|
52
|
+
|
|
53
|
+
export interface PsbtSignatureOptions {
|
|
54
|
+
readonly autoFinalized?: boolean;
|
|
55
|
+
readonly toSignInputs?: ToSignInput[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface Unisat {
|
|
59
|
+
web3?: Web3Provider;
|
|
60
|
+
|
|
61
|
+
sendBitcoin(
|
|
62
|
+
toAddress: Address,
|
|
63
|
+
satoshis: number,
|
|
64
|
+
options: { feeRate: number; memo?: string; memos?: string[] },
|
|
65
|
+
): Promise<string>;
|
|
66
|
+
|
|
67
|
+
requestAccounts(): Promise<string[]>;
|
|
68
|
+
|
|
69
|
+
getNetwork(): Promise<UnisatNetwork>;
|
|
70
|
+
|
|
71
|
+
getChain(): Promise<UnisatChainType>;
|
|
72
|
+
|
|
73
|
+
getAccounts(): Promise<string[]>;
|
|
74
|
+
|
|
75
|
+
switchNetwork(network: UnisatNetwork): Promise<void>;
|
|
76
|
+
|
|
77
|
+
getPublicKey(): Promise<string>;
|
|
78
|
+
|
|
79
|
+
getBalance(): Promise<Balance>;
|
|
80
|
+
|
|
81
|
+
signMessage(message: string, type?: MessageType): Promise<string>;
|
|
82
|
+
|
|
83
|
+
pushTx(options: { rawtx: string }): Promise<string>;
|
|
84
|
+
|
|
85
|
+
signPsbt(psbtHex: string, psbtOptions: PsbtSignatureOptions): Promise<string>;
|
|
86
|
+
|
|
87
|
+
signPsbts(psbtHex: string[], psbtOptions: PsbtSignatureOptions): Promise<string[]>;
|
|
88
|
+
|
|
89
|
+
pushPsbt(psbtHex: string): Promise<string>;
|
|
90
|
+
|
|
91
|
+
on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
92
|
+
|
|
93
|
+
on(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
|
|
94
|
+
|
|
95
|
+
on(event: 'chainChanged', listener: (network: UnisatNetwork) => void): void;
|
|
96
|
+
|
|
97
|
+
removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
98
|
+
|
|
99
|
+
removeListener(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
|
|
100
|
+
}
|