@btc-vision/transaction 1.0.86 → 1.0.87
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/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/metadata/tokens.js +1 -1
- package/build/transaction/TransactionFactory.js +2 -0
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/metadata/tokens.ts +135 -135
- package/src/transaction/TransactionFactory.ts +498 -496
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.87";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.87';
|
package/build/metadata/tokens.js
CHANGED
|
@@ -11,7 +11,7 @@ export const MOTO_ADDRESS_TESTNET = 'tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw'
|
|
|
11
11
|
export const ROUTER_ADDRESS_TESTNET = 'tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt';
|
|
12
12
|
export const FACTORY_ADDRESS_FRACTAL = 'bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q';
|
|
13
13
|
export const POOL_ADDRESS_FRACTAL = 'bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h';
|
|
14
|
-
export const WBTC_ADDRESS_FRACTAL = '
|
|
14
|
+
export const WBTC_ADDRESS_FRACTAL = 'u fou';
|
|
15
15
|
export const MOTO_ADDRESS_FRACTAL = 'bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu';
|
|
16
16
|
export const ROUTER_ADDRESS_FRACTAL = 'bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn';
|
|
17
17
|
export var OPNetNetwork;
|
|
@@ -275,6 +275,8 @@ export class TransactionFactory {
|
|
|
275
275
|
return Buffer.concat([header, buf]).toString('hex');
|
|
276
276
|
}
|
|
277
277
|
getUTXOAsTransaction(tx, to, index) {
|
|
278
|
+
if (!tx.outs[index])
|
|
279
|
+
return [];
|
|
278
280
|
const out = tx.outs[index];
|
|
279
281
|
const newUtxo = {
|
|
280
282
|
transactionId: tx.getId(),
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.87';
|
package/src/metadata/tokens.ts
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
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 = 'bcrt1qxtpreq8zg7pp9wm550kjrhaa2r5kj6lhph9he5';
|
|
6
|
-
export const POOL_ADDRESS_REGTEST: Address = 'bcrt1qqg2a8076rwuruzetdyquj8fh5jxtc22pmh9vep';
|
|
7
|
-
export const WBTC_ADDRESS_REGTEST: Address = 'bcrt1qdr7sjgtnudda8zrfklw8l5cnrxum5hns7e46hf';
|
|
8
|
-
export const MOTO_ADDRESS_REGTEST: Address = 'bcrt1q8reuxx9naek4mqesrfsgdpjv3q7a5g2llkh6ua';
|
|
9
|
-
export const ROUTER_ADDRESS_REGTEST: Address = 'bcrt1qplnz54sca73t8a03nh494jatr9ffjg6ecarrj8';
|
|
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 = 'bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q';
|
|
20
|
-
export const POOL_ADDRESS_FRACTAL: Address = 'bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h';
|
|
21
|
-
export const WBTC_ADDRESS_FRACTAL: Address = '
|
|
22
|
-
export const MOTO_ADDRESS_FRACTAL: Address = 'bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu';
|
|
23
|
-
export const ROUTER_ADDRESS_FRACTAL: Address = 'bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn';
|
|
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();
|
|
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 = 'bcrt1qxtpreq8zg7pp9wm550kjrhaa2r5kj6lhph9he5';
|
|
6
|
+
export const POOL_ADDRESS_REGTEST: Address = 'bcrt1qqg2a8076rwuruzetdyquj8fh5jxtc22pmh9vep';
|
|
7
|
+
export const WBTC_ADDRESS_REGTEST: Address = 'bcrt1qdr7sjgtnudda8zrfklw8l5cnrxum5hns7e46hf';
|
|
8
|
+
export const MOTO_ADDRESS_REGTEST: Address = 'bcrt1q8reuxx9naek4mqesrfsgdpjv3q7a5g2llkh6ua';
|
|
9
|
+
export const ROUTER_ADDRESS_REGTEST: Address = 'bcrt1qplnz54sca73t8a03nh494jatr9ffjg6ecarrj8';
|
|
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 = 'bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q';
|
|
20
|
+
export const POOL_ADDRESS_FRACTAL: Address = 'bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h';
|
|
21
|
+
export const WBTC_ADDRESS_FRACTAL: Address = 'u fou';
|
|
22
|
+
export const MOTO_ADDRESS_FRACTAL: Address = 'bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu';
|
|
23
|
+
export const ROUTER_ADDRESS_FRACTAL: Address = 'bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn';
|
|
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();
|