@gardenfi/utils 2.5.1 → 2.5.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.
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +4 -4
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +4 -4
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +13 -31
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +58 -32
- package/dist/index26.cjs +16 -1
- package/dist/index26.js +113 -11
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +32 -58
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +31 -13
- package/dist/index29.cjs +1 -16
- package/dist/index29.js +11 -113
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +38 -38
- package/package.json +1 -1
package/dist/index10.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),k=require("./index14.cjs"),f=require("./index15.cjs"),h=require("./index3.cjs"),n=require("./index5.cjs"),m=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),k=require("./index14.cjs"),f=require("./index15.cjs"),h=require("./index3.cjs"),n=require("./index5.cjs"),m=require("./index24.cjs"),y=require("./index25.cjs"),C=require("./index23.cjs"),T=require("./index26.cjs"),v=require("./index27.cjs"),S=c=>c&&c.__esModule?c:{default:c},p=S(g);class u{constructor(t,i,e){if(this.url=t.endpoint("siwe"),this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??(typeof window<"u"?window.localStorage:new k.MemoryStorage),typeof window>"u"){const r=new w.CookieJar;this.fetchWithCookies=p.default(fetch,r)}else this.fetchWithCookies=window.fetch.bind(window)}static fromDigestKey(t,i,e){const r=m.createWalletClient({account:C.privateKeyToAccount(h.add0x(i.digestKey)),transport:y.http(),chain:v.mainnet});return new u(t,r,e)}verifyToken(t,i){try{const e=h.parseJwt(t);if(!e)return n.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return n.Ok(e.exp>r&&e.user_id.toLowerCase()===i.toLowerCase())}catch{return n.Ok(!1)}}async getToken(){var s;if(!((s=this.walletClient.account)!=null&&s.address))return n.Err("Wallet client does not have an account");const t=this.store.getItem(f.StoreKeys.AUTH_TOKEN);if(t){const o=this.verifyToken(t,this.walletClient.account.address);if(o.ok&&o.val)return n.Ok(t)}const i=await this.signStatement();if(i.error)return n.Err(i.error);let e;try{const a=await(await this.fetchWithCookies(this.url.endpoint("tokens"),{method:"POST",body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(a.error||!a.result)return n.Err(a.error??"Failed to get token");e=a.result}catch(o){return n.Err("Failed to get token",o)}if(!this.verifyToken(e,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(f.StoreKeys.AUTH_TOKEN,e),n.Ok(e)}async signStatement(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return n.Err("Wallet client does not have a valid account");const t=new Date,i=new Date(t.getTime()+300*1e3);let e;try{const l=await(await this.fetchWithCookies(this.url.endpoint("challenges"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(l.error||!l.result)return n.Err("Failed to get nonce");e=l.result}catch(d){return n.Err("Failed to get nonce",d)}const r=await this.walletClient.getChainId(),s=T.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:e,uri:"https://"+this.domain,version:"1",chainId:r,notBefore:i}),o=await this.walletClient.signMessage({account:this.walletClient.account,message:s});return n.Ok({message:s,signature:o,nonce:e})}async getAuthHeaders(){const t=await this.getToken();return t.ok?n.Ok({Authorization:h.Authorization(t.val)}):n.Err(t.error)}}exports.Siwe=u;
|
package/dist/index10.js
CHANGED
|
@@ -4,11 +4,11 @@ import { MemoryStorage as w } from "./index14.js";
|
|
|
4
4
|
import { StoreKeys as d } from "./index15.js";
|
|
5
5
|
import { add0x as g, parseJwt as k, Authorization as p } from "./index3.js";
|
|
6
6
|
import { Ok as s, Err as r } from "./index5.js";
|
|
7
|
-
import { createWalletClient as y } from "./
|
|
8
|
-
import { http as C } from "./
|
|
7
|
+
import { createWalletClient as y } from "./index24.js";
|
|
8
|
+
import { http as C } from "./index25.js";
|
|
9
9
|
import { privateKeyToAccount as T } from "./index23.js";
|
|
10
|
-
import { createSiweMessage as v } from "./
|
|
11
|
-
import { mainnet as S } from "./
|
|
10
|
+
import { createSiweMessage as v } from "./index26.js";
|
|
11
|
+
import { mainnet as S } from "./index27.js";
|
|
12
12
|
class f {
|
|
13
13
|
constructor(e, n, t) {
|
|
14
14
|
if (this.url = e.endpoint("siwe"), this.walletClient = n, this.domain = (t == null ? void 0 : t.domain) || "app.garden.finance", this.domain.startsWith("https://") && (this.domain = this.domain.split("https://")[1]), this.signingStatement = (t == null ? void 0 : t.signingStatement) ?? "Garden.fi", this.store = (t == null ? void 0 : t.store) ?? (typeof window < "u" ? window.localStorage : new w()), typeof window > "u") {
|
package/dist/index16.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index5.cjs"),a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index5.cjs"),a=require("./index28.cjs"),s=require("./index27.cjs"),l=require("./index29.cjs"),b=require("./index25.cjs"),n={42161:s.mainnet,421614:a.sepolia},h=async r=>{const{chain:e}=r;if(!e)return c.Err("No chain found");const o=(u=>u in n)(e.id)?n[e.id]:e;return await i(o)},i=async r=>{const e=l.createPublicClient({chain:r,transport:b.http()});try{const t=await e.getBlockNumber();return c.Ok(Number(t))}catch(t){return c.Err("Failed to fetch evm block number",t)}};exports._fetchEVMBlockNumber=i;exports.fetchEVMBlockNumber=h;
|
package/dist/index16.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Err as c, Ok as a } from "./index5.js";
|
|
2
|
-
import { sepolia as m } from "./
|
|
3
|
-
import { mainnet as s } from "./
|
|
4
|
-
import { createPublicClient as u } from "./
|
|
5
|
-
import { http as l } from "./
|
|
2
|
+
import { sepolia as m } from "./index28.js";
|
|
3
|
+
import { mainnet as s } from "./index27.js";
|
|
4
|
+
import { createPublicClient as u } from "./index29.js";
|
|
5
|
+
import { http as l } from "./index25.js";
|
|
6
6
|
const n = {
|
|
7
7
|
42161: s,
|
|
8
8
|
421614: m
|
package/dist/index24.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index49.cjs"),c=require("./index103.cjs");function r(e){const{key:t="wallet",name:l="Wallet Client",transport:n}=e;return i.createClient({...e,key:t,name:l,transport:n,type:"walletClient"}).extend(c.walletActions)}exports.createWalletClient=r;
|
package/dist/index24.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
name: "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
name: "Etherscan",
|
|
14
|
-
url: "https://sepolia.etherscan.io",
|
|
15
|
-
apiUrl: "https://api-sepolia.etherscan.io/api"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
contracts: {
|
|
19
|
-
multicall3: {
|
|
20
|
-
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
21
|
-
blockCreated: 751532
|
|
22
|
-
},
|
|
23
|
-
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
24
|
-
ensUniversalResolver: {
|
|
25
|
-
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
26
|
-
blockCreated: 5317080
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
testnet: !0
|
|
30
|
-
});
|
|
1
|
+
import { createClient as i } from "./index49.js";
|
|
2
|
+
import { walletActions as o } from "./index103.js";
|
|
3
|
+
function m(t) {
|
|
4
|
+
const { key: e = "wallet", name: l = "Wallet Client", transport: n } = t;
|
|
5
|
+
return i({
|
|
6
|
+
...t,
|
|
7
|
+
key: e,
|
|
8
|
+
name: l,
|
|
9
|
+
transport: n,
|
|
10
|
+
type: "walletClient"
|
|
11
|
+
}).extend(o);
|
|
12
|
+
}
|
|
31
13
|
export {
|
|
32
|
-
|
|
14
|
+
m as createWalletClient
|
|
33
15
|
};
|
package/dist/index25.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("./index52.cjs"),E=require("./index53.cjs"),F=require("./index54.cjs"),H=require("./index55.cjs"),U=require("./index56.cjs");function _(k,r={}){const{batch:o,fetchOptions:u,key:l="http",methods:h,name:q="HTTP JSON-RPC",onFetchRequest:d,onFetchResponse:y,retryDelay:R,raw:f}=r;return({chain:n,retryCount:w,timeout:S})=>{const{batchSize:m=1e3,wait:C=0}=typeof o=="object"?o:{},b=r.retryCount??w,c=S??r.timeout??1e4,e=n==null?void 0:n.rpcUrls.default.http[0];if(!e)throw new E.UrlRequiredError;const a=H.getHttpRpcClient(e,{fetchOptions:u,onRequest:d,onResponse:y,timeout:c});return U.createTransport({key:l,methods:h,name:q,async request({method:T,params:B}){const i={method:T,params:B},{schedule:O}=F.createBatchScheduler({id:e,wait:C,shouldSplitBatch(t){return t.length>m},fn:t=>a.request({body:t}),sort:(t,g)=>t.id-g.id}),P=async t=>o?O(t):[await a.request({body:t})],[{error:s,result:p}]=await P(i);if(f)return{error:s,result:p};if(s)throw new j.RpcRequestError({body:i,error:s,url:e});return p},retryCount:b,retryDelay:R,timeout:c,type:"http"},{fetchOptions:u,url:e})}}exports.http=_;
|
package/dist/index25.js
CHANGED
|
@@ -1,34 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
1
|
+
import { RpcRequestError as O } from "./index52.js";
|
|
2
|
+
import { UrlRequiredError as P } from "./index53.js";
|
|
3
|
+
import { createBatchScheduler as U } from "./index54.js";
|
|
4
|
+
import { getHttpRpcClient as _ } from "./index55.js";
|
|
5
|
+
import { createTransport as j } from "./index56.js";
|
|
6
|
+
function g(k, e = {}) {
|
|
7
|
+
const { batch: o, fetchOptions: u, key: m = "http", methods: a, name: h = "HTTP JSON-RPC", onFetchRequest: f, onFetchResponse: y, retryDelay: d, raw: R } = e;
|
|
8
|
+
return ({ chain: n, retryCount: w, timeout: q }) => {
|
|
9
|
+
const { batchSize: C = 1e3, wait: S = 0 } = typeof o == "object" ? o : {}, b = e.retryCount ?? w, c = q ?? e.timeout ?? 1e4, r = n == null ? void 0 : n.rpcUrls.default.http[0];
|
|
10
|
+
if (!r)
|
|
11
|
+
throw new P();
|
|
12
|
+
const p = _(r, {
|
|
13
|
+
fetchOptions: u,
|
|
14
|
+
onRequest: f,
|
|
15
|
+
onResponse: y,
|
|
16
|
+
timeout: c
|
|
17
|
+
});
|
|
18
|
+
return j({
|
|
19
|
+
key: m,
|
|
20
|
+
methods: a,
|
|
21
|
+
name: h,
|
|
22
|
+
async request({ method: T, params: B }) {
|
|
23
|
+
const i = { method: T, params: B }, { schedule: E } = U({
|
|
24
|
+
id: r,
|
|
25
|
+
wait: S,
|
|
26
|
+
shouldSplitBatch(t) {
|
|
27
|
+
return t.length > C;
|
|
28
|
+
},
|
|
29
|
+
fn: (t) => p.request({
|
|
30
|
+
body: t
|
|
31
|
+
}),
|
|
32
|
+
sort: (t, H) => t.id - H.id
|
|
33
|
+
}), F = async (t) => o ? E(t) : [
|
|
34
|
+
await p.request({
|
|
35
|
+
body: t
|
|
36
|
+
})
|
|
37
|
+
], [{ error: s, result: l }] = await F(i);
|
|
38
|
+
if (R)
|
|
39
|
+
return { error: s, result: l };
|
|
40
|
+
if (s)
|
|
41
|
+
throw new O({
|
|
42
|
+
body: i,
|
|
43
|
+
error: s,
|
|
44
|
+
url: r
|
|
45
|
+
});
|
|
46
|
+
return l;
|
|
47
|
+
},
|
|
48
|
+
retryCount: b,
|
|
49
|
+
retryDelay: d,
|
|
50
|
+
timeout: c,
|
|
51
|
+
type: "http"
|
|
52
|
+
}, {
|
|
53
|
+
fetchOptions: u,
|
|
54
|
+
url: r
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
32
58
|
export {
|
|
33
|
-
|
|
59
|
+
g as http
|
|
34
60
|
};
|
package/dist/index26.cjs
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index298.cjs"),M=require("./index164.cjs"),h=require("./index299.cjs");function R(r){const{chainId:o,domain:s,expirationTime:l,issuedAt:m=new Date,nonce:a,notBefore:f,requestId:w,resources:g,scheme:i,uri:c,version:d}=r;{if(o!==Math.floor(o))throw new e.SiweInvalidMessageFieldError({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${o}`]});if(!(E.test(s)||F.test(s)||b.test(s)))throw new e.SiweInvalidMessageFieldError({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${s}`]});if(!A.test(a))throw new e.SiweInvalidMessageFieldError({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${a}`]});if(!h.isUri(c))throw new e.SiweInvalidMessageFieldError({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${c}`]});if(d!=="1")throw new e.SiweInvalidMessageFieldError({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${d}`]});if(i&&!P.test(i))throw new e.SiweInvalidMessageFieldError({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${i}`]});const t=r.statement;if(t!=null&&t.includes(`
|
|
2
|
+
`))throw new e.SiweInvalidMessageFieldError({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${t}`]})}const $=M.getAddress(r.address),v=i?`${i}://${s}`:s,I=r.statement?`${r.statement}
|
|
3
|
+
`:"",S=`${v} wants you to sign in with your Ethereum account:
|
|
4
|
+
${$}
|
|
5
|
+
|
|
6
|
+
${I}`;let n=`URI: ${c}
|
|
7
|
+
Version: ${d}
|
|
8
|
+
Chain ID: ${o}
|
|
9
|
+
Nonce: ${a}
|
|
10
|
+
Issued At: ${m.toISOString()}`;if(l&&(n+=`
|
|
11
|
+
Expiration Time: ${l.toISOString()}`),f&&(n+=`
|
|
12
|
+
Not Before: ${f.toISOString()}`),w&&(n+=`
|
|
13
|
+
Request ID: ${w}`),g){let t=`
|
|
14
|
+
Resources:`;for(const u of g){if(!h.isUri(u))throw new e.SiweInvalidMessageFieldError({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${u}`]});t+=`
|
|
15
|
+
- ${u}`}n+=t}return`${S}
|
|
16
|
+
${n}`}const E=/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,F=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,b=/^localhost(:[0-9]{1,5})?$/,A=/^[a-zA-Z0-9]{8,}$/,P=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/;exports.createSiweMessage=R;
|
package/dist/index26.js
CHANGED
|
@@ -1,14 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { SiweInvalidMessageFieldError as e } from "./index298.js";
|
|
2
|
+
import { getAddress as S } from "./index164.js";
|
|
3
|
+
import { isUri as $ } from "./index299.js";
|
|
4
|
+
function C(n) {
|
|
5
|
+
const { chainId: i, domain: s, expirationTime: u, issuedAt: g = /* @__PURE__ */ new Date(), nonce: a, notBefore: m, requestId: h, resources: w, scheme: o, uri: c, version: f } = n;
|
|
6
|
+
{
|
|
7
|
+
if (i !== Math.floor(i))
|
|
8
|
+
throw new e({
|
|
9
|
+
field: "chainId",
|
|
10
|
+
metaMessages: [
|
|
11
|
+
"- Chain ID must be a EIP-155 chain ID.",
|
|
12
|
+
"- See https://eips.ethereum.org/EIPS/eip-155",
|
|
13
|
+
"",
|
|
14
|
+
`Provided value: ${i}`
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
if (!(p.test(s) || M.test(s) || x.test(s)))
|
|
18
|
+
throw new e({
|
|
19
|
+
field: "domain",
|
|
20
|
+
metaMessages: [
|
|
21
|
+
"- Domain must be an RFC 3986 authority.",
|
|
22
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
23
|
+
"",
|
|
24
|
+
`Provided value: ${s}`
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
if (!A.test(a))
|
|
28
|
+
throw new e({
|
|
29
|
+
field: "nonce",
|
|
30
|
+
metaMessages: [
|
|
31
|
+
"- Nonce must be at least 8 characters.",
|
|
32
|
+
"- Nonce must be alphanumeric.",
|
|
33
|
+
"",
|
|
34
|
+
`Provided value: ${a}`
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
if (!$(c))
|
|
38
|
+
throw new e({
|
|
39
|
+
field: "uri",
|
|
40
|
+
metaMessages: [
|
|
41
|
+
"- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.",
|
|
42
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
43
|
+
"",
|
|
44
|
+
`Provided value: ${c}`
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
if (f !== "1")
|
|
48
|
+
throw new e({
|
|
49
|
+
field: "version",
|
|
50
|
+
metaMessages: [
|
|
51
|
+
"- Version must be '1'.",
|
|
52
|
+
"",
|
|
53
|
+
`Provided value: ${f}`
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
if (o && !P.test(o))
|
|
57
|
+
throw new e({
|
|
58
|
+
field: "scheme",
|
|
59
|
+
metaMessages: [
|
|
60
|
+
"- Scheme must be an RFC 3986 URI scheme.",
|
|
61
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1",
|
|
62
|
+
"",
|
|
63
|
+
`Provided value: ${o}`
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
const t = n.statement;
|
|
67
|
+
if (t != null && t.includes(`
|
|
68
|
+
`))
|
|
69
|
+
throw new e({
|
|
70
|
+
field: "statement",
|
|
71
|
+
metaMessages: [
|
|
72
|
+
"- Statement must not include '\\n'.",
|
|
73
|
+
"",
|
|
74
|
+
`Provided value: ${t}`
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const l = S(n.address), v = o ? `${o}://${s}` : s, I = n.statement ? `${n.statement}
|
|
79
|
+
` : "", R = `${v} wants you to sign in with your Ethereum account:
|
|
80
|
+
${l}
|
|
81
|
+
|
|
82
|
+
${I}`;
|
|
83
|
+
let r = `URI: ${c}
|
|
84
|
+
Version: ${f}
|
|
85
|
+
Chain ID: ${i}
|
|
86
|
+
Nonce: ${a}
|
|
87
|
+
Issued At: ${g.toISOString()}`;
|
|
88
|
+
if (u && (r += `
|
|
89
|
+
Expiration Time: ${u.toISOString()}`), m && (r += `
|
|
90
|
+
Not Before: ${m.toISOString()}`), h && (r += `
|
|
91
|
+
Request ID: ${h}`), w) {
|
|
92
|
+
let t = `
|
|
93
|
+
Resources:`;
|
|
94
|
+
for (const d of w) {
|
|
95
|
+
if (!$(d))
|
|
96
|
+
throw new e({
|
|
97
|
+
field: "resources",
|
|
98
|
+
metaMessages: [
|
|
99
|
+
"- Every resource must be a RFC 3986 URI.",
|
|
100
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
101
|
+
"",
|
|
102
|
+
`Provided value: ${d}`
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
t += `
|
|
106
|
+
- ${d}`;
|
|
107
|
+
}
|
|
108
|
+
r += t;
|
|
109
|
+
}
|
|
110
|
+
return `${R}
|
|
111
|
+
${r}`;
|
|
11
112
|
}
|
|
113
|
+
const p = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/, M = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/, x = /^localhost(:[0-9]{1,5})?$/, A = /^[a-zA-Z0-9]{8,}$/, P = /^([a-zA-Z][a-zA-Z0-9+-.]*)$/;
|
|
12
114
|
export {
|
|
13
|
-
|
|
115
|
+
C as createSiweMessage
|
|
14
116
|
};
|
package/dist/index27.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index218.cjs"),t=e.defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});exports.mainnet=t;
|
package/dist/index27.js
CHANGED
|
@@ -1,60 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
sort: (t, H) => t.id - H.id
|
|
33
|
-
}), F = async (t) => o ? E(t) : [
|
|
34
|
-
await p.request({
|
|
35
|
-
body: t
|
|
36
|
-
})
|
|
37
|
-
], [{ error: s, result: l }] = await F(i);
|
|
38
|
-
if (R)
|
|
39
|
-
return { error: s, result: l };
|
|
40
|
-
if (s)
|
|
41
|
-
throw new O({
|
|
42
|
-
body: i,
|
|
43
|
-
error: s,
|
|
44
|
-
url: r
|
|
45
|
-
});
|
|
46
|
-
return l;
|
|
47
|
-
},
|
|
48
|
-
retryCount: b,
|
|
49
|
-
retryDelay: d,
|
|
50
|
-
timeout: c,
|
|
51
|
-
type: "http"
|
|
52
|
-
}, {
|
|
53
|
-
fetchOptions: u,
|
|
54
|
-
url: r
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
}
|
|
1
|
+
import { defineChain as e } from "./index218.js";
|
|
2
|
+
const t = /* @__PURE__ */ e({
|
|
3
|
+
id: 1,
|
|
4
|
+
name: "Ethereum",
|
|
5
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
6
|
+
rpcUrls: {
|
|
7
|
+
default: {
|
|
8
|
+
http: ["https://eth.merkle.io"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
blockExplorers: {
|
|
12
|
+
default: {
|
|
13
|
+
name: "Etherscan",
|
|
14
|
+
url: "https://etherscan.io",
|
|
15
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
contracts: {
|
|
19
|
+
ensRegistry: {
|
|
20
|
+
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
|
|
21
|
+
},
|
|
22
|
+
ensUniversalResolver: {
|
|
23
|
+
address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
|
|
24
|
+
blockCreated: 19258213
|
|
25
|
+
},
|
|
26
|
+
multicall3: {
|
|
27
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
28
|
+
blockCreated: 14353601
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
58
32
|
export {
|
|
59
|
-
|
|
33
|
+
t as mainnet
|
|
60
34
|
};
|
package/dist/index28.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index218.cjs"),a=e.defineChain({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",blockCreated:5317080}},testnet:!0});exports.sepolia=a;
|
package/dist/index28.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { defineChain as e } from "./index218.js";
|
|
2
|
+
const s = /* @__PURE__ */ e({
|
|
3
|
+
id: 11155111,
|
|
4
|
+
name: "Sepolia",
|
|
5
|
+
nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
|
|
6
|
+
rpcUrls: {
|
|
7
|
+
default: {
|
|
8
|
+
http: ["https://sepolia.drpc.org"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
blockExplorers: {
|
|
12
|
+
default: {
|
|
13
|
+
name: "Etherscan",
|
|
14
|
+
url: "https://sepolia.etherscan.io",
|
|
15
|
+
apiUrl: "https://api-sepolia.etherscan.io/api"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
contracts: {
|
|
19
|
+
multicall3: {
|
|
20
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
21
|
+
blockCreated: 751532
|
|
22
|
+
},
|
|
23
|
+
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
24
|
+
ensUniversalResolver: {
|
|
25
|
+
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
26
|
+
blockCreated: 5317080
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
testnet: !0
|
|
30
|
+
});
|
|
13
31
|
export {
|
|
14
|
-
|
|
32
|
+
s as sepolia
|
|
15
33
|
};
|
package/dist/index29.cjs
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`))throw new e.SiweInvalidMessageFieldError({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${t}`]})}const $=M.getAddress(r.address),v=i?`${i}://${s}`:s,I=r.statement?`${r.statement}
|
|
3
|
-
`:"",S=`${v} wants you to sign in with your Ethereum account:
|
|
4
|
-
${$}
|
|
5
|
-
|
|
6
|
-
${I}`;let n=`URI: ${c}
|
|
7
|
-
Version: ${d}
|
|
8
|
-
Chain ID: ${o}
|
|
9
|
-
Nonce: ${a}
|
|
10
|
-
Issued At: ${m.toISOString()}`;if(l&&(n+=`
|
|
11
|
-
Expiration Time: ${l.toISOString()}`),f&&(n+=`
|
|
12
|
-
Not Before: ${f.toISOString()}`),w&&(n+=`
|
|
13
|
-
Request ID: ${w}`),g){let t=`
|
|
14
|
-
Resources:`;for(const u of g){if(!h.isUri(u))throw new e.SiweInvalidMessageFieldError({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${u}`]});t+=`
|
|
15
|
-
- ${u}`}n+=t}return`${S}
|
|
16
|
-
${n}`}const E=/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,F=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,b=/^localhost(:[0-9]{1,5})?$/,A=/^[a-zA-Z0-9]{8,}$/,P=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/;exports.createSiweMessage=R;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index49.cjs"),n=require("./index57.cjs");function l(e){const{key:t="public",name:i="Public Client"}=e;return c.createClient({...e,key:t,name:i,type:"publicClient"}).extend(n.publicActions)}exports.createPublicClient=l;
|
package/dist/index29.js
CHANGED
|
@@ -1,116 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"- Chain ID must be a EIP-155 chain ID.",
|
|
12
|
-
"- See https://eips.ethereum.org/EIPS/eip-155",
|
|
13
|
-
"",
|
|
14
|
-
`Provided value: ${i}`
|
|
15
|
-
]
|
|
16
|
-
});
|
|
17
|
-
if (!(p.test(s) || M.test(s) || x.test(s)))
|
|
18
|
-
throw new e({
|
|
19
|
-
field: "domain",
|
|
20
|
-
metaMessages: [
|
|
21
|
-
"- Domain must be an RFC 3986 authority.",
|
|
22
|
-
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
23
|
-
"",
|
|
24
|
-
`Provided value: ${s}`
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
if (!A.test(a))
|
|
28
|
-
throw new e({
|
|
29
|
-
field: "nonce",
|
|
30
|
-
metaMessages: [
|
|
31
|
-
"- Nonce must be at least 8 characters.",
|
|
32
|
-
"- Nonce must be alphanumeric.",
|
|
33
|
-
"",
|
|
34
|
-
`Provided value: ${a}`
|
|
35
|
-
]
|
|
36
|
-
});
|
|
37
|
-
if (!$(c))
|
|
38
|
-
throw new e({
|
|
39
|
-
field: "uri",
|
|
40
|
-
metaMessages: [
|
|
41
|
-
"- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.",
|
|
42
|
-
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
43
|
-
"",
|
|
44
|
-
`Provided value: ${c}`
|
|
45
|
-
]
|
|
46
|
-
});
|
|
47
|
-
if (f !== "1")
|
|
48
|
-
throw new e({
|
|
49
|
-
field: "version",
|
|
50
|
-
metaMessages: [
|
|
51
|
-
"- Version must be '1'.",
|
|
52
|
-
"",
|
|
53
|
-
`Provided value: ${f}`
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
if (o && !P.test(o))
|
|
57
|
-
throw new e({
|
|
58
|
-
field: "scheme",
|
|
59
|
-
metaMessages: [
|
|
60
|
-
"- Scheme must be an RFC 3986 URI scheme.",
|
|
61
|
-
"- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1",
|
|
62
|
-
"",
|
|
63
|
-
`Provided value: ${o}`
|
|
64
|
-
]
|
|
65
|
-
});
|
|
66
|
-
const t = n.statement;
|
|
67
|
-
if (t != null && t.includes(`
|
|
68
|
-
`))
|
|
69
|
-
throw new e({
|
|
70
|
-
field: "statement",
|
|
71
|
-
metaMessages: [
|
|
72
|
-
"- Statement must not include '\\n'.",
|
|
73
|
-
"",
|
|
74
|
-
`Provided value: ${t}`
|
|
75
|
-
]
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const l = S(n.address), v = o ? `${o}://${s}` : s, I = n.statement ? `${n.statement}
|
|
79
|
-
` : "", R = `${v} wants you to sign in with your Ethereum account:
|
|
80
|
-
${l}
|
|
81
|
-
|
|
82
|
-
${I}`;
|
|
83
|
-
let r = `URI: ${c}
|
|
84
|
-
Version: ${f}
|
|
85
|
-
Chain ID: ${i}
|
|
86
|
-
Nonce: ${a}
|
|
87
|
-
Issued At: ${g.toISOString()}`;
|
|
88
|
-
if (u && (r += `
|
|
89
|
-
Expiration Time: ${u.toISOString()}`), m && (r += `
|
|
90
|
-
Not Before: ${m.toISOString()}`), h && (r += `
|
|
91
|
-
Request ID: ${h}`), w) {
|
|
92
|
-
let t = `
|
|
93
|
-
Resources:`;
|
|
94
|
-
for (const d of w) {
|
|
95
|
-
if (!$(d))
|
|
96
|
-
throw new e({
|
|
97
|
-
field: "resources",
|
|
98
|
-
metaMessages: [
|
|
99
|
-
"- Every resource must be a RFC 3986 URI.",
|
|
100
|
-
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
101
|
-
"",
|
|
102
|
-
`Provided value: ${d}`
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
|
-
t += `
|
|
106
|
-
- ${d}`;
|
|
107
|
-
}
|
|
108
|
-
r += t;
|
|
109
|
-
}
|
|
110
|
-
return `${R}
|
|
111
|
-
${r}`;
|
|
1
|
+
import { createClient as n } from "./index49.js";
|
|
2
|
+
import { publicActions as c } from "./index57.js";
|
|
3
|
+
function u(t) {
|
|
4
|
+
const { key: e = "public", name: i = "Public Client" } = t;
|
|
5
|
+
return n({
|
|
6
|
+
...t,
|
|
7
|
+
key: e,
|
|
8
|
+
name: i,
|
|
9
|
+
type: "publicClient"
|
|
10
|
+
}).extend(c);
|
|
112
11
|
}
|
|
113
|
-
const p = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/, M = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/, x = /^localhost(:[0-9]{1,5})?$/, A = /^[a-zA-Z0-9]{8,}$/, P = /^([a-zA-Z][a-zA-Z0-9+-.]*)$/;
|
|
114
12
|
export {
|
|
115
|
-
|
|
13
|
+
u as createPublicClient
|
|
116
14
|
};
|
package/dist/index4.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index3.cjs"),e=require("./index5.cjs"),g=require("./index19.cjs"),l=require("./index20.cjs"),A=require("./index21.cjs"),h=require("./index22.cjs"),m=async(a,o,i,t)=>{if(!t.account)return e.Err("No account found");const n=g.getContract({address:u.with0x(o),abi:h.erc20Abi,client:t});try{const c=u.with0x(t.account.address),r=u.with0x(i),f=await n.read.allowance([c,r]);if(BigInt(f)<BigInt(a)){const p=await n.write.approve([r,l.maxUint256],{account:t.account,chain:t.chain}),s=await w(t,p);if(!s.ok)return e.Err(s.error);if(!s.val||s.val.status!=="success")return e.Err("Failed to approve");const d=await n.read.allowance([c,r]);return d<a?e.Err(`Insufficient allowance after approval. Needed ${a.toString()}, got ${d.toString()}.`):e.Ok(p)}return e.Ok("Already approved")}catch(c){return e.Err("Failed to approve: "+c)}},w=async(a,o,i=2e3,t=12e4)=>{const n=Math.ceil(t/i);for(let c=0;c<n;c++){try{const r=await A.getTransactionReceipt(a,{hash:o});if(r)return e.Ok(r)}catch(r){if(!r.message.includes(`Transaction receipt with hash "${o}" could not be found.`))return e.Err(r.message)}c<n-1&&await new Promise(r=>setTimeout(r,i))}return e.Err(`Timed out waiting for receipt of ${o}`)};exports.checkAllowanceAndApprove=m;exports.waitForTransactionReceipt=w;
|
package/dist/index4.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { with0x as
|
|
2
|
-
import { Err as
|
|
3
|
-
import { getContract as
|
|
4
|
-
import { maxUint256 as
|
|
5
|
-
import { getTransactionReceipt as
|
|
6
|
-
import { erc20Abi as
|
|
7
|
-
const
|
|
8
|
-
if (!t.account) return
|
|
9
|
-
const
|
|
10
|
-
address:
|
|
11
|
-
abi:
|
|
1
|
+
import { with0x as p } from "./index3.js";
|
|
2
|
+
import { Err as o, Ok as f } from "./index5.js";
|
|
3
|
+
import { getContract as w } from "./index19.js";
|
|
4
|
+
import { maxUint256 as g } from "./index20.js";
|
|
5
|
+
import { getTransactionReceipt as l } from "./index21.js";
|
|
6
|
+
import { erc20Abi as v } from "./index22.js";
|
|
7
|
+
const k = async (c, n, i, t) => {
|
|
8
|
+
if (!t.account) return o("No account found");
|
|
9
|
+
const a = w({
|
|
10
|
+
address: p(n),
|
|
11
|
+
abi: v,
|
|
12
12
|
client: t
|
|
13
13
|
});
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const e = p(t.account.address), r = p(i), m = await a.read.allowance([e, r]);
|
|
16
|
+
if (BigInt(m) < BigInt(c)) {
|
|
17
|
+
const u = await a.write.approve([r, g], {
|
|
18
|
+
account: t.account,
|
|
19
|
+
chain: t.chain
|
|
20
|
+
}), s = await A(t, u);
|
|
21
|
+
if (!s.ok) return o(s.error);
|
|
22
|
+
if (!s.val || s.val.status !== "success")
|
|
23
|
+
return o("Failed to approve");
|
|
24
|
+
const d = await a.read.allowance([e, r]);
|
|
25
|
+
return d < c ? o(
|
|
26
|
+
`Insufficient allowance after approval. Needed ${c.toString()}, got ${d.toString()}.`
|
|
27
|
+
) : f(u);
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
} catch (
|
|
31
|
-
return
|
|
29
|
+
return f("Already approved");
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return o("Failed to approve: " + e);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
for (let
|
|
33
|
+
}, A = async (c, n, i = 2e3, t = 12e4) => {
|
|
34
|
+
const a = Math.ceil(t / i);
|
|
35
|
+
for (let e = 0; e < a; e++) {
|
|
36
36
|
try {
|
|
37
|
-
const r = await
|
|
37
|
+
const r = await l(c, { hash: n });
|
|
38
38
|
if (r)
|
|
39
|
-
return
|
|
39
|
+
return f(r);
|
|
40
40
|
} catch (r) {
|
|
41
41
|
if (!r.message.includes(
|
|
42
|
-
`Transaction receipt with hash "${
|
|
42
|
+
`Transaction receipt with hash "${n}" could not be found.`
|
|
43
43
|
))
|
|
44
|
-
return
|
|
44
|
+
return o(r.message);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
e < a - 1 && await new Promise((r) => setTimeout(r, i));
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return o(`Timed out waiting for receipt of ${n}`);
|
|
49
49
|
};
|
|
50
50
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
k as checkAllowanceAndApprove,
|
|
52
|
+
A as waitForTransactionReceipt
|
|
53
53
|
};
|