@railgun-community/shared-models 3.9.4 → 3.9.6

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.
@@ -1,6 +1,5 @@
1
1
  export * from './artifact';
2
2
  export * from './blocked-address';
3
- export * from './fallback-provider';
4
3
  export * from './fee-token';
5
4
  export * from './function-types';
6
5
  export * from './merkletree-scan';
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  exports.__esModule = true;
17
17
  __exportStar(require("./artifact"), exports);
18
18
  __exportStar(require("./blocked-address"), exports);
19
- __exportStar(require("./fallback-provider"), exports);
20
19
  __exportStar(require("./fee-token"), exports);
21
20
  __exportStar(require("./function-types"), exports);
22
21
  __exportStar(require("./merkletree-scan"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,oDAAkC;AAClC,sDAAoC;AACpC,8CAA4B;AAC5B,mDAAiC;AACjC,oDAAkC;AAClC,mDAAiC;AACjC,0CAAwB;AACxB,4CAA0B;AAC1B,mDAAiC;AACjC,gDAA8B;AAC9B,2CAAyB","sourcesContent":["export * from './artifact';\nexport * from './blocked-address';\nexport * from './fallback-provider';\nexport * from './fee-token';\nexport * from './function-types';\nexport * from './merkletree-scan';\nexport * from './network-config';\nexport * from './proof';\nexport * from './relayer';\nexport * from './response-types';\nexport * from './transaction';\nexport * from './wallet';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,oDAAkC;AAClC,8CAA4B;AAC5B,mDAAiC;AACjC,oDAAkC;AAClC,mDAAiC;AACjC,0CAAwB;AACxB,4CAA0B;AAC1B,mDAAiC;AACjC,gDAA8B;AAC9B,2CAAyB","sourcesContent":["export * from './artifact';\nexport * from './blocked-address';\nexport * from './fee-token';\nexport * from './function-types';\nexport * from './merkletree-scan';\nexport * from './network-config';\nexport * from './proof';\nexport * from './relayer';\nexport * from './response-types';\nexport * from './transaction';\nexport * from './wallet';\n"]}
File without changes
@@ -32,11 +32,14 @@ var createFallbackProviderFromJsonConfig = function (config, debugMessage) {
32
32
  }
33
33
  return __assign(__assign({}, json), { provider: provider });
34
34
  });
35
- var quorum = 1;
35
+ var quorum = 2;
36
36
  return new providers_1.FallbackProvider(providers, quorum);
37
37
  }
38
38
  catch (err) {
39
- throw new Error('Cannot load provider: invalid fallback provider config.');
39
+ if (!(err instanceof Error)) {
40
+ throw err;
41
+ }
42
+ throw new Error("Invalid fallback provider config: ".concat(err.message));
40
43
  }
41
44
  };
