@btc-vision/transaction 1.0.73 → 1.0.75
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 +1 -1
- 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.75";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.75';
|
|
@@ -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 = 'bcrt1qjl0u4ugwsy4znp7v7s549p2yrrvv856reu4ltz';
|
|
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
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.75';
|
|
@@ -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;
|
package/src/metadata/tokens.ts
CHANGED
|
@@ -1,15 +1,135 @@
|
|
|
1
|
-
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
1
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { ChainId } from '../network/ChainId.js';
|
|
3
|
+
|
|
4
|
+
// Addresses Regtest
|
|
5
|
+
export const FACTORY_ADDRESS_REGTEST: Address = 'bcrt1qgph2k9dahptnz2vu72ezd9r2p4phjm2pkgu7ht';
|
|
6
|
+
export const POOL_ADDRESS_REGTEST: Address = 'bcrt1q5nkjpjmh6xwweprcyeylwdw7aud4een7p9pphd';
|
|
7
|
+
export const WBTC_ADDRESS_REGTEST: Address = 'bcrt1qdr7sjgtnudda8zrfklw8l5cnrxum5hns7e46hf';
|
|
8
|
+
export const MOTO_ADDRESS_REGTEST: Address = 'bcrt1q8reuxx9naek4mqesrfsgdpjv3q7a5g2llkh6ua';
|
|
9
|
+
export const ROUTER_ADDRESS_REGTEST: Address = 'bcrt1qjl0u4ugwsy4znp7v7s549p2yrrvv856reu4ltz';
|
|
10
|
+
|
|
11
|
+
// Addresses Testnet
|
|
12
|
+
export const FACTORY_ADDRESS_TESTNET: Address = 'tb1qgev5kldhp5zvg6j8t9vl6x4phkrwn8nk9felxh';
|
|
13
|
+
export const POOL_ADDRESS_TESTNET: Address = 'tb1q6a7yw353hjmresphupytw5vczpqxtg4yrupayk';
|
|
14
|
+
export const WBTC_ADDRESS_TESTNET: Address = 'tb1qp28xna6pv47x6wflcplhu0a9hkld5shtvjx6xv';
|
|
15
|
+
export const MOTO_ADDRESS_TESTNET: Address = 'tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw';
|
|
16
|
+
export const ROUTER_ADDRESS_TESTNET: Address = 'tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt';
|
|
17
|
+
|
|
18
|
+
// Addresses Fractal
|
|
19
|
+
export const FACTORY_ADDRESS_FRACTAL: Address = 'bc1q4h9l3ul7d06sne768y5r8jv9qvmx3jrzvdjpj5';
|
|
20
|
+
export const POOL_ADDRESS_FRACTAL: Address = 'bc1q3x6pfdvz647t7rq5zdzsy62qw5cgld092sfxsy';
|
|
21
|
+
export const WBTC_ADDRESS_FRACTAL: Address = 'bc1qeras4z6y2nx5ugqckx90wxdd02uyh8mdqptfhs';
|
|
22
|
+
export const MOTO_ADDRESS_FRACTAL: Address = 'bc1q7xnvxz7tjxdhhp7wj2dp2qm5m9sz8mveueq649';
|
|
23
|
+
export const ROUTER_ADDRESS_FRACTAL: Address = 'bc1qc8ysj702pktdc8rlxjxn3kslqnk3g7mavaa0ef';
|
|
24
|
+
|
|
25
|
+
export enum OPNetNetwork {
|
|
26
|
+
Mainnet = 'mainnet',
|
|
27
|
+
Testnet = 'testnet',
|
|
28
|
+
Regtest = 'regtest',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface OPNetTokenMetadata {
|
|
32
|
+
readonly factory: Address;
|
|
33
|
+
readonly pool: Address;
|
|
34
|
+
readonly wbtc: Address;
|
|
35
|
+
readonly moto: Address;
|
|
36
|
+
readonly router: Address;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class OPNetTokenAddressManager {
|
|
40
|
+
private readonly metadata: {
|
|
41
|
+
[key in ChainId]: { [key in OPNetNetwork]?: OPNetTokenMetadata };
|
|
42
|
+
} = {
|
|
43
|
+
[ChainId.Bitcoin]: {
|
|
44
|
+
[OPNetNetwork.Testnet]: {
|
|
45
|
+
factory: FACTORY_ADDRESS_TESTNET,
|
|
46
|
+
pool: POOL_ADDRESS_TESTNET,
|
|
47
|
+
wbtc: WBTC_ADDRESS_TESTNET,
|
|
48
|
+
moto: MOTO_ADDRESS_TESTNET,
|
|
49
|
+
router: ROUTER_ADDRESS_TESTNET,
|
|
50
|
+
},
|
|
51
|
+
[OPNetNetwork.Regtest]: {
|
|
52
|
+
factory: FACTORY_ADDRESS_REGTEST,
|
|
53
|
+
pool: POOL_ADDRESS_REGTEST,
|
|
54
|
+
wbtc: WBTC_ADDRESS_REGTEST,
|
|
55
|
+
moto: MOTO_ADDRESS_REGTEST,
|
|
56
|
+
router: ROUTER_ADDRESS_REGTEST,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
[ChainId.Fractal]: {
|
|
60
|
+
[OPNetNetwork.Mainnet]: {
|
|
61
|
+
factory: FACTORY_ADDRESS_FRACTAL,
|
|
62
|
+
pool: POOL_ADDRESS_FRACTAL,
|
|
63
|
+
wbtc: WBTC_ADDRESS_FRACTAL,
|
|
64
|
+
moto: MOTO_ADDRESS_FRACTAL,
|
|
65
|
+
router: ROUTER_ADDRESS_FRACTAL,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
public getFactoryAddress(network: OPNetNetwork, chainId: ChainId): Address {
|
|
71
|
+
const address = this.metadata[chainId][network]?.factory;
|
|
72
|
+
|
|
73
|
+
if (!address) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Factory address not found for network ${network} and chainId ${chainId}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return address;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public getPoolAddress(network: OPNetNetwork, chainId: ChainId): Address {
|
|
83
|
+
const address = this.metadata[chainId][network]?.pool;
|
|
84
|
+
|
|
85
|
+
if (!address) {
|
|
86
|
+
throw new Error(`Pool address not found for network ${network} and chainId ${chainId}`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return address;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public getWBTCAddress(network: OPNetNetwork, chainId: ChainId): Address {
|
|
93
|
+
const address = this.metadata[chainId][network]?.wbtc;
|
|
94
|
+
|
|
95
|
+
if (!address) {
|
|
96
|
+
throw new Error(`WBTC address not found for network ${network} and chainId ${chainId}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return address;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public getMOTOAddress(network: OPNetNetwork, chainId: ChainId): Address {
|
|
103
|
+
const address = this.metadata[chainId][network]?.moto;
|
|
104
|
+
|
|
105
|
+
if (!address) {
|
|
106
|
+
throw new Error(`MOTO address not found for network ${network} and chainId ${chainId}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return address;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public getRouterAddress(network: OPNetNetwork, chainId: ChainId): Address {
|
|
113
|
+
const address = this.metadata[chainId][network]?.router;
|
|
114
|
+
|
|
115
|
+
if (!address) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Router address not found for network ${network} and chainId ${chainId}`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return address;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public getAddresses(network: OPNetNetwork, chainId: ChainId): OPNetTokenMetadata {
|
|
125
|
+
const metadata = this.metadata[chainId][network];
|
|
126
|
+
|
|
127
|
+
if (!metadata) {
|
|
128
|
+
throw new Error(`Metadata not found for network ${network} and chainId ${chainId}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return metadata;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const OPNetMetadata: OPNetTokenAddressManager = new OPNetTokenAddressManager();
|
package/src/opnet.ts
CHANGED
|
@@ -46,6 +46,7 @@ export * from './transaction/builders/DeploymentTransaction.js';
|
|
|
46
46
|
/** wBTC */
|
|
47
47
|
export * from './wbtc/WrappedGenerationParameters.js';
|
|
48
48
|
export * from './wbtc/Generate.js';
|
|
49
|
+
export * from './network/ChainId.js';
|
|
49
50
|
|
|
50
51
|
/** Utils */
|
|
51
52
|
export * from './utils/BitcoinUtils.js';
|