@btc-vision/transaction 1.0.74 → 1.0.76
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/metadata/contracts/wBTC.d.ts +4 -2
- package/browser/metadata/tokens.d.ts +28 -0
- package/browser/network/ChainId.d.ts +4 -0
- package/browser/opnet.d.ts +1 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/metadata/contracts/wBTC.d.ts +4 -2
- package/build/metadata/contracts/wBTC.js +17 -4
- package/build/metadata/tokens.d.ts +28 -0
- package/build/metadata/tokens.js +85 -1
- package/build/network/ChainId.d.ts +4 -0
- package/build/network/ChainId.js +5 -0
- package/build/opnet.d.ts +1 -0
- package/build/opnet.js +1 -0
- package/package.json +109 -109
- package/src/_version.ts +1 -1
- package/src/metadata/contracts/wBTC.ts +17 -4
- package/src/metadata/tokens.ts +135 -15
- package/src/network/ChainId.ts +7 -0
- package/src/opnet.ts +1 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Network } from 'bitcoinjs-lib';
|
|
2
2
|
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
3
|
import { Address } from '@btc-vision/bsi-binary';
|
|
4
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
4
5
|
export declare class wBTC extends ContractBaseMetadata {
|
|
5
6
|
protected network: Network;
|
|
6
7
|
readonly tokenName: string;
|
|
7
8
|
readonly tokenSymbol: string;
|
|
8
9
|
readonly decimals: number;
|
|
9
10
|
protected readonly address: Address;
|
|
10
|
-
constructor(network?: Network);
|
|
11
|
-
static
|
|
11
|
+
constructor(network?: Network, chainId?: ChainId);
|
|
12
|
+
private static getWBTCAddressForChain;
|
|
13
|
+
static getAddress(network?: Network, chainId?: ChainId): Address;
|
|
12
14
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { ChainId } from '../network/ChainId.js';
|
|
2
3
|
export declare const FACTORY_ADDRESS_REGTEST: Address;
|
|
3
4
|
export declare const POOL_ADDRESS_REGTEST: Address;
|
|
4
5
|
export declare const WBTC_ADDRESS_REGTEST: Address;
|
|
@@ -9,3 +10,30 @@ export declare const POOL_ADDRESS_TESTNET: Address;
|
|
|
9
10
|
export declare const WBTC_ADDRESS_TESTNET: Address;
|
|
10
11
|
export declare const MOTO_ADDRESS_TESTNET: Address;
|
|
11
12
|
export declare const ROUTER_ADDRESS_TESTNET: Address;
|
|
13
|
+
export declare const FACTORY_ADDRESS_FRACTAL: Address;
|
|
14
|
+
export declare const POOL_ADDRESS_FRACTAL: Address;
|
|
15
|
+
export declare const WBTC_ADDRESS_FRACTAL: Address;
|
|
16
|
+
export declare const MOTO_ADDRESS_FRACTAL: Address;
|
|
17
|
+
export declare const ROUTER_ADDRESS_FRACTAL: Address;
|
|
18
|
+
export declare enum OPNetNetwork {
|
|
19
|
+
Mainnet = "mainnet",
|
|
20
|
+
Testnet = "testnet",
|
|
21
|
+
Regtest = "regtest"
|
|
22
|
+
}
|
|
23
|
+
export interface OPNetTokenMetadata {
|
|
24
|
+
readonly factory: Address;
|
|
25
|
+
readonly pool: Address;
|
|
26
|
+
readonly wbtc: Address;
|
|
27
|
+
readonly moto: Address;
|
|
28
|
+
readonly router: Address;
|
|
29
|
+
}
|
|
30
|
+
export declare class OPNetTokenAddressManager {
|
|
31
|
+
private readonly metadata;
|
|
32
|
+
getFactoryAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
33
|
+
getPoolAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
34
|
+
getWBTCAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
35
|
+
getMOTOAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
36
|
+
getRouterAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
37
|
+
getAddresses(network: OPNetNetwork, chainId: ChainId): OPNetTokenMetadata;
|
|
38
|
+
}
|
|
39
|
+
export declare const OPNetMetadata: OPNetTokenAddressManager;
|
package/browser/opnet.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
26
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
27
|
export * from './wbtc/WrappedGenerationParameters.js';
|
|
28
28
|
export * from './wbtc/Generate.js';
|
|
29
|
+
export * from './network/ChainId.js';
|
|
29
30
|
export * from './utils/BitcoinUtils.js';
|
|
30
31
|
export * from './utxo/interfaces/IUTXO.js';
|
|
31
32
|
export * from './utxo/OPNetLimitedProvider.js';
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.76";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.76';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Network } from 'bitcoinjs-lib';
|
|
2
2
|
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
3
|
import { Address } from '@btc-vision/bsi-binary';
|
|
4
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
4
5
|
export declare class wBTC extends ContractBaseMetadata {
|
|
5
6
|
protected network: Network;
|
|
6
7
|
readonly tokenName: string;
|
|
7
8
|
readonly tokenSymbol: string;
|
|
8
9
|
readonly decimals: number;
|
|
9
10
|
protected readonly address: Address;
|
|
10
|
-
constructor(network?: Network);
|
|
11
|
-
static
|
|
11
|
+
constructor(network?: Network, chainId?: ChainId);
|
|
12
|
+
private static getWBTCAddressForChain;
|
|
13
|
+
static getAddress(network?: Network, chainId?: ChainId): Address;
|
|
12
14
|
}
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import { networks } from 'bitcoinjs-lib';
|
|
2
2
|
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
|
-
import { WBTC_ADDRESS_REGTEST, WBTC_ADDRESS_TESTNET } from '../tokens.js';
|
|
3
|
+
import { WBTC_ADDRESS_FRACTAL, WBTC_ADDRESS_REGTEST, WBTC_ADDRESS_TESTNET } from '../tokens.js';
|
|
4
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
4
5
|
export class wBTC extends ContractBaseMetadata {
|
|
5
6
|
network;
|
|
6
7
|
tokenName = 'Wrapped Bitcoin';
|
|
7
8
|
tokenSymbol = 'wBTC';
|
|
8
9
|
decimals = 8;
|
|
9
10
|
address;
|
|
10
|
-
constructor(network = networks.bitcoin) {
|
|
11
|
+
constructor(network = networks.bitcoin, chainId = ChainId.Bitcoin) {
|
|
11
12
|
super(network);
|
|
12
13
|
this.network = network;
|
|
13
|
-
this.address = wBTC.getAddress(network);
|
|
14
|
+
this.address = wBTC.getAddress(network, chainId);
|
|
14
15
|
}
|
|
15
|
-
static
|
|
16
|
+
static getWBTCAddressForChain(chainId) {
|
|
17
|
+
switch (chainId) {
|
|
18
|
+
case ChainId.Bitcoin:
|
|
19
|
+
return 'unknown';
|
|
20
|
+
case ChainId.Fractal:
|
|
21
|
+
return WBTC_ADDRESS_FRACTAL;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Invalid chainId: ${chainId}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static getAddress(network = networks.bitcoin, chainId) {
|
|
16
27
|
switch (network.bech32) {
|
|
17
28
|
case networks.bitcoin.bech32:
|
|
29
|
+
if (chainId)
|
|
30
|
+
return this.getWBTCAddressForChain(chainId);
|
|
18
31
|
return 'unknown';
|
|
19
32
|
case networks.regtest.bech32:
|
|
20
33
|
return WBTC_ADDRESS_REGTEST;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { ChainId } from '../network/ChainId.js';
|
|
2
3
|
export declare const FACTORY_ADDRESS_REGTEST: Address;
|
|
3
4
|
export declare const POOL_ADDRESS_REGTEST: Address;
|
|
4
5
|
export declare const WBTC_ADDRESS_REGTEST: Address;
|
|
@@ -9,3 +10,30 @@ export declare const POOL_ADDRESS_TESTNET: Address;
|
|
|
9
10
|
export declare const WBTC_ADDRESS_TESTNET: Address;
|
|
10
11
|
export declare const MOTO_ADDRESS_TESTNET: Address;
|
|
11
12
|
export declare const ROUTER_ADDRESS_TESTNET: Address;
|
|
13
|
+
export declare const FACTORY_ADDRESS_FRACTAL: Address;
|
|
14
|
+
export declare const POOL_ADDRESS_FRACTAL: Address;
|
|
15
|
+
export declare const WBTC_ADDRESS_FRACTAL: Address;
|
|
16
|
+
export declare const MOTO_ADDRESS_FRACTAL: Address;
|
|
17
|
+
export declare const ROUTER_ADDRESS_FRACTAL: Address;
|
|
18
|
+
export declare enum OPNetNetwork {
|
|
19
|
+
Mainnet = "mainnet",
|
|
20
|
+
Testnet = "testnet",
|
|
21
|
+
Regtest = "regtest"
|
|
22
|
+
}
|
|
23
|
+
export interface OPNetTokenMetadata {
|
|
24
|
+
readonly factory: Address;
|
|
25
|
+
readonly pool: Address;
|
|
26
|
+
readonly wbtc: Address;
|
|
27
|
+
readonly moto: Address;
|
|
28
|
+
readonly router: Address;
|
|
29
|
+
}
|
|
30
|
+
export declare class OPNetTokenAddressManager {
|
|
31
|
+
private readonly metadata;
|
|
32
|
+
getFactoryAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
33
|
+
getPoolAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
34
|
+
getWBTCAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
35
|
+
getMOTOAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
36
|
+
getRouterAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
37
|
+
getAddresses(network: OPNetNetwork, chainId: ChainId): OPNetTokenMetadata;
|
|
38
|
+
}
|
|
39
|
+
export declare const OPNetMetadata: OPNetTokenAddressManager;
|
package/build/metadata/tokens.js
CHANGED
|
@@ -1,10 +1,94 @@
|
|
|
1
|
+
import { ChainId } from '../network/ChainId.js';
|
|
1
2
|
export const FACTORY_ADDRESS_REGTEST = 'bcrt1qgph2k9dahptnz2vu72ezd9r2p4phjm2pkgu7ht';
|
|
2
3
|
export const POOL_ADDRESS_REGTEST = 'bcrt1q5nkjpjmh6xwweprcyeylwdw7aud4een7p9pphd';
|
|
3
4
|
export const WBTC_ADDRESS_REGTEST = 'bcrt1qdr7sjgtnudda8zrfklw8l5cnrxum5hns7e46hf';
|
|
4
5
|
export const MOTO_ADDRESS_REGTEST = 'bcrt1q8reuxx9naek4mqesrfsgdpjv3q7a5g2llkh6ua';
|
|
5
|
-
export const ROUTER_ADDRESS_REGTEST = '
|
|
6
|
+
export const ROUTER_ADDRESS_REGTEST = 'bcrt1qa6vja0swlvy4raxgv8k8kxmsfwzkgvu4ayrnd8';
|
|
6
7
|
export const FACTORY_ADDRESS_TESTNET = 'tb1qgev5kldhp5zvg6j8t9vl6x4phkrwn8nk9felxh';
|
|
7
8
|
export const POOL_ADDRESS_TESTNET = 'tb1q6a7yw353hjmresphupytw5vczpqxtg4yrupayk';
|
|
8
9
|
export const WBTC_ADDRESS_TESTNET = 'tb1qp28xna6pv47x6wflcplhu0a9hkld5shtvjx6xv';
|
|
9
10
|
export const MOTO_ADDRESS_TESTNET = 'tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw';
|
|
10
11
|
export const ROUTER_ADDRESS_TESTNET = 'tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt';
|
|
12
|
+
export const FACTORY_ADDRESS_FRACTAL = 'bc1q4h9l3ul7d06sne768y5r8jv9qvmx3jrzvdjpj5';
|
|
13
|
+
export const POOL_ADDRESS_FRACTAL = 'bc1q3x6pfdvz647t7rq5zdzsy62qw5cgld092sfxsy';
|
|
14
|
+
export const WBTC_ADDRESS_FRACTAL = 'bc1qeras4z6y2nx5ugqckx90wxdd02uyh8mdqptfhs';
|
|
15
|
+
export const MOTO_ADDRESS_FRACTAL = 'bc1q7xnvxz7tjxdhhp7wj2dp2qm5m9sz8mveueq649';
|
|
16
|
+
export const ROUTER_ADDRESS_FRACTAL = 'bc1qc8ysj702pktdc8rlxjxn3kslqnk3g7mavaa0ef';
|
|
17
|
+
export var OPNetNetwork;
|
|
18
|
+
(function (OPNetNetwork) {
|
|
19
|
+
OPNetNetwork["Mainnet"] = "mainnet";
|
|
20
|
+
OPNetNetwork["Testnet"] = "testnet";
|
|
21
|
+
OPNetNetwork["Regtest"] = "regtest";
|
|
22
|
+
})(OPNetNetwork || (OPNetNetwork = {}));
|
|
23
|
+
export class OPNetTokenAddressManager {
|
|
24
|
+
metadata = {
|
|
25
|
+
[ChainId.Bitcoin]: {
|
|
26
|
+
[OPNetNetwork.Testnet]: {
|
|
27
|
+
factory: FACTORY_ADDRESS_TESTNET,
|
|
28
|
+
pool: POOL_ADDRESS_TESTNET,
|
|
29
|
+
wbtc: WBTC_ADDRESS_TESTNET,
|
|
30
|
+
moto: MOTO_ADDRESS_TESTNET,
|
|
31
|
+
router: ROUTER_ADDRESS_TESTNET,
|
|
32
|
+
},
|
|
33
|
+
[OPNetNetwork.Regtest]: {
|
|
34
|
+
factory: FACTORY_ADDRESS_REGTEST,
|
|
35
|
+
pool: POOL_ADDRESS_REGTEST,
|
|
36
|
+
wbtc: WBTC_ADDRESS_REGTEST,
|
|
37
|
+
moto: MOTO_ADDRESS_REGTEST,
|
|
38
|
+
router: ROUTER_ADDRESS_REGTEST,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
[ChainId.Fractal]: {
|
|
42
|
+
[OPNetNetwork.Mainnet]: {
|
|
43
|
+
factory: FACTORY_ADDRESS_FRACTAL,
|
|
44
|
+
pool: POOL_ADDRESS_FRACTAL,
|
|
45
|
+
wbtc: WBTC_ADDRESS_FRACTAL,
|
|
46
|
+
moto: MOTO_ADDRESS_FRACTAL,
|
|
47
|
+
router: ROUTER_ADDRESS_FRACTAL,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
getFactoryAddress(network, chainId) {
|
|
52
|
+
const address = this.metadata[chainId][network]?.factory;
|
|
53
|
+
if (!address) {
|
|
54
|
+
throw new Error(`Factory address not found for network ${network} and chainId ${chainId}`);
|
|
55
|
+
}
|
|
56
|
+
return address;
|
|
57
|
+
}
|
|
58
|
+
getPoolAddress(network, chainId) {
|
|
59
|
+
const address = this.metadata[chainId][network]?.pool;
|
|
60
|
+
if (!address) {
|
|
61
|
+
throw new Error(`Pool address not found for network ${network} and chainId ${chainId}`);
|
|
62
|
+
}
|
|
63
|
+
return address;
|
|
64
|
+
}
|
|
65
|
+
getWBTCAddress(network, chainId) {
|
|
66
|
+
const address = this.metadata[chainId][network]?.wbtc;
|
|
67
|
+
if (!address) {
|
|
68
|
+
throw new Error(`WBTC address not found for network ${network} and chainId ${chainId}`);
|
|
69
|
+
}
|
|
70
|
+
return address;
|
|
71
|
+
}
|
|
72
|
+
getMOTOAddress(network, chainId) {
|
|
73
|
+
const address = this.metadata[chainId][network]?.moto;
|
|
74
|
+
if (!address) {
|
|
75
|
+
throw new Error(`MOTO address not found for network ${network} and chainId ${chainId}`);
|
|
76
|
+
}
|
|
77
|
+
return address;
|
|
78
|
+
}
|
|
79
|
+
getRouterAddress(network, chainId) {
|
|
80
|
+
const address = this.metadata[chainId][network]?.router;
|
|
81
|
+
if (!address) {
|
|
82
|
+
throw new Error(`Router address not found for network ${network} and chainId ${chainId}`);
|
|
83
|
+
}
|
|
84
|
+
return address;
|
|
85
|
+
}
|
|
86
|
+
getAddresses(network, chainId) {
|
|
87
|
+
const metadata = this.metadata[chainId][network];
|
|
88
|
+
if (!metadata) {
|
|
89
|
+
throw new Error(`Metadata not found for network ${network} and chainId ${chainId}`);
|
|
90
|
+
}
|
|
91
|
+
return metadata;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export const OPNetMetadata = new OPNetTokenAddressManager();
|
package/build/opnet.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
26
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
27
|
export * from './wbtc/WrappedGenerationParameters.js';
|
|
28
28
|
export * from './wbtc/Generate.js';
|
|
29
|
+
export * from './network/ChainId.js';
|
|
29
30
|
export * from './utils/BitcoinUtils.js';
|
|
30
31
|
export * from './utxo/interfaces/IUTXO.js';
|
|
31
32
|
export * from './utxo/OPNetLimitedProvider.js';
|
package/build/opnet.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
26
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
27
|
export * from './wbtc/WrappedGenerationParameters.js';
|
|
28
28
|
export * from './wbtc/Generate.js';
|
|
29
|
+
export * from './network/ChainId.js';
|
|
29
30
|
export * from './utils/BitcoinUtils.js';
|
|
30
31
|
export * from './utxo/interfaces/IUTXO.js';
|
|
31
32
|
export * from './utxo/OPNetLimitedProvider.js';
|
package/package.json
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"browser": {
|
|
16
|
-
"import": "./browser/index.js",
|
|
17
|
-
"require": "./browser/index.js",
|
|
18
|
-
"types": "./browser/index.d.ts"
|
|
19
|
-
}
|
|
2
|
+
"type": "module",
|
|
3
|
+
"version": "1.0.76",
|
|
4
|
+
"author": "BlobMaster41",
|
|
5
|
+
"description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=16.0.0"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
"node": {
|
|
11
|
+
"import": "./build/index.js",
|
|
12
|
+
"require": "./cjs/index.js",
|
|
13
|
+
"types": "./build/index.d.ts"
|
|
20
14
|
},
|
|
21
15
|
"browser": {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"zlib": "browserify-zlib"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://opnet.org",
|
|
28
|
-
"keywords": [
|
|
29
|
-
"opnet",
|
|
30
|
-
"bsi",
|
|
31
|
-
"bsi-binary",
|
|
32
|
-
"bsi-bitcoin-rpc",
|
|
33
|
-
"bitcoin transaction",
|
|
34
|
-
"transaction builder",
|
|
35
|
-
"transaction signer",
|
|
36
|
-
"bitcoin",
|
|
37
|
-
"btc",
|
|
38
|
-
"bitcoin smart contracts",
|
|
39
|
-
"smart inscriptions",
|
|
40
|
-
"ordinals"
|
|
41
|
-
],
|
|
42
|
-
"license": "LICENSE.MD",
|
|
43
|
-
"main": "build/index.js",
|
|
44
|
-
"types": "build/index.d.ts",
|
|
45
|
-
"typings": "build/index.d.ts",
|
|
46
|
-
"module": "build/index.js",
|
|
47
|
-
"name": "@btc-vision/transaction",
|
|
48
|
-
"publishConfig": {
|
|
49
|
-
"access": "public",
|
|
50
|
-
"tag": "latest"
|
|
51
|
-
},
|
|
52
|
-
"repository": {
|
|
53
|
-
"type": "git",
|
|
54
|
-
"url": "git://github.com/btc-vision/transaction.git"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"watch": "gulp watch",
|
|
58
|
-
"build": "gulp && gulp cjs",
|
|
59
|
-
"setup": "npm npm i && npm run build",
|
|
60
|
-
"browserBuild": "webpack --mode production",
|
|
61
|
-
"cjs": "gulp cjs",
|
|
62
|
-
"docs": "typedoc --out docs --exclude 'src/tests/*.ts' --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/tests/test.ts --exclude src/index.ts src",
|
|
63
|
-
"postinstall": "gulp && gulp cjs"
|
|
64
|
-
},
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
67
|
-
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
68
|
-
"@babel/preset-env": "^7.24.5",
|
|
69
|
-
"@babel/preset-flow": "^7.24.1",
|
|
70
|
-
"@babel/preset-react": "^7.24.1",
|
|
71
|
-
"@babel/preset-typescript": "^7.24.1",
|
|
72
|
-
"@types/node": "^20.11.30",
|
|
73
|
-
"eslint": "^8.57.0",
|
|
74
|
-
"https-browserify": "^1.0.0",
|
|
75
|
-
"os-browserify": "^0.3.0",
|
|
76
|
-
"prettier": "^3.3.1",
|
|
77
|
-
"stream-browserify": "^3.0.0",
|
|
78
|
-
"stream-http": "^3.2.0",
|
|
79
|
-
"typedoc": "^0.25.13",
|
|
80
|
-
"typedoc-material-theme": "^1.0.2",
|
|
81
|
-
"typescript": "^5.4.5",
|
|
82
|
-
"typescript-eslint": "^7.4.0",
|
|
83
|
-
"webpack": "^5.91.0",
|
|
84
|
-
"webpack-cli": "^5.1.4"
|
|
85
|
-
},
|
|
86
|
-
"dependencies": {
|
|
87
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
88
|
-
"@bitcoinerlab/secp256k1": "^1.1.1",
|
|
89
|
-
"@btc-vision/bsi-binary": "^1.0.37",
|
|
90
|
-
"@btc-vision/bsi-bitcoin-rpc": "^1.0.22",
|
|
91
|
-
"@btc-vision/bsi-common": "^1.0.16",
|
|
92
|
-
"@btc-vision/logger": "^1.0.2",
|
|
93
|
-
"assert": "^2.1.0",
|
|
94
|
-
"babel-loader": "^9.1.3",
|
|
95
|
-
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
96
|
-
"babel-preset-react": "^6.24.1",
|
|
97
|
-
"babelify": "^10.0.0",
|
|
98
|
-
"bech32": "^2.0.0",
|
|
99
|
-
"bignumber.js": "^9.1.2",
|
|
100
|
-
"bip32": "^4.0.0",
|
|
101
|
-
"bitcoinjs-lib": "github:btc-vision/bitcoinjs-lib",
|
|
102
|
-
"browserify-zlib": "^0.2.0",
|
|
103
|
-
"buffer": "^6.0.3",
|
|
104
|
-
"ecpair": "^2.1.0",
|
|
105
|
-
"gulp": "^4.0.2",
|
|
106
|
-
"gulp-cached": "^1.1.1",
|
|
107
|
-
"gulp-logger": "^0.0.2",
|
|
108
|
-
"gulp-typescript": "^6.0.0-alpha.1",
|
|
109
|
-
"gulplog": "^2.2.0",
|
|
110
|
-
"process": "^0.11.10",
|
|
111
|
-
"ts-loader": "^9.5.1",
|
|
112
|
-
"ts-node": "^10.9.2"
|
|
16
|
+
"import": "./browser/index.js",
|
|
17
|
+
"require": "./browser/index.js",
|
|
18
|
+
"types": "./browser/index.d.ts"
|
|
113
19
|
}
|
|
20
|
+
},
|
|
21
|
+
"browser": {
|
|
22
|
+
"Buffer": "buffer",
|
|
23
|
+
"crypto": "./src/crypto/crypto-browser.js",
|
|
24
|
+
"stream": "stream-browserify",
|
|
25
|
+
"zlib": "browserify-zlib"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://opnet.org",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"opnet",
|
|
30
|
+
"bsi",
|
|
31
|
+
"bsi-binary",
|
|
32
|
+
"bsi-bitcoin-rpc",
|
|
33
|
+
"bitcoin transaction",
|
|
34
|
+
"transaction builder",
|
|
35
|
+
"transaction signer",
|
|
36
|
+
"bitcoin",
|
|
37
|
+
"btc",
|
|
38
|
+
"bitcoin smart contracts",
|
|
39
|
+
"smart inscriptions",
|
|
40
|
+
"ordinals"
|
|
41
|
+
],
|
|
42
|
+
"license": "LICENSE.MD",
|
|
43
|
+
"main": "build/index.js",
|
|
44
|
+
"types": "build/index.d.ts",
|
|
45
|
+
"typings": "build/index.d.ts",
|
|
46
|
+
"module": "build/index.js",
|
|
47
|
+
"name": "@btc-vision/transaction",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"tag": "latest"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git://github.com/btc-vision/transaction.git"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"watch": "gulp watch",
|
|
58
|
+
"build": "gulp && gulp cjs",
|
|
59
|
+
"setup": "npm npm i && npm run build",
|
|
60
|
+
"browserBuild": "webpack --mode production",
|
|
61
|
+
"cjs": "gulp cjs",
|
|
62
|
+
"docs": "typedoc --out docs --exclude 'src/tests/*.ts' --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/tests/test.ts --exclude src/index.ts src",
|
|
63
|
+
"postinstall": "gulp && gulp cjs"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
67
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
68
|
+
"@babel/preset-env": "^7.24.5",
|
|
69
|
+
"@babel/preset-flow": "^7.24.1",
|
|
70
|
+
"@babel/preset-react": "^7.24.1",
|
|
71
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
72
|
+
"@types/node": "^20.11.30",
|
|
73
|
+
"eslint": "^8.57.0",
|
|
74
|
+
"https-browserify": "^1.0.0",
|
|
75
|
+
"os-browserify": "^0.3.0",
|
|
76
|
+
"prettier": "^3.3.1",
|
|
77
|
+
"stream-browserify": "^3.0.0",
|
|
78
|
+
"stream-http": "^3.2.0",
|
|
79
|
+
"typedoc": "^0.25.13",
|
|
80
|
+
"typedoc-material-theme": "^1.0.2",
|
|
81
|
+
"typescript": "^5.4.5",
|
|
82
|
+
"typescript-eslint": "^7.4.0",
|
|
83
|
+
"webpack": "^5.91.0",
|
|
84
|
+
"webpack-cli": "^5.1.4"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
88
|
+
"@bitcoinerlab/secp256k1": "^1.1.1",
|
|
89
|
+
"@btc-vision/bsi-binary": "^1.0.37",
|
|
90
|
+
"@btc-vision/bsi-bitcoin-rpc": "^1.0.22",
|
|
91
|
+
"@btc-vision/bsi-common": "^1.0.16",
|
|
92
|
+
"@btc-vision/logger": "^1.0.2",
|
|
93
|
+
"assert": "^2.1.0",
|
|
94
|
+
"babel-loader": "^9.1.3",
|
|
95
|
+
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
96
|
+
"babel-preset-react": "^6.24.1",
|
|
97
|
+
"babelify": "^10.0.0",
|
|
98
|
+
"bech32": "^2.0.0",
|
|
99
|
+
"bignumber.js": "^9.1.2",
|
|
100
|
+
"bip32": "^4.0.0",
|
|
101
|
+
"bitcoinjs-lib": "github:btc-vision/bitcoinjs-lib",
|
|
102
|
+
"browserify-zlib": "^0.2.0",
|
|
103
|
+
"buffer": "^6.0.3",
|
|
104
|
+
"ecpair": "^2.1.0",
|
|
105
|
+
"gulp": "^4.0.2",
|
|
106
|
+
"gulp-cached": "^1.1.1",
|
|
107
|
+
"gulp-logger": "^0.0.2",
|
|
108
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
109
|
+
"gulplog": "^2.2.0",
|
|
110
|
+
"process": "^0.11.10",
|
|
111
|
+
"ts-loader": "^9.5.1",
|
|
112
|
+
"ts-node": "^10.9.2"
|
|
113
|
+
}
|
|
114
114
|
}
|
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.76';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Network, networks } from 'bitcoinjs-lib';
|
|
2
2
|
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
3
|
import { Address } from '@btc-vision/bsi-binary';
|
|
4
|
-
import { WBTC_ADDRESS_REGTEST, WBTC_ADDRESS_TESTNET } from '../tokens.js';
|
|
4
|
+
import { WBTC_ADDRESS_FRACTAL, WBTC_ADDRESS_REGTEST, WBTC_ADDRESS_TESTNET } from '../tokens.js';
|
|
5
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @description Wrapped Bitcoin (wBTC) contract metadata.
|
|
@@ -24,15 +25,27 @@ export class wBTC extends ContractBaseMetadata {
|
|
|
24
25
|
|
|
25
26
|
protected readonly address: Address;
|
|
26
27
|
|
|
27
|
-
constructor(protected network: Network = networks.bitcoin) {
|
|
28
|
+
constructor(protected network: Network = networks.bitcoin, chainId: ChainId = ChainId.Bitcoin) {
|
|
28
29
|
super(network);
|
|
29
30
|
|
|
30
|
-
this.address = wBTC.getAddress(network);
|
|
31
|
+
this.address = wBTC.getAddress(network, chainId);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
private static getWBTCAddressForChain(chainId: ChainId): Address {
|
|
35
|
+
switch (chainId) {
|
|
36
|
+
case ChainId.Bitcoin:
|
|
37
|
+
return 'unknown';
|
|
38
|
+
case ChainId.Fractal:
|
|
39
|
+
return WBTC_ADDRESS_FRACTAL;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Invalid chainId: ${chainId}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static getAddress(network: Network = networks.bitcoin, chainId?: ChainId): Address {
|
|
34
46
|
switch (network.bech32) {
|
|
35
47
|
case networks.bitcoin.bech32:
|
|
48
|
+
if(chainId) return this.getWBTCAddressForChain(chainId);
|
|
36
49
|
return 'unknown';
|
|
37
50
|
case networks.regtest.bech32:
|
|
38
51
|
return WBTC_ADDRESS_REGTEST;
|