42
45
  exports.createFallbackProviderFromJsonConfig = createFallbackProviderFromJsonConfig;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/utils/fallback-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAIkC;AA4B3B,IAAM,oCAAoC,GAAG,UAClD,MAAkC,EAClC,YAAoC;IAEpC,IAAI;QACF,IAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAA,IAAI;YACzC,IAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACpD,IAAM,QAAQ,GAAG,WAAW;gBAC1B,CAAC,CAAC,IAAI,6BAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9D,CAAC,CAAC,IAAI,iCAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAErE,IAAI,YAAY,EAAE;gBAChB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,KAAoB;oBACxC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;wBACxC,YAAY,CAAC,0BAAmB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAE,CAAC,CAAC;wBACvD,YAAY,CACV,+BACE,KAAK,CAAC,OAAO,CAAC,QAAQ;4BACpB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU;4BACnC,CAAC,CAAC,SAAS,CACb,CACH,CAAC;qBACH;gBACH,CAAC,CAAC,CAAC;aACJ;YAED,6BACK,IAAI,KACP,QAAQ,UAAA,IACR;QACJ,CAAC,CAAC,CAAC;QAEH,IAAM,MAAM,GAAG,CAAC,CAAC;QACjB,OAAO,IAAI,4BAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KAChD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,MAAM,IAAI,KAAK,CAAC,4CAAqC,GAAG,CAAC,OAAO,CAAE,CAAC,CAAC;KACrE;AACH,CAAC,CAAC;AAxCW,QAAA,oCAAoC,wCAwC/C","sourcesContent":["import {\n FallbackProvider,\n StaticJsonRpcProvider,\n WebSocketProvider,\n} from '@ethersproject/providers';\n\nexport type FallbackProviderJsonConfig = {\n chainId: number;\n providers: ProviderJson[];\n};\n\nexport type ProviderJson = {\n priority: number;\n weight: number;\n provider: string;\n};\n\ntype ProviderDebug = {\n action: string;\n rid: number;\n backend: {\n weight: number;\n start: number;\n duration: number;\n result?: string[];\n error?: typeof Error;\n provider?: StaticJsonRpcProvider;\n };\n request: { method: string; params: { filter?: object } };\n provider: FallbackProvider;\n};\n\nexport const createFallbackProviderFromJsonConfig = (\n config: FallbackProviderJsonConfig,\n debugMessage?: (msg: string) => void,\n): FallbackProvider => {\n try {\n const providers = config.providers.map(json => {\n const isWebsocket = json.provider.startsWith('wss');\n const provider = isWebsocket\n ? new WebSocketProvider(json.provider, Number(config.chainId))\n : new StaticJsonRpcProvider(json.provider, Number(config.chainId));\n\n if (debugMessage) {\n provider.on('debug', (debug: ProviderDebug) => {\n if (debug.backend && debug.backend.error) {\n debugMessage(`Provider error: ${debug.backend.error}`);\n debugMessage(\n `Provider connection: ${\n debug.backend.provider\n ? debug.backend.provider.connection\n : undefined\n }`,\n );\n }\n });\n }\n\n return {\n ...json,\n provider,\n };\n });\n\n const quorum = 2;\n return new FallbackProvider(providers, quorum);\n } catch (err) {\n if (!(err instanceof Error)) {\n throw err;\n }\n throw new Error(`Invalid fallback provider config: ${err.message}`);\n }\n};\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from './compare';
2
+ export * from './fallback-provider';
2
3
  export * from './error';
3
4
  export * from './format';
4
5
  export * from './gas';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  exports.__esModule = true;
17
17
  __exportStar(require("./compare"), exports);
18
+ __exportStar(require("./fallback-provider"), exports);
18
19
  __exportStar(require("./error"), exports);
19
20
  __exportStar(require("./format"), exports);
