opnet 1.2.11 → 1.2.13
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/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +2 -2
- package/browser/index.js +1 -1
- package/browser/providers/AbstractRpcProvider.d.ts +3 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +2 -2
- package/build/abi/shared/json/motoswap/NATIVE_SWAP_ABI.js +4 -4
- package/build/providers/AbstractRpcProvider.d.ts +3 -0
- package/build/providers/AbstractRpcProvider.js +9 -0
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/abi/shared/interfaces/motoswap/INativeSwapContract.ts +2 -2
- package/src/abi/shared/json/motoswap/NATIVE_SWAP_ABI.ts +4 -4
- package/src/providers/AbstractRpcProvider.ts +12 -0
|
@@ -27,6 +27,8 @@ export declare abstract class AbstractRpcProvider {
|
|
|
27
27
|
private chainId;
|
|
28
28
|
protected constructor(network: Network);
|
|
29
29
|
private _utxoManager;
|
|
30
|
+
private gasCache;
|
|
31
|
+
private lastFetchedGas;
|
|
30
32
|
get utxoManager(): UTXOsManager;
|
|
31
33
|
getPublicKeyInfo(address: string): Promise<Address>;
|
|
32
34
|
validateAddress(addr: string | Address, network: Network): AddressTypes | null;
|
|
@@ -43,6 +45,7 @@ export declare abstract class AbstractRpcProvider {
|
|
|
43
45
|
getStorageAt(address: string | Address, rawPointer: bigint | string, proofs?: boolean, height?: BigNumberish): Promise<StoredValue>;
|
|
44
46
|
call(to: string | Address, data: Buffer | string, from?: Address, height?: BigNumberish, simulatedTransaction?: ParsedSimulatedTransaction, accessList?: IAccessList): Promise<CallResult | ICallRequestError>;
|
|
45
47
|
gasParameters(): Promise<BlockGasParameters>;
|
|
48
|
+
private _gasParameters;
|
|
46
49
|
sendRawTransaction(tx: string, psbt: boolean): Promise<BroadcastedTransaction>;
|
|
47
50
|
getBlockWitness(height?: BigNumberish, trusted?: boolean, limit?: number, page?: number): Promise<BlockWitnesses>;
|
|
48
51
|
getReorg(fromBlock?: BigNumberish, toBlock?: BigNumberish): Promise<ReorgInformation[]>;
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.2.
|
|
1
|
+
export declare const version = "1.2.13";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -2,7 +2,7 @@ import { Address } from '@btc-vision/transaction';
|
|
|
2
2
|
import { CallResult } from '../../../../contracts/CallResult.js';
|
|
3
3
|
import { IOP_NETContract } from '../opnet/IOP_NETContract.js';
|
|
4
4
|
export type ReserveNativeSwap = CallResult<{
|
|
5
|
-
|
|
5
|
+
ok: boolean;
|
|
6
6
|
}>;
|
|
7
7
|
export type AddLiquidity = CallResult<{
|
|
8
8
|
ok: boolean;
|
|
@@ -14,7 +14,7 @@ export type ListLiquidity = CallResult<{
|
|
|
14
14
|
ok: boolean;
|
|
15
15
|
}>;
|
|
16
16
|
export type CancelListing = CallResult<{
|
|
17
|
-
|
|
17
|
+
ok: boolean;
|
|
18
18
|
}>;
|
|
19
19
|
export type CreatePool = CallResult<{
|
|
20
20
|
ok: boolean;
|
|
@@ -140,8 +140,8 @@ export const NativeSwapAbi = [
|
|
|
140
140
|
],
|
|
141
141
|
outputs: [
|
|
142
142
|
{
|
|
143
|
-
name: '
|
|
144
|
-
type: ABIDataTypes.
|
|
143
|
+
name: 'ok',
|
|
144
|
+
type: ABIDataTypes.BOOL,
|
|
145
145
|
},
|
|
146
146
|
],
|
|
147
147
|
type: BitcoinAbiTypes.Function,
|
|
@@ -184,8 +184,8 @@ export const NativeSwapAbi = [
|
|
|
184
184
|
],
|
|
185
185
|
outputs: [
|
|
186
186
|
{
|
|
187
|
-
name: '
|
|
188
|
-
type: ABIDataTypes.
|
|
187
|
+
name: 'ok',
|
|
188
|
+
type: ABIDataTypes.BOOL,
|
|
189
189
|
},
|
|
190
190
|
],
|
|
191
191
|
type: BitcoinAbiTypes.Function,
|
|
@@ -27,6 +27,8 @@ export declare abstract class AbstractRpcProvider {
|
|
|
27
27
|
private chainId;
|
|
28
28
|
protected constructor(network: Network);
|
|
29
29
|
private _utxoManager;
|
|
30
|
+
private gasCache;
|
|
31
|
+
private lastFetchedGas;
|
|
30
32
|
get utxoManager(): UTXOsManager;
|
|
31
33
|
getPublicKeyInfo(address: string): Promise<Address>;
|
|
32
34
|
validateAddress(addr: string | Address, network: Network): AddressTypes | null;
|
|
@@ -43,6 +45,7 @@ export declare abstract class AbstractRpcProvider {
|
|
|
43
45
|
getStorageAt(address: string | Address, rawPointer: bigint | string, proofs?: boolean, height?: BigNumberish): Promise<StoredValue>;
|
|
44
46
|
call(to: string | Address, data: Buffer | string, from?: Address, height?: BigNumberish, simulatedTransaction?: ParsedSimulatedTransaction, accessList?: IAccessList): Promise<CallResult | ICallRequestError>;
|
|
45
47
|
gasParameters(): Promise<BlockGasParameters>;
|
|
48
|
+
private _gasParameters;
|
|
46
49
|
sendRawTransaction(tx: string, psbt: boolean): Promise<BroadcastedTransaction>;
|
|
47
50
|
getBlockWitness(height?: BigNumberish, trusted?: boolean, limit?: number, page?: number): Promise<BlockWitnesses>;
|
|
48
51
|
getReorg(fromBlock?: BigNumberish, toBlock?: BigNumberish): Promise<ReorgInformation[]>;
|
|
@@ -17,6 +17,8 @@ export class AbstractRpcProvider {
|
|
|
17
17
|
this.network = network;
|
|
18
18
|
}
|
|
19
19
|
_utxoManager = new UTXOsManager(this);
|
|
20
|
+
gasCache;
|
|
21
|
+
lastFetchedGas = 0;
|
|
20
22
|
get utxoManager() {
|
|
21
23
|
return this._utxoManager;
|
|
22
24
|
}
|
|
@@ -209,6 +211,13 @@ export class AbstractRpcProvider {
|
|
|
209
211
|
return new CallResult(result, this);
|
|
210
212
|
}
|
|
211
213
|
async gasParameters() {
|
|
214
|
+
if (!this.gasCache || Date.now() - this.lastFetchedGas > 10000) {
|
|
215
|
+
this.lastFetchedGas = Date.now();
|
|
216
|
+
this.gasCache = await this._gasParameters();
|
|
217
|
+
}
|
|
218
|
+
return this.gasCache;
|
|
219
|
+
}
|
|
220
|
+
async _gasParameters() {
|
|
212
221
|
const payload = this.buildJsonRpcPayload(JSONRpcMethods.GAS, []);
|
|
213
222
|
const rawCall = await this.callPayloadSingle(payload);
|
|
214
223
|
if ('error' in rawCall) {
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -6,7 +6,7 @@ import { IOP_NETContract } from '../opnet/IOP_NETContract.js';
|
|
|
6
6
|
* @description Represents the result of the reserve function call.
|
|
7
7
|
*/
|
|
8
8
|
export type ReserveNativeSwap = CallResult<{
|
|
9
|
-
|
|
9
|
+
ok: boolean;
|
|
10
10
|
}>;
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -34,7 +34,7 @@ export type ListLiquidity = CallResult<{
|
|
|
34
34
|
* @description Represents the result of canceling a listing (new).
|
|
35
35
|
*/
|
|
36
36
|
export type CancelListing = CallResult<{
|
|
37
|
-
|
|
37
|
+
ok: boolean;
|
|
38
38
|
}>;
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -152,8 +152,8 @@ export const NativeSwapAbi: BitcoinInterfaceAbi = [
|
|
|
152
152
|
],
|
|
153
153
|
outputs: [
|
|
154
154
|
{
|
|
155
|
-
name: '
|
|
156
|
-
type: ABIDataTypes.
|
|
155
|
+
name: 'ok',
|
|
156
|
+
type: ABIDataTypes.BOOL,
|
|
157
157
|
},
|
|
158
158
|
],
|
|
159
159
|
type: BitcoinAbiTypes.Function,
|
|
@@ -204,8 +204,8 @@ export const NativeSwapAbi: BitcoinInterfaceAbi = [
|
|
|
204
204
|
],
|
|
205
205
|
outputs: [
|
|
206
206
|
{
|
|
207
|
-
name: '
|
|
208
|
-
type: ABIDataTypes.
|
|
207
|
+
name: 'ok',
|
|
208
|
+
type: ABIDataTypes.BOOL,
|
|
209
209
|
},
|
|
210
210
|
],
|
|
211
211
|
type: BitcoinAbiTypes.Function,
|
|
@@ -50,6 +50,9 @@ export abstract class AbstractRpcProvider {
|
|
|
50
50
|
|
|
51
51
|
private _utxoManager: UTXOsManager = new UTXOsManager(this);
|
|
52
52
|
|
|
53
|
+
private gasCache: BlockGasParameters | undefined;
|
|
54
|
+
private lastFetchedGas: number = 0;
|
|
55
|
+
|
|
53
56
|
/**
|
|
54
57
|
* Get the UTXO manager.
|
|
55
58
|
*/
|
|
@@ -453,6 +456,15 @@ export abstract class AbstractRpcProvider {
|
|
|
453
456
|
* @throws {Error} If something went wrong while calling the contract
|
|
454
457
|
*/
|
|
455
458
|
public async gasParameters(): Promise<BlockGasParameters> {
|
|
459
|
+
if (!this.gasCache || Date.now() - this.lastFetchedGas > 10000) {
|
|
460
|
+
this.lastFetchedGas = Date.now();
|
|
461
|
+
this.gasCache = await this._gasParameters();
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return this.gasCache;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
private async _gasParameters(): Promise<BlockGasParameters> {
|
|
456
468
|
const payload: JsonRpcPayload = this.buildJsonRpcPayload(JSONRpcMethods.GAS, []);
|
|
457
469
|
const rawCall: JsonRpcResult = await this.callPayloadSingle(payload);
|
|
458
470
|
|