@metamask-previews/controller-utils 11.6.0-preview-f15cb863 → 11.6.0-preview-29fe07c

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 +1 @@
1
- {"version":3,"file":"create-service-policy.d.mts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EAKZ,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAEnE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACpC;;;OAGG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC;;;;OAIG;IACH,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,QAAgC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,8BAA8B,QAAiB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,UAAgC,EAChC,iBAA6B,EAC7B,sBAAyD,EACzD,oBAAqD,EACrD,iBAA8C,GAC/C,GAAE,0BAA+B,GAAG,aAAa,CAmDjD"}
1
+ {"version":3,"file":"create-service-policy.d.mts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGZ,kBAAkB,EAClB,eAAe,EAEf,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,eAAe,EACf,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACpC;;;OAGG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC;;;;OAIG;IACH,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,QAAgC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,8BAA8B,QAAiB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CA4Df"}
@@ -1,5 +1,5 @@
1
- import { BrokenCircuitError, CircuitState, EventEmitter as CockatielEventEmitter, ConsecutiveBreaker, ExponentialBackoff, circuitBreaker, handleAll, handleWhen, retry, wrap } from "cockatiel";
2
- export { CircuitState, BrokenCircuitError, handleAll, handleWhen };
1
+ import { BrokenCircuitError, CircuitState, EventEmitter as CockatielEventEmitter, ConsecutiveBreaker, ExponentialBackoff, ConstantBackoff, circuitBreaker, handleAll, handleWhen, retry, wrap } from "cockatiel";
2
+ export { BrokenCircuitError, CircuitState, ConstantBackoff, ExponentialBackoff, handleAll, handleWhen };
3
3
  /**
4
4
  * The maximum number of times that a failing service should be re-run before
5
5
  * giving up.
@@ -37,21 +37,8 @@ export const DEFAULT_DEGRADED_THRESHOLD = 5000;
37
37
  * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see
38
38
  * there for more.
39
39
  *
40
- * @param options - The options to this function.
41
- * @param options.maxRetries - The maximum number of times that a failing
42
- * service should be re-invoked before giving up. Defaults to 3.
43
- * @param options.retryFilterPolicy - The policy used to control when the
44
- * service should be retried based on either the result of the servce or an
45
- * error that it throws. For instance, you could use this to retry only certain
46
- * errors. See `handleWhen` and friends from Cockatiel for more.
47
- * @param options.maxConsecutiveFailures - The maximum number of times that the
48
- * service is allowed to fail before pausing further retries. Defaults to 12.
49
- * @param options.circuitBreakDuration - The length of time (in milliseconds) to
50
- * pause retries of the action after the number of failures reaches
51
- * `maxConsecutiveFailures`.
52
- * @param options.degradedThreshold - The length of time (in milliseconds) that
53
- * governs when the service is regarded as degraded (affecting when `onDegraded`
54
- * is called). Defaults to 5 seconds.
40
+ * @param options - The options to this function. See
41
+ * {@link CreateServicePolicyOptions}.
55
42
  * @returns The service policy.
56
43
  * @example
57
44
  * This function is designed to be used in the context of a service class like
@@ -85,14 +72,15 @@ export const DEFAULT_DEGRADED_THRESHOLD = 5000;
85
72
  * }
86
73
  * ```
87
74
  */
