opnet 1.3.2 → 1.3.4

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.
Files changed (99) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/abi/shared/interfaces/motoswap/{IAdministeredOP20.d.ts → IMoto.d.ts} +2 -2
  3. package/browser/abi/shared/interfaces/motoswap/IMotoChef.d.ts +208 -0
  4. package/browser/abi/shared/interfaces/motoswap/IMotoswapPoolContract.d.ts +0 -4
  5. package/browser/abi/shared/interfaces/motoswap/IMotoswapStakingContract.d.ts +19 -3
  6. package/browser/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +13 -5
  7. package/browser/abi/shared/json/generic/STAKING_ABI.d.ts +0 -1
  8. package/{build/abi/shared/json/motoswap/REENTRANCY_GUARD_ABI.d.ts → browser/abi/shared/json/motoswap/MOTOCHEF_ABI.d.ts} +1 -1
  9. package/browser/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.d.ts +0 -1
  10. package/browser/abi/shared/json/motoswap/MOTO_ABI.d.ts +2 -0
  11. package/browser/abi/shared/json/motoswap/NATIVE_SWAP_ABI.d.ts +0 -1
  12. package/browser/fetch/fetch-browser.d.ts +4 -0
  13. package/browser/fetch/fetch.d.ts +2 -0
  14. package/browser/index.js +1 -1
  15. package/browser/opnet.d.ts +10 -12
  16. package/build/_version.d.ts +1 -1
  17. package/build/_version.js +1 -1
  18. package/build/abi/shared/interfaces/motoswap/{IAdministeredOP20.d.ts → IMoto.d.ts} +2 -2
  19. package/build/abi/shared/interfaces/motoswap/IMotoChef.d.ts +208 -0
  20. package/build/abi/shared/interfaces/motoswap/IMotoswapPoolContract.d.ts +0 -4
  21. package/build/abi/shared/interfaces/motoswap/IMotoswapStakingContract.d.ts +19 -3
  22. package/build/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +13 -5
  23. package/build/abi/shared/json/generic/STAKING_ABI.d.ts +0 -1
  24. package/build/abi/shared/json/generic/STAKING_ABI.js +1 -1
  25. package/{browser/abi/shared/json/motoswap/REENTRANCY_GUARD_ABI.d.ts → build/abi/shared/json/motoswap/MOTOCHEF_ABI.d.ts} +1 -1
  26. package/build/abi/shared/json/motoswap/MOTOCHEF_ABI.js +820 -0
  27. package/build/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.d.ts +0 -1
  28. package/build/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.js +45 -5
  29. package/build/abi/shared/json/motoswap/MOTO_ABI.d.ts +2 -0
  30. package/build/abi/shared/json/motoswap/{ADMINISTERD_OP_20_ABI.js → MOTO_ABI.js} +5 -13
  31. package/build/abi/shared/json/motoswap/NATIVE_SWAP_ABI.d.ts +0 -1
  32. package/build/abi/shared/json/motoswap/NATIVE_SWAP_ABI.js +15 -1
  33. package/build/abi/shared/json/opnet/OP_NET_ABI.js +7 -18
  34. package/build/contracts/Contract.js +2 -2
  35. package/build/fetch/fetch.d.ts +2 -0
  36. package/build/fetch/fetch.js +2 -0
  37. package/build/opnet.d.ts +10 -12
  38. package/build/opnet.js +10 -12
  39. package/build/providers/JSONRpcProvider.js +7 -1
  40. package/package.json +6 -4
  41. package/src/_version.ts +1 -1
  42. package/src/abi/shared/interfaces/motoswap/{IAdministeredOP20.ts → IMoto.ts} +4 -4
  43. package/src/abi/shared/interfaces/motoswap/IMotoChef.ts +485 -0
  44. package/src/abi/shared/interfaces/motoswap/IMotoswapPoolContract.ts +0 -5
  45. package/src/abi/shared/interfaces/motoswap/IMotoswapStakingContract.ts +50 -4
  46. package/src/abi/shared/interfaces/motoswap/INativeSwapContract.ts +19 -5
  47. package/src/abi/shared/json/generic/STAKING_ABI.ts +1 -7
  48. package/src/abi/shared/json/motoswap/MOTOCHEF_ABI.ts +831 -0
  49. package/src/abi/shared/json/motoswap/MOTOSWAP_FACTORY_ABI.ts +0 -6
  50. package/src/abi/shared/json/motoswap/MOTOSWAP_POOL_ABI.ts +0 -6
  51. package/src/abi/shared/json/motoswap/MOTOSWAP_ROUTER_ABI.ts +0 -3
  52. package/src/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.ts +51 -9
  53. package/src/abi/shared/json/motoswap/{ADMINISTERD_OP_20_ABI.ts → MOTO_ABI.ts} +7 -15
  54. package/src/abi/shared/json/motoswap/NATIVE_SWAP_ABI.ts +15 -7
  55. package/src/abi/shared/json/opnet/OP_NET_ABI.ts +7 -24
  56. package/src/contracts/CallResult.ts +1 -0
  57. package/src/contracts/Contract.ts +3 -3
  58. package/src/fetch/fetch-browser.js +5 -0
  59. package/src/fetch/fetch.ts +3 -0
  60. package/src/opnet.ts +10 -12
  61. package/src/providers/JSONRpcProvider.ts +9 -4
  62. package/webpack.config.js +1 -0
  63. package/browser/abi/shared/interfaces/motoswap/IMotoChefContract.d.ts +0 -229
  64. package/browser/abi/shared/interfaces/motoswap/IOwnableContract.d.ts +0 -12
  65. package/browser/abi/shared/interfaces/motoswap/IOwnableReentrancyGuardContract.d.ts +0 -13
  66. package/browser/abi/shared/interfaces/motoswap/IReentrancyGuardContract.d.ts +0 -7
  67. package/browser/abi/shared/interfaces/tests/IWBTCContract.d.ts +0 -13
  68. package/browser/abi/shared/json/motoswap/ADMINISTERD_OP_20_ABI.d.ts +0 -3
  69. package/browser/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.d.ts +0 -4
  70. package/browser/abi/shared/json/motoswap/OWNABLE_ABI.d.ts +0 -3
  71. package/browser/abi/shared/json/tests/WBTC_ABI.d.ts +0 -3
  72. package/build/abi/shared/interfaces/motoswap/IMotoChefContract.d.ts +0 -229
  73. package/build/abi/shared/interfaces/motoswap/IOwnableContract.d.ts +0 -12
  74. package/build/abi/shared/interfaces/motoswap/IOwnableContract.js +0 -1
  75. package/build/abi/shared/interfaces/motoswap/IOwnableReentrancyGuardContract.d.ts +0 -13
  76. package/build/abi/shared/interfaces/motoswap/IOwnableReentrancyGuardContract.js +0 -1
  77. package/build/abi/shared/interfaces/motoswap/IReentrancyGuardContract.d.ts +0 -7
  78. package/build/abi/shared/interfaces/motoswap/IReentrancyGuardContract.js +0 -1
  79. package/build/abi/shared/interfaces/tests/IWBTCContract.d.ts +0 -13
  80. package/build/abi/shared/interfaces/tests/IWBTCContract.js +0 -1
  81. package/build/abi/shared/json/motoswap/ADMINISTERD_OP_20_ABI.d.ts +0 -3
  82. package/build/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.d.ts +0 -4
  83. package/build/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.js +0 -508
  84. package/build/abi/shared/json/motoswap/OWNABLE_ABI.d.ts +0 -3
  85. package/build/abi/shared/json/motoswap/OWNABLE_ABI.js +0 -35
  86. package/build/abi/shared/json/motoswap/REENTRANCY_GUARD_ABI.js +0 -15
  87. package/build/abi/shared/json/tests/WBTC_ABI.d.ts +0 -3
  88. package/build/abi/shared/json/tests/WBTC_ABI.js +0 -57
  89. package/src/abi/shared/interfaces/motoswap/IMotoChefContract.ts +0 -484
  90. package/src/abi/shared/interfaces/motoswap/IOwnableContract.ts +0 -32
  91. package/src/abi/shared/interfaces/motoswap/IOwnableReentrancyGuardContract.ts +0 -33
  92. package/src/abi/shared/interfaces/motoswap/IReentrancyGuardContract.ts +0 -18
  93. package/src/abi/shared/interfaces/tests/IWBTCContract.ts +0 -35
  94. package/src/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.ts +0 -520
  95. package/src/abi/shared/json/motoswap/OWNABLE_ABI.ts +0 -38
  96. package/src/abi/shared/json/motoswap/REENTRANCY_GUARD_ABI.ts +0 -20
  97. package/src/abi/shared/json/tests/WBTC_ABI.ts +0 -73
  98. /package/build/abi/shared/interfaces/motoswap/{IAdministeredOP20.js → IMoto.js} +0 -0
  99. /package/build/abi/shared/interfaces/motoswap/{IMotoChefContract.js → IMotoChef.js} +0 -0
