@gardenfi/core 2.1.13-beta.2 → 2.1.14
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/dist/ccip-CQkMVqmN.cjs +1 -0
- package/dist/ccip-DgpQO1MZ.js +149 -0
- package/dist/index-BwOLJ71D.cjs +75 -0
- package/dist/index-CAqXP6qV.js +24196 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +17 -21
- package/dist/src/index.d.ts +1 -4
- package/dist/src/lib/constants.d.ts +0 -6
- package/dist/src/lib/garden/garden.d.ts +1 -11
- package/dist/src/lib/garden/garden.types.d.ts +1 -12
- package/package.json +3 -5
- package/dist/ccip-BCmQ-ZNT.cjs +0 -1
- package/dist/ccip-Bi_7Mx9G.js +0 -232
- package/dist/index-BEY92n8B.cjs +0 -81
- package/dist/index-s-IB6Vxx.js +0 -22429
- package/dist/secp256k1-BXRxY-Ty.js +0 -1290
- package/dist/secp256k1-CS4jLSmJ.cjs +0 -1
- package/dist/src/lib/solana/htlc/ISolanaHTLC.d.ts +0 -28
- package/dist/src/lib/solana/htlc/solanaHTLC.d.ts +0 -56
- package/dist/src/lib/solana/idl/solana_native_swaps.d.ts +0 -299
- package/dist/src/lib/solana/idl/solana_native_swaps.json.d.ts +0 -296
- package/dist/src/lib/solana/relayer/solanaRelay.d.ts +0 -71
- package/dist/src/lib/solana/solanaTypes.d.ts +0 -31
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BwOLJ71D.cjs");exports.API=e.API;exports.BlockNumberFetcher=e.BlockNumberFetcher;exports.EvmRelay=e.EvmRelay;exports.Garden=e.Garden;exports.OrderActions=e.OrderActions;exports.OrderStatus=e.OrderStatus;exports.ParseOrderStatus=e.ParseOrderStatus;exports.ParseSwapStatus=e.ParseSwapStatus;exports.Quote=e.Quote;exports.STARKNET_CONFIG=e.STARKNET_CONFIG;exports.SecretManager=e.SecretManager;exports.StarknetHTLC=e.StarknetHTLC;exports.StarknetRelay=e.StarknetRelay;exports.SwapStatus=e.SwapStatus;exports.botanix=e.botanixMainnet;exports.constructOrderPair=e.constructOrderPair;exports.evmToViemChainMap=e.evmToViemChainMap;exports.filterDeadlineExpiredOrders=e.filterDeadlineExpiredOrders;exports.hyperliquid=e.hyperliquid;exports.hyperliquidTestnet=e.hyperliquidTestnet;exports.isExpired=e.isExpired;exports.parseAction=e.parseAction;exports.parseActionFromStatus=e.parseActionFromStatus;exports.resolveApiConfig=e.resolveApiConfig;exports.switchOrAddNetwork=e.switchOrAddNetwork;exports.toXOnly=e.toXOnly;exports.validateBTCAddress=e.validateBTCAddress;
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as e, j as r, E as t, G as i, O as d, k as o, P as n, n as p, Q as S, I as u, t as l, h as c, S as A, m as O, D as m, u as h, y, q as C, C as T, A as k, o as v, p as w, r as x, x as E, z as P, w as F, v as N } from "./index-CAqXP6qV.js";
|
|
2
2
|
export {
|
|
3
3
|
e as API,
|
|
4
4
|
r as BlockNumberFetcher,
|
|
5
5
|
t as EvmRelay,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
i as Garden,
|
|
7
|
+
d as OrderActions,
|
|
8
8
|
o as OrderStatus,
|
|
9
9
|
n as ParseOrderStatus,
|
|
10
|
-
|
|
10
|
+
p as ParseSwapStatus,
|
|
11
11
|
S as Quote,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
A as
|
|
16
|
-
O as
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
y as
|
|
20
|
-
C as
|
|
21
|
-
|
|
22
|
-
R as evmToViemChainMap,
|
|
23
|
-
h as filterDeadlineExpiredOrders,
|
|
24
|
-
N as hyperliquid,
|
|
12
|
+
u as STARKNET_CONFIG,
|
|
13
|
+
l as SecretManager,
|
|
14
|
+
c as StarknetHTLC,
|
|
15
|
+
A as StarknetRelay,
|
|
16
|
+
O as SwapStatus,
|
|
17
|
+
m as botanix,
|
|
18
|
+
h as constructOrderPair,
|
|
19
|
+
y as evmToViemChainMap,
|
|
20
|
+
C as filterDeadlineExpiredOrders,
|
|
21
|
+
T as hyperliquid,
|
|
25
22
|
k as hyperliquidTestnet,
|
|
26
23
|
v as isExpired,
|
|
27
24
|
w as parseAction,
|
|
28
25
|
x as parseActionFromStatus,
|
|
29
26
|
E as resolveApiConfig,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
F as validateBTCAddress
|
|
27
|
+
P as switchOrAddNetwork,
|
|
28
|
+
F as toXOnly,
|
|
29
|
+
N as validateBTCAddress
|
|
34
30
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export type { IEVMHTLC } from './lib/evm/htlc.types';
|
|
|
7
7
|
export { StarknetRelay } from './lib/starknet/relay/starknetRelay';
|
|
8
8
|
export type { IStarknetHTLC } from './lib/starknet/starknetHTLC.types';
|
|
9
9
|
export { StarknetHTLC } from './lib/starknet/htlc/starknetHTLC';
|
|
10
|
-
export { SolanaRelay } from './lib/solana/relayer/solanaRelay';
|
|
11
|
-
export type { ISolanaHTLC } from './lib/solana/htlc/ISolanaHTLC';
|
|
12
|
-
export { SolanaHTLC } from './lib/solana/htlc/solanaHTLC';
|
|
13
10
|
export { BlockNumberFetcher } from './lib/blockNumberFetcher/blockNumber';
|
|
14
11
|
export type { IBlockNumberFetcher } from './lib/blockNumberFetcher/blockNumber';
|
|
15
12
|
export { OrderStatus, SwapStatus } from './lib/orderStatus/status';
|
|
@@ -20,4 +17,4 @@ export { Quote } from './lib/quote/quote';
|
|
|
20
17
|
export type { IQuote, QuoteResponse, Strategies, } from './lib/quote/quote.types';
|
|
21
18
|
export { constructOrderPair, validateBTCAddress, toXOnly, resolveApiConfig, } from './lib/utils';
|
|
22
19
|
export { evmToViemChainMap, switchOrAddNetwork, hyperliquidTestnet, hyperliquid, botanixMainnet as botanix, } from './lib/switchOrAddNetwork';
|
|
23
|
-
export { API, STARKNET_CONFIG
|
|
20
|
+
export { API, STARKNET_CONFIG } from './lib/constants';
|
|
@@ -7,18 +7,12 @@ export type Api = {
|
|
|
7
7
|
info: string;
|
|
8
8
|
evmRelay: string;
|
|
9
9
|
starknetRelay: string;
|
|
10
|
-
solanaRelay: string;
|
|
11
10
|
};
|
|
12
11
|
export declare const API: Record<Environment, Api>;
|
|
13
12
|
export declare const STARKNET_CONFIG: Record<Network, {
|
|
14
13
|
chainId: string;
|
|
15
14
|
nodeUrl: string;
|
|
16
15
|
}>;
|
|
17
|
-
export declare const SolanaRelayerAddress: Record<Network, string>;
|
|
18
|
-
export declare const solanaProgramAddress: {
|
|
19
|
-
mainnet: string;
|
|
20
|
-
staging: string;
|
|
21
|
-
};
|
|
22
16
|
export declare const DEFAULT_AFFILIATE_ASSET: {
|
|
23
17
|
chain: "base";
|
|
24
18
|
asset: "0xeae7721d779276eb0f5837e2fe260118724a2ba4";
|
|
@@ -8,7 +8,6 @@ import { IBitcoinWallet } from '@catalogfi/wallets';
|
|
|
8
8
|
import { IBlockNumberFetcher } from '../blockNumberFetcher/blockNumber';
|
|
9
9
|
import { IEVMHTLC } from '../evm/htlc.types';
|
|
10
10
|
import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
|
|
11
|
-
import { ISolanaHTLC } from '../solana/htlc/ISolanaHTLC';
|
|
12
11
|
|
|
13
12
|
export declare class Garden extends EventBroker<GardenEvents> implements IGardenJS {
|
|
14
13
|
private environment;
|
|
@@ -22,7 +21,6 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
22
21
|
private refundSacpCache;
|
|
23
22
|
private _evmHTLC;
|
|
24
23
|
private _starknetHTLC;
|
|
25
|
-
private _solanaHTLC;
|
|
26
24
|
private _btcWallet;
|
|
27
25
|
private bitcoinRedeemCache;
|
|
28
26
|
private _digestKey;
|
|
@@ -31,20 +29,13 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
31
29
|
static fromWallets(config: GardenConfigWithWallets): Garden;
|
|
32
30
|
get evmHTLC(): IEVMHTLC | undefined;
|
|
33
31
|
get starknetHTLC(): IStarknetHTLC | undefined;
|
|
34
|
-
get solanaHTLC(): ISolanaHTLC | undefined;
|
|
35
32
|
get quote(): IQuote;
|
|
36
|
-
get btcWallet(): IBitcoinWallet
|
|
33
|
+
get btcWallet(): IBitcoinWallet;
|
|
37
34
|
get orderbook(): IOrderbook;
|
|
38
35
|
get blockNumberFetcher(): IBlockNumberFetcher;
|
|
39
36
|
get secretManager(): ISecretManager;
|
|
40
37
|
get auth(): IAuth;
|
|
41
38
|
get digestKey(): DigestKey;
|
|
42
|
-
/**
|
|
43
|
-
* This method takes in the `SwapParams` and returns a placed order
|
|
44
|
-
* It internally calls `getAttestedQuote`, `createOrder` and `pollOrder`
|
|
45
|
-
* @param swapParams
|
|
46
|
-
* @returns MatchedOrder
|
|
47
|
-
*/
|
|
48
39
|
swap(params: SwapParams): AsyncResult<MatchedOrder, string>;
|
|
49
40
|
private withDefaultAffiliateFees;
|
|
50
41
|
private validateAndFillParams;
|
|
@@ -52,7 +43,6 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
52
43
|
private validateAmount;
|
|
53
44
|
private pollOrder;
|
|
54
45
|
execute(interval?: number): Promise<() => void>;
|
|
55
|
-
private solRedeem;
|
|
56
46
|
private evmRedeem;
|
|
57
47
|
private starknetRedeem;
|
|
58
48
|
private btcRedeem;
|
|
@@ -5,14 +5,12 @@ import { Environment, EventBroker, IAuth, DigestKey } from '@gardenfi/utils';
|
|
|
5
5
|
import { ISecretManager } from '../secretManager/secretManager.types';
|
|
6
6
|
import { IQuote } from '../quote/quote.types';
|
|
7
7
|
import { IBlockNumberFetcher } from '../blockNumberFetcher/blockNumber';
|
|
8
|
-
import {
|
|
8
|
+
import { IBitcoinWallet } from '@catalogfi/wallets';
|
|
9
9
|
import { IEVMHTLC } from '../evm/htlc.types';
|
|
10
10
|
import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
|
|
11
11
|
import { AccountInterface } from 'starknet';
|
|
12
12
|
import { WalletClient } from 'viem';
|
|
13
13
|
import { Api } from '../constants';
|
|
14
|
-
import { ISolanaHTLC } from '../solana/htlc/ISolanaHTLC';
|
|
15
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
16
14
|
|
|
17
15
|
export type SwapParams = {
|
|
18
16
|
/**
|
|
@@ -97,11 +95,6 @@ export interface IGardenJS extends EventBroker<GardenEvents> {
|
|
|
97
95
|
* @readonly
|
|
98
96
|
*/
|
|
99
97
|
get starknetHTLC(): IStarknetHTLC | undefined;
|
|
100
|
-
/**
|
|
101
|
-
* The Solana relay.
|
|
102
|
-
* @readonly
|
|
103
|
-
*/
|
|
104
|
-
get solanaHTLC(): ISolanaHTLC | undefined;
|
|
105
98
|
/**
|
|
106
99
|
* The current quote.
|
|
107
100
|
* @readonly
|
|
@@ -159,21 +152,17 @@ export type GardenCoreConfig = {
|
|
|
159
152
|
orderbook?: IOrderbook;
|
|
160
153
|
quote?: IQuote;
|
|
161
154
|
blockNumberFetcher?: IBlockNumberFetcher;
|
|
162
|
-
btcWallet?: BitcoinWallet;
|
|
163
|
-
solanaProgramAddress?: string;
|
|
164
155
|
};
|
|
165
156
|
export type GardenHTLCModules = {
|
|
166
157
|
htlc: {
|
|
167
158
|
evm?: IEVMHTLC;
|
|
168
159
|
starknet?: IStarknetHTLC;
|
|
169
|
-
solana?: ISolanaHTLC;
|
|
170
160
|
};
|
|
171
161
|
};
|
|
172
162
|
export type GardenWalletModules = {
|
|
173
163
|
wallets: {
|
|
174
164
|
evm?: WalletClient;
|
|
175
165
|
starknet?: AccountInterface;
|
|
176
|
-
solana?: AnchorProvider;
|
|
177
166
|
};
|
|
178
167
|
};
|
|
179
168
|
export type GardenConfigWithWallets = GardenCoreConfig & GardenWalletModules;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -26,11 +26,9 @@
|
|
|
26
26
|
"registry": "https://registry.npmjs.org/"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@catalogfi/utils": "^0.1.6",
|
|
30
29
|
"@catalogfi/wallets": "^0.2.59",
|
|
31
|
-
"@
|
|
32
|
-
"@gardenfi/
|
|
33
|
-
"@gardenfi/utils": "2.1.3-beta.20",
|
|
30
|
+
"@gardenfi/orderbook": "2.1.10",
|
|
31
|
+
"@gardenfi/utils": "2.1.3",
|
|
34
32
|
"bignumber.js": "^9.1.2",
|
|
35
33
|
"bitcoinjs-lib": "^6.1.6",
|
|
36
34
|
"starknet": "6.23.1",
|
package/dist/ccip-BCmQ-ZNT.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|
package/dist/ccip-Bi_7Mx9G.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
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
|
-
const { abi: r, data: e } = a, s = b(e, 0, 4), t = r.find((o) => o.type === "function" && s === O(x(o)));
|
|
4
|
-
if (!t)
|
|
5
|
-
throw new S(s, {
|
|
6
|
-
docsPath: "/docs/contract/decodeFunctionData"
|
|
7
|
-
});
|
|
8
|
-
return {
|
|
9
|
-
functionName: t.name,
|
|
10
|
-
args: "inputs" in t && t.inputs && t.inputs.length > 0 ? $(t.inputs, b(e, 4)) : void 0
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const p = "/docs/contract/encodeErrorResult";
|
|
14
|
-
function k(a) {
|
|
15
|
-
const { abi: r, errorName: e, args: s } = a;
|
|
16
|
-
let t = r[0];
|
|
17
|
-
if (e) {
|
|
18
|
-
const u = F({ abi: r, args: s, name: e });
|
|
19
|
-
if (!u)
|
|
20
|
-
throw new E(e, { docsPath: p });
|
|
21
|
-
t = u;
|
|
22
|
-
}
|
|
23
|
-
if (t.type !== "error")
|
|
24
|
-
throw new E(void 0, { docsPath: p });
|
|
25
|
-
const o = x(t), n = O(o);
|
|
26
|
-
let c = "0x";
|
|
27
|
-
if (s && s.length > 0) {
|
|
28
|
-
if (!t.inputs)
|
|
29
|
-
throw new I(t.name, { docsPath: p });
|
|
30
|
-
c = w(t.inputs, s);
|
|
31
|
-
}
|
|
32
|
-
return D([n, c]);
|
|
33
|
-
}
|
|
34
|
-
const h = "/docs/contract/encodeFunctionResult";
|
|
35
|
-
function J(a) {
|
|
36
|
-
const { abi: r, functionName: e, result: s } = a;
|
|
37
|
-
let t = r[0];
|
|
38
|
-
if (e) {
|
|
39
|
-
const n = F({ abi: r, name: e });
|
|
40
|
-
if (!n)
|
|
41
|
-
throw new A(e, { docsPath: h });
|
|
42
|
-
t = n;
|
|
43
|
-
}
|
|
44
|
-
if (t.type !== "function")
|
|
45
|
-
throw new A(void 0, { docsPath: h });
|
|
46
|
-
if (!t.outputs)
|
|
47
|
-
throw new G(t.name, { docsPath: h });
|
|
48
|
-
const o = (() => {
|
|
49
|
-
if (t.outputs.length === 0)
|
|
50
|
-
return [];
|
|
51
|
-
if (t.outputs.length === 1)
|
|
52
|
-
return [s];
|
|
53
|
-
if (Array.isArray(s))
|
|
54
|
-
return s;
|
|
55
|
-
throw new T(s);
|
|
56
|
-
})();
|
|
57
|
-
return w(t.outputs, o);
|
|
58
|
-
}
|
|
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
|
-
return await Promise.all(s.map(async (n, c) => {
|
|
63
|
-
try {
|
|
64
|
-
o[c] = n.urls.includes(N) ? await P({ data: n.data, ccipRequest: e }) : await e(n), t[c] = !1;
|
|
65
|
-
} catch (u) {
|
|
66
|
-
t[c] = !0, o[c] = W(u);
|
|
67
|
-
}
|
|
68
|
-
})), J({
|
|
69
|
-
abi: m,
|
|
70
|
-
functionName: "query",
|
|
71
|
-
result: [t, o]
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function W(a) {
|
|
75
|
-
return a.name === "HttpRequestError" && a.status ? k({
|
|
76
|
-
abi: m,
|
|
77
|
-
errorName: "HttpError",
|
|
78
|
-
args: [a.status, a.shortMessage]
|
|
79
|
-
}) : k({
|
|
80
|
-
abi: [C],
|
|
81
|
-
errorName: "Error",
|
|
82
|
-
args: ["shortMessage" in a ? a.shortMessage : a.message]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
class z extends y {
|
|
86
|
-
constructor({ callbackSelector: r, cause: e, data: s, extraData: t, sender: o, urls: n }) {
|
|
87
|
-
var c;
|
|
88
|
-
super(e.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
89
|
-
cause: e,
|
|
90
|
-
metaMessages: [
|
|
91
|
-
...e.metaMessages || [],
|
|
92
|
-
(c = e.metaMessages) != null && c.length ? "" : [],
|
|
93
|
-
"Offchain Gateway Call:",
|
|
94
|
-
n && [
|
|
95
|
-
" Gateway URL(s):",
|
|
96
|
-
...n.map((u) => ` ${L(u)}`)
|
|
97
|
-
],
|
|
98
|
-
` Sender: ${o}`,
|
|
99
|
-
` Data: ${s}`,
|
|
100
|
-
` Callback selector: ${r}`,
|
|
101
|
-
` Extra data: ${t}`
|
|
102
|
-
].flat(),
|
|
103
|
-
name: "OffchainLookupError"
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
class K extends y {
|
|
108
|
-
constructor({ result: r, url: e }) {
|
|
109
|
-
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
110
|
-
metaMessages: [
|
|
111
|
-
`Gateway URL: ${L(e)}`,
|
|
112
|
-
`Response: ${M(r)}`
|
|
113
|
-
],
|
|
114
|
-
name: "OffchainLookupResponseMalformedError"
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
class Q extends y {
|
|
119
|
-
constructor({ sender: r, to: e }) {
|
|
120
|
-
super("Reverted sender address does not match target contract address (`to`).", {
|
|
121
|
-
metaMessages: [
|
|
122
|
-
`Contract address: ${e}`,
|
|
123
|
-
`OffchainLookup sender address: ${r}`
|
|
124
|
-
],
|
|
125
|
-
name: "OffchainLookupSenderMismatchError"
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const Z = "0x556f1830", V = {
|
|
130
|
-
name: "OffchainLookup",
|
|
131
|
-
type: "error",
|
|
132
|
-
inputs: [
|
|
133
|
-
{
|
|
134
|
-
name: "sender",
|
|
135
|
-
type: "address"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: "urls",
|
|
139
|
-
type: "string[]"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: "callData",
|
|
143
|
-
type: "bytes"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: "callbackFunction",
|
|
147
|
-
type: "bytes4"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: "extraData",
|
|
151
|
-
type: "bytes"
|
|
152
|
-
}
|
|
153
|
-
]
|
|
154
|
-
};
|
|
155
|
-
async function tt(a, { blockNumber: r, blockTag: e, data: s, to: t }) {
|
|
156
|
-
const { args: o } = H({
|
|
157
|
-
data: s,
|
|
158
|
-
abi: [V]
|
|
159
|
-
}), [n, c, u, f, d] = o, { ccipRead: i } = a, g = i && typeof (i == null ? void 0 : i.request) == "function" ? i.request : X;
|
|
160
|
-
try {
|
|
161
|
-
if (!j(t, n))
|
|
162
|
-
throw new Q({ sender: n, to: t });
|
|
163
|
-
const l = c.includes(N) ? await P({
|
|
164
|
-
data: u,
|
|
165
|
-
ccipRequest: g
|
|
166
|
-
}) : await g({ data: u, sender: n, urls: c }), { data: q } = await v(a, {
|
|
167
|
-
blockNumber: r,
|
|
168
|
-
blockTag: e,
|
|
169
|
-
data: B([
|
|
170
|
-
f,
|
|
171
|
-
w([{ type: "bytes" }, { type: "bytes" }], [l, d])
|
|
172
|
-
]),
|
|
173
|
-
to: t
|
|
174
|
-
});
|
|
175
|
-
return q;
|
|
176
|
-
} catch (l) {
|
|
177
|
-
throw new z({
|
|
178
|
-
callbackSelector: f,
|
|
179
|
-
cause: l,
|
|
180
|
-
data: s,
|
|
181
|
-
extraData: d,
|
|
182
|
-
sender: n,
|
|
183
|
-
urls: c
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async function X({ data: a, sender: r, urls: e }) {
|
|
188
|
-
var t;
|
|
189
|
-
let s = new Error("An unknown error occurred.");
|
|
190
|
-
for (let o = 0; o < e.length; o++) {
|
|
191
|
-
const n = e[o], c = n.includes("{data}") ? "GET" : "POST", u = c === "POST" ? { data: a, sender: r } : void 0, f = c === "POST" ? { "Content-Type": "application/json" } : {};
|
|
192
|
-
try {
|
|
193
|
-
const d = await fetch(n.replace("{sender}", r.toLowerCase()).replace("{data}", a), {
|
|
194
|
-
body: JSON.stringify(u),
|
|
195
|
-
headers: f,
|
|
196
|
-
method: c
|
|
197
|
-
});
|
|
198
|
-
let i;
|
|
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
|
-
s = new R({
|
|
201
|
-
body: u,
|
|
202
|
-
details: i != null && i.error ? M(i.error) : d.statusText,
|
|
203
|
-
headers: d.headers,
|
|
204
|
-
status: d.status,
|
|
205
|
-
url: n
|
|
206
|
-
});
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
if (!U(i)) {
|
|
210
|
-
s = new K({
|
|
211
|
-
result: i,
|
|
212
|
-
url: n
|
|
213
|
-
});
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
return i;
|
|
217
|
-
} catch (d) {
|
|
218
|
-
s = new R({
|
|
219
|
-
body: u,
|
|
220
|
-
details: d.message,
|
|
221
|
-
url: n
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
throw s;
|
|
226
|
-
}
|
|
227
|
-
export {
|
|
228
|
-
X as ccipRequest,
|
|
229
|
-
tt as offchainLookup,
|
|
230
|
-
V as offchainLookupAbiItem,
|
|
231
|
-
Z as offchainLookupSignature
|
|
232
|
-
};
|