88
- export function createServicePolicy({ maxRetries = DEFAULT_MAX_RETRIES, retryFilterPolicy = handleAll, maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION, degradedThreshold = DEFAULT_DEGRADED_THRESHOLD, } = {}) {
75
+ export function createServicePolicy(options = {}) {
76
+ const { maxRetries = DEFAULT_MAX_RETRIES, retryFilterPolicy = handleAll, maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION, degradedThreshold = DEFAULT_DEGRADED_THRESHOLD, backoff = new ExponentialBackoff(), } = options;
89
77
  const retryPolicy = retry(retryFilterPolicy, {
90
78
  // Note that although the option here is called "max attempts", it's really
91
79
  // maximum number of *retries* (attempts past the initial attempt).
92
80
  maxAttempts: maxRetries,
93
81
  // Retries of the service will be executed following ever increasing delays,
94
82
  // determined by a backoff formula.
95
- backoff: new ExponentialBackoff(),
83
+ backoff,
96
84
  });
97
85
  const onRetry = retryPolicy.onRetry.bind(retryPolicy);
98
86
  const circuitBreakerPolicy = circuitBreaker(handleAll, {
@@ -1 +1 @@
1
- {"version":3,"file":"create-service-policy.mjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EACrC,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACL,kBAAkB;AASnB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAuEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAK,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,UAAU,GAAG,mBAAmB,EAChC,iBAAiB,GAAG,SAAS,EAC7B,sBAAsB,GAAG,gCAAgC,EACzD,oBAAoB,GAAG,8BAA8B,EACrD,iBAAiB,GAAG,0BAA0B,MAChB,EAAE;IAChC,MAAM,WAAW,GAAG,KAAK,CAAC,iBAAiB,EAAE;QAC3C,2EAA2E;QAC3E,mEAAmE;QACnE,WAAW,EAAE,UAAU;QACvB,4EAA4E;QAC5E,mCAAmC;QACnC,OAAO,EAAE,IAAI,kBAAkB,EAAE;KAClC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEtD,MAAM,oBAAoB,GAAG,cAAc,CAAC,SAAS,EAAE;QACrD,uEAAuE;QACvE,oEAAoE;QACpE,wEAAwE;QACxE,4EAA4E;QAC5E,qEAAqE;QACrE,qDAAqD;QACrD,aAAa,EAAE,oBAAoB;QACnC,OAAO,EAAE,IAAI,kBAAkB,CAAC,sBAAsB,CAAC;KACxD,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAExE,MAAM,sBAAsB,GAAG,IAAI,qBAAqB,EAAQ,CAAC;IACjE,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE;QACxB,IAAI,oBAAoB,CAAC,KAAK,KAAK,YAAY,CAAC,MAAM,EAAE;YACtD,sBAAsB,CAAC,IAAI,EAAE,CAAC;SAC/B;IACH,CAAC,CAAC,CAAC;IACH,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrC,IACE,oBAAoB,CAAC,KAAK,KAAK,YAAY,CAAC,MAAM;YAClD,QAAQ,GAAG,iBAAiB,EAC5B;YACA,sBAAsB,CAAC,IAAI,EAAE,CAAC;SAC/B;IACH,CAAC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,sBAAsB,CAAC,WAAW,CAAC;IAEtD,wEAAwE;IACxE,8CAA8C;IAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAEvD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,WAAW;QACX,OAAO;QACP,UAAU;QACV,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport { CircuitState, BrokenCircuitError, handleAll, handleWhen };\n\nexport type { CockatielEvent };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function.\n * @param options.maxRetries - The maximum number of times that a failing\n * service should be re-invoked before giving up. Defaults to 3.\n * @param options.retryFilterPolicy - The policy used to control when the\n * service should be retried based on either the result of the servce or an\n * error that it throws. For instance, you could use this to retry only certain\n * errors. See `handleWhen` and friends from Cockatiel for more.\n * @param options.maxConsecutiveFailures - The maximum number of times that the\n * service is allowed to fail before pausing further retries. Defaults to 12.\n * @param options.circuitBreakDuration - The length of time (in milliseconds) to\n * pause retries of the action after the number of failures reaches\n * `maxConsecutiveFailures`.\n * @param options.degradedThreshold - The length of time (in milliseconds) that\n * governs when the service is regarded as degraded (affecting when `onDegraded`\n * is called). Defaults to 5 seconds.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy({\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n}: CreateServicePolicyOptions = {}): ServicePolicy {\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff: new ExponentialBackoff(),\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const circuitBreakerPolicy = circuitBreaker(handleAll, {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: new ConsecutiveBreaker(maxConsecutiveFailures),\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter = new CockatielEventEmitter<void>();\n retryPolicy.onGiveUp(() => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n onDegradedEventEmitter.emit();\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (\n circuitBreakerPolicy.state === CircuitState.Closed &&\n duration > degradedThreshold\n ) {\n onDegradedEventEmitter.emit();\n }\n });\n const onDegraded = onDegradedEventEmitter.addListener;\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n return {\n ...policy,\n circuitBreakerPolicy,\n retryPolicy,\n onBreak,\n onDegraded,\n onRetry,\n };\n}\n"]}
1
+ {"version":3,"file":"create-service-policy.mjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EACrC,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACL,kBAAkB;AAUnB,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,EACX,CAAC;AA6EF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAK,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAsC,EAAE;IAExC,MAAM,EACJ,UAAU,GAAG,mBAAmB,EAChC,iBAAiB,GAAG,SAAS,EAC7B,sBAAsB,GAAG,gCAAgC,EACzD,oBAAoB,GAAG,8BAA8B,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AE,oBAAoB,CAAC,CAAC;IAEvD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,WAAW;QACX,OAAO;QACP,UAAU;QACV,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n ConstantBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n IBackoffFactory,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport {\n BrokenCircuitError,\n CircuitState,\n ConstantBackoff,\n ExponentialBackoff,\n handleAll,\n handleWhen,\n};\n\nexport type { CockatielEvent };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The backoff strategy to use. Mainly useful for testing so that a constant\n * backoff can be used when mocking timers. Defaults to an instance of\n * ExponentialBackoff.\n */\n backoff?: IBackoffFactory<unknown>;\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function. See\n * {@link CreateServicePolicyOptions}.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy(\n options: CreateServicePolicyOptions = {},\n): ServicePolicy {\n const {\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n backoff = new ExponentialBackoff(),\n } = options;\n\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff,\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const circuitBreakerPolicy = circuitBreaker(handleAll, {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: new ConsecutiveBreaker(maxConsecutiveFailures),\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter = new CockatielEventEmitter<void>();\n retryPolicy.onGiveUp(() => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n onDegradedEventEmitter.emit();\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (\n circuitBreakerPolicy.state === CircuitState.Closed &&\n duration > degradedThreshold\n ) {\n onDegradedEventEmitter.emit();\n }\n });\n const onDegraded = onDegradedEventEmitter.addListener;\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n return {\n ...policy,\n circuitBreakerPolicy,\n retryPolicy,\n onBreak,\n onDegraded,\n onRetry,\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -14,14 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isEqualCaseInsensitive = exports.weiHexToGweiDec = exports.toHex = exports.toChecksumHexAddress = exports.timeoutFetch = exports.successfulFetch = exports.safelyExecuteWithTimeout = exports.safelyExecute = exports.query = exports.normalizeEnsName = exports.isValidHexAddress = exports.isValidJson = exports.isSmartContractCode = exports.isSafeDynamicKey = exports.isSafeChainId = exports.isPlainObject = exports.isNonEmptyArray = exports.hexToText = exports.hexToBN = exports.handleFetch = exports.gweiDecToWEIBN = exports.getBuyURL = exports.fromHex = exports.fractionBN = exports.fetchWithErrorHandling = exports.convertHexToDecimal = exports.BNToHex = exports.handleWhen = exports.handleAll = exports.createServicePolicy = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_MAX_CONSECUTIVE_FAILURES = exports.DEFAULT_DEGRADED_THRESHOLD = exports.DEFAULT_CIRCUIT_BREAK_DURATION = exports.CircuitState = exports.BrokenCircuitError = void 0;
17
+ exports.isEqualCaseInsensitive = exports.weiHexToGweiDec = exports.toHex = exports.toChecksumHexAddress = exports.timeoutFetch = exports.successfulFetch = exports.safelyExecuteWithTimeout = exports.safelyExecute = exports.query = exports.normalizeEnsName = exports.isValidHexAddress = exports.isValidJson = exports.isSmartContractCode = exports.isSafeDynamicKey = exports.isSafeChainId = exports.isPlainObject = exports.isNonEmptyArray = exports.hexToText = exports.hexToBN = exports.handleFetch = exports.gweiDecToWEIBN = exports.getBuyURL = exports.fromHex = exports.fractionBN = exports.fetchWithErrorHandling = exports.convertHexToDecimal = exports.BNToHex = exports.handleWhen = exports.handleAll = exports.createServicePolicy = exports.ExponentialBackoff = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_MAX_CONSECUTIVE_FAILURES = exports.DEFAULT_DEGRADED_THRESHOLD = exports.DEFAULT_CIRCUIT_BREAK_DURATION = exports.ConstantBackoff = exports.CircuitState = exports.BrokenCircuitError = void 0;
18
18
  var create_service_policy_1 = require("./create-service-policy.cjs");
19
19
  Object.defineProperty(exports, "BrokenCircuitError", { enumerable: true, get: function () { return create_service_policy_1.BrokenCircuitError; } });
20
20
  Object.defineProperty(exports, "CircuitState", { enumerable: true, get: function () { return create_service_policy_1.CircuitState; } });
21
+ Object.defineProperty(exports, "ConstantBackoff", { enumerable: true, get: function () { return create_service_policy_1.ConstantBackoff; } });
21
22
  Object.defineProperty(exports, "DEFAULT_CIRCUIT_BREAK_DURATION", { enumerable: true, get: function () { return create_service_policy_1.DEFAULT_CIRCUIT_BREAK_DURATION; } });
22
23
  Object.defineProperty(exports, "DEFAULT_DEGRADED_THRESHOLD", { enumerable: true, get: function () { return create_service_policy_1.DEFAULT_DEGRADED_THRESHOLD; } });
23
24
  Object.defineProperty(exports, "DEFAULT_MAX_CONSECUTIVE_FAILURES", { enumerable: true, get: function () { return create_service_policy_1.DEFAULT_MAX_CONSECUTIVE_FAILURES; } });
24
25
  Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", { enumerable: true, get: function () { return create_service_policy_1.DEFAULT_MAX_RETRIES; } });
26
+ Object.defineProperty(exports, "ExponentialBackoff", { enumerable: true, get: function () { return create_service_policy_1.ExponentialBackoff; } });
25
27
  Object.defineProperty(exports, "createServicePolicy", { enumerable: true, get: function () { return create_service_policy_1.createServicePolicy; } });
26
28
  Object.defineProperty(exports, "handleAll", { enumerable: true, get: function () { return create_service_policy_1.handleAll; } });
27
29
  Object.defineProperty(exports, "handleWhen", { enumerable: true, get: function () { return create_service_policy_1.handleWhen; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qEAUiC;AAT/B,2HAAA,kBAAkB,OAAA;AAClB,qHAAA,YAAY,OAAA;AACZ,uIAAA,8BAA8B,OAAA;AAC9B,mIAAA,0BAA0B,OAAA;AAC1B,yIAAA,gCAAgC,OAAA;AAChC,4HAAA,mBAAmB,OAAA;AACnB,4HAAA,mBAAmB,OAAA;AACnB,kHAAA,SAAS,OAAA;AACT,mHAAA,UAAU,OAAA;AAOZ,kDAA4B;AAE5B,mCA4BgB;AA3Bd,+FAAA,OAAO,OAAA;AACP,2GAAA,mBAAmB,OAAA;AACnB,8GAAA,sBAAsB,OAAA;AACtB,kGAAA,UAAU,OAAA;AACV,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,uGAAA,eAAe,OAAA;AACf,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,wGAAA,gBAAgB,OAAA;AAChB,2GAAA,mBAAmB,OAAA;AACnB,mGAAA,WAAW,OAAA;AACX,yGAAA,iBAAiB,OAAA;AACjB,wGAAA,gBAAgB,OAAA;AAChB,6FAAA,KAAK,OAAA;AACL,qGAAA,aAAa,OAAA;AACb,gHAAA,wBAAwB,OAAA;AACxB,uGAAA,eAAe,OAAA;AACf,oGAAA,YAAY,OAAA;AACZ,4GAAA,oBAAoB,OAAA;AACpB,6FAAA,KAAK,OAAA;AACL,uGAAA,eAAe,OAAA;AACf,8GAAA,sBAAsB,OAAA;AAExB,8CAAwB;AACxB,6CAAuB","sourcesContent":["export {\n BrokenCircuitError,\n CircuitState,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n createServicePolicy,\n handleAll,\n handleWhen,\n} from './create-service-policy';\nexport type {\n CockatielEvent,\n CreateServicePolicyOptions,\n ServicePolicy,\n} from './create-service-policy';\nexport * from './constants';\nexport type { NonEmptyArray } from './util';\nexport {\n BNToHex,\n convertHexToDecimal,\n fetchWithErrorHandling,\n fractionBN,\n fromHex,\n getBuyURL,\n gweiDecToWEIBN,\n handleFetch,\n hexToBN,\n hexToText,\n isNonEmptyArray,\n isPlainObject,\n isSafeChainId,\n isSafeDynamicKey,\n isSmartContractCode,\n isValidJson,\n isValidHexAddress,\n normalizeEnsName,\n query,\n safelyExecute,\n safelyExecuteWithTimeout,\n successfulFetch,\n timeoutFetch,\n toChecksumHexAddress,\n toHex,\n weiHexToGweiDec,\n isEqualCaseInsensitive,\n} from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qEAYiC;AAX/B,2HAAA,kBAAkB,OAAA;AAClB,qHAAA,YAAY,OAAA;AACZ,wHAAA,eAAe,OAAA;AACf,uIAAA,8BAA8B,OAAA;AAC9B,mIAAA,0BAA0B,OAAA;AAC1B,yIAAA,gCAAgC,OAAA;AAChC,4HAAA,mBAAmB,OAAA;AACnB,2HAAA,kBAAkB,OAAA;AAClB,4HAAA,mBAAmB,OAAA;AACnB,kHAAA,SAAS,OAAA;AACT,mHAAA,UAAU,OAAA;AAOZ,kDAA4B;AAE5B,mCA4BgB;AA3Bd,+FAAA,OAAO,OAAA;AACP,2GAAA,mBAAmB,OAAA;AACnB,8GAAA,sBAAsB,OAAA;AACtB,kGAAA,UAAU,OAAA;AACV,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,uGAAA,eAAe,OAAA;AACf,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,wGAAA,gBAAgB,OAAA;AAChB,2GAAA,mBAAmB,OAAA;AACnB,mGAAA,WAAW,OAAA;AACX,yGAAA,iBAAiB,OAAA;AACjB,wGAAA,gBAAgB,OAAA;AAChB,6FAAA,KAAK,OAAA;AACL,qGAAA,aAAa,OAAA;AACb,gHAAA,wBAAwB,OAAA;AACxB,uGAAA,eAAe,OAAA;AACf,oGAAA,YAAY,OAAA;AACZ,4GAAA,oBAAoB,OAAA;AACpB,6FAAA,KAAK,OAAA;AACL,uGAAA,eAAe,OAAA;AACf,8GAAA,sBAAsB,OAAA;AAExB,8CAAwB;AACxB,6CAAuB","sourcesContent":["export {\n BrokenCircuitError,\n CircuitState,\n ConstantBackoff,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n ExponentialBackoff,\n createServicePolicy,\n handleAll,\n handleWhen,\n} from './create-service-policy';\nexport type {\n CockatielEvent,\n CreateServicePolicyOptions,\n ServicePolicy,\n} from './create-service-policy';\nexport * from './constants';\nexport type { NonEmptyArray } from './util';\nexport {\n BNToHex,\n convertHexToDecimal,\n fetchWithErrorHandling,\n fractionBN,\n fromHex,\n getBuyURL,\n gweiDecToWEIBN,\n handleFetch,\n hexToBN,\n hexToText,\n isNonEmptyArray,\n isPlainObject,\n isSafeChainId,\n isSafeDynamicKey,\n isSmartContractCode,\n isValidJson,\n isValidHexAddress,\n normalizeEnsName,\n query,\n safelyExecute,\n safelyExecuteWithTimeout,\n successfulFetch,\n timeoutFetch,\n toChecksumHexAddress,\n toHex,\n weiHexToGweiDec,\n isEqualCaseInsensitive,\n} from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { BrokenCircuitError, CircuitState, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, createServicePolicy, handleAll, handleWhen, } from "./create-service-policy.cjs";
1
+ export { BrokenCircuitError, CircuitState, ConstantBackoff, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, ExponentialBackoff, createServicePolicy, handleAll, handleWhen, } from "./create-service-policy.cjs";
2
2
  export type { CockatielEvent, CreateServicePolicyOptions, ServicePolicy, } from "./create-service-policy.cjs";
3
3
  export * from "./constants.cjs";
4
4
  export type { NonEmptyArray } from "./util.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,UAAU,GACX,oCAAgC;AACjC,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,aAAa,GACd,oCAAgC;AACjC,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,GACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,UAAU,GACX,oCAAgC;AACjC,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,aAAa,GACd,oCAAgC;AACjC,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,GACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { BrokenCircuitError, CircuitState, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, createServicePolicy, handleAll, handleWhen, } from "./create-service-policy.mjs";
1
+ export { BrokenCircuitError, CircuitState, ConstantBackoff, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, ExponentialBackoff, createServicePolicy, handleAll, handleWhen, } from "./create-service-policy.mjs";
2
2
  export type { CockatielEvent, CreateServicePolicyOptions, ServicePolicy, } from "./create-service-policy.mjs";
3
3
  export * from "./constants.mjs";
4
4
  export type { NonEmptyArray } from "./util.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,UAAU,GACX,oCAAgC;AACjC,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,aAAa,GACd,oCAAgC;AACjC,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,GACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,UAAU,GACX,oCAAgC;AACjC,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,aAAa,GACd,oCAAgC;AACjC,gCAA4B;AAC5B,YAAY,EAAE,aAAa,EAAE,mBAAe;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,GACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { BrokenCircuitError, CircuitState, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, createServicePolicy, handleAll, handleWhen } from "./create-service-policy.mjs";
1
+ export { BrokenCircuitError, CircuitState, ConstantBackoff, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_DEGRADED_THRESHOLD, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, ExponentialBackoff, createServicePolicy, handleAll, handleWhen } from "./create-service-policy.mjs";
2
2
  export * from "./constants.mjs";
3
3
  export { BNToHex, convertHexToDecimal, fetchWithErrorHandling, fractionBN, fromHex, getBuyURL, gweiDecToWEIBN, handleFetch, hexToBN, hexToText, isNonEmptyArray, isPlainObject, isSafeChainId, isSafeDynamicKey, isSmartContractCode, isValidJson, isValidHexAddress, normalizeEnsName, query, safelyExecute, safelyExecuteWithTimeout, successfulFetch, timeoutFetch, toChecksumHexAddress, toHex, weiHexToGweiDec, isEqualCaseInsensitive } from "./util.mjs";
4
4
  export * from "./types.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,UAAU,EACX,oCAAgC;AAMjC,gCAA4B;AAE5B,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,EACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB","sourcesContent":["export {\n BrokenCircuitError,\n CircuitState,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n createServicePolicy,\n handleAll,\n handleWhen,\n} from './create-service-policy';\nexport type {\n CockatielEvent,\n CreateServicePolicyOptions,\n ServicePolicy,\n} from './create-service-policy';\nexport * from './constants';\nexport type { NonEmptyArray } from './util';\nexport {\n BNToHex,\n convertHexToDecimal,\n fetchWithErrorHandling,\n fractionBN,\n fromHex,\n getBuyURL,\n gweiDecToWEIBN,\n handleFetch,\n hexToBN,\n hexToText,\n isNonEmptyArray,\n isPlainObject,\n isSafeChainId,\n isSafeDynamicKey,\n isSmartContractCode,\n isValidJson,\n isValidHexAddress,\n normalizeEnsName,\n query,\n safelyExecute,\n safelyExecuteWithTimeout,\n successfulFetch,\n timeoutFetch,\n toChecksumHexAddress,\n toHex,\n weiHexToGweiDec,\n isEqualCaseInsensitive,\n} from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,UAAU,EACX,oCAAgC;AAMjC,gCAA4B;AAE5B,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,eAAe,EACf,sBAAsB,EACvB,mBAAe;AAChB,4BAAwB;AACxB,2BAAuB","sourcesContent":["export {\n BrokenCircuitError,\n CircuitState,\n ConstantBackoff,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n ExponentialBackoff,\n createServicePolicy,\n handleAll,\n handleWhen,\n} from './create-service-policy';\nexport type {\n CockatielEvent,\n CreateServicePolicyOptions,\n ServicePolicy,\n} from './create-service-policy';\nexport * from './constants';\nexport type { NonEmptyArray } from './util';\nexport {\n BNToHex,\n convertHexToDecimal,\n fetchWithErrorHandling,\n fractionBN,\n fromHex,\n getBuyURL,\n gweiDecToWEIBN,\n handleFetch,\n hexToBN,\n hexToText,\n isNonEmptyArray,\n isPlainObject,\n isSafeChainId,\n isSafeDynamicKey,\n isSmartContractCode,\n isValidJson,\n isValidHexAddress,\n normalizeEnsName,\n query,\n safelyExecute,\n safelyExecuteWithTimeout,\n successfulFetch,\n timeoutFetch,\n toChecksumHexAddress,\n toHex,\n weiHexToGweiDec,\n isEqualCaseInsensitive,\n} from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NetworkNickname = exports.BlockExplorerUrl = exports.NetworksTicker = exports.ChainId = exports.BuiltInNetworkName = exports.isInfuraNetworkType = exports.isNetworkType = exports.NetworkType = exports.InfuraNetworkType = void 0;
3
+ exports.NetworkNickname = exports.BlockExplorerUrl = exports.NetworksTicker = exports.ChainId = exports.BuiltInNetworkName = exports.isInfuraNetworkType = exports.isNetworkType = exports.NetworkType = exports.CustomNetworkType = exports.InfuraNetworkType = void 0;
4
4
  /**
5
5
  * The names of built-in Infura networks
6
6
  */
@@ -12,11 +12,18 @@ exports.InfuraNetworkType = {
12
12
  'linea-sepolia': 'linea-sepolia',
13
13
  'linea-mainnet': 'linea-mainnet',
14
14
  };
15
+ /**
16
+ * Custom network types that are not part of Infura.
17
+ */
18
+ exports.CustomNetworkType = {
19
+ 'megaeth-testnet': 'megaeth-testnet',
20
+ };
15
21
  /**
16
22
  * The "network type"; either the name of a built-in network, or "rpc" for custom networks.
17
23
  */
18
24
  exports.NetworkType = {
19
25
  ...exports.InfuraNetworkType,
26
+ ...exports.CustomNetworkType,
20
27
  rpc: 'rpc',
21
28
  };
22
29
  /**
@@ -55,6 +62,7 @@ var BuiltInNetworkName;
55
62
  BuiltInNetworkName["LineaSepolia"] = "linea-sepolia";
56
63
  BuiltInNetworkName["LineaMainnet"] = "linea-mainnet";
57
64
  BuiltInNetworkName["Aurora"] = "aurora";
65
+ BuiltInNetworkName["MegaETHTestnet"] = "megaeth-testnet";
58
66
  })(BuiltInNetworkName || (exports.BuiltInNetworkName = BuiltInNetworkName = {}));
59
67
  /**
60
68
  * Decimal string chain IDs of built-in networks, by name.
@@ -68,7 +76,8 @@ exports.ChainId = {
68
76
  [BuiltInNetworkName.Aurora]: '0x4e454152',
69
77
  [BuiltInNetworkName.LineaGoerli]: '0xe704',
70
78
  [BuiltInNetworkName.LineaSepolia]: '0xe705',
71
- [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)
79
+ [BuiltInNetworkName.LineaMainnet]: '0xe708',
80
+ [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)
72
81
  };
73
82
  var NetworksTicker;
74
83
  (function (NetworksTicker) {
@@ -84,6 +93,7 @@ var NetworksTicker;
84
93
  NetworksTicker["linea-goerli"] = "LineaETH";
85
94
  NetworksTicker["linea-sepolia"] = "LineaETH";
86
95
  NetworksTicker["linea-mainnet"] = "ETH";
96
+ NetworksTicker["megaeth-testnet"] = "MegaETH";
87
97
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
88
98
  // eslint-disable-next-line @typescript-eslint/naming-convention
89
99
  NetworksTicker["rpc"] = "";
@@ -95,6 +105,7 @@ exports.BlockExplorerUrl = {
95
105
  [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',
96
106
  [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',
97
107
  [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',
108
+ [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',
98
109
  };
99
110
  exports.NetworkNickname = {
100
111
  [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',
@@ -103,5 +114,6 @@ exports.NetworkNickname = {
103
114
  [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',
104
115
  [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',
105
116
  [BuiltInNetworkName.LineaMainnet]: 'Linea',
117
+ [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',
106
118
  };
107
119
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA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AE,QAAQ;IAC3C,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,eAAe;CACpD,CAAC;AAGX,IAAY,cAgBX;AAhBD,WAAY,cAAc;IACxB,gFAAgF;IAChF,gEAAgE;IAChE,iCAAe,CAAA;IACf,gFAAgF;IAChF,gEAAgE;IAChE,sCAAoB,CAAA;IACpB,gFAAgF;IAChF,gEAAgE;IAChE,wCAAsB,CAAA;IACtB,2CAA2B,CAAA;IAC3B,4CAA4B,CAAA;IAC5B,uCAAuB,CAAA;IACvB,gFAAgF;IAChF,gEAAgE;IAChE,0BAAQ,CAAA;AACV,CAAC,EAhBW,cAAc,8BAAd,cAAc,QAgBzB;AAEY,QAAA,gBAAgB,GAAG;IAC9B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,sBAAsB;IACpD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,6BAA6B;IAC1D,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,8BAA8B;IAC5D,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,gCAAgC;IAClE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,iCAAiC;IACpE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,yBAAyB;CACR,CAAC;AAI1C,QAAA,eAAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;CACU,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\nexport enum NetworksTicker {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n mainnet = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n goerli = 'GoerliETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n 'linea-sepolia' = 'LineaETH',\n 'linea-mainnet' = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n rpc = '',\n}\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n} as const satisfies Record<InfuraNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n} as const satisfies Record<InfuraNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;CACxB,CAAC;AAKX;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,iBAAiB,EAAE,iBAAiB;CAC5B,CAAC;AASX;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,GAAG,yBAAiB;IACpB,GAAG,yBAAiB;IACpB,GAAG,EAAE,KAAK;CACF,CAAC;AAIX;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC,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AA;IAC5B,uCAAuB,CAAA;IACvB,6CAA6B,CAAA;IAC7B,gFAAgF;IAChF,gEAAgE;IAChE,0BAAQ,CAAA;AACV,CAAC,EAjBW,cAAc,8BAAd,cAAc,QAiBzB;AAEY,QAAA,gBAAgB,GAAG;IAC9B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,sBAAsB;IACpD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,6BAA6B;IAC1D,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,8BAA8B;IAC5D,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,gCAAgC;IAClE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,iCAAiC;IACpE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,yBAAyB;IAC5D,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,0BAA0B;CACV,CAAC;AAI3C,QAAA,eAAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;IAC1C,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,cAAc;CACE,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n 'megaeth-testnet': 'megaeth-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n MegaETHTestnet = 'megaeth-testnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\nexport enum NetworksTicker {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n mainnet = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n goerli = 'GoerliETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n 'linea-sepolia' = 'LineaETH',\n 'linea-mainnet' = 'ETH',\n 'megaeth-testnet' = 'MegaETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n rpc = '',\n}\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
package/dist/types.d.cts CHANGED
@@ -10,11 +10,23 @@ export declare const InfuraNetworkType: {
10
10
  readonly 'linea-mainnet': "linea-mainnet";
11
11
  };
12
12
  export type InfuraNetworkType = (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];
13
+ /**
14
+ * Custom network types that are not part of Infura.
15
+ */
16
+ export declare const CustomNetworkType: {
17
+ readonly 'megaeth-testnet': "megaeth-testnet";
18
+ };
19
+ export type CustomNetworkType = (typeof CustomNetworkType)[keyof typeof CustomNetworkType];
20
+ /**
21
+ * Network types supported including both Infura networks and other networks.
22
+ */
23
+ export type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;
13
24
  /**
14
25
  * The "network type"; either the name of a built-in network, or "rpc" for custom networks.
15
26
  */
16
27
  export declare const NetworkType: {
17
28
  readonly rpc: "rpc";
29
+ readonly 'megaeth-testnet': "megaeth-testnet";
18
30
  readonly mainnet: "mainnet";
19
31
  readonly goerli: "goerli";
20
32
  readonly sepolia: "sepolia";
@@ -50,7 +62,8 @@ export declare enum BuiltInNetworkName {
50
62
  LineaGoerli = "linea-goerli",
51
63
  LineaSepolia = "linea-sepolia",
52
64
  LineaMainnet = "linea-mainnet",
53
- Aurora = "aurora"
65
+ Aurora = "aurora",
66
+ MegaETHTestnet = "megaeth-testnet"
54
67
  }
55
68
  /**
56
69
  * Decimal string chain IDs of built-in networks, by name.
@@ -65,6 +78,7 @@ export declare const ChainId: {
65
78
  readonly "linea-goerli": "0xe704";
66
79
  readonly "linea-sepolia": "0xe705";
67
80
  readonly "linea-mainnet": "0xe708";
81
+ readonly "megaeth-testnet": "0x18c6";
68
82
  };
69
83
  export type ChainId = (typeof ChainId)[keyof typeof ChainId];
70
84
  export declare enum NetworksTicker {
@@ -74,6 +88,7 @@ export declare enum NetworksTicker {
74
88
  'linea-goerli' = "LineaETH",
75
89
  'linea-sepolia' = "LineaETH",
76
90
  'linea-mainnet' = "ETH",
91
+ 'megaeth-testnet' = "MegaETH",
77
92
  rpc = ""
78
93
  }
79
94
  export declare const BlockExplorerUrl: {
@@ -83,6 +98,7 @@ export declare const BlockExplorerUrl: {
83
98
  readonly "linea-goerli": "https://goerli.lineascan.build";
84
99
  readonly "linea-sepolia": "https://sepolia.lineascan.build";
85
100
  readonly "linea-mainnet": "https://lineascan.build";
101
+ readonly "megaeth-testnet": "https://megaexplorer.xyz";
86
102
  };
87
103
  export type BlockExplorerUrl = (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
88
104
  export declare const NetworkNickname: {
@@ -92,6 +108,7 @@ export declare const NetworkNickname: {
92
108
  readonly "linea-goerli": "Linea Goerli";
93
109
  readonly "linea-sepolia": "Linea Sepolia";
94
110
  readonly "linea-mainnet": "Linea";
111
+ readonly "megaeth-testnet": "Mega Testnet";
95
112
  };
96
113
  export type NetworkNickname = (typeof NetworkNickname)[keyof typeof NetworkNickname];
97
114
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAOpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;CAGd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAG5B;AAED;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,WAAW,iBAAiB;IAC5B,YAAY,kBAAkB;IAC9B,YAAY,kBAAkB;IAC9B,MAAM,WAAW;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;;;;CAQV,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,oBAAY,cAAc;IAGxB,OAAO,QAAQ;IAGf,MAAM,cAAc;IAGpB,OAAO,eAAe;IACtB,cAAc,aAAa;I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,CAAC"}
package/dist/types.d.mts CHANGED
@@ -10,11 +10,23 @@ export declare const InfuraNetworkType: {
10
10
  readonly 'linea-mainnet': "linea-mainnet";
11
11
  };
12
12
  export type InfuraNetworkType = (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];
13
+ /**
14
+ * Custom network types that are not part of Infura.
15
+ */
16
+ export declare const CustomNetworkType: {
17
+ readonly 'megaeth-testnet': "megaeth-testnet";
18
+ };
19
+ export type CustomNetworkType = (typeof CustomNetworkType)[keyof typeof CustomNetworkType];
20
+ /**
21
+ * Network types supported including both Infura networks and other networks.
22
+ */
23
+ export type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;
13
24
  /**
14
25
  * The "network type"; either the name of a built-in network, or "rpc" for custom networks.
15
26
  */
16
27
  export declare const NetworkType: {
17
28
  readonly rpc: "rpc";
29
+ readonly 'megaeth-testnet': "megaeth-testnet";
18
30
  readonly mainnet: "mainnet";
19
31
  readonly goerli: "goerli";
20
32
  readonly sepolia: "sepolia";
@@ -50,7 +62,8 @@ export declare enum BuiltInNetworkName {
50
62
  LineaGoerli = "linea-goerli",
51
63
  LineaSepolia = "linea-sepolia",
52
64
  LineaMainnet = "linea-mainnet",
53
- Aurora = "aurora"
65
+ Aurora = "aurora",
66
+ MegaETHTestnet = "megaeth-testnet"
54
67
  }
55
68
  /**
56
69
  * Decimal string chain IDs of built-in networks, by name.
@@ -65,6 +78,7 @@ export declare const ChainId: {
65
78
  readonly "linea-goerli": "0xe704";
66
79
  readonly "linea-sepolia": "0xe705";
67
80
  readonly "linea-mainnet": "0xe708";
81
+ readonly "megaeth-testnet": "0x18c6";
68
82
  };
69
83
  export type ChainId = (typeof ChainId)[keyof typeof ChainId];
70
84
  export declare enum NetworksTicker {
@@ -74,6 +88,7 @@ export declare enum NetworksTicker {
74
88
  'linea-goerli' = "LineaETH",
75
89
  'linea-sepolia' = "LineaETH",
76
90
  'linea-mainnet' = "ETH",
91
+ 'megaeth-testnet' = "MegaETH",
77
92
  rpc = ""
78
93
  }
79
94
  export declare const BlockExplorerUrl: {
@@ -83,6 +98,7 @@ export declare const BlockExplorerUrl: {
83
98
  readonly "linea-goerli": "https://goerli.lineascan.build";
84
99
  readonly "linea-sepolia": "https://sepolia.lineascan.build";
85
100
  readonly "linea-mainnet": "https://lineascan.build";
101
+ readonly "megaeth-testnet": "https://megaexplorer.xyz";
86
102
  };
87
103
  export type BlockExplorerUrl = (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
88
104
  export declare const NetworkNickname: {
@@ -92,6 +108,7 @@ export declare const NetworkNickname: {
92
108
  readonly "linea-goerli": "Linea Goerli";
93
109
  readonly "linea-sepolia": "Linea Sepolia";
94
110
  readonly "linea-mainnet": "Linea";
111
+ readonly "megaeth-testnet": "Mega Testnet";
95
112
  };
96
113
  export type NetworkNickname = (typeof NetworkNickname)[keyof typeof NetworkNickname];
97
114
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAOpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;CAGd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAG5B;AAED;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,WAAW,iB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B,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAClD,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,UAAU;AACrC,wDAAwD;AACxD,OAAO,EAAE,YAAY;AAErB;;;;GAIG;AACH,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,UAAU,KACxC,OAAO,CAAC,UAAU,CAAC,CAAC"}
package/dist/types.mjs CHANGED
@@ -9,11 +9,18 @@ export const InfuraNetworkType = {
9
9
  'linea-sepolia': 'linea-sepolia',
10
10
  'linea-mainnet': 'linea-mainnet',
11
11
  };
12
+ /**
13
+ * Custom network types that are not part of Infura.
14
+ */
15
+ export const CustomNetworkType = {
16
+ 'megaeth-testnet': 'megaeth-testnet',
17
+ };
12
18
  /**
13
19
  * The "network type"; either the name of a built-in network, or "rpc" for custom networks.
14
20
  */
15
21
  export const NetworkType = {
16
22
  ...InfuraNetworkType,
23
+ ...CustomNetworkType,
17
24
  rpc: 'rpc',
18
25
  };
19
26
  /**
@@ -50,6 +57,7 @@ export var BuiltInNetworkName;
50
57
  BuiltInNetworkName["LineaSepolia"] = "linea-sepolia";
51
58
  BuiltInNetworkName["LineaMainnet"] = "linea-mainnet";
52
59
  BuiltInNetworkName["Aurora"] = "aurora";
60
+ BuiltInNetworkName["MegaETHTestnet"] = "megaeth-testnet";
53
61
  })(BuiltInNetworkName || (BuiltInNetworkName = {}));
54
62
  /**
55
63
  * Decimal string chain IDs of built-in networks, by name.
@@ -63,7 +71,8 @@ export const ChainId = {
63
71
  [BuiltInNetworkName.Aurora]: '0x4e454152',
64
72
  [BuiltInNetworkName.LineaGoerli]: '0xe704',
65
73
  [BuiltInNetworkName.LineaSepolia]: '0xe705',
66
- [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)
74
+ [BuiltInNetworkName.LineaMainnet]: '0xe708',
75
+ [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)
67
76
  };
68
77
  export var NetworksTicker;
69
78
  (function (NetworksTicker) {
@@ -79,6 +88,7 @@ export var NetworksTicker;
79
88
  NetworksTicker["linea-goerli"] = "LineaETH";
80
89
  NetworksTicker["linea-sepolia"] = "LineaETH";
81
90
  NetworksTicker["linea-mainnet"] = "ETH";
91
+ NetworksTicker["megaeth-testnet"] = "MegaETH";
82
92
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
83
93
  // eslint-disable-next-line @typescript-eslint/naming-convention
84
94
  NetworksTicker["rpc"] = "";
@@ -90,6 +100,7 @@ export const BlockExplorerUrl = {
90
100
  [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',
91
101
  [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',
92
102
  [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',
103
+ [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',
93
104
  };
94
105
  export const NetworkNickname = {
95
106
  [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',
@@ -98,5 +109,6 @@ export const NetworkNickname = {
98
109
  [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',
99
110
  [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',
100
111
  [BuiltInNetworkName.LineaMainnet]: 'Linea',
112
+ [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',
101
113
  };
102
114
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;CACxB,CAAC;AAKX;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AAA;IACf,gFAAgF;IAChF,gEAAgE;IAChE,sCAAoB,CAAA;IACpB,gFAAgF;IAChF,gEAAgE;IAChE,wCAAsB,CAAA;IACtB,2CAA2B,CAAA;IAC3B,4CAA4B,CAAA;IAC5B,uCAAuB,CAAA;IACvB,gFAAgF;IAChF,gEAAgE;IAChE,0BAAQ,CAAA;AACV,CAAC,EAhBW,cAAc,KAAd,cAAc,QAgBzB;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,sBAAsB;IACpD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,6BAA6B;IAC1D,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,8BAA8B;IAC5D,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,gCAAgC;IAClE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,iCAAiC;IACpE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,yBAAyB;CACR,CAAC;AAIvD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;CACU,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\nexport enum NetworksTicker {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n mainnet = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n goerli = 'GoerliETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n 'linea-sepolia' = 'LineaETH',\n 'linea-mainnet' = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n rpc = '',\n}\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n} as const satisfies Record<InfuraNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n} as const satisfies Record<InfuraNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;CACxB,CAAC;AAKX;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,iBAAiB,EAAE,iBAAiB;CAC5B,CAAC;AASX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,iBAAiB;IACpB,GAAG,iBAAiB;IACpB,GAAG,EAAE,KAAK;CACF,CAAC;AAIX;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,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AACV,CAAC,EAjBW,cAAc,KAAd,cAAc,QAiBzB;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,sBAAsB;IACpD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,6BAA6B;IAC1D,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,8BAA8B;IAC5D,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,gCAAgC;IAClE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,iCAAiC;IACpE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,yBAAyB;IAC5D,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,0BAA0B;CACV,CAAC;AAIxD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;IAC1C,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,cAAc;CACE,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n 'megaeth-testnet': 'megaeth-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n MegaETHTestnet = 'megaeth-testnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\nexport enum NetworksTicker {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n mainnet = 'ETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n goerli = 'GoerliETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n 'linea-sepolia' = 'LineaETH',\n 'linea-mainnet' = 'ETH',\n 'megaeth-testnet' = 'MegaETH',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n rpc = '',\n}\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/controller-utils",
3
- "version": "11.6.0-preview-f15cb863",
3
+ "version": "11.6.0-preview-29fe07c",
4
4
  "description": "Data and convenience functions shared by multiple packages",
5
5
  "keywords": [
6
6
  "MetaMask",