@gardenfi/utils 2.0.1 → 2.0.3
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/index12.cjs +1 -1
- package/dist/index12.js +29 -29
- package/dist/index13.cjs +16 -1
- package/dist/index13.js +112 -30
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +18 -17
- package/dist/index15.cjs +1 -16
- package/dist/index15.js +30 -113
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +5 -6
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +27 -24
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +1 -1
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +6 -8
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +8 -6
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +1 -1
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +10 -11
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +19 -13
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +8 -8
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/src/lib/auth/siwe.d.ts +1 -1
- package/package.json +2 -2
package/dist/index12.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index17.cjs"),k=require("./index23.cjs"),g=require("./index29.cjs"),O=require("./index30.cjs"),S=require("./index33.cjs"),y=require("./index34.cjs"),$=require("./index32.cjs"),P=require("./index16.cjs"),W=require("./index22.cjs"),q=require("./index25.cjs"),x=require("./index27.cjs");async function z(n,{confirmations:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index17.cjs"),k=require("./index23.cjs"),g=require("./index29.cjs"),O=require("./index30.cjs"),S=require("./index33.cjs"),y=require("./index34.cjs"),$=require("./index32.cjs"),P=require("./index16.cjs"),W=require("./index22.cjs"),q=require("./index25.cjs"),x=require("./index27.cjs");async function z(n,{confirmations:c=1,hash:p,onReplaced:h,pollingInterval:m=n.pollingInterval,retryCount:w=6,retryDelay:R=({count:d})=>~~(1<<d)*200,timeout:N=18e4}){const d=$.stringify(["waitForTransactionReceipt",n.uid,p]);let a,o,e,i=!1;const{promise:B,resolve:F,reject:v}=S.withResolvers(),A=N?setTimeout(()=>v(new k.WaitForTransactionReceiptTimeoutError({hash:p})),N):void 0,j=O.observe(d,{onReplaced:h,resolve:F,reject:v},r=>{const E=g.getAction(n,x.watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:m,async onBlockNumber(_){const u=b=>{clearTimeout(A),E(),b(),j()};let l=_;if(!i)try{if(e){if(c>1&&(!e.blockNumber||l-e.blockNumber+1n<c))return;u(()=>r.resolve(e));return}if(a||(i=!0,await y.withRetry(async()=>{a=await g.getAction(n,W.getTransaction,"getTransaction")({hash:p}),a.blockNumber&&(l=a.blockNumber)},{delay:R,retryCount:w}),i=!1),e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:p}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c))return;u(()=>r.resolve(e))}catch(b){if(b instanceof k.TransactionNotFoundError||b instanceof k.TransactionReceiptNotFoundError){if(!a){i=!1;return}try{o=a,i=!0;const f=await y.withRetry(()=>g.getAction(n,P.getBlock,"getBlock")({blockNumber:l,includeTransactions:!0}),{delay:R,retryCount:w,shouldRetry:({error:s})=>s instanceof M.BlockNotFoundError});i=!1;const t=f.transactions.find(({from:s,nonce:I})=>s===o.from&&I===o.nonce);if(!t||(e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:t.hash}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c)))return;let T="replaced";t.to===o.to&&t.value===o.value&&t.input===o.input?T="repriced":t.from===t.to&&t.value===0n&&(T="cancelled"),u(()=>{var s;(s=r.onReplaced)==null||s.call(r,{reason:T,replacedTransaction:o,transaction:t,transactionReceipt:e}),r.resolve(e)})}catch(f){u(()=>r.reject(f))}}else u(()=>r.reject(b))}}})});return B}exports.waitForTransactionReceipt=z;
|
package/dist/index12.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNotFoundError as A } from "./index17.js";
|
|
2
2
|
import { WaitForTransactionReceiptTimeoutError as M, TransactionNotFoundError as O, TransactionReceiptNotFoundError as W } from "./index23.js";
|
|
3
|
-
import { getAction as
|
|
3
|
+
import { getAction as f } from "./index29.js";
|
|
4
4
|
import { observe as q } from "./index30.js";
|
|
5
5
|
import { withResolvers as z } from "./index33.js";
|
|
6
6
|
import { withRetry as v } from "./index34.js";
|
|
@@ -10,7 +10,7 @@ import { getTransaction as J } from "./index22.js";
|
|
|
10
10
|
import { getTransactionReceipt as R } from "./index25.js";
|
|
11
11
|
import { watchBlockNumber as K } from "./index27.js";
|
|
12
12
|
async function D(o, {
|
|
13
|
-
confirmations:
|
|
13
|
+
confirmations: a = 1,
|
|
14
14
|
hash: m,
|
|
15
15
|
onReplaced: y,
|
|
16
16
|
pollingInterval: B = o.pollingInterval,
|
|
@@ -20,43 +20,43 @@ async function D(o, {
|
|
|
20
20
|
timeout: w = 18e4
|
|
21
21
|
}) {
|
|
22
22
|
const b = G(["waitForTransactionReceipt", o.uid, m]);
|
|
23
|
-
let
|
|
24
|
-
const { promise: h, resolve: F, reject: g } = z(), E = w ? setTimeout(() => g(new M({ hash: m })), w) : void 0, _ = q(b, { onReplaced: y, resolve: F, reject: g }, (
|
|
25
|
-
const j =
|
|
23
|
+
let c, n, r, i = !1;
|
|
24
|
+
const { promise: h, resolve: F, reject: g } = z(), E = w ? setTimeout(() => g(new M({ hash: m })), w) : void 0, _ = q(b, { onReplaced: y, resolve: F, reject: g }, (t) => {
|
|
25
|
+
const j = f(o, K, "watchBlockNumber")({
|
|
26
26
|
emitMissed: !0,
|
|
27
27
|
emitOnBegin: !0,
|
|
28
28
|
poll: !0,
|
|
29
29
|
pollingInterval: B,
|
|
30
30
|
async onBlockNumber(I) {
|
|
31
|
-
const l = (
|
|
32
|
-
clearTimeout(E), j(),
|
|
31
|
+
const l = (p) => {
|
|
32
|
+
clearTimeout(E), j(), p(), _();
|
|
33
33
|
};
|
|
34
34
|
let u = I;
|
|
35
35
|
if (!i)
|
|
36
36
|
try {
|
|
37
37
|
if (r) {
|
|
38
|
-
if (
|
|
38
|
+
if (a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a))
|
|
39
39
|
return;
|
|
40
|
-
l(() =>
|
|
40
|
+
l(() => t.resolve(r));
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
43
|
+
if (c || (i = !0, await v(async () => {
|
|
44
|
+
c = await f(o, J, "getTransaction")({ hash: m }), c.blockNumber && (u = c.blockNumber);
|
|
45
45
|
}, {
|
|
46
46
|
delay: N,
|
|
47
47
|
retryCount: k
|
|
48
|
-
}), i = !1), r = await
|
|
48
|
+
}), i = !1), r = await f(o, R, "getTransactionReceipt")({ hash: m }), a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a))
|
|
49
49
|
return;
|
|
50
|
-
l(() =>
|
|
51
|
-
} catch (
|
|
52
|
-
if (
|
|
53
|
-
if (!
|
|
50
|
+
l(() => t.resolve(r));
|
|
51
|
+
} catch (p) {
|
|
52
|
+
if (p instanceof O || p instanceof W) {
|
|
53
|
+
if (!c) {
|
|
54
54
|
i = !1;
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
|
-
|
|
59
|
-
const d = await v(() =>
|
|
58
|
+
n = c, i = !0;
|
|
59
|
+
const d = await v(() => f(o, H, "getBlock")({
|
|
60
60
|
blockNumber: u,
|
|
61
61
|
includeTransactions: !0
|
|
62
62
|
}), {
|
|
@@ -65,26 +65,26 @@ async function D(o, {
|
|
|
65
65
|
shouldRetry: ({ error: s }) => s instanceof A
|
|
66
66
|
});
|
|
67
67
|
i = !1;
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
hash:
|
|
71
|
-
}),
|
|
68
|
+
const e = d.transactions.find(({ from: s, nonce: x }) => s === n.from && x === n.nonce);
|
|
69
|
+
if (!e || (r = await f(o, R, "getTransactionReceipt")({
|
|
70
|
+
hash: e.hash
|
|
71
|
+
}), a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a)))
|
|
72
72
|
return;
|
|
73
73
|
let T = "replaced";
|
|
74
|
-
|
|
74
|
+
e.to === n.to && e.value === n.value && e.input === n.input ? T = "repriced" : e.from === e.to && e.value === 0n && (T = "cancelled"), l(() => {
|
|
75
75
|
var s;
|
|
76
|
-
(s =
|
|
76
|
+
(s = t.onReplaced) == null || s.call(t, {
|
|
77
77
|
reason: T,
|
|
78
|
-
replacedTransaction:
|
|
79
|
-
transaction:
|
|
78
|
+
replacedTransaction: n,
|
|
79
|
+
transaction: e,
|
|
80
80
|
transactionReceipt: r
|
|
81
|
-
}),
|
|
81
|
+
}), t.resolve(r);
|
|
82
82
|
});
|
|
83
83
|
} catch (d) {
|
|
84
|
-
l(() =>
|
|
84
|
+
l(() => t.reject(d));
|
|
85
85
|
}
|
|
86
86
|
} else
|
|
87
|
-
l(() =>
|
|
87
|
+
l(() => t.reject(p));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
});
|
package/dist/index13.cjs
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index49.cjs"),M=require("./index42.cjs"),h=require("./index50.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/index13.js
CHANGED
|
@@ -1,34 +1,116 @@
|
|
|
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
|
-
|
|
1
|
+
import { SiweInvalidMessageFieldError as e } from "./index49.js";
|
|
2
|
+
import { getAddress as S } from "./index42.js";
|
|
3
|
+
import { isUri as $ } from "./index50.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}`;
|
|
29
107
|
}
|
|
108
|
+
r += t;
|
|
30
109
|
}
|
|
31
|
-
}
|
|
110
|
+
return `${R}
|
|
111
|
+
${r}`;
|
|
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+-.]*)$/;
|
|
32
114
|
export {
|
|
33
|
-
|
|
115
|
+
C as createSiweMessage
|
|
34
116
|
};
|
package/dist/index14.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index52.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/index14.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { defineChain as e } from "./
|
|
2
|
-
const
|
|
3
|
-
id:
|
|
4
|
-
name: "
|
|
5
|
-
nativeCurrency: { name: "
|
|
1
|
+
import { defineChain as e } from "./index52.js";
|
|
2
|
+
const t = /* @__PURE__ */ e({
|
|
3
|
+
id: 1,
|
|
4
|
+
name: "Ethereum",
|
|
5
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
6
6
|
rpcUrls: {
|
|
7
7
|
default: {
|
|
8
|
-
http: ["https://
|
|
8
|
+
http: ["https://eth.merkle.io"]
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
blockExplorers: {
|
|
12
12
|
default: {
|
|
13
13
|
name: "Etherscan",
|
|
14
|
-
url: "https://
|
|
15
|
-
apiUrl: "https://api
|
|
14
|
+
url: "https://etherscan.io",
|
|
15
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
contracts: {
|
|
19
|
-
|
|
20
|
-
address: "
|
|
21
|
-
blockCreated: 751532
|
|
19
|
+
ensRegistry: {
|
|
20
|
+
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
|
|
22
21
|
},
|
|
23
|
-
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
24
22
|
ensUniversalResolver: {
|
|
25
|
-
address: "
|
|
26
|
-
blockCreated:
|
|
23
|
+
address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
|
|
24
|
+
blockCreated: 19258213
|
|
25
|
+
},
|
|
26
|
+
multicall3: {
|
|
27
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
28
|
+
blockCreated: 14353601
|
|
27
29
|
}
|
|
28
|
-
}
|
|
29
|
-
testnet: !0
|
|
30
|
+
}
|
|
30
31
|
});
|
|
31
32
|
export {
|
|
32
|
-
|
|
33
|
+
t as mainnet
|
|
33
34
|
};
|
package/dist/index15.cjs
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
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 e=require("./index52.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/index15.js
CHANGED
|
@@ -1,116 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
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}`;
|
|
1
|
+
import { defineChain as e } from "./index52.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"]
|
|
107
9
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
+
});
|
|
114
31
|
export {
|
|
115
|
-
|
|
32
|
+
s as sepolia
|
|
116
33
|
};
|
package/dist/index19.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 t=require("./index24.cjs");function i(e){const s=(e.transactions??[]).map(n=>typeof n=="string"?n:t.formatTransaction(n));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:s,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}exports.formatBlock=i;
|
package/dist/index19.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { formatTransaction as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
const i = (s = e.transactions) == null ? void 0 : s.map((n) => typeof n == "string" ? n : t(n));
|
|
1
|
+
import { formatTransaction as i } from "./index24.js";
|
|
2
|
+
function a(e) {
|
|
3
|
+
const s = (e.transactions ?? []).map((n) => typeof n == "string" ? n : i(n));
|
|
5
4
|
return {
|
|
6
5
|
...e,
|
|
7
6
|
baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
|
|
@@ -16,10 +15,10 @@ function u(e) {
|
|
|
16
15
|
number: e.number ? BigInt(e.number) : null,
|
|
17
16
|
size: e.size ? BigInt(e.size) : void 0,
|
|
18
17
|
timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
|
|
19
|
-
transactions:
|
|
18
|
+
transactions: s,
|
|
20
19
|
totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
export {
|
|
24
|
-
|
|
23
|
+
a as formatBlock
|
|
25
24
|
};
|
package/dist/index30.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=new Map,r=new Map;let m=0;function w(n,u,C){const o=++m,s=()=>i.get(n)||[],y=()=>{const t=s();i.set(n,t.filter(e=>e.id!==o))},a=()=>{const t=s();if(!t.some(c=>c.id===o))return;const e=r.get(n);t.length===1&&e&&e(),y()},l=s();if(i.set(n,[...l,{id:o,fns:u}]),l&&l.length>0)return a;const f={};for(const t in u)f[t]=(...e)=>{var h,p;const c=s();if(c.length!==0)for(const b of c)(p=(h=b.fns)[t])==null||p.call(h,...e)};const g=C(f);return typeof g=="function"&&r.set(n,g),a}exports.cleanupCache=r;exports.listenersCache=i;exports.observe=w;
|
package/dist/index30.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
const n =
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
const n =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
const l = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
2
|
+
let m = 0;
|
|
3
|
+
function y(e, f, w) {
|
|
4
|
+
const i = ++m, s = () => l.get(e) || [], C = () => {
|
|
5
|
+
const n = s();
|
|
6
|
+
l.set(e, n.filter((t) => t.id !== i));
|
|
7
|
+
}, r = () => {
|
|
8
|
+
const n = s();
|
|
9
|
+
if (!n.some((c) => c.id === i))
|
|
10
|
+
return;
|
|
11
|
+
const t = h.get(e);
|
|
12
|
+
n.length === 1 && t && t(), C();
|
|
13
|
+
}, o = s();
|
|
14
|
+
if (l.set(e, [
|
|
15
|
+
...o,
|
|
16
|
+
{ id: i, fns: f }
|
|
17
|
+
]), o && o.length > 0)
|
|
18
|
+
return r;
|
|
16
19
|
const u = {};
|
|
17
|
-
for (const n in
|
|
18
|
-
u[n] = (...
|
|
20
|
+
for (const n in f)
|
|
21
|
+
u[n] = (...t) => {
|
|
19
22
|
var p, g;
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
for (const k of
|
|
23
|
-
(g = (p = k.fns)[n]) == null || g.call(p, ...
|
|
23
|
+
const c = s();
|
|
24
|
+
if (c.length !== 0)
|
|
25
|
+
for (const k of c)
|
|
26
|
+
(g = (p = k.fns)[n]) == null || g.call(p, ...t);
|
|
24
27
|
};
|
|
25
28
|
const a = w(u);
|
|
26
|
-
return typeof a == "function" && h.set(
|
|
29
|
+
return typeof a == "function" && h.set(e, a), r;
|
|
27
30
|
}
|
|
28
31
|
export {
|
|
29
32
|
h as cleanupCache,
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
l as listenersCache,
|
|
34
|
+
y as observe
|
|
32
35
|
};
|
package/dist/index36.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index51.cjs");function p(e,{dir:n,size:t=32}={}){return typeof e=="string"?o(e,{dir:n,size:t}):l(e,{dir:n,size:t})}function o(e,{dir:n,size:t=32}={}){if(t===null)return e;const r=e.replace("0x","");if(r.length>t*2)throw new i.SizeExceedsPaddingSizeError({size:Math.ceil(r.length/2),targetSize:t,type:"hex"});return`0x${r[n==="right"?"padEnd":"padStart"](t*2,"0")}`}function l(e,{dir:n,size:t=32}={}){if(t===null)return e;if(e.length>t)throw new i.SizeExceedsPaddingSizeError({size:e.length,targetSize:t,type:"bytes"});const r=new Uint8Array(t);for(let a=0;a<t;a++){const d=n==="right";r[d?a:t-a-1]=e[d?a:e.length-a-1]}return r}exports.pad=p;exports.padBytes=l;exports.padHex=o;
|
package/dist/index36.js
CHANGED
package/dist/index38.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.22.23";exports.version=e;
|
package/dist/index38.js
CHANGED
package/dist/index51.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index37.cjs");class d extends i.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;
|
package/dist/index51.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
...e
|
|
7
|
-
};
|
|
1
|
+
import { BaseError as i } from "./index37.js";
|
|
2
|
+
class a extends i {
|
|
3
|
+
constructor({ size: r, targetSize: s, type: e }) {
|
|
4
|
+
super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
5
|
+
}
|
|
8
6
|
}
|
|
9
7
|
export {
|
|
10
|
-
|
|
8
|
+
a as SizeExceedsPaddingSizeError
|
|
11
9
|
};
|
package/dist/index52.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}exports.defineChain=n;
|
package/dist/index52.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function n(e) {
|
|
2
|
+
return {
|
|
3
|
+
formatters: void 0,
|
|
4
|
+
fees: void 0,
|
|
5
|
+
serializers: void 0,
|
|
6
|
+
...e
|
|
7
|
+
};
|
|
6
8
|
}
|
|
7
9
|
export {
|
|
8
|
-
|
|
10
|
+
n as defineChain
|
|
9
11
|
};
|
package/dist/index53.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index54.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index54.cjs"),f=require("./index55.cjs"),c=require("./index56.cjs"),I=[],O=[],w=[],B=BigInt(0),a=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=a,s=1,n=0;i<24;i++){[s,n]=[n,(2*s+3*n)%5],I.push(2*(5*n+s)),O.push((i+1)*(i+2)/2%64);let o=B;for(let r=0;r<7;r++)t=(t<<a^(t>>S)*T)%H,t&A&&(o^=a<<(a<<BigInt(r))-a);w.push(o)}const[m,E]=f.split(w,!0),y=(i,t,s)=>s>32?f.rotlBH(i,t,s):f.rotlSH(i,t,s),b=(i,t,s)=>s>32?f.rotlBL(i,t,s):f.rotlSL(i,t,s);function L(i,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let e=0;e<10;e++)s[e]=i[e]^i[e+10]^i[e+20]^i[e+30]^i[e+40];for(let e=0;e<10;e+=2){const h=(e+8)%10,p=(e+2)%10,d=s[p],u=s[p+1],_=y(d,u,1)^s[h],g=b(d,u,1)^s[h+1];for(let k=0;k<50;k+=10)i[e+k]^=_,i[e+k+1]^=g}let o=i[2],r=i[3];for(let e=0;e<24;e++){const h=O[e],p=y(o,r,h),d=b(o,r,h),u=I[e];o=i[u],r=i[u+1],i[u]=p,i[u+1]=d}for(let e=0;e<50;e+=10){for(let h=0;h<10;h++)s[h]=i[e+h];for(let h=0;h<10;h++)i[e+h]^=~s[(h+2)%10]&s[(h+4)%10]}i[0]^=m[n],i[1]^=E[n]}s.fill(0)}class x extends c.Hash{constructor(t,s,n,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,l.anumber(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=c.u32(this.state)}keccak(){c.isLE||c.byteSwap32(this.state32),L(this.state32,this.rounds),c.isLE||c.byteSwap32(this.state32),this.posOut=0,this.pos=0}update(t){l.aexists(this);const{blockLen:s,state:n}=this;t=c.toBytes(t);const o=t.length;for(let r=0;r<o;){const e=Math.min(s-this.pos,o-r);for(let h=0;h<e;h++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:o}=this;t[n]^=s,s&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){l.aexists(this,!1),l.abytes(t),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,r=t.length;o<r;){this.posOut>=n&&this.keccak();const e=Math.min(n-this.posOut,r-o);t.set(s.subarray(this.posOut,this.posOut+e),o),this.posOut+=e,o+=e}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return l.anumber(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.aoutput(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:o,rounds:r,enableXOF:e}=this;return t||(t=new x(s,n,o,e,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=n,t.outputLen=o,t.enableXOF=e,t.destroyed=this.destroyed,t}}const F=(i,t,s)=>c.wrapConstructor(()=>new x(t,i,s)),P=F(1,136,256/8);exports.Keccak=x;exports.keccakP=L;exports.keccak_256=P;
|
package/dist/index53.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { anumber as d, aexists as k, abytes as B, aoutput as A } from "./index54.js";
|
|
2
2
|
import { split as H, rotlBH as m, rotlSH as S, rotlBL as T, rotlSL as F } from "./index55.js";
|
|
3
3
|
import { wrapConstructor as X, Hash as E, u32 as U, isLE as x, byteSwap32 as I, toBytes as P } from "./index56.js";
|
|
4
4
|
const y = [], L = [], b = [], M = /* @__PURE__ */ BigInt(0), f = /* @__PURE__ */ BigInt(1), R = /* @__PURE__ */ BigInt(2), j = /* @__PURE__ */ BigInt(7), C = /* @__PURE__ */ BigInt(256), q = /* @__PURE__ */ BigInt(113);
|
package/dist/index54.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function n(e,...t){if(!i(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function a(e,t){n(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}exports.abytes=n;exports.aexists=s;exports.anumber=o;exports.aoutput=a;
|
package/dist/index54.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
function i(e) {
|
|
2
2
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
3
|
-
throw new Error(
|
|
3
|
+
throw new Error("positive integer expected, got " + e);
|
|
4
4
|
}
|
|
5
5
|
function n(e) {
|
|
6
|
-
return e instanceof Uint8Array || e
|
|
6
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
7
7
|
}
|
|
8
8
|
function o(e, ...t) {
|
|
9
9
|
if (!n(e))
|
|
10
10
|
throw new Error("Uint8Array expected");
|
|
11
11
|
if (t.length > 0 && !t.includes(e.length))
|
|
12
|
-
throw new Error(
|
|
12
|
+
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function s(e, t = !0) {
|
|
15
15
|
if (e.destroyed)
|
|
16
16
|
throw new Error("Hash instance has been destroyed");
|
|
17
17
|
if (t && e.finished)
|
|
18
18
|
throw new Error("Hash#digest() has already been called");
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function f(e, t) {
|
|
21
21
|
o(e);
|
|
22
22
|
const r = t.outputLen;
|
|
23
23
|
if (e.length < r)
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error("digestInto() expects output buffer of length at least " + r);
|
|
25
25
|
}
|
|
26
26
|
export {
|
|
27
|
-
o as
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
s as output
|
|
27
|
+
o as abytes,
|
|
28
|
+
s as aexists,
|
|
29
|
+
i as anumber,
|
|
30
|
+
f as aoutput
|
|
32
31
|
};
|
package/dist/index56.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("./index54.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}const s=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function o(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function y(t){for(let e=0;e<t.length;e++)t[e]=o(t[e])}function r(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function f(t){return typeof t=="string"&&(t=r(t)),i.abytes(t),t}class p{clone(){return this._cloneInto()}}function b(t){const e=u=>t().update(f(u)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}exports.Hash=p;exports.byteSwap=o;exports.byteSwap32=y;exports.isLE=s;exports.toBytes=f;exports.u32=c;exports.utf8ToBytes=r;exports.wrapConstructor=b;
|
package/dist/index56.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { abytes as o } from "./index54.js";
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
function y(t) {
|
|
4
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
5
|
+
}
|
|
6
|
+
const p = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
7
|
+
function r(t) {
|
|
8
|
+
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
9
|
+
}
|
|
10
|
+
function s(t) {
|
|
5
11
|
for (let e = 0; e < t.length; e++)
|
|
6
12
|
t[e] = r(t[e]);
|
|
7
13
|
}
|
|
8
|
-
function
|
|
14
|
+
function u(t) {
|
|
9
15
|
if (typeof t != "string")
|
|
10
|
-
throw new Error(
|
|
16
|
+
throw new Error("utf8ToBytes expected string, got " + typeof t);
|
|
11
17
|
return new Uint8Array(new TextEncoder().encode(t));
|
|
12
18
|
}
|
|
13
|
-
function
|
|
14
|
-
return typeof t == "string" && (t =
|
|
19
|
+
function i(t) {
|
|
20
|
+
return typeof t == "string" && (t = u(t)), o(t), t;
|
|
15
21
|
}
|
|
16
22
|
class b {
|
|
17
23
|
// Safe version that clones internal state
|
|
@@ -20,16 +26,16 @@ class b {
|
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
function x(t) {
|
|
23
|
-
const e = (
|
|
29
|
+
const e = (f) => t().update(i(f)).digest(), n = t();
|
|
24
30
|
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
|
|
25
31
|
}
|
|
26
32
|
export {
|
|
27
33
|
b as Hash,
|
|
28
34
|
r as byteSwap,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
s as byteSwap32,
|
|
36
|
+
p as isLE,
|
|
37
|
+
i as toBytes,
|
|
38
|
+
y as u32,
|
|
39
|
+
u as utf8ToBytes,
|
|
34
40
|
x as wrapConstructor
|
|
35
41
|
};
|
package/dist/index6.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index11.cjs"),d=require("./index7.cjs"),l=require("./index8.cjs"),w=require("jwt-decode"),f=require("./index3.cjs"),g=require("./index5.cjs"),y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index11.cjs"),d=require("./index7.cjs"),l=require("./index8.cjs"),w=require("jwt-decode"),f=require("./index3.cjs"),g=require("./index5.cjs"),y=require("./index13.cjs");class m{constructor(t,n,e){this.API="https://api.garden.finance",this.url=new g.Url("/",t??this.API),this.walletClient=n,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)??new d.MemoryStorage}verifyToken(t,n){try{const e=u(t);if(!e)return r.Ok(!1);const i=Math.floor(Date.now()/1e3)+120;return r.Ok(e.exp>i&&e.user_id.toLowerCase()===n.toLowerCase())}catch{return r.Ok(!1)}}async getToken(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return r.Err("Wallet client does not have an account");const t=this.store.getItem(l.StoreKeys.AUTH_TOKEN);if(t){const s=this.verifyToken(t,this.walletClient.account.address);if(s.ok&&s.val)return r.Ok(t)}const n=await this.signStatement();if(n.error)return r.Err(n.error);const e=await r.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...n.val}),headers:{"Content-Type":"application/json"}});if(e.error)return r.Err(e.error);const i=e.result;if(!i)return r.Err("Failed to get token");if(!this.verifyToken(i,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(l.StoreKeys.AUTH_TOKEN,i),r.Ok(i)}async signStatement(){var h;if(!((h=this.walletClient.account)!=null&&h.address))return r.Err("Wallet client does not have a valid account");const t=new Date,n=new Date(t.getTime()+300*1e3),i=(await r.Fetcher.get(this.url.endpoint("nonce"))).result;if(!i)return r.Err("Failed to get nonce");const c=await this.walletClient.getChainId(),a=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:i,uri:"https://"+this.domain,version:"1",chainId:c,notBefore:n}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return r.Ok({message:a,signature:s,nonce:i})}}const u=o=>{try{return w.jwtDecode(o)}catch{return}};class k{constructor(t){if(!t.siwe&&!t.apiKey)throw new Error("Either siwe or apiKey must be provided");this.siwe=t.siwe,this.apiKey=t.apiKey}async getAuthHeaders(){if(this.siwe){const t=await this.siwe.getToken();return t.error?r.Err(t.error):r.Ok({Authorization:f.Authorization(t.val)})}return this.apiKey?r.Ok({"api-key":this.apiKey}):r.Err("No authentication method available")}}exports.Auth=k;exports.Siwe=m;exports.parseJwt=u;
|
package/dist/index6.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Ok as n, Err as a, Fetcher as
|
|
1
|
+
import { Ok as n, Err as a, Fetcher as u } from "./index11.js";
|
|
2
2
|
import { MemoryStorage as f } from "./index7.js";
|
|
3
|
-
import { StoreKeys as
|
|
3
|
+
import { StoreKeys as d } from "./index8.js";
|
|
4
4
|
import { jwtDecode as m } from "jwt-decode";
|
|
5
5
|
import { Authorization as w } from "./index3.js";
|
|
6
6
|
import { Url as g } from "./index5.js";
|
|
7
|
-
import { createSiweMessage as y } from "./
|
|
7
|
+
import { createSiweMessage as y } from "./index13.js";
|
|
8
8
|
class I {
|
|
9
9
|
constructor(e, r, t) {
|
|
10
10
|
this.API = "https://api.garden.finance", this.url = new g("/", e ?? this.API), this.walletClient = r, 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) ?? new f();
|
|
@@ -15,7 +15,7 @@ class I {
|
|
|
15
15
|
if (!t) return n(!1);
|
|
16
16
|
const i = Math.floor(Date.now() / 1e3) + 120;
|
|
17
17
|
return n(
|
|
18
|
-
t.exp > i && t.
|
|
18
|
+
t.exp > i && t.user_id.toLowerCase() === r.toLowerCase()
|
|
19
19
|
);
|
|
20
20
|
} catch {
|
|
21
21
|
return n(!1);
|
|
@@ -25,7 +25,7 @@ class I {
|
|
|
25
25
|
var s;
|
|
26
26
|
if (!((s = this.walletClient.account) != null && s.address))
|
|
27
27
|
return a("Wallet client does not have an account");
|
|
28
|
-
const e = this.store.getItem(
|
|
28
|
+
const e = this.store.getItem(d.AUTH_TOKEN);
|
|
29
29
|
if (e) {
|
|
30
30
|
const o = this.verifyToken(
|
|
31
31
|
e,
|
|
@@ -36,7 +36,7 @@ class I {
|
|
|
36
36
|
const r = await this.signStatement();
|
|
37
37
|
if (r.error)
|
|
38
38
|
return a(r.error);
|
|
39
|
-
const t = await
|
|
39
|
+
const t = await u.post(
|
|
40
40
|
this.url.endpoint("verify"),
|
|
41
41
|
{
|
|
42
42
|
body: JSON.stringify({
|
|
@@ -52,13 +52,13 @@ class I {
|
|
|
52
52
|
if (!i) return a("Failed to get token");
|
|
53
53
|
if (!this.verifyToken(i, this.walletClient.account.address).val)
|
|
54
54
|
throw new Error("Token verification failed");
|
|
55
|
-
return this.store.setItem(
|
|
55
|
+
return this.store.setItem(d.AUTH_TOKEN, i), n(i);
|
|
56
56
|
}
|
|
57
57
|
async signStatement() {
|
|
58
58
|
var l;
|
|
59
59
|
if (!((l = this.walletClient.account) != null && l.address))
|
|
60
60
|
return a("Wallet client does not have a valid account");
|
|
61
|
-
const e = /* @__PURE__ */ new Date(), r = new Date(e.getTime() + 300 * 1e3), i = (await
|
|
61
|
+
const e = /* @__PURE__ */ new Date(), r = new Date(e.getTime() + 300 * 1e3), i = (await u.get(
|
|
62
62
|
this.url.endpoint("nonce")
|
|
63
63
|
)).result;
|
|
64
64
|
if (!i)
|
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index11.cjs"),n=require("viem"),s=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index11.cjs"),n=require("viem"),s=require("./index14.cjs"),l=require("./index15.cjs"),o={42161:s.mainnet,421614:l.sepolia},b=async e=>{const{chain:t}=e;if(!t)return r.Err("No chain found");const a=(u=>u in o)(t.id)?o[t.id]:t;return await i(a)},i=async e=>{const t=n.createPublicClient({chain:e,transport:n.http()});try{const c=await t.getBlockNumber();return r.Ok(Number(c))}catch(c){return r.Err("Failed to fetch evm block number",c)}},m=async e=>{try{const t=await e.getLatestTip();return r.Ok(t)}catch(t){return r.Err("Failed to fetch bitcoin block number",t)}};exports._fetchEVMBlockNumber=i;exports.fetchBitcoinBlockNumber=m;exports.fetchEVMBlockNumber=b;
|
package/dist/index9.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Err as o, Ok as n } from "./index11.js";
|
|
2
2
|
import { createPublicClient as s, http as m } from "viem";
|
|
3
|
-
import { mainnet as u } from "./
|
|
4
|
-
import { sepolia as b } from "./
|
|
3
|
+
import { mainnet as u } from "./index14.js";
|
|
4
|
+
import { sepolia as b } from "./index15.js";
|
|
5
5
|
const e = {
|
|
6
6
|
42161: u,
|
|
7
7
|
421614: b
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"jwt-decode": "^4.0.0",
|
|
39
|
-
"viem": "^2.21.
|
|
39
|
+
"viem": "^2.21.23"
|
|
40
40
|
}
|
|
41
41
|
}
|