opnet 1.2.25 → 1.2.27

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.
@@ -27,12 +27,14 @@ export declare abstract class AbstractRpcProvider {
27
27
  private chainId;
28
28
  private gasCache;
29
29
  private lastFetchedGas;
30
+ private preimageCache;
30
31
  protected constructor(network: Network);
31
32
  private _utxoManager;
32
33
  get utxoManager(): UTXOsManager;
33
34
  getPublicKeyInfo(address: string): Promise<Address>;
34
35
  validateAddress(addr: string | Address, network: Network): AddressTypes | null;
35
36
  getBlockNumber(): Promise<bigint>;
37
+ getPreimage(): Promise<Buffer>;
36
38
  getBlock(blockNumberOrHash: BlockTag, prefetchTxs?: boolean): Promise<Block>;
37
39
  getBlocks(blockNumbers: BlockTag[], prefetchTxs?: boolean): Promise<Block[]>;
38
40
  getBlockByHash(blockHash: string): Promise<Block>;
@@ -54,7 +56,7 @@ export declare abstract class AbstractRpcProvider {
54
56
  callPayloadSingle(payload: JsonRpcPayload): Promise<JsonRpcResult>;
55
57
  callMultiplePayloads(payloads: JsonRpcPayload[]): Promise<JsonRpcCallResult>;
56
58
  buildJsonRpcPayload<T extends JSONRpcMethods>(method: T, params: unknown[]): JsonRpcPayload;
57
- getPublicKeysInfo(addresses: string | string[] | Address | Address[]): Promise<AddressesInfo>;
59
+ getPublicKeysInfo(addresses: string | string[] | Address | Address[], logErrors?: boolean): Promise<AddressesInfo>;
58
60
  protected abstract providerUrl(url: string): string;
59
61
  private _gasParameters;
60
62
  private parseSimulatedTransaction;
@@ -7,14 +7,14 @@ export declare enum JSONRpcMethods {
7
7
  GAS = "btc_gas",
8
8
  GET_TRANSACTION_BY_HASH = "btc_getTransactionByHash",
9
9
  BROADCAST_TRANSACTION = "btc_sendRawTransaction",
10
- GENERATE = "btc_generate",
10
+ TRANSACTION_PREIMAGE = "btc_preimage",
11
+ PUBLIC_KEY_INFO = "btc_publicKeyInfo",
11
12
  GET_UTXOS = "btc_getUTXOs",
13
+ GET_BALANCE = "btc_getBalance",
12
14
  BLOCK_WITNESS = "btc_blockWitness",
13
15
  GET_TRANSACTION_RECEIPT = "btc_getTransactionReceipt",
14
16
  GET_CODE = "btc_getCode",
15
17
  GET_STORAGE_AT = "btc_getStorageAt",
16
- GET_BALANCE = "btc_getBalance",
17
18
  CALL = "btc_call",
18
- SIMULATE = "btc_simulate",
19
- PUBLIC_KEY_INFO = "btc_publicKeyInfo"
19
+ SIMULATE = "btc_simulate"
20
20
  }
@@ -1 +1 @@
1
- export declare const version = "1.2.25";
1
+ export declare const version = "1.2.27";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.2.25';
1
+ export const version = '1.2.27';
@@ -51,17 +51,19 @@ export class CallResult {
51
51
  if (!UTXOs || UTXOs.length === 0) {
52
52
  throw new Error('No UTXOs found');
53
53
  }
54
+ const preimage = await this.#provider.getPreimage();
54
55
  const params = {
55
56
  calldata: this.calldata,
56
57
  priorityFee: priorityFee,
57
58
  gasSatFee: this.estimatedSatGas,
58
59
  feeRate: interactionParams.feeRate || 10,
59
60
  from: interactionParams.refundTo,
60
- signer: interactionParams.signer,
61
61
  utxos: UTXOs,
62
62
  to: this.to,
63
63
  network: interactionParams.network,
64
64
  optionalOutputs: interactionParams.extraOutputs || [],
65
+ signer: interactionParams.signer,
66
+ preimage: preimage,
65
67
  };
66
68
  const transaction = await factory.signInteraction(params);
67
69
  const tx1 = await this.#provider.sendRawTransaction(transaction.fundingTransaction, false);
@@ -27,12 +27,14 @@ export declare abstract class AbstractRpcProvider {
27
27
  private chainId;
28
28
  private gasCache;
29
29
  private lastFetchedGas;
30
+ private preimageCache;
30
31
  protected constructor(network: Network);
31
32
  private _utxoManager;
32
33
  get utxoManager(): UTXOsManager;
33
34
  getPublicKeyInfo(address: string): Promise<Address>;
34
35
  validateAddress(addr: string | Address, network: Network): AddressTypes | null;
35
36
  getBlockNumber(): Promise<bigint>;
37
+ getPreimage(): Promise<Buffer>;
36
38
  getBlock(blockNumberOrHash: BlockTag, prefetchTxs?: boolean): Promise<Block>;
37
39
  getBlocks(blockNumbers: BlockTag[], prefetchTxs?: boolean): Promise<Block[]>;
38
40
  getBlockByHash(blockHash: string): Promise<Block>;
@@ -54,7 +56,7 @@ export declare abstract class AbstractRpcProvider {
54
56
  callPayloadSingle(payload: JsonRpcPayload): Promise<JsonRpcResult>;
55
57
  callMultiplePayloads(payloads: JsonRpcPayload[]): Promise<JsonRpcCallResult>;
56
58
  buildJsonRpcPayload<T extends JSONRpcMethods>(method: T, params: unknown[]): JsonRpcPayload;
57
- getPublicKeysInfo(addresses: string | string[] | Address | Address[]): Promise<AddressesInfo>;
59
+ getPublicKeysInfo(addresses: string | string[] | Address | Address[], logErrors?: boolean): Promise<AddressesInfo>;
58
60
  protected abstract providerUrl(url: string): string;
59
61
  private _gasParameters;
60
62
  private parseSimulatedTransaction;
@@ -15,6 +15,7 @@ export class AbstractRpcProvider {
15
15
  chainId;
16
16
  gasCache;
17
17
  lastFetchedGas = 0;
18
+ preimageCache;
18
19
  constructor(network) {
19
20
  this.network = network;
20
21
  }
@@ -53,6 +54,26 @@ export class AbstractRpcProvider {
53
54
  const result = rawBlockNumber.result;
54
55
  return BigInt(result);
55
56
  }
57
+ async getPreimage() {
58
+ if (this.preimageCache) {
59
+ if (this.preimageCache.expireAt > Date.now()) {
60
+ return this.preimageCache.preimage;
61
+ }
62
+ }
63
+ const payload = this.buildJsonRpcPayload(JSONRpcMethods.TRANSACTION_PREIMAGE, []);
64
+ const rawBlockNumber = await this.callPayloadSingle(payload);
65
+ const result = rawBlockNumber.result;
66
+ if (!result ||
67
+ result.preimage === '0000000000000000000000000000000000000000000000000000000000000000') {
68
+ throw new Error('No preimage found. OPNet is probably not active yet on this blockchain.');
69
+ }
70
+ const preimage = Buffer.from(result.preimage, 'hex');
71
+ this.preimageCache = {
72
+ preimage: preimage,
73
+ expireAt: Date.now() + 10_000,
74
+ };
75
+ return preimage;
76
+ }
56
77
  async getBlock(blockNumberOrHash, prefetchTxs = false) {
57
78
  const method = typeof blockNumberOrHash === 'string'
58
79
  ? JSONRpcMethods.GET_BLOCK_BY_HASH
@@ -341,7 +362,7 @@ export class AbstractRpcProvider {
341
362
  jsonrpc: '2.0',
342
363
  };
343
364
  }
344
- async getPublicKeysInfo(addresses) {
365
+ async getPublicKeysInfo(addresses, logErrors = false) {
345
366
  const addressArray = Array.isArray(addresses) ? addresses : [addresses];
346
367
  addressArray.forEach((addr) => {
347
368
  if (this.validateAddress(addr, this.network) === null) {
@@ -360,7 +381,10 @@ export class AbstractRpcProvider {
360
381
  for (const pubKey of keys) {
361
382
  const pubKeyValue = result[pubKey];
362
383
  if ('error' in pubKeyValue) {
363
- throw new Error(`Error fetching public key info: ${pubKeyValue.error}`);
384
+ if (logErrors) {
385
+ console.error(`Error fetching public key info for ${pubKey}: ${pubKeyValue.error}`);
386
+ }
387
+ continue;
364
388
  }
365
389
  response[pubKey] = pubKeyValue.originalPubKey
366
390
  ? Address.fromString(pubKeyValue.originalPubKey)
@@ -7,14 +7,14 @@ export declare enum JSONRpcMethods {
7
7
  GAS = "btc_gas",
8
8
  GET_TRANSACTION_BY_HASH = "btc_getTransactionByHash",
9
9
  BROADCAST_TRANSACTION = "btc_sendRawTransaction",
10
- GENERATE = "btc_generate",
10
+ TRANSACTION_PREIMAGE = "btc_preimage",
11
+ PUBLIC_KEY_INFO = "btc_publicKeyInfo",
11
12
  GET_UTXOS = "btc_getUTXOs",
13
+ GET_BALANCE = "btc_getBalance",
12
14
  BLOCK_WITNESS = "btc_blockWitness",
13
15
  GET_TRANSACTION_RECEIPT = "btc_getTransactionReceipt",
14
16
  GET_CODE = "btc_getCode",
15
17
  GET_STORAGE_AT = "btc_getStorageAt",
16
- GET_BALANCE = "btc_getBalance",
17
18
  CALL = "btc_call",
18
- SIMULATE = "btc_simulate",
19
- PUBLIC_KEY_INFO = "btc_publicKeyInfo"
19
+ SIMULATE = "btc_simulate"
20
20
  }
@@ -8,14 +8,14 @@ export var JSONRpcMethods;
8
8
  JSONRpcMethods["GAS"] = "btc_gas";
9
9
  JSONRpcMethods["GET_TRANSACTION_BY_HASH"] = "btc_getTransactionByHash";
10
10
  JSONRpcMethods["BROADCAST_TRANSACTION"] = "btc_sendRawTransaction";
11
- JSONRpcMethods["GENERATE"] = "btc_generate";
11
+ JSONRpcMethods["TRANSACTION_PREIMAGE"] = "btc_preimage";
12
+ JSONRpcMethods["PUBLIC_KEY_INFO"] = "btc_publicKeyInfo";
12
13
  JSONRpcMethods["GET_UTXOS"] = "btc_getUTXOs";
14
+ JSONRpcMethods["GET_BALANCE"] = "btc_getBalance";
13
15
  JSONRpcMethods["BLOCK_WITNESS"] = "btc_blockWitness";
14
16
  JSONRpcMethods["GET_TRANSACTION_RECEIPT"] = "btc_getTransactionReceipt";
15
17
  JSONRpcMethods["GET_CODE"] = "btc_getCode";
16
18
  JSONRpcMethods["GET_STORAGE_AT"] = "btc_getStorageAt";
17
- JSONRpcMethods["GET_BALANCE"] = "btc_getBalance";
18
19
  JSONRpcMethods["CALL"] = "btc_call";
19
20
  JSONRpcMethods["SIMULATE"] = "btc_simulate";
20
- JSONRpcMethods["PUBLIC_KEY_INFO"] = "btc_publicKeyInfo";
21
21
  })(JSONRpcMethods || (JSONRpcMethods = {}));
package/package.json CHANGED
@@ -1,112 +1,112 @@
1
1
  {
2
- "name": "opnet",
3
- "type": "module",
4
- "version": "1.2.25",
5
- "author": "OP_NET",
6
- "description": "The perfect library for building Bitcoin-based applications.",
7
- "engines": {
8
- "node": ">=21.0.0"
2
+ "name": "opnet",
3
+ "type": "module",
4
+ "version": "1.2.27",
5
+ "author": "OP_NET",
6
+ "description": "The perfect library for building Bitcoin-based applications.",
7
+ "engines": {
8
+ "node": ">=21.0.0"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "browser": "./browser/index.js",
13
+ "import": "./build/index.js",
14
+ "require": "./build/index.js",
15
+ "types": "./build/index.d.ts"
9
16
  },
10
- "exports": {
11
- ".": {
12
- "browser": "./browser/index.js",
13
- "import": "./build/index.js",
14
- "require": "./build/index.js",
15
- "types": "./build/index.d.ts"
16
- },
17
- "./browser": {
18
- "import": "./browser/index.js",
19
- "require": "./browser/index.js",
20
- "types": "./browser/index.d.ts"
21
- }
22
- },
23
- "browser": {
24
- "./build/index.d.ts": "./browser/index.d.ts",
25
- "./build/index.js": "./browser/index.js",
26
- "Buffer": "buffer",
27
- "crypto": "./src/crypto/crypto-browser.js",
28
- "stream": "stream-browserify"
29
- },
30
- "homepage": "https://opnet.org",
31
- "keywords": [
32
- "opnet",
33
- "bsi",
34
- "bsi-bitcoin-rpc",
35
- "bitcoin",
36
- "btc",
37
- "bitcoin smart contracts",
38
- "smart inscriptions",
39
- "ordinals"
40
- ],
41
- "license": "MIT",
42
- "main": "build/index.js",
43
- "types": "build/index.d.ts",
44
- "typings": "build/index.d.ts",
45
- "module": "build/index.js",
46
- "publishConfig": {
47
- "access": "public",
48
- "tag": "latest"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "git://github.com/btc-vision/opnet.git"
53
- },
54
- "scripts": {
55
- "watch": "gulp watch",
56
- "build": "gulp build",
57
- "test": "jest --runInBand",
58
- "setup": "npm i && npm run build",
59
- "browserBuild": "webpack --mode production",
60
- "docs": "typedoc --out docs --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/scripts/test.ts --exclude src/index.ts src"
61
- },
62
- "devDependencies": {
63
- "@babel/core": "^7.26.8",
64
- "@babel/plugin-proposal-class-properties": "^7.18.6",
65
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
66
- "@babel/plugin-transform-runtime": "^7.26.8",
67
- "@babel/preset-env": "^7.26.8",
68
- "@babel/preset-flow": "^7.25.9",
69
- "@babel/preset-react": "^7.26.3",
70
- "@babel/preset-typescript": "^7.26.0",
71
- "@eslint/js": "^9.20.0",
72
- "@types/node": "^22.13.2",
73
- "@types/sha.js": "^2.4.4",
74
- "@types/ws": "^8.5.14",
75
- "assert": "^2.1.0",
76
- "babel-loader": "^9.2.1",
77
- "babel-plugin-transform-import-meta": "^2.3.2",
78
- "babel-preset-react": "^6.24.1",
79
- "babelify": "^10.0.0",
80
- "eslint": "^9.20.1",
81
- "gulp": "^5.0.0",
82
- "gulp-cached": "^1.1.1",
83
- "gulp-clean": "^0.4.0",
84
- "gulp-eslint-new": "^2.4.0",
85
- "gulp-logger-new": "^1.0.1",
86
- "gulp-typescript": "^6.0.0-alpha.1",
87
- "https-browserify": "^1.0.0",
88
- "os-browserify": "^0.3.0",
89
- "prettier": "^3.5.0",
90
- "process": "^0.11.10",
91
- "stream-browserify": "^3.0.0",
92
- "stream-http": "^3.2.0",
93
- "ts-loader": "^9.5.2",
94
- "ts-node": "^10.9.2",
95
- "typedoc": "^0.27.7",
96
- "typescript": "^5.7.3",
97
- "typescript-eslint": "^8.24.0",
98
- "webpack": "^5.97.1",
99
- "webpack-cli": "^6.0.1"
100
- },
101
- "dependencies": {
102
- "@bitcoinerlab/secp256k1": "^1.2.0",
103
- "@btc-vision/bitcoin": "^6.3.6",
104
- "@btc-vision/bitcoin-rpc": "^1.0.1",
105
- "@btc-vision/transaction": "^1.2.13",
106
- "@noble/hashes": "^1.7.1",
107
- "bignumber.js": "^9.1.2",
108
- "buffer": "^6.0.3",
109
- "ecpair": "^2.1.0",
110
- "tiny-secp256k1": "^2.2.3"
17
+ "./browser": {
18
+ "import": "./browser/index.js",
19
+ "require": "./browser/index.js",
20
+ "types": "./browser/index.d.ts"
111
21
  }
22
+ },
23
+ "browser": {
24
+ "./build/index.d.ts": "./browser/index.d.ts",
25
+ "./build/index.js": "./browser/index.js",
26
+ "Buffer": "buffer",
27
+ "crypto": "./src/crypto/crypto-browser.js",
28
+ "stream": "stream-browserify"
29
+ },
30
+ "homepage": "https://opnet.org",
31
+ "keywords": [
32
+ "opnet",
33
+ "bsi",
34
+ "bsi-bitcoin-rpc",
35
+ "bitcoin",
36
+ "btc",
37
+ "bitcoin smart contracts",
38
+ "smart inscriptions",
39
+ "ordinals"
40
+ ],
41
+ "license": "MIT",
42
+ "main": "build/index.js",
43
+ "types": "build/index.d.ts",
44
+ "typings": "build/index.d.ts",
45
+ "module": "build/index.js",
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "tag": "latest"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git://github.com/btc-vision/opnet.git"
53
+ },
54
+ "scripts": {
55
+ "watch": "gulp watch",
56
+ "build": "gulp build",
57
+ "test": "jest --runInBand",
58
+ "setup": "npm i && npm run build",
59
+ "browserBuild": "webpack --mode production",
60
+ "docs": "typedoc --out docs --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/scripts/test.ts --exclude src/index.ts src"
61
+ },
62
+ "devDependencies": {
63
+ "@babel/core": "^7.26.8",
64
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
65
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
66
+ "@babel/plugin-transform-runtime": "^7.26.8",
67
+ "@babel/preset-env": "^7.26.8",
68
+ "@babel/preset-flow": "^7.25.9",
69
+ "@babel/preset-react": "^7.26.3",
70
+ "@babel/preset-typescript": "^7.26.0",
71
+ "@eslint/js": "^9.20.0",
72
+ "@types/node": "^22.13.2",
73
+ "@types/sha.js": "^2.4.4",
74
+ "@types/ws": "^8.5.14",
75
+ "assert": "^2.1.0",
76
+ "babel-loader": "^9.2.1",
77
+ "babel-plugin-transform-import-meta": "^2.3.2",
78
+ "babel-preset-react": "^6.24.1",
79
+ "babelify": "^10.0.0",
80
+ "eslint": "^9.20.1",
81
+ "gulp": "^5.0.0",
82
+ "gulp-cached": "^1.1.1",
83
+ "gulp-clean": "^0.4.0",
84
+ "gulp-eslint-new": "^2.4.0",
85
+ "gulp-logger-new": "^1.0.1",
86
+ "gulp-typescript": "^6.0.0-alpha.1",
87
+ "https-browserify": "^1.0.0",
88
+ "os-browserify": "^0.3.0",
89
+ "prettier": "^3.5.0",
90
+ "process": "^0.11.10",
91
+ "stream-browserify": "^3.0.0",
92
+ "stream-http": "^3.2.0",
93
+ "ts-loader": "^9.5.2",
94
+ "ts-node": "^10.9.2",
95
+ "typedoc": "^0.27.7",
96
+ "typescript": "^5.7.3",
97
+ "typescript-eslint": "^8.24.0",
98
+ "webpack": "^5.97.1",
99
+ "webpack-cli": "^6.0.1"
100
+ },
101
+ "dependencies": {
102
+ "@bitcoinerlab/secp256k1": "^1.2.0",
103
+ "@btc-vision/bitcoin": "^6.3.6",
104
+ "@btc-vision/bitcoin-rpc": "^1.0.1",
105
+ "@btc-vision/transaction": "^1.2.14",
106
+ "@noble/hashes": "^1.7.1",
107
+ "bignumber.js": "^9.1.2",
108
+ "buffer": "^6.0.3",
109
+ "ecpair": "^2.1.0",
110
+ "tiny-secp256k1": "^2.2.3"
111
+ }
112
112
  }
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.2.25';
1
+ export const version = '1.2.27';
@@ -127,17 +127,19 @@ export class CallResult<
127
127
  throw new Error('No UTXOs found');
128
128
  }
129
129
 
130
+ const preimage = await this.#provider.getPreimage();
130
131
  const params: IInteractionParameters | InteractionParametersWithoutSigner = {
131
132
  calldata: this.calldata,
132
133
  priorityFee: priorityFee,
133
134
  gasSatFee: this.estimatedSatGas,
134
135
  feeRate: interactionParams.feeRate || 10,
135
136
  from: interactionParams.refundTo,
136
- signer: interactionParams.signer,
137
137
  utxos: UTXOs,
138
138
  to: this.to,
139
139
  network: interactionParams.network,
140
140
  optionalOutputs: interactionParams.extraOutputs || [],
141
+ signer: interactionParams.signer,
142
+ preimage: preimage,
141
143
  };
142
144
 
143
145
  const transaction = await factory.signInteraction(params);
@@ -36,6 +36,11 @@ import {
36
36
  import { AddressesInfo, IPublicKeyInfoResult } from './interfaces/PublicKeyInfo.js';
37
37
  import { ReorgInformation } from './interfaces/ReorgInformation.js';
38
38
 
39
+ interface PreimageCache {
40
+ readonly preimage: Buffer;
41
+ readonly expireAt: number;
42
+ }
43
+
39
44
  /**
40
45
  * @description This class is used to provide an abstract RPC provider.
41
46
  * @abstract
@@ -48,6 +53,8 @@ export abstract class AbstractRpcProvider {
48
53
  private gasCache: BlockGasParameters | undefined;
49
54
  private lastFetchedGas: number = 0;
50
55
 
56
+ private preimageCache: PreimageCache | undefined;
57
+
51
58
  protected constructor(public readonly network: Network) {}
52
59
 
53
60
  private _utxoManager: UTXOsManager = new UTXOsManager(this);
@@ -119,6 +126,44 @@ export abstract class AbstractRpcProvider {
119
126
  return BigInt(result);
120
127
  }
121
128
 
129
+ /**
130
+ * Get the latest preimage to use in a transaction.
131
+ * @description This method is used to get the latest preimage to use in a transaction.
132
+ * @returns {Promise<Buffer>} The preimage
133
+ */
134
+ public async getPreimage(): Promise<Buffer> {
135
+ if (this.preimageCache) {
136
+ if (this.preimageCache.expireAt > Date.now()) {
137
+ return this.preimageCache.preimage;
138
+ }
139
+ }
140
+
141
+ const payload: JsonRpcPayload = this.buildJsonRpcPayload(
142
+ JSONRpcMethods.TRANSACTION_PREIMAGE,
143
+ [],
144
+ );
145
+
146
+ const rawBlockNumber: JsonRpcResult = await this.callPayloadSingle(payload);
147
+ const result: { preimage: string } = rawBlockNumber.result as { preimage: string };
148
+
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
+ );
156
+ }
157
+
158
+ const preimage = Buffer.from(result.preimage, 'hex');
159
+ this.preimageCache = {
160
+ preimage: preimage,
161
+ expireAt: Date.now() + 10_000,
162
+ };
163
+
164
+ return preimage;
165
+ }
166
+
122
167
  /**
123
168
  * Get block by number or hash.
124
169
  * @param {BlockTag} blockNumberOrHash The block number or hash
@@ -738,12 +783,14 @@ export abstract class AbstractRpcProvider {
738
783
  * Get the public key information.
739
784
  * @description This method is used to get the public key information.
740
785
  * @param {string | string[] | Address | Address[]} addresses The address or addresses to get the public key information of
786
+ * @param logErrors
741
787
  * @returns {Promise<AddressesInfo>} The public keys information
742
788
  * @example await getPublicKeysInfo(['addressA', 'addressB']);
743
789
  * @throws {Error} If the address is invalid
744
790
  */
745
791
  public async getPublicKeysInfo(
746
792
  addresses: string | string[] | Address | Address[],
793
+ logErrors: boolean = false,
747
794
  ): Promise<AddressesInfo> {
748
795
  const addressArray = Array.isArray(addresses) ? addresses : [addresses];
749
796
 
@@ -768,7 +815,13 @@ export abstract class AbstractRpcProvider {
768
815
  for (const pubKey of keys) {
769
816
  const pubKeyValue = result[pubKey];
770
817
  if ('error' in pubKeyValue) {
771
- throw new Error(`Error fetching public key info: ${pubKeyValue.error}`);
818
+ if (logErrors) {
819
+ console.error(
820
+ `Error fetching public key info for ${pubKey}: ${pubKeyValue.error}`,
821
+ );
822
+ }
823
+
824
+ continue;
772
825
  }
773
826
 
774
827
  response[pubKey] = pubKeyValue.originalPubKey
@@ -14,25 +14,22 @@ export enum JSONRpcMethods {
14
14
  /** Transactions */
15
15
  GET_TRANSACTION_BY_HASH = 'btc_getTransactionByHash',
16
16
  BROADCAST_TRANSACTION = 'btc_sendRawTransaction',
17
+ TRANSACTION_PREIMAGE = 'btc_preimage',
17
18
 
18
- /** Opnet */
19
- GENERATE = 'btc_generate',
20
-
21
- /** Historical */
19
+ /** Addresses */
20
+ PUBLIC_KEY_INFO = 'btc_publicKeyInfo',
22
21
  GET_UTXOS = 'btc_getUTXOs',
22
+ GET_BALANCE = 'btc_getBalance',
23
23
 
24
- /** PoA */
24
+ /** PoC */
25
25
  BLOCK_WITNESS = 'btc_blockWitness',
26
26
 
27
27
  /** State Methods */
28
28
  GET_TRANSACTION_RECEIPT = 'btc_getTransactionReceipt',
29
29
  GET_CODE = 'btc_getCode',
30
30
  GET_STORAGE_AT = 'btc_getStorageAt',
31
- GET_BALANCE = 'btc_getBalance',
32
31
 
32
+ /** Simulation */
33
33
  CALL = 'btc_call',
34
34
  SIMULATE = 'btc_simulate',
35
-
36
- /** Account */
37
- PUBLIC_KEY_INFO = 'btc_publicKeyInfo',
38
- }
35
+ }