@btc-vision/transaction 1.2.9 → 1.2.11

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.
@@ -4,8 +4,8 @@ export * from './generators/builders/CalldataGenerator.js';
4
4
  export * from './generators/builders/CustomGenerator.js';
5
5
  export * from './generators/builders/DeploymentGenerator.js';
6
6
  export * from './generators/builders/LegacyCalldataGenerator.js';
7
- export * from './generators/builders/MultiSignGenerator.js';
8
7
  export * from './generators/builders/MineableReward.js';
8
+ export * from './generators/builders/MultiSignGenerator.js';
9
9
  export * from './generators/Features.js';
10
10
  export * from './generators/Generator.js';
11
11
  export * from './transaction/mineable/ChallengeGenerator.js';
@@ -23,6 +23,7 @@ export * from './transaction/enums/TransactionType.js';
23
23
  export * from './transaction/interfaces/ITransactionParameters.js';
24
24
  export * from './transaction/interfaces/Tap.js';
25
25
  export * from './transaction/TransactionFactory.js';
26
+ export * from './transaction/builders/ChallengeSolutionTransaction.js';
26
27
  export * from './transaction/builders/CustomScriptTransaction.js';
27
28
  export * from './transaction/builders/DeploymentTransaction.js';
28
29
  export * from './transaction/builders/FundingTransaction.js';
@@ -30,7 +31,6 @@ export * from './transaction/builders/InteractionTransaction.js';
30
31
  export * from './transaction/builders/MultiSignTransaction.js';
31
32
  export * from './transaction/builders/SharedInteractionTransaction.js';
32
33
  export * from './transaction/builders/TransactionBuilder.js';
33
- export * from './transaction/builders/ChallengeSolutionTransaction.js';
34
34
  export * from './utils/BitcoinUtils.js';
35
35
  export * from './utils/lengths.js';
36
36
  export * from './utxo/interfaces/IUTXO.js';
@@ -59,8 +59,7 @@ export * from './transaction/browser/extensions/UnisatSigner.js';
59
59
  export * from './transaction/browser/extensions/XverseSigner.js';
60
60
  export * from './transaction/browser/types/Unisat.js';
61
61
  export * from './transaction/browser/types/Xverse.js';
62
- export * from './transaction/browser/WalletConnection.js';
63
62
  export * from './metadata/tokens.js';
64
63
  export * from './transaction/browser/Web3Provider.js';
65
- export * from './transaction/ContractAddress.js';
66
64
  export * from './keypair/Secp256k1PointDeriver.js';
