@gardenfi/core 2.1.12 → 2.1.13-beta.2

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BEY92n8B.cjs");function k(a){const{abi:s,data:r}=a,n=t.slice(r,0,4),e=s.find(c=>c.type==="function"&&n===t.toFunctionSelector(t.formatAbiItem(c)));if(!e)throw new t.AbiFunctionSignatureNotFoundError(n,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:e.name,args:"inputs"in e&&e.inputs&&e.inputs.length>0?t.decodeAbiParameters(e.inputs,t.slice(r,4)):void 0}}const h="/docs/contract/encodeErrorResult";function w(a){const{abi:s,errorName:r,args:n}=a;let e=s[0];if(r){const d=t.getAbiItem({abi:s,args:n,name:r});if(!d)throw new t.AbiErrorNotFoundError(r,{docsPath:h});e=d}if(e.type!=="error")throw new t.AbiErrorNotFoundError(void 0,{docsPath:h});const c=t.formatAbiItem(e),o=t.toFunctionSelector(c);let i="0x";if(n&&n.length>0){if(!e.inputs)throw new t.AbiErrorInputsNotFoundError(e.name,{docsPath:h});i=t.encodeAbiParameters(e.inputs,n)}return t.concatHex([o,i])}const m="/docs/contract/encodeFunctionResult";function F(a){const{abi:s,functionName:r,result:n}=a;let e=s[0];if(r){const o=t.getAbiItem({abi:s,name:r});if(!o)throw new t.AbiFunctionNotFoundError(r,{docsPath:m});e=o}if(e.type!=="function")throw new t.AbiFunctionNotFoundError(void 0,{docsPath:m});if(!e.outputs)throw new t.AbiFunctionOutputsNotFoundError(e.name,{docsPath:m});const c=(()=>{if(e.outputs.length===0)return[];if(e.outputs.length===1)return[n];if(Array.isArray(n))return n;throw new t.InvalidArrayError(n)})();return t.encodeAbiParameters(e.outputs,c)}const y="x-batch-gateway:true";async function g(a){const{data:s,ccipRequest:r}=a,{args:[n]}=k({abi:t.batchGatewayAbi,data:s}),e=[],c=[];return await Promise.all(n.map(async(o,i)=>{try{c[i]=o.urls.includes(y)?await g({data:o.data,ccipRequest:r}):await r(o),e[i]=!1}catch(d){e[i]=!0,c[i]=L(d)}})),F({abi:t.batchGatewayAbi,functionName:"query",result:[e,c]})}function L(a){return a.name==="HttpRequestError"&&a.status?w({abi:t.batchGatewayAbi,errorName:"HttpError",args:[a.status,a.shortMessage]}):w({abi:[t.solidityError],errorName:"Error",args:["shortMessage"in a?a.shortMessage:a.message]})}class O extends t.BaseError{constructor({callbackSelector:s,cause:r,data:n,extraData:e,sender:c,urls:o}){var i;super(r.shortMessage||"An error occurred while fetching for an offchain result.",{cause:r,metaMessages:[...r.metaMessages||[],(i=r.metaMessages)!=null&&i.length?"":[],"Offchain Gateway Call:",o&&[" Gateway URL(s):",...o.map(d=>` ${t.getUrl(d)}`)],` Sender: ${c}`,` Data: ${n}`,` Callback selector: ${s}`,` Extra data: ${e}`].flat(),name:"OffchainLookupError"})}}class P extends t.BaseError{constructor({result:s,url:r}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t.getUrl(r)}`,`Response: ${t.stringify(s)}`],name:"OffchainLookupResponseMalformedError"})}}class S extends t.BaseError{constructor({sender:s,to:r}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${r}`,`OffchainLookup sender address: ${s}`],name:"OffchainLookupSenderMismatchError"})}}const x="0x556f1830",E={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 M(a,{blockNumber:s,blockTag:r,data:n,to:e}){const{args:c}=t.decodeErrorResult({data:n,abi:[E]}),[o,i,d,l,f]=c,{ccipRead:u}=a,b=u&&typeof(u==null?void 0:u.request)=="function"?u.request:A;try{if(!t.isAddressEqual(e,o))throw new S({sender:o,to:e});const p=i.includes(y)?await g({data:d,ccipRequest:b}):await b({data:d,sender:o,urls:i}),{data:R}=await t.call(a,{blockNumber:s,blockTag:r,data:t.concat([l,t.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,f])]),to:e});return R}catch(p){throw new O({callbackSelector:l,cause:p,data:n,extraData:f,sender:o,urls:i})}}async function A({data:a,sender:s,urls:r}){var e;let n=new Error("An unknown error occurred.");for(let c=0;c<r.length;c++){const o=r[c],i=o.includes("{data}")?"GET":"POST",d=i==="POST"?{data:a,sender:s}:void 0,l=i==="POST"?{"Content-Type":"application/json"}:{};try{const f=await fetch(o.replace("{sender}",s.toLowerCase()).replace("{data}",a),{body:JSON.stringify(d),headers:l,method:i});let u;if((e=f.headers.get("Content-Type"))!=null&&e.startsWith("application/json")?u=(await f.json()).data:u=await f.text(),!f.ok){n=new t.HttpRequestError({body:d,details:u!=null&&u.error?t.stringify(u.error):f.statusText,headers:f.headers,status:f.status,url:o});continue}if(!t.isHex(u)){n=new P({result:u,url:o});continue}return u}catch(f){n=new t.HttpRequestError({body:d,details:f.message,url:o})}}throw n}exports.ccipRequest=A;exports.offchainLookup=M;exports.offchainLookupAbiItem=E;exports.offchainLookupSignature=x;
@@ -1,13 +1,13 @@
1
- import { s as b, t as O, f as x, A as N, d as P, g as F, a as E, b as S, e as w, c as $, h as A, i as I, I as D, j as m, k as G, B as y, l as L, m as q, n as T, o as C, p as H, q as j, H as R, r as v } from "./index-CBKJdpVQ.js";
2
- function B(a) {
1
+ import { s as b, t as O, f as x, A as S, d as $, g as F, a as E, b as I, e as w, c as D, h as A, i as G, I as T, j as m, k as C, B as y, l as L, m as M, n as H, o as j, p as v, q as B, H as R, r as U } from "./index-s-IB6Vxx.js";
2
+ function _(a) {
3
3
  const { abi: r, data: e } = a, s = b(e, 0, 4), t = r.find((o) => o.type === "function" && s === O(x(o)));
4
4
  if (!t)
5
- throw new N(s, {
5
+ throw new S(s, {
6
6
  docsPath: "/docs/contract/decodeFunctionData"
7
7
  });
8
8
  return {
9
9
  functionName: t.name,
10
- args: "inputs" in t && t.inputs && t.inputs.length > 0 ? P(t.inputs, b(e, 4)) : void 0
10
+ args: "inputs" in t && t.inputs && t.inputs.length > 0 ? $(t.inputs, b(e, 4)) : void 0
11
11
  };
12
12
  }
13
13
  const p = "/docs/contract/encodeErrorResult";
@@ -26,13 +26,13 @@ function k(a) {
26
26
  let c = "0x";
27
27
  if (s && s.length > 0) {
28
28
  if (!t.inputs)
29
- throw new S(t.name, { docsPath: p });
29
+ throw new I(t.name, { docsPath: p });
30
30
  c = w(t.inputs, s);
31
31
  }
32
- return $([n, c]);
32
+ return D([n, c]);
33
33
  }
34
34
  const h = "/docs/contract/encodeFunctionResult";
35
- function U(a) {
35
+ function J(a) {
36
36
  const { abi: r, functionName: e, result: s } = a;
37
37
  let t = r[0];
38
38
  if (e) {
@@ -44,7 +44,7 @@ function U(a) {
44
44
  if (t.type !== "function")
45
45
  throw new A(void 0, { docsPath: h });
46
46
  if (!t.outputs)
47
- throw new I(t.name, { docsPath: h });
47
+ throw new G(t.name, { docsPath: h });
48
48
  const o = (() => {
49
49
  if (t.outputs.length === 0)
50
50
  return [];
@@ -52,20 +52,20 @@ function U(a) {
52
52
  return [s];
53
53
  if (Array.isArray(s))
54
54
  return s;
55
- throw new D(s);
55
+ throw new T(s);
56
56
  })();
57
57
  return w(t.outputs, o);
58
58
  }
59
- const _ = "x-batch-gateway:true";
60
- async function J(a) {
61
- const { data: r, ccipRequest: e } = a, { args: [s] } = B({ abi: m, data: r }), t = [], o = [];
59
+ const N = "x-batch-gateway:true";
60
+ async function P(a) {
61
+ const { data: r, ccipRequest: e } = a, { args: [s] } = _({ abi: m, data: r }), t = [], o = [];
62
62
  return await Promise.all(s.map(async (n, c) => {
63
63
  try {
64
- o[c] = await e(n), t[c] = !1;
64
+ o[c] = n.urls.includes(N) ? await P({ data: n.data, ccipRequest: e }) : await e(n), t[c] = !1;
65
65
  } catch (u) {
66
66
  t[c] = !0, o[c] = W(u);
67
67
  }
68
- })), U({
68
+ })), J({
69
69
  abi: m,
70
70
  functionName: "query",
71
71
  result: [t, o]
@@ -77,7 +77,7 @@ function W(a) {
77
77
  errorName: "HttpError",
78
78
  args: [a.status, a.shortMessage]
79
79
  }) : k({
80
- abi: [G],
80
+ abi: [C],
81
81
  errorName: "Error",
82
82
  args: ["shortMessage" in a ? a.shortMessage : a.message]
83
83
  });
@@ -109,7 +109,7 @@ class K extends y {
109
109
  super("Offchain gateway response is malformed. Response data must be a hex value.", {
110
110
  metaMessages: [
111
111
  `Gateway URL: ${L(e)}`,
112
- `Response: ${q(r)}`
112
+ `Response: ${M(r)}`
113
113
  ],
114
114
  name: "OffchainLookupResponseMalformedError"
115
115
  });
@@ -153,26 +153,26 @@ const Z = "0x556f1830", V = {
153
153
  ]
154
154
  };
155
155
  async function tt(a, { blockNumber: r, blockTag: e, data: s, to: t }) {
156
- const { args: o } = T({
156
+ const { args: o } = H({
157
157
  data: s,
158
158
  abi: [V]
159
159
  }), [n, c, u, f, d] = o, { ccipRead: i } = a, g = i && typeof (i == null ? void 0 : i.request) == "function" ? i.request : X;
160
160
  try {
161
- if (!C(t, n))
161
+ if (!j(t, n))
162
162
  throw new Q({ sender: n, to: t });
163
- const l = c.includes(_) ? await J({
163
+ const l = c.includes(N) ? await P({
164
164
  data: u,
165
165
  ccipRequest: g
166
- }) : await g({ data: u, sender: n, urls: c }), { data: M } = await H(a, {
166
+ }) : await g({ data: u, sender: n, urls: c }), { data: q } = await v(a, {
167
167
  blockNumber: r,
168
168
  blockTag: e,
169
- data: j([
169
+ data: B([
170
170
  f,
171
171
  w([{ type: "bytes" }, { type: "bytes" }], [l, d])
172
172
  ]),
173
173
  to: t
174
174
  });
175
- return M;
175
+ return q;
176
176
  } catch (l) {
177
177
  throw new z({
178
178
  callbackSelector: f,
@@ -199,14 +199,14 @@ async function X({ data: a, sender: r, urls: e }) {
199
199
  if ((t = d.headers.get("Content-Type")) != null && t.startsWith("application/json") ? i = (await d.json()).data : i = await d.text(), !d.ok) {
200
200
  s = new R({
201
201
  body: u,
202
- details: i != null && i.error ? q(i.error) : d.statusText,
202
+ details: i != null && i.error ? M(i.error) : d.statusText,
203
203
  headers: d.headers,
204
204
  status: d.status,
205
205
  url: n
206
206
  });
207
207
  continue;
208
208
  }
209
- if (!v(i)) {
209
+ if (!U(i)) {
210
210
  s = new K({
211
211
  result: i,
212
212
  url: n