@gardenfi/utils 0.0.1-beta.5 → 0.0.1-beta.7
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/index.cjs +1 -1
- package/dist/index.js +8 -11
- package/dist/index10.cjs +16 -1
- package/dist/index10.js +112 -93
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +18 -31
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +7 -31
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +20 -24
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +23 -31
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +8 -17
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +30 -6
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +25 -19
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +23 -22
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +52 -8
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +12 -31
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +24 -26
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +74 -22
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +22 -51
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +7 -12
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +29 -24
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +15 -75
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +2 -24
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +20 -7
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +12 -29
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +34 -15
- package/dist/index31.cjs +2 -1
- package/dist/index31.js +60 -2
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +2 -21
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +4 -8
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +11 -12
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +3 -34
- package/dist/index36.cjs +1 -2
- package/dist/index36.js +20 -58
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +13 -2
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +55 -4
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +6 -11
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +21 -3
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +11 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +3 -6
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +14 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +22 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +9 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +107 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +32 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +21 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +35 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +24 -31
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +88 -19
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +10 -88
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +2 -15
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +95 -2
- package/dist/src/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/src/lib/switchOrAddNetwork.d.ts +0 -5
package/dist/index.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 r=require("./index2.cjs"),e=require("./index3.cjs"),t=require("./index4.cjs"),o=require("./index5.cjs"),i=require("./index6.cjs"),s=require("./index7.cjs"),n=require("./index8.cjs");exports.ApiStatus=r.ApiStatus;exports.Authorization=e.Authorization;exports.sleep=e.sleep;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=t.checkAllowanceAndApprove;exports.Url=o.Url;exports.Siwe=i.Siwe;exports.MemoryStorage=s.MemoryStorage;exports.StoreKeys=n.StoreKeys;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { ApiStatus as e } from "./index2.js";
|
|
2
2
|
import { Authorization as p, sleep as m, with0x as x } from "./index3.js";
|
|
3
3
|
import { checkAllowanceAndApprove as i } from "./index4.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { StoreKeys as k } from "./index9.js";
|
|
4
|
+
import { Url as a } from "./index5.js";
|
|
5
|
+
import { Siwe as S } from "./index6.js";
|
|
6
|
+
import { MemoryStorage as h } from "./index7.js";
|
|
7
|
+
import { StoreKeys as s } from "./index8.js";
|
|
9
8
|
export {
|
|
10
9
|
e as ApiStatus,
|
|
11
10
|
p as Authorization,
|
|
12
|
-
|
|
13
|
-
S as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
c as Url,
|
|
11
|
+
h as MemoryStorage,
|
|
12
|
+
S as Siwe,
|
|
13
|
+
s as StoreKeys,
|
|
14
|
+
a as Url,
|
|
17
15
|
i as checkAllowanceAndApprove,
|
|
18
16
|
m as sleep,
|
|
19
|
-
h as switchOrAddNetwork,
|
|
20
17
|
x as with0x
|
|
21
18
|
};
|
package/dist/index10.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("./index43.cjs"),M=require("./index36.cjs"),h=require("./index44.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/index10.js
CHANGED
|
@@ -1,97 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
retryCount: T = 6,
|
|
17
|
-
retryDelay: N = ({ count: m }) => ~~(1 << m) * 200,
|
|
18
|
-
// exponential backoff
|
|
19
|
-
timeout: w = 18e4
|
|
20
|
-
}) {
|
|
21
|
-
const m = P(["waitForTransactionReceipt", o.uid, b]);
|
|
22
|
-
let a, c, r, i = !1;
|
|
23
|
-
return new Promise((F, g) => {
|
|
24
|
-
w && setTimeout(() => g(new x({ hash: b })), w);
|
|
25
|
-
const h = O(m, { onReplaced: y, resolve: F, reject: g }, (e) => {
|
|
26
|
-
const E = p(o, z, "watchBlockNumber")({
|
|
27
|
-
emitMissed: !0,
|
|
28
|
-
emitOnBegin: !0,
|
|
29
|
-
poll: !0,
|
|
30
|
-
pollingInterval: B,
|
|
31
|
-
async onBlockNumber(_) {
|
|
32
|
-
const l = (f) => {
|
|
33
|
-
E(), f(), h();
|
|
34
|
-
};
|
|
35
|
-
let u = _;
|
|
36
|
-
if (!i)
|
|
37
|
-
try {
|
|
38
|
-
if (r) {
|
|
39
|
-
if (n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
|
|
40
|
-
return;
|
|
41
|
-
l(() => e.resolve(r));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (a || (i = !0, await R(async () => {
|
|
45
|
-
a = await p(o, q, "getTransaction")({ hash: b }), a.blockNumber && (u = a.blockNumber);
|
|
46
|
-
}, {
|
|
47
|
-
delay: N,
|
|
48
|
-
retryCount: T
|
|
49
|
-
}), i = !1), r = await p(o, v, "getTransactionReceipt")({ hash: b }), n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
|
|
50
|
-
return;
|
|
51
|
-
l(() => e.resolve(r));
|
|
52
|
-
} catch (f) {
|
|
53
|
-
if (f instanceof A || f instanceof M) {
|
|
54
|
-
if (!a) {
|
|
55
|
-
i = !1;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
c = a, i = !0;
|
|
60
|
-
const d = await R(() => p(o, W, "getBlock")({
|
|
61
|
-
blockNumber: u,
|
|
62
|
-
includeTransactions: !0
|
|
63
|
-
}), {
|
|
64
|
-
delay: N,
|
|
65
|
-
retryCount: T,
|
|
66
|
-
shouldRetry: ({ error: s }) => s instanceof j
|
|
67
|
-
});
|
|
68
|
-
i = !1;
|
|
69
|
-
const t = d.transactions.find(({ from: s, nonce: I }) => s === c.from && I === c.nonce);
|
|
70
|
-
if (!t || (r = await p(o, v, "getTransactionReceipt")({
|
|
71
|
-
hash: t.hash
|
|
72
|
-
}), n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n)))
|
|
73
|
-
return;
|
|
74
|
-
let k = "replaced";
|
|
75
|
-
t.to === c.to && t.value === c.value ? k = "repriced" : t.from === t.to && t.value === 0n && (k = "cancelled"), l(() => {
|
|
76
|
-
var s;
|
|
77
|
-
(s = e.onReplaced) == null || s.call(e, {
|
|
78
|
-
reason: k,
|
|
79
|
-
replacedTransaction: c,
|
|
80
|
-
transaction: t,
|
|
81
|
-
transactionReceipt: r
|
|
82
|
-
}), e.resolve(r);
|
|
83
|
-
});
|
|
84
|
-
} catch (d) {
|
|
85
|
-
l(() => e.reject(d));
|
|
86
|
-
}
|
|
87
|
-
} else
|
|
88
|
-
l(() => e.reject(f));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import { SiweInvalidMessageFieldError as e } from "./index43.js";
|
|
2
|
+
import { getAddress as S } from "./index36.js";
|
|
3
|
+
import { isUri as $ } from "./index44.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
|
+
]
|
|
91
16
|
});
|
|
92
|
-
|
|
93
|
-
|
|
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}`;
|
|
94
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+-.]*)$/;
|
|
95
114
|
export {
|
|
96
|
-
|
|
115
|
+
C as createSiweMessage
|
|
97
116
|
};
|
package/dist/index11.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 f=require("./index12.cjs"),m=require("./index13.cjs"),k=require("./index14.cjs");async function B(t,{blockHash:o,blockNumber:r,blockTag:l,includeTransactions:i}={}){var c,s,u;const d=l??"latest",n=i??!1,a=r!==void 0?m.numberToHex(r):void 0;let e=null;if(o?e=await t.request({method:"eth_getBlockByHash",params:[o,n]},{dedupe:!0}):e=await t.request({method:"eth_getBlockByNumber",params:[a||d,n]},{dedupe:!!a}),!e)throw new f.BlockNotFoundError({blockHash:o,blockNumber:r});return(((u=(s=(c=t.chain)==null?void 0:c.formatters)==null?void 0:s.block)==null?void 0:u.format)||k.formatBlock)(e)}exports.getBlock=B;
|
package/dist/index11.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
nativeCurrency: {
|
|
19
|
-
name: "Ethereum",
|
|
20
|
-
symbol: "ETH",
|
|
21
|
-
decimals: 18
|
|
22
|
-
},
|
|
23
|
-
rpcUrls: {
|
|
24
|
-
default: {
|
|
25
|
-
http: ["http://localhost:8545/"]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
testnet: !0
|
|
29
|
-
};
|
|
1
|
+
import { BlockNotFoundError as i } from "./index12.js";
|
|
2
|
+
import { numberToHex as l } from "./index13.js";
|
|
3
|
+
import { formatBlock as p } from "./index14.js";
|
|
4
|
+
async function T(e, { blockHash: t, blockNumber: r, blockTag: f, includeTransactions: u } = {}) {
|
|
5
|
+
var m, s, c;
|
|
6
|
+
const d = f ?? "latest", a = u ?? !1, n = r !== void 0 ? l(r) : void 0;
|
|
7
|
+
let o = null;
|
|
8
|
+
if (t ? o = await e.request({
|
|
9
|
+
method: "eth_getBlockByHash",
|
|
10
|
+
params: [t, a]
|
|
11
|
+
}, { dedupe: !0 }) : o = await e.request({
|
|
12
|
+
method: "eth_getBlockByNumber",
|
|
13
|
+
params: [n || d, a]
|
|
14
|
+
}, { dedupe: !!n }), !o)
|
|
15
|
+
throw new i({ blockHash: t, blockNumber: r });
|
|
16
|
+
return (((c = (s = (m = e.chain) == null ? void 0 : m.formatters) == null ? void 0 : s.block) == null ? void 0 : c.format) || p)(o);
|
|
17
|
+
}
|
|
30
18
|
export {
|
|
31
|
-
|
|
32
|
-
e as EthereumLocalnet
|
|
19
|
+
T as getBlock
|
|
33
20
|
};
|
package/dist/index12.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("./index31.cjs");class n extends t.BaseError{constructor({blockHash:r,blockNumber:e}){let o="Block";r&&(o=`Block at hash "${r}"`),e&&(o=`Block at number "${e}"`),super(`${o} could not be found.`,{name:"BlockNotFoundError"})}}exports.BlockNotFoundError=n;
|
package/dist/index12.js
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rpcUrls: {
|
|
7
|
-
default: {
|
|
8
|
-
http: ["https://cloudflare-eth.com"]
|
|
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
|
-
}
|
|
1
|
+
import { BaseError as e } from "./index31.js";
|
|
2
|
+
class d extends e {
|
|
3
|
+
constructor({ blockHash: r, blockNumber: t }) {
|
|
4
|
+
let o = "Block";
|
|
5
|
+
r && (o = `Block at hash "${r}"`), t && (o = `Block at number "${t}"`), super(`${o} could not be found.`, { name: "BlockNotFoundError" });
|
|
30
6
|
}
|
|
31
|
-
}
|
|
7
|
+
}
|
|
32
8
|
export {
|
|
33
|
-
|
|
9
|
+
d as BlockNotFoundError
|
|
34
10
|
};
|
package/dist/index13.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 s=require("./index29.cjs"),c=require("./index30.cjs");function m(i,f={}){const{signed:r,size:e}=f,t=BigInt(i);let n;e?r?n=(1n<<BigInt(e)*8n-1n)-1n:n=2n**(BigInt(e)*8n)-1n:typeof i=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const u=typeof n=="bigint"&&r?-n-1n:0;if(n&&t>n||t<u){const o=typeof i=="bigint"?"n":"";throw new s.IntegerOutOfRangeError({max:n?`${n}${o}`:void 0,min:`${u}${o}`,signed:r,size:e,value:`${i}${o}`})}const g=`0x${(r&&t<0?(1n<<BigInt(e*8))+BigInt(t):t).toString(16)}`;return e?c.pad(g,{size:e}):g}exports.numberToHex=m;
|
package/dist/index13.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
contracts: {
|
|
19
|
-
multicall3: {
|
|
20
|
-
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
21
|
-
blockCreated: 7654707
|
|
22
|
-
}
|
|
1
|
+
import { IntegerOutOfRangeError as s } from "./index29.js";
|
|
2
|
+
import { pad as u } from "./index30.js";
|
|
3
|
+
function x(i, m = {}) {
|
|
4
|
+
const { signed: o, size: t } = m, e = BigInt(i);
|
|
5
|
+
let n;
|
|
6
|
+
t ? o ? n = (1n << BigInt(t) * 8n - 1n) - 1n : n = 2n ** (BigInt(t) * 8n) - 1n : typeof i == "number" && (n = BigInt(Number.MAX_SAFE_INTEGER));
|
|
7
|
+
const f = typeof n == "bigint" && o ? -n - 1n : 0;
|
|
8
|
+
if (n && e > n || e < f) {
|
|
9
|
+
const r = typeof i == "bigint" ? "n" : "";
|
|
10
|
+
throw new s({
|
|
11
|
+
max: n ? `${n}${r}` : void 0,
|
|
12
|
+
min: `${f}${r}`,
|
|
13
|
+
signed: o,
|
|
14
|
+
size: t,
|
|
15
|
+
value: `${i}${r}`
|
|
16
|
+
});
|
|
23
17
|
}
|
|
24
|
-
}
|
|
18
|
+
const g = `0x${(o && e < 0 ? (1n << BigInt(t * 8)) + BigInt(e) : e).toString(16)}`;
|
|
19
|
+
return t ? u(g, { size: t }) : g;
|
|
20
|
+
}
|
|
25
21
|
export {
|
|
26
|
-
|
|
22
|
+
x as numberToHex
|
|
27
23
|
};
|
package/dist/index14.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("./index19.cjs");function a(e){var s;const t=(s=e.transactions)==null?void 0:s.map(n=>typeof n=="string"?n:i.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:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}exports.formatBlock=a;
|
package/dist/index14.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
24
|
-
ensUniversalResolver: {
|
|
25
|
-
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
26
|
-
blockCreated: 5317080
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
testnet: !0
|
|
30
|
-
});
|
|
1
|
+
import { formatTransaction as t } from "./index19.js";
|
|
2
|
+
function u(e) {
|
|
3
|
+
var s;
|
|
4
|
+
const i = (s = e.transactions) == null ? void 0 : s.map((n) => typeof n == "string" ? n : t(n));
|
|
5
|
+
return {
|
|
6
|
+
...e,
|
|
7
|
+
baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
|
|
8
|
+
blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
|
|
9
|
+
difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
|
|
10
|
+
excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
|
|
11
|
+
gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
|
|
12
|
+
gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
|
|
13
|
+
hash: e.hash ? e.hash : null,
|
|
14
|
+
logsBloom: e.logsBloom ? e.logsBloom : null,
|
|
15
|
+
nonce: e.nonce ? e.nonce : null,
|
|
16
|
+
number: e.number ? BigInt(e.number) : null,
|
|
17
|
+
size: e.size ? BigInt(e.size) : void 0,
|
|
18
|
+
timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
|
|
19
|
+
transactions: i,
|
|
20
|
+
totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
31
23
|
export {
|
|
32
|
-
|
|
24
|
+
u as formatBlock
|
|
33
25
|
};
|
package/dist/index15.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 o=require("./index16.cjs"),r=e=>`blockNumber.${e}`;async function u(e,{cacheTime:c=e.cacheTime}={}){const t=await o.withCache(()=>e.request({method:"eth_blockNumber"}),{cacheKey:r(e.uid),cacheTime:c});return BigInt(t)}exports.getBlockNumber=u;
|
package/dist/index15.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (t ? o = await e.request({
|
|
9
|
-
method: "eth_getBlockByHash",
|
|
10
|
-
params: [t, a]
|
|
11
|
-
}, { dedupe: !0 }) : o = await e.request({
|
|
12
|
-
method: "eth_getBlockByNumber",
|
|
13
|
-
params: [n || d, a]
|
|
14
|
-
}, { dedupe: !!n }), !o)
|
|
15
|
-
throw new i({ blockHash: t, blockNumber: r });
|
|
16
|
-
return (((c = (s = (m = e.chain) == null ? void 0 : m.formatters) == null ? void 0 : s.block) == null ? void 0 : c.format) || p)(o);
|
|
1
|
+
import { withCache as t } from "./index16.js";
|
|
2
|
+
const r = (e) => `blockNumber.${e}`;
|
|
3
|
+
async function u(e, { cacheTime: c = e.cacheTime } = {}) {
|
|
4
|
+
const o = await t(() => e.request({
|
|
5
|
+
method: "eth_blockNumber"
|
|
6
|
+
}), { cacheKey: r(e.uid), cacheTime: c });
|
|
7
|
+
return BigInt(o);
|
|
17
8
|
}
|
|
18
9
|
export {
|
|
19
|
-
|
|
10
|
+
u as getBlockNumber
|
|
20
11
|
};
|
package/dist/index16.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,c=new Map;function p(o){const a=(s,t)=>({clear:()=>t.delete(s),get:()=>t.get(s),set:n=>t.set(s,n)}),r=a(o,i),e=a(o,c);return{clear:()=>{r.clear(),e.clear()},promise:r,response:e}}async function l(o,{cacheKey:a,cacheTime:r=Number.POSITIVE_INFINITY}){const e=p(a),s=e.response.get();if(s&&r>0&&new Date().getTime()-s.created.getTime()<r)return s.data;let t=e.promise.get();t||(t=o(),e.promise.set(t));try{const n=await t;return e.response.set({created:new Date,data:n}),n}finally{e.promise.clear()}}exports.getCache=p;exports.promiseCache=i;exports.responseCache=c;exports.withCache=l;
|
package/dist/index16.js
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
2
|
+
function p(o) {
|
|
3
|
+
const a = (s, t) => ({
|
|
4
|
+
clear: () => t.delete(s),
|
|
5
|
+
get: () => t.get(s),
|
|
6
|
+
set: (r) => t.set(s, r)
|
|
7
|
+
}), n = a(o, i), e = a(o, c);
|
|
8
|
+
return {
|
|
9
|
+
clear: () => {
|
|
10
|
+
n.clear(), e.clear();
|
|
11
|
+
},
|
|
12
|
+
promise: n,
|
|
13
|
+
response: e
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function l(o, { cacheKey: a, cacheTime: n = Number.POSITIVE_INFINITY }) {
|
|
17
|
+
const e = p(a), s = e.response.get();
|
|
18
|
+
if (s && n > 0 && (/* @__PURE__ */ new Date()).getTime() - s.created.getTime() < n)
|
|
19
|
+
return s.data;
|
|
20
|
+
let t = e.promise.get();
|
|
21
|
+
t || (t = o(), e.promise.set(t));
|
|
22
|
+
try {
|
|
23
|
+
const r = await t;
|
|
24
|
+
return e.response.set({ created: /* @__PURE__ */ new Date(), data: r }), r;
|
|
25
|
+
} finally {
|
|
26
|
+
e.promise.clear();
|
|
6
27
|
}
|
|
7
28
|
}
|
|
8
29
|
export {
|
|
9
|
-
|
|
30
|
+
p as getCache,
|
|
31
|
+
i as promiseCache,
|
|
32
|
+
c as responseCache,
|
|
33
|
+
l as withCache
|
|
10
34
|
};
|
package/dist/index17.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("./index18.cjs"),u=require("./index13.cjs"),g=require("./index19.cjs");async function l(t,{blockHash:a,blockNumber:n,blockTag:f,hash:r,index:o}){var c,d,m;const s=f||"latest",i=n!==void 0?u.numberToHex(n):void 0;let e=null;if(r?e=await t.request({method:"eth_getTransactionByHash",params:[r]},{dedupe:!0}):a?e=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[a,u.numberToHex(o)]},{dedupe:!0}):(i||s)&&(e=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||s,u.numberToHex(o)]},{dedupe:!!i})),!e)throw new T.TransactionNotFoundError({blockHash:a,blockNumber:n,blockTag:s,hash:r,index:o});return(((m=(d=(c=t.chain)==null?void 0:c.formatters)==null?void 0:d.transaction)==null?void 0:m.format)||g.formatTransaction)(e)}exports.getTransaction=l;
|