@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.
@@ -1,7 +1,16 @@
1
- import { IInteractionParameters } from '../interfaces/ITransactionParameters.js';
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'>; //| 'utxos'
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('Invalid network');
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
- FRACTAL_BITCOIN_MAINNET = 'FRACTAL_BITCOIN_MAINNET',
14
- BITCOIN_REGTEST = 'BITCOIN_REGTEST',
15
- }
16
-
17
- export interface UnisatChainInfo {
18
- readonly enum: UnisatChainType;
19
- readonly name: string;
20
- readonly network: UnisatNetwork;
21
- }
22
-
23
- export interface Balance {
24
- readonly confirmed: number;
25
- readonly unconfirmed: number;
26
- readonly total: number;
27
- }
28
-
29
- export enum MessageType {
30
- ecdsa = 'ecdsa',
31
- bip322 = 'bip322-simple',
32
- }
33
-
34
- interface ToSignInputBase {
35
- readonly index: number;
36
- readonly sighashTypes?: number[];
37
- readonly disableTweakSigner?: boolean;
38
- }
39
-
40
- export interface ToSignInputPublicKey extends ToSignInputBase {
41
- readonly publicKey: string;
42
- }
43
-
44
- export interface ToSignInputAddress extends ToSignInputBase {
45
- readonly address: Address;
46
- }
47
-
48
- export type ToSignInput = ToSignInputPublicKey | ToSignInputAddress;
49
-
50
- export interface PsbtSignatureOptions {
51
- readonly autoFinalized?: boolean;
52
- readonly toSignInputs?: ToSignInput[];
53
- }
54
-
55
- export interface Unisat {
56
- web3?: Web3Provider;
57
-
58
- sendBitcoin(
59
- toAddress: Address,
60
- satoshis: number,
61
- options: { feeRate: number; memo?: string; memos?: string[] },
62
- ): Promise<string>;
63
-
64
- requestAccounts(): Promise<string[]>;
65
-
66
- getNetwork(): Promise<UnisatNetwork>;
67
-
68
- getChain(): Promise<UnisatChainType>;
69
-
70
- getAccounts(): Promise<string[]>;
71
-
72
- switchNetwork(network: UnisatNetwork): Promise<void>;
73
-
74
- getPublicKey(): Promise<string>;
75
-
76
- getBalance(): Promise<Balance>;
77
-
78
- signMessage(message: string, type?: MessageType): Promise<string>;
79
-
80
- pushTx(options: { rawtx: string }): Promise<string>;
81
-
82
- signPsbt(psbtHex: string, psbtOptions: PsbtSignatureOptions): Promise<string>;
83
-
84
- signPsbts(psbtHex: string[], psbtOptions: PsbtSignatureOptions): Promise<string[]>;
85
-
86
- pushPsbt(psbtHex: string): Promise<string>;
87
-
88
- on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
89
-
90
- on(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
91
-
92
- on(event: 'chainChanged', listener: (network: UnisatNetwork) => void): void;
93
-
94
- removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
95
-
96
- removeListener(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
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
+ }