opnet 1.2.26 → 1.3.0

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 (46) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/abi/shared/interfaces/motoswap/IMotoChefContract.d.ts +101 -34
  3. package/browser/abi/shared/interfaces/motoswap/IMotoswapFactoryContract.d.ts +6 -0
  4. package/browser/abi/shared/interfaces/motoswap/IMotoswapPoolContract.d.ts +13 -1
  5. package/browser/abi/shared/interfaces/motoswap/IMotoswapStakingContract.d.ts +4 -1
  6. package/browser/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +3 -4
  7. package/browser/abi/shared/interfaces/opnet/IOP_20Contract.d.ts +1 -1
  8. package/browser/index.js +1 -1
  9. package/browser/providers/AbstractRpcProvider.d.ts +1 -1
  10. package/build/_version.d.ts +1 -1
  11. package/build/_version.js +1 -1
  12. package/build/abi/shared/interfaces/motoswap/IMotoChefContract.d.ts +101 -34
  13. package/build/abi/shared/interfaces/motoswap/IMotoswapFactoryContract.d.ts +6 -0
  14. package/build/abi/shared/interfaces/motoswap/IMotoswapPoolContract.d.ts +13 -1
  15. package/build/abi/shared/interfaces/motoswap/IMotoswapStakingContract.d.ts +4 -1
  16. package/build/abi/shared/interfaces/motoswap/INativeSwapContract.d.ts +3 -4
  17. package/build/abi/shared/interfaces/opnet/IOP_20Contract.d.ts +1 -1
  18. package/build/abi/shared/json/motoswap/MOTOSWAP_FACTORY_ABI.js +27 -0
  19. package/build/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.js +115 -50
  20. package/build/abi/shared/json/motoswap/MOTOSWAP_POOL_ABI.js +12 -1
  21. package/build/abi/shared/json/motoswap/MOTOSWAP_ROUTER_ABI.js +2 -2
  22. package/build/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.js +14 -6
  23. package/build/abi/shared/json/motoswap/NATIVE_SWAP_ABI.js +107 -363
  24. package/build/abi/shared/json/opnet/OP_20_ABI.js +1 -1
  25. package/build/contracts/Contract.js +2 -12
  26. package/build/contracts/TypeToStr.js +0 -1
  27. package/build/providers/AbstractRpcProvider.d.ts +1 -1
  28. package/build/providers/AbstractRpcProvider.js +8 -4
  29. package/package.json +13 -13
  30. package/src/_version.ts +1 -1
  31. package/src/abi/shared/interfaces/motoswap/IMotoChefContract.ts +147 -62
  32. package/src/abi/shared/interfaces/motoswap/IMotoswapFactoryContract.ts +6 -0
  33. package/src/abi/shared/interfaces/motoswap/IMotoswapPoolContract.ts +9 -1
  34. package/src/abi/shared/interfaces/motoswap/IMotoswapStakingContract.ts +12 -7
  35. package/src/abi/shared/interfaces/motoswap/INativeSwapContract.ts +31 -11
  36. package/src/abi/shared/interfaces/opnet/IOP_20Contract.ts +1 -1
  37. package/src/abi/shared/json/motoswap/MOTOSWAP_FACTORY_ABI.ts +27 -0
  38. package/src/abi/shared/json/motoswap/MOTOSWAP_MOTOCHEF_ABI.ts +116 -51
  39. package/src/abi/shared/json/motoswap/MOTOSWAP_POOL_ABI.ts +12 -1
  40. package/src/abi/shared/json/motoswap/MOTOSWAP_ROUTER_ABI.ts +2 -2
  41. package/src/abi/shared/json/motoswap/MOTOSWAP_STAKING_ABI.ts +15 -6
  42. package/src/abi/shared/json/motoswap/NATIVE_SWAP_ABI.ts +128 -375
  43. package/src/abi/shared/json/opnet/OP_20_ABI.ts +1 -1
  44. package/src/contracts/Contract.ts +2 -13
  45. package/src/contracts/TypeToStr.ts +0 -1
  46. package/src/providers/AbstractRpcProvider.ts +21 -32
@@ -378,14 +378,6 @@ export abstract class IBaseContract<T extends BaseContractProperties> implements
378
378
  writer.writeAddress(value as Address);
379
379
  break;
380
380
  }