20
21
  __exportStar(require("./gas"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,6CAA2B;AAC3B,+CAA6B;AAC7B,6CAA2B","sourcesContent":["export * from './compare';\nexport * from './error';\nexport * from './format';\nexport * from './gas';\nexport * from './network';\nexport * from './promises';\nexport * from './serializer';\nexport * from './versions';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,sDAAoC;AACpC,0CAAwB;AACxB,2CAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,6CAA2B;AAC3B,+CAA6B;AAC7B,6CAA2B","sourcesContent":["export * from './compare';\nexport * from './fallback-provider';\nexport * from './error';\nexport * from './format';\nexport * from './gas';\nexport * from './network';\nexport * from './promises';\nexport * from './serializer';\nexport * from './versions';\n"]}
@@ -37,7 +37,7 @@ exports.serializeUnsignedTransaction = serializeUnsignedTransaction;
37
37
  var deserializeTransaction = function (rawTransaction, nonce, chainId) {
38
38
  var _a, _b, _c, _d, _e;
39
39
  var transaction = (0, transactions_1.parse)(rawTransaction);
40
- return cleanTransaction(__assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId,
40
+ return removeUndefinedValues(__assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId,
41
41
  // Set gas-related vars as undefined if they're zero.
42
42
  gasLimit: ((_b = transaction.gasLimit) === null || _b === void 0 ? void 0 : _b.eq(0)) ? undefined : transaction.gasLimit, gasPrice: ((_c = transaction.gasPrice) === null || _c === void 0 ? void 0 : _c.eq(0)) ? undefined : transaction.gasPrice, maxFeePerGas: ((_d = transaction.maxFeePerGas) === null || _d === void 0 ? void 0 : _d.eq(0))
43
43
  ? undefined
@@ -46,11 +46,12 @@ var deserializeTransaction = function (rawTransaction, nonce, chainId) {
46
46
  : transaction.maxPriorityFeePerGas }));
47
47
  };
48
48
  exports.deserializeTransaction = deserializeTransaction;
49
- var cleanTransaction = function (tx) {
50
- // Remove keys that have an undefined value
51
- return Object.fromEntries(Object.entries(tx).filter(function (_a) {
52
- var _k = _a[0], v = _a[1];
53
- return v !== undefined;
49
+ var removeUndefinedValues = function (tx) {
50
+ return Object.fromEntries(
51
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
+ Object.entries(tx).filter(function (_a) {
53
+ var _key = _a[0], value = _a[1];
54
+ return value !== undefined;
54
55
  }));
55
56
  };
56
57
  //# sourceMappingURL=serializer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAsD;AAEtD,IAAM,oBAAoB,GAAG,UAAC,WAAiC;IAC7D,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,2BAAU,CAAC,KAAK,IAAI,WAAW,CAAC,UAAU,EAAE;QACnE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;AACH,CAAC,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,WAAiC;IAEjC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,IAAA,wBAAS,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF,8CAA8C;AAC9C,uCAAuC;AACvC,8BAA8B;AAC9B,iBAAiB;AACjB,uCAAuC;AACvC,8CAA8C;AAC9C,KAAK;AAEE,IAAM,sBAAsB,GAAG,UACpC,cAAsB,EACtB,KAAuB,EACvB,OAAe;;IAEf,IAAM,WAAW,GAAgB,IAAA,oBAAK,EAAC,cAAc,CAAC,CAAC;IACvD,OAAO,gBAAgB,uBAClB,WAAW,KACd,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS,EACnC,KAAK,OAAA,EACL,OAAO,SAAA;QAEP,qDAAqD;QACrD,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,YAAY,EAAE,CAAA,MAAA,WAAW,CAAC,YAAY,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,YAAY,EAC5B,oBAAoB,EAAE,CAAA,MAAA,WAAW,CAAC,oBAAoB,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,oBAAoB,IACpC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC;AAEF,IAAM,gBAAgB,GAAG,UAAC,EAAsB;IAC9C,2CAA2C;IAC3C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAC,EAAO;YAAN,EAAE,QAAA,EAAE,CAAC,QAAA;QAAM,OAAA,CAAC,KAAK,SAAS;IAAf,CAAe,CAAC,CACxD,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\nimport { EVMGasType } from '../models/response-types';\n\nconst validatePreserialize = (transaction: PopulatedTransaction) => {\n if (transaction.from) {\n throw new Error(`Cannot serialize 'from' field on transaction.`);\n }\n if (transaction.type === EVMGasType.Type0 && transaction.accessList) {\n throw new Error(\n `Cannot serialize 'accessList' field on Type0 transaction.`,\n );\n }\n};\n\nexport const serializeUnsignedTransaction = (\n transaction: PopulatedTransaction,\n): string => {\n validatePreserialize(transaction);\n return serialize(transaction);\n};\n\n// export const serializeSignedTransaction = (\n// transaction: PopulatedTransaction,\n// signature: SignatureLike,\n// ): string => {\n// validatePreserialize(transaction);\n// return serialize(transaction, signature);\n// };\n\nexport const deserializeTransaction = (\n rawTransaction: string,\n nonce: Optional<number>,\n chainId: number,\n): TransactionRequest => {\n const transaction: Transaction = parse(rawTransaction);\n return cleanTransaction({\n ...transaction,\n type: transaction.type ?? undefined,\n nonce,\n chainId,\n\n // Set gas-related vars as undefined if they're zero.\n gasLimit: transaction.gasLimit?.eq(0) ? undefined : transaction.gasLimit,\n gasPrice: transaction.gasPrice?.eq(0) ? undefined : transaction.gasPrice,\n maxFeePerGas: transaction.maxFeePerGas?.eq(0)\n ? undefined\n : transaction.maxFeePerGas,\n maxPriorityFeePerGas: transaction.maxPriorityFeePerGas?.eq(0)\n ? undefined\n : transaction.maxPriorityFeePerGas,\n });\n};\n\nconst cleanTransaction = (tx: TransactionRequest): TransactionRequest => {\n // Remove keys that have an undefined value\n return Object.fromEntries(\n Object.entries(tx).filter(([_k, v]) => v !== undefined),\n );\n};\n"]}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAsD;AAEtD,IAAM,oBAAoB,GAAG,UAAC,WAAiC;IAC7D,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,2BAAU,CAAC,KAAK,IAAI,WAAW,CAAC,UAAU,EAAE;QACnE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;AACH,CAAC,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,WAAiC;IAEjC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,IAAA,wBAAS,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF,8CAA8C;AAC9C,uCAAuC;AACvC,8BAA8B;AAC9B,iBAAiB;AACjB,uCAAuC;AACvC,8CAA8C;AAC9C,KAAK;AAEE,IAAM,sBAAsB,GAAG,UACpC,cAAsB,EACtB,KAAuB,EACvB,OAAe;;IAEf,IAAM,WAAW,GAAgB,IAAA,oBAAK,EAAC,cAAc,CAAC,CAAC;IACvD,OAAO,qBAAqB,uBACvB,WAAW,KACd,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS,EACnC,KAAK,OAAA,EACL,OAAO,SAAA;QAEP,qDAAqD;QACrD,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,YAAY,EAAE,CAAA,MAAA,WAAW,CAAC,YAAY,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,YAAY,EAC5B,oBAAoB,EAAE,CAAA,MAAA,WAAW,CAAC,oBAAoB,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,oBAAoB,IACpC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC;AAEF,IAAM,qBAAqB,GAAG,UAAC,EAAsB;IACnD,OAAO,MAAM,CAAC,WAAW;IACvB,6DAA6D;IAC7D,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAC,EAAa;YAAZ,IAAI,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,KAAK,KAAK,SAAS;IAAnB,CAAmB,CAAC,CAClE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\nimport { EVMGasType } from '../models/response-types';\n\nconst validatePreserialize = (transaction: PopulatedTransaction) => {\n if (transaction.from) {\n throw new Error(`Cannot serialize 'from' field on transaction.`);\n }\n if (transaction.type === EVMGasType.Type0 && transaction.accessList) {\n throw new Error(\n `Cannot serialize 'accessList' field on Type0 transaction.`,\n );\n }\n};\n\nexport const serializeUnsignedTransaction = (\n transaction: PopulatedTransaction,\n): string => {\n validatePreserialize(transaction);\n return serialize(transaction);\n};\n\n// export const serializeSignedTransaction = (\n// transaction: PopulatedTransaction,\n// signature: SignatureLike,\n// ): string => {\n// validatePreserialize(transaction);\n// return serialize(transaction, signature);\n// };\n\nexport const deserializeTransaction = (\n rawTransaction: string,\n nonce: Optional<number>,\n chainId: number,\n): TransactionRequest => {\n const transaction: Transaction = parse(rawTransaction);\n return removeUndefinedValues({\n ...transaction,\n type: transaction.type ?? undefined,\n nonce,\n chainId,\n\n // Set gas-related vars as undefined if they're zero.\n gasLimit: transaction.gasLimit?.eq(0) ? undefined : transaction.gasLimit,\n gasPrice: transaction.gasPrice?.eq(0) ? undefined : transaction.gasPrice,\n maxFeePerGas: transaction.maxFeePerGas?.eq(0)\n ? undefined\n : transaction.maxFeePerGas,\n maxPriorityFeePerGas: transaction.maxPriorityFeePerGas?.eq(0)\n ? undefined\n : transaction.maxPriorityFeePerGas,\n });\n};\n\nconst removeUndefinedValues = (tx: TransactionRequest): TransactionRequest => {\n return Object.fromEntries(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Object.entries(tx).filter(([_key, value]) => value !== undefined),\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railgun-community/shared-models",
3
- "version": "3.9.4",
3
+ "version": "3.9.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/models/fallback-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAIkC;AA4B3B,IAAM,oCAAoC,GAAG,UAClD,MAAkC,EAClC,YAAoC;IAEpC,IAAI;QACF,IAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAA,IAAI;YACzC,IAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACpD,IAAM,QAAQ,GAAG,WAAW;gBAC1B,CAAC,CAAC,IAAI,6BAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9D,CAAC,CAAC,IAAI,iCAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAErE,IAAI,YAAY,EAAE;gBAChB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,KAAoB;oBACxC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;wBACxC,YAAY,CAAC,0BAAmB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAE,CAAC,CAAC;wBACvD,YAAY,CACV,+BACE,KAAK,CAAC,OAAO,CAAC,QAAQ;4BACpB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU;4BACnC,CAAC,CAAC,SAAS,CACb,CACH,CAAC;qBACH;gBACH,CAAC,CAAC,CAAC;aACJ;YAED,6BACK,IAAI,KACP,QAAQ,UAAA,IACR;QACJ,CAAC,CAAC,CAAC;QAEH,IAAM,MAAM,GAAG,CAAC,CAAC;QACjB,OAAO,IAAI,4BAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KAChD;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;AACH,CAAC,CAAC;AArCW,QAAA,oCAAoC,wCAqC/C","sourcesContent":["import {\n FallbackProvider,\n StaticJsonRpcProvider,\n WebSocketProvider,\n} from '@ethersproject/providers';\n\nexport type FallbackProviderJsonConfig = {\n chainId: number;\n providers: ProviderJson[];\n};\n\nexport type ProviderJson = {\n priority: number;\n weight: number;\n provider: string;\n};\n\ntype ProviderDebug = {\n action: string;\n rid: number;\n backend: {\n weight: number;\n start: number;\n duration: number;\n result?: string[];\n error?: typeof Error;\n provider?: StaticJsonRpcProvider;\n };\n request: { method: string; params: { filter?: object } };\n provider: FallbackProvider;\n};\n\nexport const createFallbackProviderFromJsonConfig = (\n config: FallbackProviderJsonConfig,\n debugMessage?: (msg: string) => void,\n): FallbackProvider => {\n try {\n const providers = config.providers.map(json => {\n const isWebsocket = json.provider.startsWith('wss');\n const provider = isWebsocket\n ? new WebSocketProvider(json.provider, Number(config.chainId))\n : new StaticJsonRpcProvider(json.provider, Number(config.chainId));\n\n if (debugMessage) {\n provider.on('debug', (debug: ProviderDebug) => {\n if (debug.backend && debug.backend.error) {\n debugMessage(`Provider error: ${debug.backend.error}`);\n debugMessage(\n `Provider connection: ${\n debug.backend.provider\n ? debug.backend.provider.connection\n : undefined\n }`,\n );\n }\n });\n }\n\n return {\n ...json,\n provider,\n };\n });\n\n const quorum = 1;\n return new FallbackProvider(providers, quorum);\n } catch (err) {\n throw new Error('Cannot load provider: invalid fallback provider config.');\n }\n};\n"]}