65
+ export * from './transaction/ContractAddress.js';
@@ -1 +1 @@
1
- export declare const version = "1.2.9";
1
+ export declare const version = "1.2.11";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.2.9';
1
+ export const version = '1.2.11';
@@ -5,6 +5,7 @@ export declare enum ABIDataTypes {
5
5
  UINT64 = "UINT64",
6
6
  UINT128 = "UINT128",
7
7
  UINT256 = "UINT256",
8
+ INT128 = "INT128",
8
9
  BOOL = "BOOL",
9
10
  ADDRESS = "ADDRESS",
10
11
  STRING = "STRING",
@@ -9,6 +9,7 @@ export var ABIDataTypes;
9
9
  ABIDataTypes["UINT64"] = "UINT64";
10
10
  ABIDataTypes["UINT128"] = "UINT128";
11
11
  ABIDataTypes["UINT256"] = "UINT256";
12
+ ABIDataTypes["INT128"] = "INT128";
12
13
  ABIDataTypes["BOOL"] = "BOOL";
13
14
  ABIDataTypes["ADDRESS"] = "ADDRESS";
14
15
  ABIDataTypes["STRING"] = "STRING";
@@ -60,6 +61,9 @@ export class ABICoder {
60
61
  case ABIDataTypes.UINT256:
61
62
  result.push(byteReader.readU256());
62
63
  break;
64
+ case ABIDataTypes.INT128:
65
+ result.push(byteReader.readI128());
66
+ break;
63
67
  case ABIDataTypes.TUPLE:
64
68
  result.push(byteReader.readTuple());
65
69
  break;
@@ -27,6 +27,7 @@ export declare class BinaryReader {
27
27
  readAddressValueTuple(): AddressMap<bigint>;
28
28
  readU128(): bigint;
29
29
  readU256(): bigint;
30
+ readI128(): bigint;
30
31
  readBytes(length: u32, zeroStop?: boolean): Uint8Array;
31
32
  readString(length: u16): string;
32
33
  readSelector(): Selector;
@@ -1,6 +1,6 @@
1
1
  import { AddressMap } from '../deterministic/AddressMap.js';
2
2
  import { Address } from '../keypair/Address.js';
3
- import { ADDRESS_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
3
+ import { ADDRESS_BYTE_LENGTH, I128_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
4
4
  export class BinaryReader {
5
5
  constructor(bytes) {
6
6
  this.currentOffset = 0;
@@ -158,6 +158,16 @@ export class BinaryReader {
158
158
  const next32Bytes = this.readBytes(U256_BYTE_LENGTH);
159
159
  return BigInt('0x' + next32Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''));
160
160
  }
161
+ readI128() {
162
+ const next16Bytes = this.readBytes(I128_BYTE_LENGTH);
163
+ let value = BigInt('0x' + next16Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''));
164
+ if (next16Bytes[0] & 0x80) {
165
+ const mask = (BigInt(1) << BigInt(128)) - BigInt(1);
166
+ value = (value ^ mask) + BigInt(1);
167
+ value = -value;
168
+ }
169
+ return value;
170
+ }
161
171
  readBytes(length, zeroStop = false) {
162
172
  let bytes = new Uint8Array(length);
163
173
  for (let i = 0; i < length; i++) {
package/build/opnet.d.ts CHANGED
@@ -4,8 +4,8 @@ export * from './generators/builders/CalldataGenerator.js';
4
4
  export * from './generators/builders/CustomGenerator.js';
5
5
  export * from './generators/builders/DeploymentGenerator.js';
6
6
  export * from './generators/builders/LegacyCalldataGenerator.js';
7
- export * from './generators/builders/MultiSignGenerator.js';
8
7
  export * from './generators/builders/MineableReward.js';
8
+ export * from './generators/builders/MultiSignGenerator.js';
9
9
  export * from './generators/Features.js';
10
10
  export * from './generators/Generator.js';
11
11
  export * from './transaction/mineable/ChallengeGenerator.js';
@@ -23,6 +23,7 @@ export * from './transaction/enums/TransactionType.js';
23
23
  export * from './transaction/interfaces/ITransactionParameters.js';
24
24
  export * from './transaction/interfaces/Tap.js';
25
25
  export * from './transaction/TransactionFactory.js';
26
+ export * from './transaction/builders/ChallengeSolutionTransaction.js';
26
27
  export * from './transaction/builders/CustomScriptTransaction.js';
27
28
  export * from './transaction/builders/DeploymentTransaction.js';
28
29
  export * from './transaction/builders/FundingTransaction.js';
@@ -30,7 +31,6 @@ export * from './transaction/builders/InteractionTransaction.js';
30
31
  export * from './transaction/builders/MultiSignTransaction.js';
31
32
  export * from './transaction/builders/SharedInteractionTransaction.js';
32
33
  export * from './transaction/builders/TransactionBuilder.js';
33
- export * from './transaction/builders/ChallengeSolutionTransaction.js';
34
34
  export * from './utils/BitcoinUtils.js';
35
35
  export * from './utils/lengths.js';
36
36
  export * from './utxo/interfaces/IUTXO.js';
@@ -59,8 +59,7 @@ export * from './transaction/browser/extensions/UnisatSigner.js';
59
59
  export * from './transaction/browser/extensions/XverseSigner.js';
60
60
  export * from './transaction/browser/types/Unisat.js';
61
61
  export * from './transaction/browser/types/Xverse.js';
62
- export * from './transaction/browser/WalletConnection.js';
63
62
  export * from './metadata/tokens.js';
64
63
  export * from './transaction/browser/Web3Provider.js';
65
- export * from './transaction/ContractAddress.js';
66
64
  export * from './keypair/Secp256k1PointDeriver.js';
65
+ export * from './transaction/ContractAddress.js';
package/build/opnet.js CHANGED
@@ -4,8 +4,8 @@ export * from './generators/builders/CalldataGenerator.js';
4
4
  export * from './generators/builders/CustomGenerator.js';
5
5
  export * from './generators/builders/DeploymentGenerator.js';
6
6
  export * from './generators/builders/LegacyCalldataGenerator.js';
7
- export * from './generators/builders/MultiSignGenerator.js';
8
7
  export * from './generators/builders/MineableReward.js';
8
+ export * from './generators/builders/MultiSignGenerator.js';
9
9
  export * from './generators/Features.js';
10
10
  export * from './generators/Generator.js';
11
11
  export * from './transaction/mineable/ChallengeGenerator.js';
@@ -23,6 +23,7 @@ export * from './transaction/enums/TransactionType.js';
23
23
  export * from './transaction/interfaces/ITransactionParameters.js';
24
24
  export * from './transaction/interfaces/Tap.js';
25
25
  export * from './transaction/TransactionFactory.js';
26
+ export * from './transaction/builders/ChallengeSolutionTransaction.js';
26
27
  export * from './transaction/builders/CustomScriptTransaction.js';
27
28
  export * from './transaction/builders/DeploymentTransaction.js';
28
29
  export * from './transaction/builders/FundingTransaction.js';
@@ -30,7 +31,6 @@ export * from './transaction/builders/InteractionTransaction.js';
30
31
  export * from './transaction/builders/MultiSignTransaction.js';
31
32
  export * from './transaction/builders/SharedInteractionTransaction.js';
32
33
  export * from './transaction/builders/TransactionBuilder.js';
33
- export * from './transaction/builders/ChallengeSolutionTransaction.js';
34
34
  export * from './utils/BitcoinUtils.js';
35
35
  export * from './utils/lengths.js';
36
36
  export * from './utxo/interfaces/IUTXO.js';
@@ -59,8 +59,7 @@ export * from './transaction/browser/extensions/UnisatSigner.js';
59
59
  export * from './transaction/browser/extensions/XverseSigner.js';
60
60
  export * from './transaction/browser/types/Unisat.js';
61
61
  export * from './transaction/browser/types/Xverse.js';
62
- export * from './transaction/browser/WalletConnection.js';
63
62
  export * from './metadata/tokens.js';
64
63
  export * from './transaction/browser/Web3Provider.js';
65
- export * from './transaction/ContractAddress.js';
66
64
  export * from './keypair/Secp256k1PointDeriver.js';
65
+ export * from './transaction/ContractAddress.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.2.9",
4
+ "version": "1.2.11",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
@@ -21,8 +21,8 @@
21
21
  }
22
22
  },
23
23
  "browser": {
24
- "./build/index.js": "./browser/index.js",
25
24
  "./build/index.d.ts": "./browser/index.d.ts",
25
+ "./build/index.js": "./browser/index.js",
26
26
  "Buffer": "buffer",
27
27
  "crypto": "./src/crypto/crypto-browser.js",
28
28
  "stream": "stream-browserify",
@@ -89,7 +89,7 @@
89
89
  "dependencies": {
90
90
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
91
91
  "@bitcoinerlab/secp256k1": "^1.1.1",
92
- "@btc-vision/bitcoin": "^6.3.5",
92
+ "@btc-vision/bitcoin": "^6.3.6",
93
93
  "@btc-vision/bitcoin-rpc": "^1.0.0",
94
94
  "@btc-vision/logger": "^1.0.6",
95
95
  "@eslint/js": "^9.14.0",
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.2.9';
1
+ export const version = '1.2.11';
@@ -10,6 +10,7 @@ export enum ABIDataTypes {
10
10
  UINT64 = 'UINT64',
11
11
  UINT128 = 'UINT128',
12
12
  UINT256 = 'UINT256',
13
+ INT128 = 'INT128',
13
14
  BOOL = 'BOOL',
14
15
  ADDRESS = 'ADDRESS',
15
16
  STRING = 'STRING',
@@ -63,6 +64,9 @@ export class ABICoder {
63
64
  case ABIDataTypes.UINT256:
64
65
  result.push(byteReader.readU256());
65
66
  break;
67
+ case ABIDataTypes.INT128:
68
+ result.push(byteReader.readI128());
69
+ break;
66
70
  case ABIDataTypes.TUPLE: // very basic for now, only contains uint256
67
71
  result.push(byteReader.readTuple());
68
72
  break;
@@ -2,6 +2,7 @@ import { AddressMap } from '../deterministic/AddressMap.js';
2
2
  import { Address } from '../keypair/Address.js';
3
3
  import {
4
4
  ADDRESS_BYTE_LENGTH,
5
+ I128_BYTE_LENGTH,
5
6
  U128_BYTE_LENGTH,
6
7
  U16_BYTE_LENGTH,
7
8
  U256_BYTE_LENGTH,
@@ -230,6 +231,21 @@ export class BinaryReader {
230
231
  );
231
232
  }
232
233
 
234
+ readI128() {
235
+ const next16Bytes = this.readBytes(I128_BYTE_LENGTH);
236
+ let value = BigInt(
237
+ '0x' + next16Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''),
238
+ );
239
+
240
+ if (next16Bytes[0] & 0x80) {
241
+ const mask = (BigInt(1) << BigInt(128)) - BigInt(1);
242
+ value = (value ^ mask) + BigInt(1);
243
+ value = -value;
244
+ }
245
+
246
+ return value;
247
+ }
248
+
233
249
  public readBytes(length: u32, zeroStop: boolean = false): Uint8Array {
234
250
  let bytes: Uint8Array = new Uint8Array(length);
235
251
  for (let i: u32 = 0; i < length; i++) {
package/src/opnet.ts CHANGED
@@ -8,8 +8,8 @@ export * from './generators/builders/CalldataGenerator.js';
8
8
  export * from './generators/builders/CustomGenerator.js';
9
9
  export * from './generators/builders/DeploymentGenerator.js';
10
10
  export * from './generators/builders/LegacyCalldataGenerator.js';
11
- export * from './generators/builders/MultiSignGenerator.js';
12
11
  export * from './generators/builders/MineableReward.js';
12
+ export * from './generators/builders/MultiSignGenerator.js';
13
13
  export * from './generators/Features.js';
14
14
  export * from './generators/Generator.js';
15
15
 
@@ -40,6 +40,7 @@ export * from './transaction/interfaces/Tap.js';
40
40
  export * from './transaction/TransactionFactory.js';
41
41
 
42
42
  /** Builders */
43
+ export * from './transaction/builders/ChallengeSolutionTransaction.js';
43
44
  export * from './transaction/builders/CustomScriptTransaction.js';
44
45
  export * from './transaction/builders/DeploymentTransaction.js';
45
46
  export * from './transaction/builders/FundingTransaction.js';
@@ -47,7 +48,6 @@ export * from './transaction/builders/InteractionTransaction.js';
47
48
  export * from './transaction/builders/MultiSignTransaction.js';
48
49
  export * from './transaction/builders/SharedInteractionTransaction.js';
49
50
  export * from './transaction/builders/TransactionBuilder.js';
50
- export * from './transaction/builders/ChallengeSolutionTransaction.js';
51
51
 
52
52
  /** Utils */
53
53
  export * from './utils/BitcoinUtils.js';
@@ -91,10 +91,9 @@ export * from './transaction/browser/extensions/UnisatSigner.js';
91
91
  export * from './transaction/browser/extensions/XverseSigner.js';
92
92
  export * from './transaction/browser/types/Unisat.js';
93
93
  export * from './transaction/browser/types/Xverse.js';
94
- export * from './transaction/browser/WalletConnection.js';
95
94
 
96
95
  export * from './metadata/tokens.js';
97
96
  export * from './transaction/browser/Web3Provider.js';
98
97
 
99
- export * from './transaction/ContractAddress.js';
100
98
  export * from './keypair/Secp256k1PointDeriver.js';
99
+ export * from './transaction/ContractAddress.js';
@@ -1,18 +0,0 @@
1
- import { Address } from '../../opnet.js';
2
- import { UnisatSigner } from './extensions/UnisatSigner.js';
3
- import { XverseSigner } from './extensions/XverseSigner.js';
4
- export declare enum SupportedWallets {
5
- Unisat = "unisat",
6
- Xverse = "xverse"
7
- }
8
- export declare class WalletConnection {
9
- wallet_type: SupportedWallets | null;
10
- private unisatSigner;
11
- private xverseSigner;
12
- connect(): Promise<void>;
13
- disconnect(): Promise<void>;
14
- switchTo(walletType: SupportedWallets): Promise<void>;
15
- getAddress(): Address;
16
- getSigner(): UnisatSigner | XverseSigner;
17
- }
18
- export default WalletConnection;
@@ -1,18 +0,0 @@
1
- import { Address } from '../../opnet.js';
2
- import { UnisatSigner } from './extensions/UnisatSigner.js';
3
- import { XverseSigner } from './extensions/XverseSigner.js';
4
- export declare enum SupportedWallets {
5
- Unisat = "unisat",
6
- Xverse = "xverse"
7
- }
8
- export declare class WalletConnection {
9
- wallet_type: SupportedWallets | null;
10
- private unisatSigner;
11
- private xverseSigner;
12
- connect(): Promise<void>;
13
- disconnect(): Promise<void>;
14
- switchTo(walletType: SupportedWallets): Promise<void>;
15
- getAddress(): Address;
16
- getSigner(): UnisatSigner | XverseSigner;
17
- }
18
- export default WalletConnection;
@@ -1,95 +0,0 @@
1
- import { Address } from '../../opnet.js';
2
- import { UnisatSigner } from './extensions/UnisatSigner.js';
3
- import { XverseSigner } from './extensions/XverseSigner.js';
4
- export var SupportedWallets;
5
- (function (SupportedWallets) {
6
- SupportedWallets["Unisat"] = "unisat";
7
- SupportedWallets["Xverse"] = "xverse";
8
- })(SupportedWallets || (SupportedWallets = {}));
9
- export class WalletConnection {
10
- constructor() {
11
- this.wallet_type = null;
12
- this.unisatSigner = null;
13
- this.xverseSigner = null;
14
- }
15
- async connect() {
16
- if (this.wallet_type) {
17
- throw new Error('Wallet already connected');
18
- }
19
- this.unisatSigner = new UnisatSigner();
20
- this.xverseSigner = new XverseSigner();
21
- if (window.opnet || window.unisat) {
22
- try {
23
- await this.unisatSigner.init();
24
- this.wallet_type = SupportedWallets.Unisat;
25
- return;
26
- }
27
- catch (error) {
28
- if (error instanceof Error) {
29
- throw new Error(error.message);
30
- }
31
- throw new Error('Error connecting wallet');
32
- }
33
- }
34
- if (window.BitcoinProvider) {
35
- try {
36
- await this.xverseSigner.init();
37
- this.wallet_type = SupportedWallets.Xverse;
38
- return;
39
- }
40
- catch (error) {
41
- if (error instanceof Error) {
42
- throw new Error(error.message);
43
- }
44
- throw new Error('Error connecting wallet');
45
- }
46
- }
47
- throw new Error('Wallet not found');
48
- }
49
- async disconnect() {
50
- if (!this.unisatSigner || !this.xverseSigner) {
51
- throw new Error('Wallet not connected');
52
- }
53
- if (this.wallet_type === SupportedWallets.Unisat) {
54
- this.unisatSigner.unisat.disconnect();
55
- }
56
- else {
57
- await this.xverseSigner.BitcoinProvider.request('wallet_disconnect', null);
58
- }
59
- this.wallet_type = null;
60
- }
61
- async switchTo(walletType) {
62
- if (!this.unisatSigner || !this.xverseSigner) {
63
- throw new Error('Wallet not connected');
64
- }
65
- if (this.wallet_type === walletType)
66
- return;
67
- if (walletType === SupportedWallets.Unisat) {
68
- await this.unisatSigner.init();
69
- this.wallet_type = SupportedWallets.Unisat;
70
- }
71
- else {
72
- await this.xverseSigner.init();
73
- this.wallet_type = SupportedWallets.Xverse;
74
- }
75
- }
76
- getAddress() {
77
- if (!this.unisatSigner || !this.xverseSigner) {
78
- throw new Error('Wallet not connected');
79
- }
80
- if (this.wallet_type === SupportedWallets.Unisat) {
81
- return Address.fromString(this.unisatSigner.getPublicKey().toString('hex'));
82
- }
83
- return Address.fromString(this.xverseSigner.getPublicKey().toString('hex'));
84
- }
85
- getSigner() {
86
- if (!this.unisatSigner || !this.xverseSigner) {
87
- throw new Error('Wallet not connected');
88
- }
89
- if (this.wallet_type === SupportedWallets.Unisat) {
90
- return this.unisatSigner;
91
- }
92
- return this.xverseSigner;
93
- }
94
- }
95
- export default WalletConnection;
@@ -1,110 +0,0 @@
1
- import { Address } from '../../opnet.js';
2
- import { UnisatSigner } from './extensions/UnisatSigner.js';
3
- import { XverseSigner } from './extensions/XverseSigner.js';
4
-
5
- export enum SupportedWallets {
6
- Unisat = 'unisat',
7
- Xverse = 'xverse',
8
- }
9
-
10
- export class WalletConnection {
11
- public wallet_type: SupportedWallets | null = null;
12
-
13
- private unisatSigner: UnisatSigner | null = null; // OP_WALLET and Unisat wallet
14
- private xverseSigner: XverseSigner | null = null;
15
-
16
- public async connect(): Promise<void> {
17
- if (this.wallet_type) {
18
- throw new Error('Wallet already connected');
19
- }
20
-
21
- this.unisatSigner = new UnisatSigner();
22
- this.xverseSigner = new XverseSigner();
23
-
24
- if (window.opnet || window.unisat) {
25
- try {
26
- await this.unisatSigner.init();
27
- this.wallet_type = SupportedWallets.Unisat;
28
- return;
29
- } catch (error: unknown) {
30
- if (error instanceof Error) {
31
- throw new Error(error.message);
32
- }
33
-
34
- throw new Error('Error connecting wallet');
35
- }
36
- }
37
-
38
- if (window.BitcoinProvider) {
39
- try {
40
- await this.xverseSigner.init();
41
- this.wallet_type = SupportedWallets.Xverse;
42
- return;
43
- } catch (error: unknown) {
44
- if (error instanceof Error) {
45
- throw new Error(error.message);
46
- }
47
-
48
- throw new Error('Error connecting wallet');
49
- }
50
- }
51
-
52
- throw new Error('Wallet not found');
53
- }
54
-
55
- public async disconnect(): Promise<void> {
56
- if (!this.unisatSigner || !this.xverseSigner) {
57
- throw new Error('Wallet not connected');
58
- }
59
-
60
- if (this.wallet_type === SupportedWallets.Unisat) {
61
- this.unisatSigner.unisat.disconnect();
62
- } else {
63
- await this.xverseSigner.BitcoinProvider.request('wallet_disconnect', null);
64
- }
65
-
66
- this.wallet_type = null;
67
- }
68
-
69
- public async switchTo(walletType: SupportedWallets): Promise<void> {
70
- if (!this.unisatSigner || !this.xverseSigner) {
71
- throw new Error('Wallet not connected');
72
- }
73
-
74
- if (this.wallet_type === walletType) return;
75
-
76
- if (walletType === SupportedWallets.Unisat) {
77
- await this.unisatSigner.init();
78
- this.wallet_type = SupportedWallets.Unisat;
79
- } else {
80
- await this.xverseSigner.init();
81
- this.wallet_type = SupportedWallets.Xverse;
82
- }
83
- }
84
-
85
- public getAddress(): Address {
86
- if (!this.unisatSigner || !this.xverseSigner) {
87
- throw new Error('Wallet not connected');
88
- }
89
-
90
- if (this.wallet_type === SupportedWallets.Unisat) {
91
- return Address.fromString(this.unisatSigner.getPublicKey().toString('hex'));
92
- }
93
-
94
- return Address.fromString(this.xverseSigner.getPublicKey().toString('hex'));
95
- }
96
-
97
- public getSigner(): UnisatSigner | XverseSigner {
98
- if (!this.unisatSigner || !this.xverseSigner) {
99
- throw new Error('Wallet not connected');
100
- }
101
-
102
- if (this.wallet_type === SupportedWallets.Unisat) {
103
- return this.unisatSigner;
104
- }
105
-
106
- return this.xverseSigner;
107
- }
108
- }
109
-
110
- export default WalletConnection;