@metamask/browser-playground 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/build/asset-manifest.json +5 -5
- package/build/index.html +1 -1
- package/build/static/js/{700.06adf8f4.chunk.js → 700.6c474807.chunk.js} +2 -2
- package/build/static/js/{700.06adf8f4.chunk.js.map → 700.6c474807.chunk.js.map} +1 -1
- package/build/static/js/main.844c8295.js +3 -0
- package/build/static/js/{main.9ff152f2.js.map → main.844c8295.js.map} +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -20
- package/build/static/js/main.9ff152f2.js +0 -3
- /package/build/static/js/{main.9ff152f2.js.LICENSE.txt → main.844c8295.js.LICENSE.txt} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Change LegacyEVM card's `sendTransaction` to have an address field and default it to the connected address ([#247](https://github.com/MetaMask/connect-monorepo/pull/247))
|
|
15
|
+
- Add `localhost` to wagmi's configured chains ([#246](https://github.com/MetaMask/connect-monorepo/pull/246))
|
|
16
|
+
- Bump wagmi from `^2.19.2` to `^3.5.0` and apply v3 migration changes: use `useConnectors()` instead of `useConnect().connectors`, `useChains()` instead of `useSwitchChain().chains`, and rename `useAccount` to `useConnection` ([#233](https://github.com/MetaMask/connect-monorepo/pull/233))
|
|
17
|
+
- Bump `@wagmi/core` from `^2.22.1` to `^3.4.0` ([#233](https://github.com/MetaMask/connect-monorepo/pull/233))
|
|
18
|
+
- Bump `@tanstack/react-query` from `>=5.45.1` to `^5.90.21` ([#233](https://github.com/MetaMask/connect-monorepo/pull/233))
|
|
19
|
+
- Bump `@tanstack/react-query-persist-client`, `@tanstack/query-sync-storage-persister`, and `@tanstack/react-query-devtools` from `5.0.5` to latest (`^5.90.24` / `^5.91.3`) ([#233](https://github.com/MetaMask/connect-monorepo/pull/233))
|
|
20
|
+
|
|
10
21
|
## [0.5.1]
|
|
11
22
|
|
|
12
23
|
### Changed
|
|
@@ -112,7 +123,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
112
123
|
|
|
113
124
|
- Initial release
|
|
114
125
|
|
|
115
|
-
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.
|
|
126
|
+
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.6.0...HEAD
|
|
127
|
+
[0.6.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.5.1...@metamask/browser-playground@0.6.0
|
|
116
128
|
[0.5.1]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.5.0...@metamask/browser-playground@0.5.1
|
|
117
129
|
[0.5.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.4.2...@metamask/browser-playground@0.5.0
|
|
118
130
|
[0.4.2]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/browser-playground@0.4.1...@metamask/browser-playground@0.4.2
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "./static/css/main.cdee3abe.css",
|
|
4
|
-
"main.js": "./static/js/main.
|
|
4
|
+
"main.js": "./static/js/main.844c8295.js",
|
|
5
5
|
"static/js/435.8081f498.chunk.js": "./static/js/435.8081f498.chunk.js",
|
|
6
6
|
"static/js/817.bf92ca72.chunk.js": "./static/js/817.bf92ca72.chunk.js",
|
|
7
|
-
"static/js/700.06adf8f4.chunk.js": "./static/js/700.06adf8f4.chunk.js",
|
|
8
7
|
"static/js/578.67e35af4.chunk.js": "./static/js/578.67e35af4.chunk.js",
|
|
8
|
+
"static/js/700.6c474807.chunk.js": "./static/js/700.6c474807.chunk.js",
|
|
9
9
|
"static/js/29.1c56f7d4.chunk.js": "./static/js/29.1c56f7d4.chunk.js",
|
|
10
10
|
"index.html": "./index.html",
|
|
11
11
|
"main.cdee3abe.css.map": "./static/css/main.cdee3abe.css.map",
|
|
12
|
-
"main.
|
|
12
|
+
"main.844c8295.js.map": "./static/js/main.844c8295.js.map",
|
|
13
13
|
"435.8081f498.chunk.js.map": "./static/js/435.8081f498.chunk.js.map",
|
|
14
14
|
"817.bf92ca72.chunk.js.map": "./static/js/817.bf92ca72.chunk.js.map",
|
|
15
|
-
"700.06adf8f4.chunk.js.map": "./static/js/700.06adf8f4.chunk.js.map",
|
|
16
15
|
"578.67e35af4.chunk.js.map": "./static/js/578.67e35af4.chunk.js.map",
|
|
16
|
+
"700.6c474807.chunk.js.map": "./static/js/700.6c474807.chunk.js.map",
|
|
17
17
|
"29.1c56f7d4.chunk.js.map": "./static/js/29.1c56f7d4.chunk.js.map"
|
|
18
18
|
},
|
|
19
19
|
"entrypoints": [
|
|
20
20
|
"static/css/main.cdee3abe.css",
|
|
21
|
-
"static/js/main.
|
|
21
|
+
"static/js/main.844c8295.js"
|
|
22
22
|
]
|
|
23
23
|
}
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./alt-fox.svg"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><title>Multichain Test Dapp</title><script defer="defer" src="./static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./alt-fox.svg"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><title>Multichain Test Dapp</title><script defer="defer" src="./static/js/main.844c8295.js"></script><link href="./static/css/main.cdee3abe.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_metamask_browser_playground=self.webpackChunk_metamask_browser_playground||[]).push([[700],{6700:(t,e,a)=>{a.d(e,{offchainLookup:()=>S,offchainLookupSignature:()=>T});var r=a(
|
|
2
|
-
//# sourceMappingURL=700.
|
|
1
|
+
"use strict";(self.webpackChunk_metamask_browser_playground=self.webpackChunk_metamask_browser_playground||[]).push([[700],{6700:(t,e,a)=>{a.d(e,{offchainLookup:()=>S,offchainLookupSignature:()=>T});var r=a(7862),s=a(8551),n=a(8090),o=a(9603);class c extends n.C{constructor(t){var e;let{callbackSelector:a,cause:r,data:s,extraData:n,sender:c,urls:i}=t;super(r.shortMessage||"An error occurred while fetching for an offchain result.",{cause:r,metaMessages:[...r.metaMessages||[],null!==(e=r.metaMessages)&&void 0!==e&&e.length?"":[],"Offchain Gateway Call:",i&&[" Gateway URL(s):",...i.map(t=>" ".concat((0,o.I)(t)))]," Sender: ".concat(c)," Data: ".concat(s)," Callback selector: ".concat(a)," Extra data: ".concat(n)].flat(),name:"OffchainLookupError"})}}class i extends n.C{constructor(t){let{result:e,url:a}=t;super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:["Gateway URL: ".concat((0,o.I)(a)),"Response: ".concat((0,s.A)(e))],name:"OffchainLookupResponseMalformedError"})}}class u extends n.C{constructor(t){let{sender:e,to:a}=t;super("Reverted sender address does not match target contract address (`to`).",{metaMessages:["Contract address: ".concat(a),"OffchainLookup sender address: ".concat(e)],name:"OffchainLookupSenderMismatchError"})}}var d=a(3467),l=a(9774),f=a(5210),h=a(7578),p=a(2569);var w=a(7683),m=a(226),y=a(6351),b=a(8445),g=a(1588),k=a(2129),v=a(1503),C=a(1187),M=a(2311);var P=a(7188);const x="/docs/contract/encodeErrorResult";function R(t){const{abi:e,errorName:a,args:r}=t;let s=e[0];if(a){const t=(0,P.iY)({abi:e,args:r,name:a});if(!t)throw new g.yy(a,{docsPath:x});s=t}if("error"!==s.type)throw new g.yy(void 0,{docsPath:x});const n=(0,M.B)(s),o=(0,v.V)(n);let c="0x";if(r&&r.length>0){if(!s.inputs)throw new g.ZP(s.name,{docsPath:x});c=(0,f.h)(s.inputs,r)}return(0,w.aP)([o,c])}const L="/docs/contract/encodeFunctionResult";const E="x-batch-gateway:true";async function O(t){const{data:e,ccipRequest:a}=t,{args:[r]}=function(t){const{abi:e,data:a}=t,r=(0,k.di)(a,0,4),s=e.find(t=>"function"===t.type&&r===(0,v.V)((0,M.B)(t)));if(!s)throw new g.EB(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?(0,C.n)(s.inputs,(0,k.di)(a,4)):void 0}}({abi:y.b2,data:e}),s=[],n=[];return await Promise.all(r.map(async(t,e)=>{try{n[e]=t.urls.includes(E)?await O({data:t.data,ccipRequest:a}):await a(t),s[e]=!1}catch(o){s[e]=!0,n[e]="HttpRequestError"===(r=o).name&&r.status?R({abi:y.b2,errorName:"HttpError",args:[r.status,r.shortMessage]}):R({abi:[b.Mc],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}var r})),function(t){const{abi:e,functionName:a,result:r}=t;let s=e[0];if(a){const t=(0,P.iY)({abi:e,name:a});if(!t)throw new g.Iz(a,{docsPath:L});s=t}if("function"!==s.type)throw new g.Iz(void 0,{docsPath:L});if(!s.outputs)throw new g.MR(s.name,{docsPath:L});const n=(()=>{if(0===s.outputs.length)return[];if(1===s.outputs.length)return[r];if(Array.isArray(r))return r;throw new g.dm(r)})();return(0,f.h)(s.outputs,n)}({abi:y.b2,functionName:"query",result:[s,n]})}const T="0x556f1830",N={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function S(t,e){let{blockNumber:a,blockTag:s,data:n,to:o}=e;const{args:i}=(0,l.W)({data:n,abi:[N]}),[d,m,y,b,g]=i,{ccipRead:k}=t,v=k&&"function"===typeof(null===k||void 0===k?void 0:k.request)?k.request:q;try{if(!function(t,e){if(!(0,p.P)(t,{strict:!1}))throw new h.M({address:t});if(!(0,p.P)(e,{strict:!1}))throw new h.M({address:e});return t.toLowerCase()===e.toLowerCase()}(o,d))throw new u({sender:d,to:o});const e=m.includes(E)?await O({data:y,ccipRequest:v}):await v({data:y,sender:d,urls:m}),{data:n}=await(0,r.T)(t,{blockNumber:a,blockTag:s,data:(0,w.xW)([b,(0,f.h)([{type:"bytes"},{type:"bytes"}],[e,g])]),to:o});return n}catch(C){throw new c({callbackSelector:b,cause:C,data:n,extraData:g,sender:d,urls:m})}}async function q(t){let{data:e,sender:a,urls:r}=t,n=new Error("An unknown error occurred.");for(let l=0;l<r.length;l++){const t=r[l],f=t.includes("{data}")?"GET":"POST",h="POST"===f?{data:e,sender:a}:void 0,p="POST"===f?{"Content-Type":"application/json"}:{};try{var o;const r=await fetch(t.replace("{sender}",a.toLowerCase()).replace("{data}",e),{body:JSON.stringify(h),headers:p,method:f});let u;if(u=null!==(o=r.headers.get("Content-Type"))&&void 0!==o&&o.startsWith("application/json")?(await r.json()).data:await r.text(),!r.ok){var c;n=new d.Ci({body:h,details:null!==(c=u)&&void 0!==c&&c.error?(0,s.A)(u.error):r.statusText,headers:r.headers,status:r.status,url:t});continue}if(!(0,m.q)(u)){n=new i({result:u,url:t});continue}return u}catch(u){n=new d.Ci({body:h,details:u.message,url:t})}}throw n}}}]);
|
|
2
|
+
//# sourceMappingURL=700.6c474807.chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static/js/700.06adf8f4.chunk.js","mappings":"mPAWM,MAAOA,UAA4BC,EAAAA,EACvCC,WAAAA,CAAAC,GAcC,IAAAC,EAAA,IAdW,iBACVC,EAAgB,MAChBC,EAAK,KACLC,EAAI,UACJC,EAAS,OACTC,EAAM,KACNC,GAQDP,EACCQ,MACEL,EAAMM,cACJ,2DACF,CACEN,QACAO,aAAc,IACRP,EAAMO,cAAgB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B,IAAK,IAAIpC,EAAI,EAAGA,EAAIzD,EAAKI,OAAQqD,IAAK,CACpC,MAAMnD,EAAMN,EAAKyD,GACXqC,EAASxF,EAAIoD,SAAS,UAAY,MAAQ,OAC1CqC,EAAkB,SAAXD,EAAoB,CAAEjG,OAAME,eAAW8B,EAC9CmE,EACO,SAAXF,EAAoB,CAAE,eAAgB,oBAAuB,CAAC,EAEhE,IAAI,IAAAG,EACF,MAAMC,QAAiBC,MACrB7F,EAAI8F,QAAQ,WAAYrG,EAAO0F,eAAeW,QAAQ,SAAUvG,GAChE,CACEkG,KAAMM,KAAKvF,UAAUiF,GACrBC,UACAF,WAIJ,IAAIjF,EASJ,GALEA,EAFoC,QADtCoF,EACEC,EAASF,QAAQM,IAAI,uBAAe,IAAAL,GAApCA,EAAsCM,WAAW,2BAEjCL,EAASM,QAAQ3G,WAEjBqG,EAASO,QAGtBP,EAASQ,GAAI,KAAAC,EAChB/C,EAAQ,IAAIgD,EAAAA,GAAiB,CAC3Bb,OACAc,QAAe,QAANF,EAAA9F,SAAM,IAAA8F,GAANA,EAAQ/C,OACb9C,EAAAA,EAAAA,GAAUD,EAAO+C,OACjBsC,EAASY,WACbd,QAASE,EAASF,QAClBnC,OAAQqC,EAASrC,OACjBvD,QAEF,QACF,CAEA,KAAKyG,EAAAA,EAAAA,GAAMlG,GAAS,CAClB+C,EAAQ,IAAIjD,EAAqC,CAC/CE,SACAP,QAEF,QACF,CAEA,OAAOO,CACT,CAAE,MAAO8C,GACPC,EAAQ,IAAIgD,EAAAA,GAAiB,CAC3Bb,OACAc,QAAUlD,EAAcI,QACxBzD,OAEJ,CACF,CAEA,MAAMsD,CACR,C","sources":["../../../node_modules/viem/errors/ccip.ts","../../../node_modules/viem/utils/abi/encodeErrorResult.ts","../../../node_modules/viem/utils/abi/encodeFunctionResult.ts","../../../node_modules/viem/utils/ens/localBatchGatewayRequest.ts","../../../node_modules/viem/utils/abi/decodeFunctionData.ts","../../../node_modules/viem/utils/ccip.ts","../../../node_modules/viem/utils/address/isAddressEqual.ts"],"sourcesContent":["import type { Address } from 'abitype'\n\nimport type { Hex } from '../types/misc.js'\nimport { stringify } from '../utils/stringify.js'\n\nimport { BaseError } from './base.js'\nimport { getUrl } from './utils.js'\n\nexport type OffchainLookupErrorType = OffchainLookupError & {\n name: 'OffchainLookupError'\n}\nexport class OffchainLookupError extends BaseError {\n constructor({\n callbackSelector,\n cause,\n data,\n extraData,\n sender,\n urls,\n }: {\n callbackSelector: Hex\n cause: BaseError\n data: Hex\n extraData: Hex\n sender: Address\n urls: readonly string[]\n }) {\n super(\n cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.',\n {\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 }\n}\n\nexport type OffchainLookupResponseMalformedErrorType =\n OffchainLookupResponseMalformedError & {\n name: 'OffchainLookupResponseMalformedError'\n }\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }: { result: any; url: string }) {\n super(\n 'Offchain gateway response is malformed. Response data must be a hex value.',\n {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n },\n )\n }\n}\n\n/** @internal */\nexport type OffchainLookupSenderMismatchErrorType =\n OffchainLookupSenderMismatchError & {\n name: 'OffchainLookupSenderMismatchError'\n }\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }: { sender: Address; to: Address }) {\n super(\n 'Reverted sender address does not match target contract address (`to`).',\n {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n },\n )\n }\n}\n","import type { Abi, ExtractAbiErrors } from 'abitype'\n\nimport {\n AbiErrorInputsNotFoundError,\n AbiErrorNotFoundError,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractErrorArgs,\n ContractErrorName,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport { type ConcatHexErrorType, concatHex } from '../data/concat.js'\nimport {\n type ToFunctionSelectorErrorType,\n toFunctionSelector,\n} from '../hash/toFunctionSelector.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from './encodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\nimport { type GetAbiItemErrorType, getAbiItem } from './getAbiItem.js'\n\nconst docsPath = '/docs/contract/encodeErrorResult'\n\nexport type EncodeErrorResultParameters<\n abi extends Abi | readonly unknown[] = Abi,\n errorName extends ContractErrorName<abi> | undefined = ContractErrorName<abi>,\n ///\n hasErrors = abi extends Abi\n ? Abi extends abi\n ? true\n : [ExtractAbiErrors<abi>] extends [never]\n ? false\n : true\n : true,\n allArgs = ContractErrorArgs<\n abi,\n errorName extends ContractErrorName<abi>\n ? errorName\n : ContractErrorName<abi>\n >,\n allErrorNames = ContractErrorName<abi>,\n> = {\n abi: abi\n args?: allArgs | undefined\n} & UnionEvaluate<\n IsNarrowable<abi, Abi> extends true\n ? abi['length'] extends 1\n ? { errorName?: errorName | allErrorNames | undefined }\n : { errorName: errorName | allErrorNames }\n : { errorName?: errorName | allErrorNames | undefined }\n> &\n (hasErrors extends true ? unknown : never)\n\nexport type EncodeErrorResultReturnType = Hex\n\nexport type EncodeErrorResultErrorType =\n | GetAbiItemErrorType\n | FormatAbiItemErrorType\n | ToFunctionSelectorErrorType\n | EncodeAbiParametersErrorType\n | ConcatHexErrorType\n | ErrorType\n\nexport function encodeErrorResult<\n const abi extends Abi | readonly unknown[],\n errorName extends ContractErrorName<abi> | undefined = undefined,\n>(\n parameters: EncodeErrorResultParameters<abi, errorName>,\n): EncodeErrorResultReturnType {\n const { abi, errorName, args } = parameters as EncodeErrorResultParameters\n\n let abiItem = abi[0]\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName })\n if (!item) throw new AbiErrorNotFoundError(errorName, { docsPath })\n abiItem = item\n }\n\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath })\n\n const definition = formatAbiItem(abiItem)\n const signature = toFunctionSelector(definition)\n\n let data: Hex = '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","import type { Abi, AbiStateMutability, ExtractAbiFunctions } from 'abitype'\n\nimport {\n AbiFunctionNotFoundError,\n AbiFunctionOutputsNotFoundError,\n InvalidArrayError,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractFunctionName,\n ContractFunctionReturnType,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from './encodeAbiParameters.js'\nimport { type GetAbiItemErrorType, getAbiItem } from './getAbiItem.js'\n\nconst docsPath = '/docs/contract/encodeFunctionResult'\n\nexport type EncodeFunctionResultParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends\n | ContractFunctionName<abi>\n | undefined = ContractFunctionName<abi>,\n ///\n hasFunctions = abi extends Abi\n ? Abi extends abi\n ? true\n : [ExtractAbiFunctions<abi>] extends [never]\n ? false\n : true\n : true,\n allFunctionNames = ContractFunctionName<abi>,\n> = {\n abi: abi\n result?:\n | ContractFunctionReturnType<\n abi,\n AbiStateMutability,\n functionName extends ContractFunctionName<abi>\n ? functionName\n : ContractFunctionName<abi>,\n never // allow all args. required for overloads to work.\n >\n | undefined\n} & UnionEvaluate<\n IsNarrowable<abi, Abi> extends true\n ? abi['length'] extends 1\n ? { functionName?: functionName | allFunctionNames | undefined }\n : { functionName: functionName | allFunctionNames }\n : { functionName?: functionName | allFunctionNames | undefined }\n> &\n (hasFunctions extends true ? unknown : never)\n\nexport type EncodeFunctionResultReturnType = Hex\n\nexport type EncodeFunctionResultErrorType =\n | AbiFunctionOutputsNotFoundError\n | AbiFunctionNotFoundError\n | EncodeAbiParametersErrorType\n | GetAbiItemErrorType\n | ErrorType\n\nexport function encodeFunctionResult<\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi> | undefined = undefined,\n>(\n parameters: EncodeFunctionResultParameters<abi, functionName>,\n): EncodeFunctionResultReturnType {\n const { abi, functionName, result } =\n parameters as EncodeFunctionResultParameters\n\n let abiItem = abi[0]\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName })\n if (!item) throw new AbiFunctionNotFoundError(functionName, { docsPath })\n abiItem = item\n }\n\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath })\n\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath })\n\n const values = (() => {\n if (abiItem.outputs.length === 0) return []\n if (abiItem.outputs.length === 1) return [result]\n if (Array.isArray(result)) return result\n throw new InvalidArrayError(result)\n })()\n\n return encodeAbiParameters(abiItem.outputs, values)\n}\n","import { batchGatewayAbi } from '../../constants/abis.js'\nimport { solidityError } from '../../constants/solidity.js'\nimport type { Hex } from '../../types/misc.js'\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js'\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js'\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js'\nimport type {\n CcipRequestErrorType,\n CcipRequestParameters,\n CcipRequestReturnType,\n} from '../ccip.js'\n\nexport const localBatchGatewayUrl = 'x-batch-gateway:true'\n\nexport async function localBatchGatewayRequest(parameters: {\n data: Hex\n ccipRequest: (\n parameters: CcipRequestParameters,\n ) => Promise<CcipRequestReturnType>\n}): Promise<Hex> {\n const { data, ccipRequest } = parameters\n\n const {\n args: [queries],\n } = decodeFunctionData({ abi: batchGatewayAbi, data })\n\n const failures: boolean[] = []\n const responses: Hex[] = []\n await Promise.all(\n 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 } catch (err) {\n failures[i] = true\n responses[i] = encodeError(err as CcipRequestErrorType)\n }\n }),\n )\n\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n })\n}\n\nfunction encodeError(error: CcipRequestErrorType): Hex {\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","import type { Abi, AbiStateMutability } from 'abitype'\n\nimport { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport { type SliceErrorType, slice } from '../data/slice.js'\nimport {\n type ToFunctionSelectorErrorType,\n toFunctionSelector,\n} from '../hash/toFunctionSelector.js'\nimport {\n type DecodeAbiParametersErrorType,\n decodeAbiParameters,\n} from './decodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\n\nexport type DecodeFunctionDataParameters<\n abi extends Abi | readonly unknown[] = Abi,\n> = {\n abi: abi\n data: Hex\n}\n\nexport type DecodeFunctionDataReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n ///\n allFunctionNames extends\n ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = IsNarrowable<abi, Abi> extends true\n ? UnionEvaluate<\n {\n [functionName in allFunctionNames]: {\n args: ContractFunctionArgs<abi, AbiStateMutability, functionName>\n functionName: functionName\n }\n }[allFunctionNames]\n >\n : {\n args: readonly unknown[] | undefined\n functionName: string\n }\n\nexport type DecodeFunctionDataErrorType =\n | AbiFunctionSignatureNotFoundError\n | DecodeAbiParametersErrorType\n | FormatAbiItemErrorType\n | ToFunctionSelectorErrorType\n | SliceErrorType\n | ErrorType\n\nexport function decodeFunctionData<const abi extends Abi | readonly unknown[]>(\n parameters: DecodeFunctionDataParameters<abi>,\n) {\n const { abi, data } = parameters as DecodeFunctionDataParameters\n const signature = slice(data, 0, 4)\n const description = abi.find(\n (x) =>\n x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)),\n )\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n })\n return {\n functionName: (description as { name: string }).name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined) as readonly unknown[] | undefined,\n } as DecodeFunctionDataReturnType<abi>\n}\n","import type { Abi, Address } from 'abitype'\n\nimport { type CallParameters, call } from '../actions/public/call.js'\nimport type { Client } from '../clients/createClient.js'\nimport type { Transport } from '../clients/transports/createTransport.js'\nimport type { BaseError } from '../errors/base.js'\nimport {\n OffchainLookupError,\n type OffchainLookupErrorType as OffchainLookupErrorType_,\n OffchainLookupResponseMalformedError,\n type OffchainLookupResponseMalformedErrorType,\n OffchainLookupSenderMismatchError,\n} from '../errors/ccip.js'\nimport {\n HttpRequestError,\n type HttpRequestErrorType,\n} from '../errors/request.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Hex } from '../types/misc.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 {\n localBatchGatewayRequest,\n localBatchGatewayUrl,\n} from './ens/localBatchGatewayRequest.js'\nimport { stringify } from './stringify.js'\n\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} as const satisfies Abi[number]\n\nexport type OffchainLookupErrorType = OffchainLookupErrorType_ | ErrorType\n\nexport async function offchainLookup<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n data,\n to,\n }: Pick<CallParameters, 'blockNumber' | 'blockTag'> & {\n data: Hex\n to: Address\n },\n): Promise<Hex> {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n })\n const [sender, urls, callData, callbackSelector, extraData] = args\n\n const { ccipRead } = client\n const ccipRequest_ =\n ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest\n\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to })\n\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls })\n\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters(\n [{ type: 'bytes' }, { type: 'bytes' }],\n [result, extraData],\n ),\n ]),\n to,\n } as CallParameters)\n\n return data_!\n } catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err as BaseError,\n data,\n extraData,\n sender,\n urls,\n })\n }\n}\n\nexport type CcipRequestParameters = {\n data: Hex\n sender: Address\n urls: readonly string[]\n}\n\nexport type CcipRequestReturnType = Hex\n\nexport type CcipRequestErrorType =\n | HttpRequestErrorType\n | OffchainLookupResponseMalformedErrorType\n | ErrorType\n\nexport async function ccipRequest({\n data,\n sender,\n urls,\n}: CcipRequestParameters): Promise<CcipRequestReturnType> {\n let error = new Error('An unknown error occurred.')\n\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: HeadersInit =\n method === 'POST' ? { 'Content-Type': 'application/json' } : {}\n\n try {\n const response = await fetch(\n url.replace('{sender}', sender.toLowerCase()).replace('{data}', data),\n {\n body: JSON.stringify(body),\n headers,\n method,\n },\n )\n\n let result: any\n if (\n response.headers.get('Content-Type')?.startsWith('application/json')\n ) {\n result = (await response.json()).data\n } else {\n result = (await response.text()) as any\n }\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\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n })\n continue\n }\n\n return result\n } catch (err) {\n error = new HttpRequestError({\n body,\n details: (err as Error).message,\n url,\n })\n }\n }\n\n throw error\n}\n","import type { Address } from 'abitype'\n\nimport {\n InvalidAddressError,\n type InvalidAddressErrorType,\n} from '../../errors/address.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport { isAddress } from './isAddress.js'\n\nexport type IsAddressEqualReturnType = boolean\nexport type IsAddressEqualErrorType = InvalidAddressErrorType | ErrorType\n\nexport function isAddressEqual(a: Address, b: Address) {\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"],"names":["OffchainLookupError","BaseError","constructor","_ref","_cause$metaMessages","callbackSelector","cause","data","extraData","sender","urls","super","shortMessage","metaMessages","length","map","url","concat","getUrl","flat","name","OffchainLookupResponseMalformedError","_ref2","result","stringify","OffchainLookupSenderMismatchError","_ref3","to","docsPath","encodeErrorResult","parameters","abi","errorName","args","abiItem","item","getAbiItem","AbiErrorNotFoundError","type","undefined","definition","formatAbiItem","signature","toFunctionSelector","inputs","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","localBatchGatewayUrl","async","localBatchGatewayRequest","ccipRequest","queries","slice","description","find","x","AbiFunctionSignatureNotFoundError","functionName","decodeAbiParameters","decodeFunctionData","batchGatewayAbi","failures","responses","Promise","all","query","i","includes","err","error","status","solidityError","message","AbiFunctionNotFoundError","outputs","AbiFunctionOutputsNotFoundError","values","Array","isArray","InvalidArrayError","encodeFunctionResult","offchainLookupSignature","offchainLookupAbiItem","offchainLookup","client","blockNumber","blockTag","decodeErrorResult","callData","ccipRead","ccipRequest_","request","a","b","isAddress","strict","InvalidAddressError","address","toLowerCase","isAddressEqual","data_","call","Error","method","body","headers","_response$headers$get","response","fetch","replace","JSON","get","startsWith","json","text","ok","_result","HttpRequestError","details","statusText","isHex"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"static/js/700.6c474807.chunk.js","mappings":"mPAWM,MAAOA,UAA4BC,EAAAA,EACvCC,WAAAA,CAAAC,GAcC,IAAAC,EAAA,IAdW,iBACVC,EAAgB,MAChBC,EAAK,KACLC,EAAI,UACJC,EAAS,OACTC,EAAM,KACNC,GAQDP,EACCQ,MACEL,EAAMM,cACJ,2DACF,CACEN,QACAO,aAAc,IACRP,EAAMO,cAAgB,GACR,QAAlBT,EAAAE,EAAMO,oBAAY,IAAAT,GAAlBA,EAAoBU,OAAS,GAAK,GAClC,yBACAJ,GAAQ,CACN,uBACGA,EAAKK,IAAKC,GAAG,OAAAC,QAAYC,EAAAA,EAAAA,GAAOF,MACpC,aAAAC,OACYR,GAAM,WAAAQ,OACRV,GAAI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,EAAoB,CAAE,eAAgB,oBAAuB,CAAC,EAEhE,IAAI,IAAAG,EACF,MAAMC,QAAiBC,MACrB7F,EAAI8F,QAAQ,WAAYrG,EAAO0F,eAAeW,QAAQ,SAAUvG,GAChE,CACEkG,KAAMM,KAAKvF,UAAUiF,GACrBC,UACAF,WAIJ,IAAIjF,EASJ,GALEA,EAFoC,QADtCoF,EACEC,EAASF,QAAQM,IAAI,uBAAe,IAAAL,GAApCA,EAAsCM,WAAW,2BAEjCL,EAASM,QAAQ3G,WAEjBqG,EAASO,QAGtBP,EAASQ,GAAI,KAAAC,EAChB/C,EAAQ,IAAIgD,EAAAA,GAAiB,CAC3Bb,OACAc,QAAe,QAANF,EAAA9F,SAAM,IAAA8F,GAANA,EAAQ/C,OACb9C,EAAAA,EAAAA,GAAUD,EAAO+C,OACjBsC,EAASY,WACbd,QAASE,EAASF,QAClBnC,OAAQqC,EAASrC,OACjBvD,QAEF,QACF,CAEA,KAAKyG,EAAAA,EAAAA,GAAMlG,GAAS,CAClB+C,EAAQ,IAAIjD,EAAqC,CAC/CE,SACAP,QAEF,QACF,CAEA,OAAOO,CACT,CAAE,MAAO8C,GACPC,EAAQ,IAAIgD,EAAAA,GAAiB,CAC3Bb,OACAc,QAAUlD,EAAcI,QACxBzD,OAEJ,CACF,CAEA,MAAMsD,CACR,C","sources":["../../../node_modules/viem/errors/ccip.ts","../../../node_modules/viem/utils/abi/encodeErrorResult.ts","../../../node_modules/viem/utils/abi/encodeFunctionResult.ts","../../../node_modules/viem/utils/ens/localBatchGatewayRequest.ts","../../../node_modules/viem/utils/abi/decodeFunctionData.ts","../../../node_modules/viem/utils/ccip.ts","../../../node_modules/viem/utils/address/isAddressEqual.ts"],"sourcesContent":["import type { Address } from 'abitype'\n\nimport type { Hex } from '../types/misc.js'\nimport { stringify } from '../utils/stringify.js'\n\nimport { BaseError } from './base.js'\nimport { getUrl } from './utils.js'\n\nexport type OffchainLookupErrorType = OffchainLookupError & {\n name: 'OffchainLookupError'\n}\nexport class OffchainLookupError extends BaseError {\n constructor({\n callbackSelector,\n cause,\n data,\n extraData,\n sender,\n urls,\n }: {\n callbackSelector: Hex\n cause: BaseError\n data: Hex\n extraData: Hex\n sender: Address\n urls: readonly string[]\n }) {\n super(\n cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.',\n {\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 }\n}\n\nexport type OffchainLookupResponseMalformedErrorType =\n OffchainLookupResponseMalformedError & {\n name: 'OffchainLookupResponseMalformedError'\n }\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }: { result: any; url: string }) {\n super(\n 'Offchain gateway response is malformed. Response data must be a hex value.',\n {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n },\n )\n }\n}\n\n/** @internal */\nexport type OffchainLookupSenderMismatchErrorType =\n OffchainLookupSenderMismatchError & {\n name: 'OffchainLookupSenderMismatchError'\n }\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }: { sender: Address; to: Address }) {\n super(\n 'Reverted sender address does not match target contract address (`to`).',\n {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n },\n )\n }\n}\n","import type { Abi, ExtractAbiErrors } from 'abitype'\n\nimport {\n AbiErrorInputsNotFoundError,\n AbiErrorNotFoundError,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractErrorArgs,\n ContractErrorName,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport { type ConcatHexErrorType, concatHex } from '../data/concat.js'\nimport {\n type ToFunctionSelectorErrorType,\n toFunctionSelector,\n} from '../hash/toFunctionSelector.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from './encodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\nimport { type GetAbiItemErrorType, getAbiItem } from './getAbiItem.js'\n\nconst docsPath = '/docs/contract/encodeErrorResult'\n\nexport type EncodeErrorResultParameters<\n abi extends Abi | readonly unknown[] = Abi,\n errorName extends ContractErrorName<abi> | undefined = ContractErrorName<abi>,\n ///\n hasErrors = abi extends Abi\n ? Abi extends abi\n ? true\n : [ExtractAbiErrors<abi>] extends [never]\n ? false\n : true\n : true,\n allArgs = ContractErrorArgs<\n abi,\n errorName extends ContractErrorName<abi>\n ? errorName\n : ContractErrorName<abi>\n >,\n allErrorNames = ContractErrorName<abi>,\n> = {\n abi: abi\n args?: allArgs | undefined\n} & UnionEvaluate<\n IsNarrowable<abi, Abi> extends true\n ? abi['length'] extends 1\n ? { errorName?: errorName | allErrorNames | undefined }\n : { errorName: errorName | allErrorNames }\n : { errorName?: errorName | allErrorNames | undefined }\n> &\n (hasErrors extends true ? unknown : never)\n\nexport type EncodeErrorResultReturnType = Hex\n\nexport type EncodeErrorResultErrorType =\n | GetAbiItemErrorType\n | FormatAbiItemErrorType\n | ToFunctionSelectorErrorType\n | EncodeAbiParametersErrorType\n | ConcatHexErrorType\n | ErrorType\n\nexport function encodeErrorResult<\n const abi extends Abi | readonly unknown[],\n errorName extends ContractErrorName<abi> | undefined = undefined,\n>(\n parameters: EncodeErrorResultParameters<abi, errorName>,\n): EncodeErrorResultReturnType {\n const { abi, errorName, args } = parameters as EncodeErrorResultParameters\n\n let abiItem = abi[0]\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName })\n if (!item) throw new AbiErrorNotFoundError(errorName, { docsPath })\n abiItem = item\n }\n\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath })\n\n const definition = formatAbiItem(abiItem)\n const signature = toFunctionSelector(definition)\n\n let data: Hex = '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","import type { Abi, AbiStateMutability, ExtractAbiFunctions } from 'abitype'\n\nimport {\n AbiFunctionNotFoundError,\n AbiFunctionOutputsNotFoundError,\n InvalidArrayError,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractFunctionName,\n ContractFunctionReturnType,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from './encodeAbiParameters.js'\nimport { type GetAbiItemErrorType, getAbiItem } from './getAbiItem.js'\n\nconst docsPath = '/docs/contract/encodeFunctionResult'\n\nexport type EncodeFunctionResultParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends\n | ContractFunctionName<abi>\n | undefined = ContractFunctionName<abi>,\n ///\n hasFunctions = abi extends Abi\n ? Abi extends abi\n ? true\n : [ExtractAbiFunctions<abi>] extends [never]\n ? false\n : true\n : true,\n allFunctionNames = ContractFunctionName<abi>,\n> = {\n abi: abi\n result?:\n | ContractFunctionReturnType<\n abi,\n AbiStateMutability,\n functionName extends ContractFunctionName<abi>\n ? functionName\n : ContractFunctionName<abi>,\n never // allow all args. required for overloads to work.\n >\n | undefined\n} & UnionEvaluate<\n IsNarrowable<abi, Abi> extends true\n ? abi['length'] extends 1\n ? { functionName?: functionName | allFunctionNames | undefined }\n : { functionName: functionName | allFunctionNames }\n : { functionName?: functionName | allFunctionNames | undefined }\n> &\n (hasFunctions extends true ? unknown : never)\n\nexport type EncodeFunctionResultReturnType = Hex\n\nexport type EncodeFunctionResultErrorType =\n | AbiFunctionOutputsNotFoundError\n | AbiFunctionNotFoundError\n | EncodeAbiParametersErrorType\n | GetAbiItemErrorType\n | ErrorType\n\nexport function encodeFunctionResult<\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi> | undefined = undefined,\n>(\n parameters: EncodeFunctionResultParameters<abi, functionName>,\n): EncodeFunctionResultReturnType {\n const { abi, functionName, result } =\n parameters as EncodeFunctionResultParameters\n\n let abiItem = abi[0]\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName })\n if (!item) throw new AbiFunctionNotFoundError(functionName, { docsPath })\n abiItem = item\n }\n\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath })\n\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath })\n\n const values = (() => {\n if (abiItem.outputs.length === 0) return []\n if (abiItem.outputs.length === 1) return [result]\n if (Array.isArray(result)) return result\n throw new InvalidArrayError(result)\n })()\n\n return encodeAbiParameters(abiItem.outputs, values)\n}\n","import { batchGatewayAbi } from '../../constants/abis.js'\nimport { solidityError } from '../../constants/solidity.js'\nimport type { Hex } from '../../types/misc.js'\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js'\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js'\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js'\nimport type {\n CcipRequestErrorType,\n CcipRequestParameters,\n CcipRequestReturnType,\n} from '../ccip.js'\n\nexport const localBatchGatewayUrl = 'x-batch-gateway:true'\n\nexport async function localBatchGatewayRequest(parameters: {\n data: Hex\n ccipRequest: (\n parameters: CcipRequestParameters,\n ) => Promise<CcipRequestReturnType>\n}): Promise<Hex> {\n const { data, ccipRequest } = parameters\n\n const {\n args: [queries],\n } = decodeFunctionData({ abi: batchGatewayAbi, data })\n\n const failures: boolean[] = []\n const responses: Hex[] = []\n await Promise.all(\n 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 } catch (err) {\n failures[i] = true\n responses[i] = encodeError(err as CcipRequestErrorType)\n }\n }),\n )\n\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n })\n}\n\nfunction encodeError(error: CcipRequestErrorType): Hex {\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","import type { Abi, AbiStateMutability } from 'abitype'\n\nimport { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport { type SliceErrorType, slice } from '../data/slice.js'\nimport {\n type ToFunctionSelectorErrorType,\n toFunctionSelector,\n} from '../hash/toFunctionSelector.js'\nimport {\n type DecodeAbiParametersErrorType,\n decodeAbiParameters,\n} from './decodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\n\nexport type DecodeFunctionDataParameters<\n abi extends Abi | readonly unknown[] = Abi,\n> = {\n abi: abi\n data: Hex\n}\n\nexport type DecodeFunctionDataReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n ///\n allFunctionNames extends\n ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = IsNarrowable<abi, Abi> extends true\n ? UnionEvaluate<\n {\n [functionName in allFunctionNames]: {\n args: ContractFunctionArgs<abi, AbiStateMutability, functionName>\n functionName: functionName\n }\n }[allFunctionNames]\n >\n : {\n args: readonly unknown[] | undefined\n functionName: string\n }\n\nexport type DecodeFunctionDataErrorType =\n | AbiFunctionSignatureNotFoundError\n | DecodeAbiParametersErrorType\n | FormatAbiItemErrorType\n | ToFunctionSelectorErrorType\n | SliceErrorType\n | ErrorType\n\nexport function decodeFunctionData<const abi extends Abi | readonly unknown[]>(\n parameters: DecodeFunctionDataParameters<abi>,\n) {\n const { abi, data } = parameters as DecodeFunctionDataParameters\n const signature = slice(data, 0, 4)\n const description = abi.find(\n (x) =>\n x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)),\n )\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n })\n return {\n functionName: (description as { name: string }).name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined) as readonly unknown[] | undefined,\n } as DecodeFunctionDataReturnType<abi>\n}\n","import type { Abi, Address } from 'abitype'\n\nimport { type CallParameters, call } from '../actions/public/call.js'\nimport type { Client } from '../clients/createClient.js'\nimport type { Transport } from '../clients/transports/createTransport.js'\nimport type { BaseError } from '../errors/base.js'\nimport {\n OffchainLookupError,\n type OffchainLookupErrorType as OffchainLookupErrorType_,\n OffchainLookupResponseMalformedError,\n type OffchainLookupResponseMalformedErrorType,\n OffchainLookupSenderMismatchError,\n} from '../errors/ccip.js'\nimport {\n HttpRequestError,\n type HttpRequestErrorType,\n} from '../errors/request.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Hex } from '../types/misc.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 {\n localBatchGatewayRequest,\n localBatchGatewayUrl,\n} from './ens/localBatchGatewayRequest.js'\nimport { stringify } from './stringify.js'\n\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} as const satisfies Abi[number]\n\nexport type OffchainLookupErrorType = OffchainLookupErrorType_ | ErrorType\n\nexport async function offchainLookup<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n data,\n to,\n }: Pick<CallParameters, 'blockNumber' | 'blockTag'> & {\n data: Hex\n to: Address\n },\n): Promise<Hex> {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n })\n const [sender, urls, callData, callbackSelector, extraData] = args\n\n const { ccipRead } = client\n const ccipRequest_ =\n ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest\n\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to })\n\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls })\n\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters(\n [{ type: 'bytes' }, { type: 'bytes' }],\n [result, extraData],\n ),\n ]),\n to,\n } as CallParameters)\n\n return data_!\n } catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err as BaseError,\n data,\n extraData,\n sender,\n urls,\n })\n }\n}\n\nexport type CcipRequestParameters = {\n data: Hex\n sender: Address\n urls: readonly string[]\n}\n\nexport type CcipRequestReturnType = Hex\n\nexport type CcipRequestErrorType =\n | HttpRequestErrorType\n | OffchainLookupResponseMalformedErrorType\n | ErrorType\n\nexport async function ccipRequest({\n data,\n sender,\n urls,\n}: CcipRequestParameters): Promise<CcipRequestReturnType> {\n let error = new Error('An unknown error occurred.')\n\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: HeadersInit =\n method === 'POST' ? { 'Content-Type': 'application/json' } : {}\n\n try {\n const response = await fetch(\n url.replace('{sender}', sender.toLowerCase()).replace('{data}', data),\n {\n body: JSON.stringify(body),\n headers,\n method,\n },\n )\n\n let result: any\n if (\n response.headers.get('Content-Type')?.startsWith('application/json')\n ) {\n result = (await response.json()).data\n } else {\n result = (await response.text()) as any\n }\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\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n })\n continue\n }\n\n return result\n } catch (err) {\n error = new HttpRequestError({\n body,\n details: (err as Error).message,\n url,\n })\n }\n }\n\n throw error\n}\n","import type { Address } from 'abitype'\n\nimport {\n InvalidAddressError,\n type InvalidAddressErrorType,\n} from '../../errors/address.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport { isAddress } from './isAddress.js'\n\nexport type IsAddressEqualReturnType = boolean\nexport type IsAddressEqualErrorType = InvalidAddressErrorType | ErrorType\n\nexport function isAddressEqual(a: Address, b: Address) {\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"],"names":["OffchainLookupError","BaseError","constructor","_ref","_cause$metaMessages","callbackSelector","cause","data","extraData","sender","urls","super","shortMessage","metaMessages","length","map","url","concat","getUrl","flat","name","OffchainLookupResponseMalformedError","_ref2","result","stringify","OffchainLookupSenderMismatchError","_ref3","to","docsPath","encodeErrorResult","parameters","abi","errorName","args","abiItem","item","getAbiItem","AbiErrorNotFoundError","type","undefined","definition","formatAbiItem","signature","toFunctionSelector","inputs","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","localBatchGatewayUrl","async","localBatchGatewayRequest","ccipRequest","queries","slice","description","find","x","AbiFunctionSignatureNotFoundError","functionName","decodeAbiParameters","decodeFunctionData","batchGatewayAbi","failures","responses","Promise","all","query","i","includes","err","error","status","solidityError","message","AbiFunctionNotFoundError","outputs","AbiFunctionOutputsNotFoundError","values","Array","isArray","InvalidArrayError","encodeFunctionResult","offchainLookupSignature","offchainLookupAbiItem","offchainLookup","client","blockNumber","blockTag","decodeErrorResult","callData","ccipRead","ccipRequest_","request","a","b","isAddress","strict","InvalidAddressError","address","toLowerCase","isAddressEqual","data_","call","Error","method","body","headers","_response$headers$get","response","fetch","replace","JSON","get","startsWith","json","text","ok","_result","HttpRequestError","details","statusText","isHex"],"sourceRoot":""}
|