381
- case ABIDataTypes.TUPLE: {
382
- if (!(value instanceof Array)) {
383
- throw new Error(`Expected value to be of type Array (${name})`);
384
- }
385
-
386
- writer.writeTuple(value as bigint[]);
387
- break;
388
- }
389
381
  case ABIDataTypes.UINT8: {
390
382
  if (typeof value !== 'number') {
391
383
  throw new Error(`Expected value to be of type number (${name})`);
@@ -415,7 +407,7 @@ export abstract class IBaseContract<T extends BaseContractProperties> implements
415
407
  break;
416
408
  }
417
409
  case ABIDataTypes.ADDRESS_UINT256_TUPLE: {
418
- writer.writeAddressValueTupleMap(value as AddressMap<bigint>);
410
+ writer.writeAddressValueTuple(value as AddressMap<bigint>);
419
411
  break;
420
412
  }
421
413
  case ABIDataTypes.BYTES: {
@@ -553,9 +545,6 @@ export abstract class IBaseContract<T extends BaseContractProperties> implements
553
545
  case ABIDataTypes.ADDRESS:
554
546
  decodedResult = reader.readAddress();
555
547
  break;
556
- case ABIDataTypes.TUPLE:
557
- decodedResult = reader.readTuple();
558
- break;
559
548
  case ABIDataTypes.UINT8:
560
549
  decodedResult = reader.readU8();
561
550
  break;
@@ -641,7 +630,7 @@ export abstract class IBaseContract<T extends BaseContractProperties> implements
641
630
  const exactGas = ((gas / 1000000n) * gasPerSat) / 1000000n;
642
631
 
643
632
  // Add 15% extra gas
644
- const extraGas = (exactGas * 50n) / 100n;
633
+ const extraGas = (exactGas * 15n) / 100n;
645
634
 
646
635
  return this.max(exactGas + extraGas, 330n);
647
636
  }
@@ -23,5 +23,4 @@ export const AbiTypeToStr: { [key in ABIDataTypes]: string } = {
23
23
  [ABIDataTypes.ARRAY_OF_UINT8]: 'uint8[]',
24
24
  [ABIDataTypes.ARRAY_OF_BYTES]: 'bytes[]',
25
25
  [ABIDataTypes.ARRAY_OF_STRING]: 'string[]',
26
- [ABIDataTypes.TUPLE]: 'tuple256',
27
26
  };
@@ -132,8 +132,8 @@ export abstract class AbstractRpcProvider {
132
132
  * @returns {Promise<Buffer>} The preimage
133
133
  */
134
134
  public async getPreimage(): Promise<Buffer> {
135
- if(this.preimageCache) {
136
- if(this.preimageCache.expireAt > Date.now()) {
135
+ if (this.preimageCache) {
136
+ if (this.preimageCache.expireAt > Date.now()) {
137
137
  return this.preimageCache.preimage;
138
138
  }
139
139
  }
@@ -144,17 +144,22 @@ export abstract class AbstractRpcProvider {
144
144
  );
145
145
 
146
146
  const rawBlockNumber: JsonRpcResult = await this.callPayloadSingle(payload);
147
- const result: { preimage: string } = rawBlockNumber.result as {preimage: string};
147
+ const result: { preimage: string } = rawBlockNumber.result as { preimage: string };
148
148
 
149
- if(!result || result.preimage === '0000000000000000000000000000000000000000000000000000000000000000') {
150
- throw new Error('No preimage found. OPNet is probably not active yet on this blockchain.');
149
+ if (
150
+ !result ||
151
+ result.preimage === '0000000000000000000000000000000000000000000000000000000000000000'
152
+ ) {
153
+ throw new Error(
154
+ 'No preimage found. OPNet is probably not active yet on this blockchain.',
155
+ );
151
156
  }
152
157
 
153
158
  const preimage = Buffer.from(result.preimage, 'hex');
154
159
  this.preimageCache = {
155
160
  preimage: preimage,
156
- expireAt: Date.now() + 10_000
157
- }
161
+ expireAt: Date.now() + 10_000,
162
+ };
158
163
 
159
164
  return preimage;
160
165
  }
@@ -710,30 +715,6 @@ export abstract class AbstractRpcProvider {
710
715
  return data as JSONRpc2ResponseResult<JSONRpcMethods>;
711
716
  }
712
717
 
713
- /*
714
- * Generate parameters needed to wrap bitcoin.
715
- * @description This method is used to generate the parameters needed to wrap bitcoin.
716
- * @param {BigNumberish} amount The amount to wrap
717
- * @returns {Promise<WrappedGeneration>} The wrapped generation parameters
718
- * @example await requestTrustedPublicKeyForBitcoinWrapping(100000000n);
719
- * @throws {Error} If something went wrong while generating the parameters
720
- */
721
-
722
- /*public async requestTrustedPublicKeyForBitcoinWrapping(
723
- amount: BigNumberish,
724
- ): Promise<WrappedGeneration> {
725
- const payload: JsonRpcPayload = this.buildJsonRpcPayload(JSONRpcMethods.GENERATE, [
726
- GenerateTarget.WRAP,
727
- amount.toString(),
728
- ]);
729
-
730
- const rawPublicKey: JsonRpcResult = await this.callPayloadSingle(payload);
731
- const result: WrappedGenerationParameters =
732
- rawPublicKey.result as WrappedGenerationParameters;
733
-
734
- return new WrappedGeneration(result);
735
- }*/
736
-
737
718
  /**
738
719
  * Send multiple payloads. This method is used to send multiple payloads.
739
720
  * @param {JsonRpcPayload[]} payloads The payloads to send
@@ -778,12 +759,14 @@ export abstract class AbstractRpcProvider {
778
759
  * Get the public key information.
779
760
  * @description This method is used to get the public key information.
780
761
  * @param {string | string[] | Address | Address[]} addresses The address or addresses to get the public key information of
762
+ * @param logErrors
781
763
  * @returns {Promise<AddressesInfo>} The public keys information
782
764
  * @example await getPublicKeysInfo(['addressA', 'addressB']);
783
765
  * @throws {Error} If the address is invalid
784
766
  */
785
767
  public async getPublicKeysInfo(
786
768
  addresses: string | string[] | Address | Address[],
769
+ logErrors: boolean = false,
787
770
  ): Promise<AddressesInfo> {
788
771
  const addressArray = Array.isArray(addresses) ? addresses : [addresses];
789
772
 
@@ -808,7 +791,13 @@ export abstract class AbstractRpcProvider {
808
791
  for (const pubKey of keys) {
809
792
  const pubKeyValue = result[pubKey];
810
793
  if ('error' in pubKeyValue) {
811
- throw new Error(`Error fetching public key info: ${pubKeyValue.error}`);
794
+ if (logErrors) {
795
+ console.error(
796
+ `Error fetching public key info for ${pubKey}: ${pubKeyValue.error}`,
797
+ );
798
+ }
799
+
800
+ continue;
812
801
  }
813
802
 
814
803
  response[pubKey] = pubKeyValue.originalPubKey