@@ -3,9 +3,6 @@ import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
3
  import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
4
  import { OP_NET_ABI } from '../opnet/OP_NET_ABI.js';
5
5
 
6
- /**
7
- * @category Events
8
- */
9
6
  export const MotoSwapFactoryEvents: BitcoinInterfaceAbi = [
10
7
  {
11
8
  name: 'PoolCreated',
@@ -27,9 +24,6 @@ export const MotoSwapFactoryEvents: BitcoinInterfaceAbi = [
27
24
  },
28
25
  ];
29
26
 
30
- /**
31
- * @category ABI
32
- */
33
27
  export const MotoSwapFactoryAbi: BitcoinInterfaceAbi = [
34
28
  {
35
29
  name: 'createPool',
@@ -3,9 +3,6 @@ import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
3
  import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
4
  import { OP_20_ABI } from '../opnet/OP_20_ABI.js';
5
5
 
6
- /**
7
- * @category Events
8
- */
9
6
  export const MotoSwapPoolEvents: BitcoinInterfaceAbi = [
10
7
  {
11
8
  name: 'PoolBurn',
@@ -89,9 +86,6 @@ export const MotoSwapPoolEvents: BitcoinInterfaceAbi = [
89
86
  },
90
87
  ];
91
88
 
92
- /**
93
- * @category ABI
94
- */
95
89
  export const MotoswapPoolAbi: BitcoinInterfaceAbi = [
96
90
  {
97
91
  name: 'initialize',
@@ -6,9 +6,6 @@ import { OP_NET_ABI } from '../opnet/OP_NET_ABI.js';
6
6
  import { MotoSwapFactoryEvents } from './MOTOSWAP_FACTORY_ABI.js';
7
7
  import { MotoSwapPoolEvents } from './MOTOSWAP_POOL_ABI.js';
8
8
 
9
- /**
10
- * @category ABI
11
- */
12
9
  export const MOTOSWAP_ROUTER_ABI: BitcoinInterfaceAbi = [
13
10
  /** Liquidity functions */
14
11
  {
@@ -2,10 +2,55 @@ import { ABIDataTypes } from '@btc-vision/transaction';
2
2
  import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
3
  import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
4
  import { OP_NET_ABI } from '../opnet/OP_NET_ABI.js';
5
- import OWNABLE_ABI from './OWNABLE_ABI.js';
6
- import { REENTRANCY_GUARD_ABI } from './REENTRANCY_GUARD_ABI.js';
7
5
 
8
- export const MotoswapStakingEvents: BitcoinInterfaceAbi = [
6
+ const MOTOSWAP_OWNABLE_REENTRANCY_GUARD_ABI: BitcoinInterfaceAbi = [
7
+ // Ownable
8
+ {
9
+ name: 'admin',
10
+ type: BitcoinAbiTypes.Function,
11
+ constant: true,
12
+ inputs: [],
13
+ outputs: [
14
+ {
15
+ name: 'adminAddress',
16
+ type: ABIDataTypes.ADDRESS,
17
+ },
18
+ ],
19
+ },
20
+ {
21
+ name: 'changeAdmin',
22
+ type: BitcoinAbiTypes.Function,
23
+ constant: false,
24
+ payable: false,
25
+ inputs: [
26
+ {
27
+ name: 'newAdmin',
28
+ type: ABIDataTypes.ADDRESS,
29
+ },
30
+ ],
31
+ outputs: [
32
+ {
33
+ name: 'success',
34
+ type: ABIDataTypes.BOOL,
35
+ },
36
+ ],
37
+ },
38
+
39
+ // Reentrancy guard
40
+ {
41
+ name: 'status',
42
+ inputs: [],
43
+ outputs: [
44
+ {
45
+ name: 'status',
46
+ type: ABIDataTypes.UINT256,
47
+ },
48
+ ],
49
+ type: BitcoinAbiTypes.Function,
50
+ },
51
+ ];
52
+
53
+ const MotoswapStakingEvents: BitcoinInterfaceAbi = [
9
54
  {
10
55
  name: 'RewardTokenAdded',
11
56
  type: BitcoinAbiTypes.Event,
@@ -163,15 +208,12 @@ export const MOTOSWAP_STAKING_ABI: BitcoinInterfaceAbi = [
163
208
  outputs: [{ name: 'success', type: ABIDataTypes.BOOL }],
164
209
  },
165
210
 
211
+ // Ownable Reentrancy Guard
212
+ ...MOTOSWAP_OWNABLE_REENTRANCY_GUARD_ABI,
213
+
166
214
  // Events
167
215
  ...MotoswapStakingEvents,
168
216
 
169
217
  // OP_NET
170
218
  ...OP_NET_ABI,
171
-
172
- // Reentrancy contract
173
- ...REENTRANCY_GUARD_ABI,
174
-
175
- // Ownable contract
176
- ...OWNABLE_ABI,
177
219
  ];
@@ -1,17 +1,16 @@
1
1
  import { ABIDataTypes } from '@btc-vision/transaction';
2
- import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
- import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
- import { OP_20_ABI } from '../opnet/OP_20_ABI.js';
2
+ import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes';
3
+ import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi';
4
+ import { OP_20_ABI } from '../opnet/OP_20_ABI';
5
5
 
6
- const ADMINISTERED_OP_20_ABI: BitcoinInterfaceAbi = [
6
+ export const MOTO_ABI: BitcoinInterfaceAbi = [
7
7
  {
8
8
  name: 'admin',
9
9
  type: BitcoinAbiTypes.Function,
10
- constant: true,
11
10
  inputs: [],
12
11
  outputs: [
13
12
  {
14
- name: 'ADDRESS',
13
+ name: 'adminAddress',
15
14
  type: ABIDataTypes.ADDRESS,
16
15
  },
17
16
  ],
@@ -19,11 +18,9 @@ const ADMINISTERED_OP_20_ABI: BitcoinInterfaceAbi = [
19
18
  {
20
19
  name: 'changeAdmin',
21
20
  type: BitcoinAbiTypes.Function,
22
- constant: false,
23
- payable: false,
24
21
  inputs: [
25
22
  {
26
- name: 'newAdmin',
23
+ name: 'to',
27
24
  type: ABIDataTypes.ADDRESS,
28
25
  },
29
26
  ],
@@ -37,8 +34,6 @@ const ADMINISTERED_OP_20_ABI: BitcoinInterfaceAbi = [
37
34
  {
38
35
  name: 'adminMint',
39
36
  type: BitcoinAbiTypes.Function,
40
- constant: false,
41
- payable: false,
42
37
  inputs: [
43
38
  {
44
39
  name: 'to',
@@ -59,8 +54,6 @@ const ADMINISTERED_OP_20_ABI: BitcoinInterfaceAbi = [
59
54
  {
60
55
  name: 'adminBurn',
61
56
  type: BitcoinAbiTypes.Function,
62
- constant: false,
63
- payable: false,
64
57
  inputs: [
65
58
  {
66
59
  name: 'from',
@@ -78,8 +71,7 @@ const ADMINISTERED_OP_20_ABI: BitcoinInterfaceAbi = [
78
71
  },
79
72
  ],
80
73
  },
74
+
81
75
  // OP_20
82
76
  ...OP_20_ABI,
83
77
  ];
84
-
85
- export default ADMINISTERED_OP_20_ABI;
@@ -3,10 +3,7 @@ import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
3
  import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
4
  import { OP_NET_ABI } from '../opnet/OP_NET_ABI.js';
5
5
 
6
- /**
7
- * @category Events
8
- */
9
- export const NativeSwapEvents: BitcoinInterfaceAbi = [
6
+ const NativeSwapEvents: BitcoinInterfaceAbi = [
10
7
  {
11
8
  name: 'LiquidityAdded',
12
9
  values: [
@@ -64,14 +61,25 @@ export const NativeSwapEvents: BitcoinInterfaceAbi = [
64
61
  values: [
65
62
  { name: 'depositAddress', type: ABIDataTypes.STRING },
66
63
  { name: 'amount', type: ABIDataTypes.UINT128 },
64
+ { name: 'providerId', type: ABIDataTypes.UINT256 },
65
+ ],
66
+ type: BitcoinAbiTypes.Event,
67
+ },
68
+ {
69
+ name: 'ActivateProvider',
70
+ values: [
71
+ { name: 'providerId', type: ABIDataTypes.UINT256 },
72
+ { name: 'listingAmount', type: ABIDataTypes.UINT128 },
67
73
  ],
68
74
  type: BitcoinAbiTypes.Event,
69
75
  },
76
+ {
77
+ name: 'FulfilledProvider',
78
+ values: [{ name: 'providerId', type: ABIDataTypes.UINT256 }],
79
+ type: BitcoinAbiTypes.Event,
80
+ },
70
81
  ];
71
82
 
72
- /**
73
- * @category ABI
74
- */
75
83
  export const NativeSwapAbi: BitcoinInterfaceAbi = [
76
84
  //=================================================
77
85
  // RESERVE
@@ -2,44 +2,27 @@ import { ABIDataTypes } from '@btc-vision/transaction';
2
2
  import { BitcoinAbiTypes } from '../../../BitcoinAbiTypes.js';
3
3
  import { BitcoinInterfaceAbi } from '../../../interfaces/BitcoinInterfaceAbi.js';
4
4
 
5
- /**
6
- * @category ABI
7
- */
8
5
  export const OP_NET_ABI: BitcoinInterfaceAbi = [
9
- // OP_NET
10
6
  {
11
- name: 'owner',
12
- constant: true,
13
- outputs: [
14
- {
15
- name: 'owner',
16
- type: ABIDataTypes.ADDRESS,
17
- },
18
- ],
7
+ name: 'address',
19
8
  type: BitcoinAbiTypes.Function,
20
- },
21
-
22
- {
23
- name: 'deployer',
24
- constant: true,
9
+ inputs: [],
25
10
  outputs: [
26
11
  {
27
- name: 'deployer',
12
+ name: 'address',
28
13
  type: ABIDataTypes.ADDRESS,
29
14
  },
30
15
  ],
31
- type: BitcoinAbiTypes.Function,
32
16
  },
33
-
34
17
  {
35
- name: 'address',
36
- constant: true,
18
+ name: 'contractDeployer',
19
+ type: BitcoinAbiTypes.Function,
20
+ inputs: [],
37
21
  outputs: [
38
22
  {
39
- name: 'address',
23
+ name: 'contractDeployer',
40
24
  type: ABIDataTypes.ADDRESS,
41
25
  },
42
26
  ],
43
- type: BitcoinAbiTypes.Function,
44
27
  },
45
28
  ];
@@ -152,6 +152,7 @@ export class CallResult<
152
152
  transaction.fundingTransaction,
153
153
  false,
154
154
  );
155
+
155
156
  if (!tx1 || tx1.error) {
156
157
  throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
157
158
  }
@@ -629,10 +629,10 @@ export abstract class IBaseContract<T extends BaseContractProperties> implements
629
629
  const gasPerSat = gasParameters.gasPerSat;
630
630
  const exactGas = ((gas / 1000000n) * gasPerSat) / 1000000n;
631
631
 
632
- // Add 15% extra gas
633
- const extraGas = (exactGas * 15n) / 100n;
632
+ // Add 25% extra gas
633
+ const extraGas = (exactGas * 25n) / 100n;
634
634
 
635
- return this.max(exactGas + extraGas, 330n);
635
+ return this.max(exactGas + extraGas, 330n) + 1n;
636
636
  }
637
637
 
638
638
  private max(a: bigint, b: bigint): bigint {
@@ -0,0 +1,5 @@
1
+ export default {
2
+ fetch(input, init) {
3
+ return window.fetch(input, init);
4
+ },
5
+ };
@@ -0,0 +1,3 @@
1
+ import { fetch } from 'undici';
2
+
3
+ export default fetch;
package/src/opnet.ts CHANGED
@@ -12,10 +12,10 @@ export * from './transactions/metadata/TransactionInput.js';
12
12
  export * from './transactions/metadata/TransactionOutput.js';
13
13
  export * from './transactions/Transaction.js';
14
14
 
15
+ export * from './transactions/interfaces/ProofOfWorkChallenge.js';
15
16
  export * from './transactions/interfaces/transactions/ICommonTransaction.js';
16
17
  export * from './transactions/interfaces/transactions/IDeploymentTransaction.js';
17
18
  export * from './transactions/interfaces/transactions/IInteractionTransaction.js';
18
- export * from './transactions/interfaces/ProofOfWorkChallenge.js';
19
19
 
20
20
  /** Providers */
21
21
  export * from './providers/AbstractRpcProvider.js';
@@ -45,8 +45,8 @@ export * from './contracts/ContractData.js';
45
45
  export * from './contracts/interfaces/IAccessList.js';
46
46
  export * from './contracts/interfaces/ICallResult.js';
47
47
  export * from './contracts/interfaces/IContract.js';
48
- export * from './contracts/OPNetEvent.js';
49
48
  export * from './contracts/interfaces/SimulatedTransaction.js';
49
+ export * from './contracts/OPNetEvent.js';
50
50
  export * from './contracts/TypeToStr.js';
51
51
 
52
52
  /** Abi */
@@ -86,25 +86,23 @@ export * from './bitcoin/UTXOs.js';
86
86
  export { ABIDataTypes } from '@btc-vision/transaction';
87
87
 
88
88
  /** ABI JSON */
89
+ export * from './abi/shared/json/generic/STAKING_ABI.js';
90
+ export * from './abi/shared/json/motoswap/MOTO_ABI.js';
91
+ export * from './abi/shared/json/motoswap/MOTOCHEF_ABI.js';
89
92
  export * from './abi/shared/json/motoswap/MOTOSWAP_FACTORY_ABI.js';
90
93
  export * from './abi/shared/json/motoswap/MOTOSWAP_POOL_ABI.js';
91
94
  export * from './abi/shared/json/motoswap/MOTOSWAP_ROUTER_ABI.js';
92
- export * from './abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.js';
93
- export * from './abi/shared/json/motoswap/ADMINISTERD_OP_20_ABI.js';
95
+ export * from './abi/shared/json/motoswap/NATIVE_SWAP_ABI.js';
94
96
  export * from './abi/shared/json/opnet/OP_20_ABI.js';
95
97
  export * from './abi/shared/json/opnet/OP_NET_ABI.js';
96
- export * from './abi/shared/json/generic/STAKING_ABI.js';
97
- export * from './abi/shared/json/tests/WBTC_ABI.js';
98
- export * from './abi/shared/json/motoswap/NATIVE_SWAP_ABI.js';
99
98
 
100
99
  /** ABI Interfaces */
100
+ export * from './abi/shared/interfaces/generic/IStackingContract.js';
101
+ export * from './abi/shared/interfaces/motoswap/IMoto.js';
102
+ export * from './abi/shared/interfaces/motoswap/IMotoChef.js';
101
103
  export * from './abi/shared/interfaces/motoswap/IMotoswapFactoryContract.js';
102
104
  export * from './abi/shared/interfaces/motoswap/IMotoswapPoolContract.js';
103
105
  export * from './abi/shared/interfaces/motoswap/IMotoswapRouterContract.js';
104
- export * from './abi/shared/interfaces/motoswap/IMotoChefContract.js';
105
- export * from './abi/shared/interfaces/motoswap/IAdministeredOP20.js';
106
+ export * from './abi/shared/interfaces/motoswap/INativeSwapContract.js';
106
107
  export * from './abi/shared/interfaces/opnet/IOP_20Contract.js';
107
108
  export * from './abi/shared/interfaces/opnet/IOP_NETContract.js';
108
- export * from './abi/shared/interfaces/generic/IStackingContract.js';
109
- export * from './abi/shared/interfaces/tests/IWBTCContract.js';
110
- export * from './abi/shared/interfaces/motoswap/INativeSwapContract.js';
@@ -3,6 +3,9 @@ import { AbstractRpcProvider } from './AbstractRpcProvider.js';
3
3
  import { JsonRpcPayload } from './interfaces/JSONRpc.js';
4
4
  import { JsonRpcCallResult, JsonRpcError, JsonRpcResult } from './interfaces/JSONRpcResult.js';
5
5
 
6
+ import fetch from '../fetch/fetch.js';
7
+ import { Response } from 'undici/types/fetch';
8
+
6
9
  /**
7
10
  * @description This class is used to provide a JSON RPC provider.
8
11
  * @class JSONRpcProvider
@@ -38,8 +41,12 @@ export class JSONRpcProvider extends AbstractRpcProvider {
38
41
  method: 'POST',
39
42
  headers: {
40
43
  'Content-Type': 'application/json',
41
- Connection: 'close',
42
44
  'User-Agent': 'OPNET/1.0',
45
+ 'Accept-Encoding': 'gzip, deflate, br',
46
+ Accept: 'application/json',
47
+ 'Accept-Charset': 'utf-8',
48
+ 'Accept-Language': 'en-US',
49
+ Connection: 'Keep-Alive',
43
50
  },
44
51
  body: JSON.stringify(payload),
45
52
  timeout: this.timeout,
@@ -54,9 +61,6 @@ export class JSONRpcProvider extends AbstractRpcProvider {
54
61
 
55
62
  clearTimeout(timeoutId);
56
63
 
57
- //const str = await resp.text();
58
- //fs.writeFileSync('response.json', str);
59
-
60
64
  const fetchedData = (await resp.json()) as JsonRpcResult | JsonRpcError;
61
65
  if (!fetchedData) {
62
66
  throw new Error('No data fetched');
@@ -64,6 +68,7 @@ export class JSONRpcProvider extends AbstractRpcProvider {
64
68
 
65
69
  return [fetchedData];
66
70
  } catch (e) {
71
+ console.log(e);
67
72
  const error = e as Error;
68
73
  if (error.name === 'AbortError') {
69
74
  throw new Error(`Request timed out after ${this.timeout}ms`);
package/webpack.config.js CHANGED
@@ -29,6 +29,7 @@ export default {
29
29
 
30
30
  assert: import.meta.resolve('assert/'),
31
31
  crypto: import.meta.resolve('./src/crypto/crypto-browser.js'),
32
+ undici: import.meta.resolve('./src/fetch/fetch-browser.js'),
32
33
  http: import.meta.resolve('stream-http/'),
33
34
  https: import.meta.resolve('https-browserify/'),
34
35
  os: import.meta.resolve('os-browserify/browser/'),
@@ -1,229 +0,0 @@
1
- import { Address } from '@btc-vision/transaction';
2
- import { CallResult, OPNetEvent } from '../../../../opnet.js';
3
- import { IOwnableReentrancyGuardContract } from './IOwnableReentrancyGuardContract.js';
4
- export type PoolInfo = {
5
- allocPoint: number;
6
- lastRewardBlock: number;
7
- accMotoPerShare: bigint;
8
- };
9
- export type UserInfo = {
10
- amount: bigint;
11
- rewardDebt: bigint;
12
- };
13
- export type Initialize = CallResult<{
14
- success: boolean;
15
- }, [
16
- OPNetEvent<LogPoolAdditionEvent>,
17
- OPNetEvent<LogInitEvent>
18
- ]>;
19
- export type GetLpToken = CallResult<{
20
- lpTokenAddress: Address;
21
- }>;
22
- export type GetLpTokens = CallResult<{
23
- lpTokens: Address[];
24
- }>;
25
- export type GetRewarder = CallResult<{
26
- rewarderAddress: Address;
27
- }>;
28
- export type GetPoolInfo = CallResult<PoolInfo>;
29
- export type GetPoolsLength = CallResult<{
30
- poolLength: bigint;
31
- }>;
32
- export type GetUserInfo = CallResult<UserInfo>;
33
- export type Pools = CallResult<{
34
- poolLength: number;
35
- poolsData: Uint8Array;
36
- }>;
37
- export type TotalAllocPoint = CallResult<{
38
- totalAllocPoint: bigint;
39
- }>;
40
- export type Devaddr = CallResult<{
41
- devaddr: Address;
42
- }>;
43
- export type MotoPerBlock = CallResult<{
44
- motoPerBlock: bigint;
45
- }>;
46
- export type BonusEndBlock = CallResult<{
47
- bonusEndBlock: bigint;
48
- }>;
49
- export type BonusMultiplier = CallResult<{
50
- bonusMultiplier: bigint;
51
- }>;
52
- export type TotalBtcStaked = CallResult<{
53
- totalBtcStaked: bigint;
54
- }>;
55
- export type TreasuryAddress = CallResult<{
56
- TreasuryAddress: string;
57
- }>;
58
- export type GetStakingTxId = CallResult<{
59
- stakingTxId: bigint;
60
- }>;
61
- export type GetStakingIndex = CallResult<{
62
- stakingIndex: bigint;
63
- }>;
64
- export type Add = CallResult<{
65
- success: boolean;
66
- }, [
67
- OPNetEvent<LogPoolAdditionEvent>
68
- ]>;
69
- export type Set = CallResult<{
70
- success: boolean;
71
- }, [
72
- OPNetEvent<LogSetPoolEvent>
73
- ]>;
74
- export type SetMigrator = CallResult<{
75
- success: boolean;
76
- }>;
77
- export type Migrate = CallResult<{
78
- success: boolean;
79
- }>;
80
- export type GetMultiplier = CallResult<{
81
- multiplier: bigint;
82
- }>;
83
- export type PendingMoto = CallResult<{
84
- pendingMoto: number;
85
- }>;
86
- export type MassUpdatePools = CallResult<{
87
- success: boolean;
88
- }>;
89
- export type UpdatePool = CallResult<PoolInfo, [OPNetEvent<LogUpdatePoolEvent>]>;
90
- export type Deposit = CallResult<{
91
- success: boolean;
92
- }, [
93
- OPNetEvent<DepositEvent>
94
- ]>;
95
- export type Withdraw = CallResult<{
96
- success: boolean;
97
- }, [
98
- OPNetEvent<WithdrawEvent>
99
- ]>;
100
- export type Harvest = CallResult<{
101
- success: boolean;
102
- }, [
103
- OPNetEvent<HarvestEvent>
104
- ]>;
105
- export type WithdrawAndHarvest = CallResult<{
106
- success: boolean;
107
- }, [
108
- OPNetEvent<WithdrawEvent>,
109
- OPNetEvent<HarvestEvent>
110
- ]>;
111
- export type SetDev = CallResult<{
112
- success: boolean;
113
- }>;
114
- export type SetMotoPerBlock = CallResult<{
115
- success: boolean;
116
- }>;
117
- export type SetBonusEndBlock = CallResult<{
118
- success: boolean;
119
- }>;
120
- export type SetBonusMultiplier = CallResult<{
121
- success: boolean;
122
- }>;
123
- export type EmergencyWithdraw = CallResult<{
124
- success: boolean;
125
- }, [
126
- OPNetEvent<EmergencyWithdrawEvent>
127
- ]>;
128
- export type StakeBtc = CallResult<{
129
- success: boolean;
130
- }, [
131
- OPNetEvent<StakeBTCEvent>
132
- ]>;
133
- export type UnstakeBtc = CallResult<{
134
- success: boolean;
135
- }, [
136
- OPNetEvent<UnstakeBTCEvent>
137
- ]>;
138
- export type LogInitEvent = {
139
- success: boolean;
140
- };
141
- export type LogPoolAdditionEvent = {
142
- readonly pid: bigint;
143
- readonly allocPoint: bigint;
144
- readonly lpToken: Address;
145
- readonly rewarder: Address;
146
- };
147
- export type LogSetPoolEvent = {
148
- readonly pid: bigint;
149
- readonly allocPoint: bigint;
150
- readonly rewarder: Address;
151
- readonly overwrite: boolean;
152
- };
153
- export type LogUpdatePoolEvent = {
154
- readonly pid: bigint;
155
- readonly lastRewardBlock: bigint;
156
- readonly lpSupply: bigint;
157
- readonly accMotoPerShare: bigint;
158
- };
159
- export type DepositEvent = {
160
- readonly user: Address;
161
- readonly pid: bigint;
162
- readonly amount: bigint;
163
- readonly to: Address;
164
- };
165
- export type WithdrawEvent = {
166
- readonly user: Address;
167
- readonly pid: bigint;
168
- readonly amount: bigint;
169
- readonly to: Address;
170
- };
171
- export type HarvestEvent = {
172
- readonly user: Address;
173
- readonly pid: bigint;
174
- readonly amount: bigint;
175
- };
176
- export type EmergencyWithdrawEvent = {
177
- readonly user: Address;
178
- readonly pid: bigint;
179
- readonly amount: bigint;
180
- readonly to: Address;
181
- };
182
- export type StakeBTCEvent = {
183
- readonly user: Address;
184
- readonly amount: bigint;
185
- readonly stakingTxId: bigint;
186
- readonly stakingIndex: bigint;
187
- };
188
- export type UnstakeBTCEvent = {
189
- readonly user: Address;
190
- readonly amount: bigint;
191
- readonly stakingTxId: bigint;
192
- readonly stakingIndex: bigint;
193
- };
194
- export interface IMotoChefContract extends IOwnableReentrancyGuardContract {
195
- initialize(MOTO: Address, premineAmount: bigint, devaddr: Address, motoPerBlock: bigint, bonusEndBlock: bigint, bonusMultiplier: bigint, treasuryAddress: string, btcAllocPoint: bigint): Promise<Initialize>;
196
- getLpToken(pid: bigint): Promise<GetLpToken>;
197
- getLpTokens(): Promise<GetLpTokens>;
198
- getPoolInfo(pid: bigint): Promise<GetPoolInfo>;
199
- getPoolsLength(): Promise<GetPoolsLength>;
200
- getUserInfo(pid: bigint, user: Address): Promise<GetUserInfo>;
201
- totalAllocPoint(): Promise<TotalAllocPoint>;
202
- devaddr(): Promise<Devaddr>;
203
- getMotoPerBlock(): Promise<MotoPerBlock>;
204
- getBonusEndBlock(): Promise<BonusEndBlock>;
205
- getBonusMultiplier(): Promise<BonusMultiplier>;
206
- totalBtcStaked(): Promise<TotalBtcStaked>;
207
- treasuryAddress(): Promise<TreasuryAddress>;
208
- getStakingTxId(): Promise<GetStakingTxId>;
209
- getStakingIndex(): Promise<GetStakingIndex>;
210
- setMotoPerBlock(motoPerBlock: bigint): Promise<SetMotoPerBlock>;
211
- setBonusEndBlock(bonusEndBlock: bigint): Promise<SetBonusEndBlock>;
212
- setBonusMultiplier(bonusMultiplier: bigint): Promise<SetBonusMultiplier>;
213
- add(allocPoint: bigint, lpToken: Address): Promise<Add>;
214
- set(pid: bigint, allocPoint: bigint): Promise<Set>;
215
- setMigrator(migrator: Address): Promise<SetMigrator>;
216
- migrate(pid: bigint): Promise<Migrate>;
217
- getMultiplier(from: bigint, to: bigint): Promise<GetMultiplier>;
218
- pendingMoto(pid: bigint, user: Address): Promise<PendingMoto>;
219
- massUpdatePools(length: number, pids: bigint[]): Promise<MassUpdatePools>;
220
- updatePool(pid: bigint): Promise<UpdatePool>;
221
- deposit(pid: bigint, amount: bigint, to: Address): Promise<Deposit>;
222
- withdraw(pid: bigint, amount: bigint, to: Address): Promise<Withdraw>;
223
- harvest(pid: bigint, to: Address): Promise<Harvest>;
224
- withdrawAndHarvest(pid: bigint, amount: bigint, to: Address): Promise<WithdrawAndHarvest>;
225
- emergencyWithdraw(pid: bigint, to: Address): Promise<EmergencyWithdraw>;
226
- setDev(devaddr: Address): Promise<SetDev>;
227
- stakeBtc(stakeAmount: bigint): Promise<StakeBtc>;
228
- unstakeBtc(): Promise<UnstakeBtc>;
229
- }
@@ -1,12 +0,0 @@
1
- import { Address } from '@btc-vision/transaction';
2
- import { CallResult, IOP_NETContract } from '../../../../opnet';
3
- export type Admin = CallResult<{
4
- adminAddress: Address;
5
- }>;
6
- export type ChangeAdmin = CallResult<{
7
- success: boolean;
8
- }>;
9
- export interface IOwnableContract extends IOP_NETContract {
10
- admin(): Promise<Admin>;
11
- changeAdmin(newAdmin: Address): Promise<ChangeAdmin>;
12
- }