@manifoldxyz/client-sdk 0.2.1-beta.0 → 0.2.1-beta.1

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,4 +1,4 @@
1
- import { s as slice, t as toFunctionSelector, f as formatAbiItem, A as AbiFunctionSignatureNotFoundError, d as decodeAbiParameters, g as getAbiItem, a as AbiErrorNotFoundError, b as AbiErrorInputsNotFoundError, e as encodeAbiParameters, c as concatHex, h as AbiFunctionNotFoundError, i as AbiFunctionOutputsNotFoundError, I as InvalidArrayError, j as batchGatewayAbi, k as solidityError, l as isAddress, m as InvalidAddressError, B as BaseError, n as getUrl, o as stringify, p as decodeErrorResult, q as call, r as concat, H as HttpRequestError, u as isHex } from "./index-DGpw9QQu.js";
1
+ import { s as slice, t as toFunctionSelector, f as formatAbiItem, A as AbiFunctionSignatureNotFoundError, d as decodeAbiParameters, g as getAbiItem, a as AbiErrorNotFoundError, b as AbiErrorInputsNotFoundError, e as encodeAbiParameters, c as concatHex, h as AbiFunctionNotFoundError, i as AbiFunctionOutputsNotFoundError, I as InvalidArrayError, j as batchGatewayAbi, k as solidityError, l as isAddress, m as InvalidAddressError, B as BaseError, n as getUrl, o as stringify, p as decodeErrorResult, q as call, r as concat, H as HttpRequestError, u as isHex } from "./index-C8izdeEk.js";
2
2
  function decodeFunctionData(parameters) {
3
3
  const { abi, data } = parameters;
4
4
  const signature = slice(data, 0, 4);
@@ -259,4 +259,4 @@ export {
259
259
  offchainLookupAbiItem,
260
260
  offchainLookupSignature
261
261
  };
262
- //# sourceMappingURL=ccip-Dn3GN1nR.js.map
262
+ //# sourceMappingURL=ccip-DSmOv0SM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ccip-Dn3GN1nR.js","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["docsPath","ccipRequest"],"mappings":";AAKO,SAAS,mBAAmB,YAAY;AAC3C,QAAM,EAAE,KAAK,KAAI,IAAK;AACtB,QAAM,YAAY,MAAM,MAAM,GAAG,CAAC;AAClC,QAAM,cAAc,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,cAC3C,cAAc,mBAAmB,cAAc,CAAC,CAAC,CAAC;AACtD,MAAI,CAAC;AACD,UAAM,IAAI,kCAAkC,WAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAc,YAAY;AAAA,IAC1B,MAAO,YAAY,eACf,YAAY,UACZ,YAAY,OAAO,SAAS,IAC1B,oBAAoB,YAAY,QAAQ,MAAM,MAAM,CAAC,CAAC,IACtD;AAAA,EACd;AACA;AChBA,MAAMA,aAAW;AACV,SAAS,kBAAkB,YAAY;AAC1C,QAAM,EAAE,KAAK,WAAW,KAAI,IAAK;AACjC,MAAI,UAAU,IAAI,CAAC;AACnB,MAAI,WA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_ignoreList":[0,1,2,3,4,5,6]}
1
+ {"version":3,"file":"ccip-DSmOv0SM.js","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["docsPath","ccipRequest"],"mappings":";AAKO,SAAS,mBAAmB,YAAY;AAC3C,QAAM,EAAE,KAAK,KAAI,IAAK;AACtB,QAAM,YAAY,MAAM,MAAM,GAAG,CAAC;AAClC,QAAM,cAAc,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,cAC3C,cAAc,mBAAmB,cAAc,CAAC,CAAC,CAAC;AACtD,MAAI,CAAC;AACD,UAAM,IAAI,kCAAkC,WAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAc,YAAY;AAAA,IAC1B,MAAO,YAAY,eACf,YAAY,UACZ,YAAY,OAAO,SAAS,IAC1B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AAA,QACpB,CAAiB;AACD;AAAA,MACJ;AACA,aAAO;AAAA,IACX,SACO,KAAK;AACR,cAAQ,IAAI,iBAAiB;AAAA,QACzB;AAAA,QACA,SAAS,IAAI;AAAA,QACb;AAAA,MAChB,CAAa;AAAA,IACL;AAAA,EACJ;AACA,QAAM;AACV;","x_google_ignoreList":[0,1,2,3,4,5,6]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-z_D3mW1P.cjs");
3
+ const index = require("./index-DlJgkZgw.cjs");
4
4
  function decodeFunctionData(parameters) {
5
5
  const { abi, data } = parameters;
6
6
  const signature = index.slice(data, 0, 4);
@@ -259,4 +259,4 @@ exports.ccipRequest = ccipRequest;
259
259
  exports.offchainLookup = offchainLookup;
260
260
  exports.offchainLookupAbiItem = offchainLookupAbiItem;
261
261
  exports.offchainLookupSignature = offchainLookupSignature;
262
- //# sourceMappingURL=ccip-Bw7U8LOx.cjs.map
262
+ //# sourceMappingURL=ccip-R9qiZGzw.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ccip-Bw7U8LOx.cjs","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["slice","toFunctionSelector","formatAbiItem","AbiFunctionSignatureNotFoundError","decodeAbiParameters","docsPath","getAbiItem","AbiErrorNotFoundError","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","AbiFunctionNotFoundError","AbiFunctionOutputsNotFoundError","InvalidArrayError","ccipRequest","batchGatewayAbi","solidityError","isAddress","InvalidAddressError","BaseError","getUrl","stringify","decodeErrorResult","call","concat","HttpRequestError","isHex"],"mappings":";;;AAKO,SAAS,mBAAmB,YAAY;AAC3C,QAAM,EAAE,KAAK,KAAI,IAAK;AACtB,QAAM,YAAYA,MAAAA,MAAM,MAAM,GAAG,CAAC;AAClC,QAAM,cAAc,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,cAC3C,cAAcC,MAAAA,mBAAmBC,oBAAc,CAAC,CAAC,CAAC;AACtD,MAAI,CAAC;AACD,UAAM,IAAIC,MAAAA,kCAAkC,WAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAc,YAAY;AAAA,IAC1B,MAAO,YAAY,eACf,YAAY,UACZ,YAAY,OAAO,SAAS,IAC1BC,MAAAA,oBAAoB,YAAY,QAAQJ,MAAAA,MAAM,MAAM,CAAC,CAAC,IACtD;AAAA,EACd;AACA;AChBA,MAAMK,aAAW;AACV,SAAS,kBAAkB,YAAY;AAC1C,QAAM,EAAE,KAAK,WAAW,KAAI,IAAK;AACjC,MAAI,UAAU,IAAI,CAAC;AACnB,MAAI,WAAW;AACX,UAAM,OAAOC,MAAAA,WAAW,EAAE,KAAK,MAAM,MAAM,WAAW;AACtD,QAAI,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B,CAAiB;AACD;AAAA,MACJ;AACA,aAAO;AAAA,IACX,SACO,KAAK;AACR,cAAQ,IAAID,MAAAA,iBAAiB;AAAA,QACzB;AAAA,QACA,SAAS,IAAI;AAAA,QACb;AAAA,MAChB,CAAa;AAAA,IACL;AAAA,EACJ;AACA,QAAM;AACV;;;;;","x_google_ignoreList":[0,1,2,3,4,5,6]}
1
+ {"version":3,"file":"ccip-R9qiZGzw.cjs","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["slice","toFunctionSelector","formatAbiItem","AbiFunctionSignatureNotFoundError","decodeAbiParameters","docsPath","getAbiItem","AbiErrorNotFoundError","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","AbiFunctionNotFoundError","AbiFunctionOutputsNotFoundError","InvalidArrayError","ccipRequest","batchGatewayAbi","solidityError","isAddress","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AAE,MAAM,OAAM,IAAK;AACpD,UAAM,UAAU,WAAW,SAAS,EAAE,gBAAgB,mBAAkB,IAAK,CAAA;AAC7E,QAAI;AACA,YAAM,WAAW,MAAM,MAAM,IAAI,QAAQ,YAAY,OAAO,YAAW,CAAE,EAAE,QAAQ,UAAU,IAAI,GAAG;AAAA,QAChG,MAAM,KAAK,UAAU,IAAI;AAAA,QACzB;AAAA,QACA;AAAA,MAChB,CAAa;AACD,UAAI;AACJ,UAAI,SAAS,QAAQ,IAAI,cAAc,GAAG,WAAW,kBAAkB,GAAG;AACtE,kBAAU,MAAM,SAAS,KAAI,GAAI;AAAA,MACrC,OACK;AACD,iBAAU,MAAM,SAAS;MAC7B;AACA,UAAI,CAAC,SAAS,IAAI;AACd,gBAAQ,IAAIgB,MAAAA,iBAAiB;AAAA,UACzB;AAAA,UACA,SAAS,QAAQ,QACXJ,MAAAA,UAAU,OAAO,KAAK,IACtB,SAAS;AAAA,UACf,SAAS,SAAS;AAAA,UAClB,QAAQ,SAAS;AAAA,UACjB;AAAA,QACpB,CAAiB;AACD;AAAA,MACJ;AACA,UAAI,CAACK,MAAAA,MAAM,MAAM,GAAG;AAChB,gBAAQ,IAAI,qCAAqC;AAAA,UAC7C;AAAA,UACA;AAAA,QACpB,CAAiB;AACD;AAAA,MACJ;AACA,aAAO;AAAA,IACX,SACO,KAAK;AACR,cAAQ,IAAID,MAAAA,iBAAiB;AAAA,QACzB;AAAA,QACA,SAAS,IAAI;AAAA,QACb;AAAA,MAChB,CAAa;AAAA,IACL;AAAA,EACJ;AACA,QAAM;AACV;;;;;","x_google_ignoreList":[0,1,2,3,4,5,6]}
@@ -9992,16 +9992,19 @@ var PlatformFeeType = /* @__PURE__ */ ((PlatformFeeType2) => {
9992
9992
  PlatformFeeType2["MINT_FEE_MERKLE"] = "MINT_FEE_MERKLE";
9993
9993
  return PlatformFeeType2;
9994
9994
  })(PlatformFeeType || {});
9995
- function createProvider(options) {
9995
+ async function createProvider(options) {
9996
9996
  const { networkId, customRpcUrls, useBridge = true } = options;
9997
9997
  const primary = createPrimaryProvider(networkId, customRpcUrls);
9998
9998
  if (primary) {
9999
- return primary;
9999
+ const isHealthy = await isProviderHealthy(primary);
10000
+ if (isHealthy) {
10001
+ return primary;
10002
+ }
10000
10003
  }
10001
10004
  if (!useBridge) {
10002
10005
  throw new ClientSDKError(
10003
10006
  ErrorCode.MISSING_RPC_URL,
10004
- `No RPC URL available for networkId ${networkId}`
10007
+ `Unable to obtain valid RPC URL for networkId ${networkId}`
10005
10008
  );
10006
10009
  }
10007
10010
  const bridgeProvider = new ManifoldBridgeProvider(networkId);
@@ -10022,6 +10025,15 @@ function createPrimaryProvider(networkId, customRpcUrls) {
10022
10025
  return null;
10023
10026
  }
10024
10027
  }
10028
+ async function isProviderHealthy(provider) {
10029
+ try {
10030
+ await provider.getBlockNumber();
10031
+ return true;
10032
+ } catch (error) {
10033
+ console.warn("Primary RPC health check failed:", error.message);
10034
+ return false;
10035
+ }
10036
+ }
10025
10037
  const GachaExtensionERC1155ABIv2 = [
10026
10038
  {
10027
10039
  inputs: [{ internalType: "address", name: "initialOwner", type: "address" }],
@@ -11950,13 +11962,13 @@ class BlindMintProduct {
11950
11962
  if (this.onchainData && !force) {
11951
11963
  return this.onchainData;
11952
11964
  }
11953
- const contract = this._getClaimContract();
11965
+ const contract = await this._getClaimContract();
11954
11966
  try {
11955
11967
  const claimData = await contract.getClaim(this._creatorContract, this.id);
11956
11968
  const onchainData = await this._processClaimData(claimData);
11957
11969
  const mintFee = await contract.MINT_FEE();
11958
11970
  const networkId = this.data.publicData.network;
11959
- const provider = createProvider({
11971
+ const provider = await createProvider({
11960
11972
  networkId,
11961
11973
  customRpcUrls: this._httpRPCs
11962
11974
  });
@@ -12054,7 +12066,7 @@ class BlindMintProduct {
12054
12066
  throw new ClientSDKError(ErrorCode.INVALID_INPUT, "Quantity exceeds available allocation");
12055
12067
  }
12056
12068
  const onchainData = await this.fetchOnchainData();
12057
- const provider = createProvider({
12069
+ const provider = await createProvider({
12058
12070
  networkId,
12059
12071
  customRpcUrls: this._httpRPCs
12060
12072
  });
@@ -12236,9 +12248,9 @@ class BlindMintProduct {
12236
12248
  // =============================================================================
12237
12249
  // HELPER METHODS
12238
12250
  // =============================================================================
12239
- _getClaimContract() {
12251
+ async _getClaimContract() {
12240
12252
  const networkId = this.data.publicData.network || 1;
12241
- const provider = createProvider({
12253
+ const provider = await createProvider({
12242
12254
  networkId,
12243
12255
  customRpcUrls: this._httpRPCs
12244
12256
  });
@@ -12255,7 +12267,7 @@ class BlindMintProduct {
12255
12267
  return !unixSeconds ? void 0 : new Date(unixSeconds * 1e3);
12256
12268
  };
12257
12269
  const networkId = this.data.publicData.network;
12258
- const provider = createProvider({
12270
+ const provider = await createProvider({
12259
12271
  networkId,
12260
12272
  customRpcUrls: this._httpRPCs
12261
12273
  });
@@ -12315,7 +12327,7 @@ class BlindMintProduct {
12315
12327
  // HELPER METHODS
12316
12328
  // =============================================================================
12317
12329
  async _estimateGas(from, _to, quantity, value) {
12318
- const contract = this._getClaimContract();
12330
+ const contract = await this._getClaimContract();
12319
12331
  const mintIndices = [];
12320
12332
  const merkleProofs = [];
12321
12333
  return await estimateGas({
@@ -12579,10 +12591,10 @@ class EditionProduct {
12579
12591
  return this.onchainData;
12580
12592
  }
12581
12593
  try {
12582
- const contract = this._getClaimContract();
12594
+ const contract = await this._getClaimContract();
12583
12595
  const claimData = await contract.getClaim(this._creatorContract, this.id);
12584
12596
  const networkId = this.data.publicData.network;
12585
- const provider = createProvider({
12597
+ const provider = await createProvider({
12586
12598
  networkId,
12587
12599
  customRpcUrls: this._httpRPCs
12588
12600
  });
@@ -12690,7 +12702,7 @@ class EditionProduct {
12690
12702
  throw new ClientSDKError(ErrorCode.INVALID_INPUT, "Quantity exceeds available allocation");
12691
12703
  }
12692
12704
  const onchainData = await this.fetchOnchainData();
12693
- const provider = createProvider({
12705
+ const provider = await createProvider({
12694
12706
  networkId,
12695
12707
  customRpcUrls: this._httpRPCs
12696
12708
  });
@@ -12807,7 +12819,7 @@ class EditionProduct {
12807
12819
  execute: async (account2, options) => {
12808
12820
  await account2.switchNetwork(networkId);
12809
12821
  const address2 = await account2.getAddress();
12810
- const editionContract = this._getClaimContract();
12822
+ const editionContract = await this._getClaimContract();
12811
12823
  const gasEstimate = await estimateGas({
12812
12824
  contract: editionContract,
12813
12825
  method: "mintProxy",
@@ -12921,9 +12933,9 @@ class EditionProduct {
12921
12933
  `Unsupported contract spec: ${this.contract.spec}`
12922
12934
  );
12923
12935
  }
12924
- _getClaimContract() {
12936
+ async _getClaimContract() {
12925
12937
  const networkId = this.data.publicData.network || 1;
12926
- const provider = createProvider({
12938
+ const provider = await createProvider({
12927
12939
  networkId,
12928
12940
  customRpcUrls: this._httpRPCs
12929
12941
  });
@@ -12938,7 +12950,7 @@ class EditionProduct {
12938
12950
  return new Date(unixSeconds * 1e3);
12939
12951
  };
12940
12952
  const networkId = this.data.publicData.network;
12941
- const provider = createProvider({
12953
+ const provider = await createProvider({
12942
12954
  networkId,
12943
12955
  customRpcUrls: this._httpRPCs
12944
12956
  });
@@ -13009,7 +13021,7 @@ class EditionProduct {
13009
13021
  return { mintIndices: [], merkleProofs: [] };
13010
13022
  }
13011
13023
  if (this.data.publicData.instanceAllowlist?.merkleTreeId) {
13012
- const contract = this._getClaimContract();
13024
+ const contract = await this._getClaimContract();
13013
13025
  const claimableMerkleInfo = await this._fetchClaimableMerkleInfo(
13014
13026
  this.data.publicData.instanceAllowlist.merkleTreeId,
13015
13027
  walletAddress,
@@ -13049,7 +13061,7 @@ class EditionProduct {
13049
13061
  });
13050
13062
  }
13051
13063
  const onchainData = await this.fetchOnchainData();
13052
- const contract = this._getClaimContract();
13064
+ const contract = await this._getClaimContract();
13053
13065
  const totalSupply = onchainData.totalMax || Infinity;
13054
13066
  const total = onchainData.total;
13055
13067
  const availableSupply = Math.max(0, totalSupply - total);
@@ -13180,87 +13192,6 @@ class EditionProduct {
13180
13192
  function isEditionProduct(product) {
13181
13193
  return product?.type === AppType.EDITION;
13182
13194
  }
13183
- async function poll$1(options) {
13184
- const {
13185
- fetch: fetch2,
13186
- validate,
13187
- intervalMs = 500,
13188
- maxAttempts = 20,
13189
- errorMessage = "Polling condition not satisfied within timeout"
13190
- } = options;
13191
- let attempts = 0;
13192
- while (attempts < maxAttempts) {
13193
- const value = await fetch2();
13194
- if (validate(value)) {
13195
- return value;
13196
- }
13197
- attempts += 1;
13198
- if (attempts >= maxAttempts) {
13199
- break;
13200
- }
13201
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
13202
- }
13203
- throw new ClientSDKError(ErrorCode.TIMEOUT, errorMessage);
13204
- }
13205
- async function ensureConnectedNetwork(options) {
13206
- const {
13207
- getConnectedNetwork,
13208
- switchNetwork,
13209
- addNetwork,
13210
- targetNetworkId,
13211
- pollIntervalMs = 500,
13212
- maxAttempts = 20
13213
- } = options;
13214
- const networkName = d.getDisplayNameForNetworkId(targetNetworkId, true);
13215
- const throwEnsureError = async (message, originalError) => {
13216
- const actualNetworkId = await getConnectedNetwork();
13217
- throw new ClientSDKError(ErrorCode.WRONG_NETWORK, message, {
13218
- expectedNetworkId: targetNetworkId,
13219
- actualNetworkId,
13220
- originalError: originalError instanceof Error ? originalError : void 0
13221
- });
13222
- };
13223
- try {
13224
- await switchNetwork(targetNetworkId);
13225
- } catch (switchError) {
13226
- console.error(switchError);
13227
- const code = switchError?.code;
13228
- if (code === 4902) {
13229
- try {
13230
- const networkConfigs = d.NETWORK_CONFIGS[targetNetworkId];
13231
- if (networkConfigs) {
13232
- const params = {
13233
- chainId: `0x${targetNetworkId.toString(16)}`,
13234
- chainName: networkConfigs.chainName,
13235
- nativeCurrency: networkConfigs.nativeCurrency,
13236
- rpcUrls: networkConfigs.rpcUrls,
13237
- blockExplorerUrls: networkConfigs.blockExplorerUrls
13238
- };
13239
- await addNetwork(params);
13240
- }
13241
- await switchNetwork(targetNetworkId);
13242
- } catch (addNetworkError) {
13243
- const message = addNetworkError instanceof Error && addNetworkError.message ? addNetworkError.message : `Failed to switch to the ${networkName} network`;
13244
- await throwEnsureError(message, addNetworkError);
13245
- }
13246
- } else {
13247
- const message = switchError instanceof Error && switchError.message ? switchError.message : `Failed to switch to the ${networkName} network`;
13248
- await throwEnsureError(message, switchError);
13249
- }
13250
- }
13251
- try {
13252
- await poll$1({
13253
- fetch: () => getConnectedNetwork(),
13254
- validate: (value) => value === targetNetworkId,
13255
- intervalMs: pollIntervalMs,
13256
- maxAttempts,
13257
- errorMessage: `Failed to confirm network switch to ${networkName}`
13258
- });
13259
- } catch (confirmationError) {
13260
- const message = confirmationError instanceof Error && confirmationError.message ? confirmationError.message : `Failed to confirm network switch to ${networkName}`;
13261
- await throwEnsureError(message, confirmationError);
13262
- }
13263
- }
13264
13195
  function isBlindMintInstanceData(instanceData) {
13265
13196
  return instanceData.appId === AppId.BLIND_MINT_1155;
13266
13197
  }
@@ -13269,19 +13200,8 @@ function isEditionInstanceData(instanceData) {
13269
13200
  }
13270
13201
  function createClient(config) {
13271
13202
  const httpRPCs = config?.httpRPCs ?? {};
13272
- const providers = {};
13273
- if (httpRPCs && Object.keys(httpRPCs).length > 0) {
13274
- for (const [networkIdStr] of Object.entries(httpRPCs)) {
13275
- const networkId = Number(networkIdStr);
13276
- providers[networkId] = createProvider({
13277
- networkId,
13278
- customRpcUrls: httpRPCs,
13279
- useBridge: false
13280
- });
13281
- }
13282
- }
13283
13203
  return {
13284
- providers,
13204
+ httpRPCs,
13285
13205
  /**
13286
13206
  * Fetches detailed product information from Manifold.
13287
13207
  *
@@ -13413,6 +13333,87 @@ function createClient(config) {
13413
13333
  }
13414
13334
  };
13415
13335
  }
13336
+ async function poll$1(options) {
13337
+ const {
13338
+ fetch: fetch2,
13339
+ validate,
13340
+ intervalMs = 500,
13341
+ maxAttempts = 20,
13342
+ errorMessage = "Polling condition not satisfied within timeout"
13343
+ } = options;
13344
+ let attempts = 0;
13345
+ while (attempts < maxAttempts) {
13346
+ const value = await fetch2();
13347
+ if (validate(value)) {
13348
+ return value;
13349
+ }
13350
+ attempts += 1;
13351
+ if (attempts >= maxAttempts) {
13352
+ break;
13353
+ }
13354
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
13355
+ }
13356
+ throw new ClientSDKError(ErrorCode.TIMEOUT, errorMessage);
13357
+ }
13358
+ async function ensureConnectedNetwork(options) {
13359
+ const {
13360
+ getConnectedNetwork,
13361
+ switchNetwork,
13362
+ addNetwork,
13363
+ targetNetworkId,
13364
+ pollIntervalMs = 500,
13365
+ maxAttempts = 20
13366
+ } = options;
13367
+ const networkName = d.getDisplayNameForNetworkId(targetNetworkId, true);
13368
+ const throwEnsureError = async (message, originalError) => {
13369
+ const actualNetworkId = await getConnectedNetwork();
13370
+ throw new ClientSDKError(ErrorCode.WRONG_NETWORK, message, {
13371
+ expectedNetworkId: targetNetworkId,
13372
+ actualNetworkId,
13373
+ originalError: originalError instanceof Error ? originalError : void 0
13374
+ });
13375
+ };
13376
+ try {
13377
+ await switchNetwork(targetNetworkId);
13378
+ } catch (switchError) {
13379
+ console.error(switchError);
13380
+ const code = switchError?.code;
13381
+ if (code === 4902) {
13382
+ try {
13383
+ const networkConfigs = d.NETWORK_CONFIGS[targetNetworkId];
13384
+ if (networkConfigs) {
13385
+ const params = {
13386
+ chainId: `0x${targetNetworkId.toString(16)}`,
13387
+ chainName: networkConfigs.chainName,
13388
+ nativeCurrency: networkConfigs.nativeCurrency,
13389
+ rpcUrls: networkConfigs.rpcUrls,
13390
+ blockExplorerUrls: networkConfigs.blockExplorerUrls
13391
+ };
13392
+ await addNetwork(params);
13393
+ }
13394
+ await switchNetwork(targetNetworkId);
13395
+ } catch (addNetworkError) {
13396
+ const message = addNetworkError instanceof Error && addNetworkError.message ? addNetworkError.message : `Failed to switch to the ${networkName} network`;
13397
+ await throwEnsureError(message, addNetworkError);
13398
+ }
13399
+ } else {
13400
+ const message = switchError instanceof Error && switchError.message ? switchError.message : `Failed to switch to the ${networkName} network`;
13401
+ await throwEnsureError(message, switchError);
13402
+ }
13403
+ }
13404
+ try {
13405
+ await poll$1({
13406
+ fetch: () => getConnectedNetwork(),
13407
+ validate: (value) => value === targetNetworkId,
13408
+ intervalMs: pollIntervalMs,
13409
+ maxAttempts,
13410
+ errorMessage: `Failed to confirm network switch to ${networkName}`
13411
+ });
13412
+ } catch (confirmationError) {
13413
+ const message = confirmationError instanceof Error && confirmationError.message ? confirmationError.message : `Failed to confirm network switch to ${networkName}`;
13414
+ await throwEnsureError(message, confirmationError);
13415
+ }
13416
+ }
13416
13417
  class Ethers5Account {
13417
13418
  /**
13418
13419
  * Initialize adapter with ethers v5 provider or signer.
@@ -13623,7 +13624,11 @@ class Ethers5Account {
13623
13624
  if (!wallet) {
13624
13625
  throw new ClientSDKError(ErrorCode.UNKNOWN_ERROR, `Unknown error, could not locate wallet`);
13625
13626
  }
13626
- const provider = this._client.providers?.[networkId];
13627
+ const provider = await createProvider({
13628
+ customRpcUrls: this._client.httpRPCs,
13629
+ networkId,
13630
+ useBridge: false
13631
+ });
13627
13632
  if (!provider) {
13628
13633
  throw new ClientSDKError(
13629
13634
  ErrorCode.MISSING_RPC_URL,
@@ -17800,7 +17805,7 @@ async function call(client, args) {
17800
17805
  return { data: response };
17801
17806
  } catch (err) {
17802
17807
  const data2 = getRevertErrorData(err);
17803
- const { offchainLookup, offchainLookupSignature } = await import("./ccip-Dn3GN1nR.js");
17808
+ const { offchainLookup, offchainLookupSignature } = await import("./ccip-DSmOv0SM.js");
17804
17809
  if (client.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature && to2)
17805
17810
  return { data: await offchainLookup(client, { data: data2, to: to2 }) };
17806
17811
  if (deploylessCall && data2?.slice(0, 10) === "0x101bb98d")
@@ -20045,4 +20050,4 @@ export {
20045
20050
  AppType as y,
20046
20051
  AppId as z
20047
20052
  };
20048
- //# sourceMappingURL=index-DGpw9QQu.js.map
20053
+ //# sourceMappingURL=index-C8izdeEk.js.map