@gardenfi/utils 0.0.1-beta.2 → 0.0.1-beta.21
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 +21 -16
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +17 -93
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +94 -31
- package/dist/index12.cjs +16 -1
- package/dist/index12.js +112 -30
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +17 -10
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +2 -2
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +13 -14
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +7 -4
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +8 -20
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +20 -8
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +1 -1
- package/dist/index36.cjs +2 -2
- package/dist/index36.js +8 -8
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +1 -1
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +20 -21
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +21 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +11 -5
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +58 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +9 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +24 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +14 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +6 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +14 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +22 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +24 -31
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +11 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +9 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +107 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +32 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +21 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +35 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +89 -14
- 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 +34 -2
- package/dist/src/index.d.ts +2 -1
- package/dist/src/lib/approve.d.ts +0 -3
- package/dist/src/lib/auth/siwe.d.ts +4 -0
- package/dist/src/lib/blockNumber/blockNumber.d.ts +17 -0
- package/dist/src/lib/blockNumber/index.d.ts +1 -0
- package/dist/src/lib/eventBroker/eventBroker.d.ts +7 -0
- package/dist/src/lib/eventBroker/index.d.ts +2 -0
- package/dist/src/lib/url/Url.d.ts +1 -0
- package/dist/src/lib/utils.d.ts +9 -0
- package/package.json +2 -2
- 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 o=require("./index2.cjs"),e=require("./index3.cjs"),i=require("./index4.cjs"),n=require("./index5.cjs"),r=require("./index6.cjs"),c=require("./index7.cjs"),s=require("./index8.cjs"),t=require("./index9.cjs"),u=require("./index10.cjs");exports.ApiStatus=o.ApiStatus;exports.Authorization=e.Authorization;exports.Environment=e.Environment;exports.Network=e.Network;exports.sleep=e.sleep;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=i.checkAllowanceAndApprove;exports.Url=n.Url;exports.Siwe=r.Siwe;exports.parseJwt=r.parseJwt;exports.MemoryStorage=c.MemoryStorage;exports.StoreKeys=s.StoreKeys;exports.fetchBitcoinBlockNumber=t.fetchBitcoinBlockNumber;exports.fetchEVMBlockNumber=t.fetchEVMBlockNumber;exports.EventBroker=u.EventBroker;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { ApiStatus as e } from "./index2.js";
|
|
2
|
-
import { Authorization as p,
|
|
3
|
-
import { checkAllowanceAndApprove as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { Authorization as p, Environment as m, Network as f, sleep as x, with0x as c } from "./index3.js";
|
|
3
|
+
import { checkAllowanceAndApprove as n } from "./index4.js";
|
|
4
|
+
import { Url as a } from "./index5.js";
|
|
5
|
+
import { Siwe as k, parseJwt as w } from "./index6.js";
|
|
6
|
+
import { MemoryStorage as s } from "./index7.js";
|
|
7
|
+
import { StoreKeys as B } from "./index8.js";
|
|
8
|
+
import { fetchBitcoinBlockNumber as v, fetchEVMBlockNumber as E } from "./index9.js";
|
|
9
|
+
import { EventBroker as b } from "./index10.js";
|
|
9
10
|
export {
|
|
10
11
|
e as ApiStatus,
|
|
11
12
|
p as Authorization,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
m as Environment,
|
|
14
|
+
b as EventBroker,
|
|
15
|
+
s as MemoryStorage,
|
|
16
|
+
f as Network,
|
|
17
|
+
k as Siwe,
|
|
18
|
+
B as StoreKeys,
|
|
19
|
+
a as Url,
|
|
20
|
+
n as checkAllowanceAndApprove,
|
|
21
|
+
v as fetchBitcoinBlockNumber,
|
|
22
|
+
E as fetchEVMBlockNumber,
|
|
23
|
+
w as parseJwt,
|
|
24
|
+
x as sleep,
|
|
25
|
+
c as with0x
|
|
21
26
|
};
|
package/dist/index10.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class n{constructor(){this.listeners=new Map}emit(e,...t){(this.listeners.get(e)??[]).forEach(i=>{i(...t)})}on(e,t){const s=this.listeners.get(e)??[];s.push(t),this.listeners.set(e,s)}off(e,t){const s=this.listeners.get(e)??[],i=s.indexOf(t);i!==-1&&s.splice(i,1)}}exports.EventBroker=n;
|
package/dist/index10.js
CHANGED
|
@@ -1,97 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { getTransaction as q } from "./index21.js";
|
|
9
|
-
import { getTransactionReceipt as v } from "./index24.js";
|
|
10
|
-
import { watchBlockNumber as z } from "./index26.js";
|
|
11
|
-
async function Y(o, {
|
|
12
|
-
confirmations: n = 1,
|
|
13
|
-
hash: b,
|
|
14
|
-
onReplaced: y,
|
|
15
|
-
pollingInterval: B = o.pollingInterval,
|
|
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
|
-
}
|
|
91
|
-
});
|
|
1
|
+
class r {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
4
|
+
}
|
|
5
|
+
emit(s, ...t) {
|
|
6
|
+
(this.listeners.get(s) ?? []).forEach((i) => {
|
|
7
|
+
i(...t);
|
|
92
8
|
});
|
|
93
|
-
}
|
|
9
|
+
}
|
|
10
|
+
on(s, t) {
|
|
11
|
+
const e = this.listeners.get(s) ?? [];
|
|
12
|
+
e.push(t), this.listeners.set(s, e);
|
|
13
|
+
}
|
|
14
|
+
off(s, t) {
|
|
15
|
+
const e = this.listeners.get(s) ?? [], i = e.indexOf(t);
|
|
16
|
+
i !== -1 && e.splice(i, 1);
|
|
17
|
+
}
|
|
94
18
|
}
|
|
95
19
|
export {
|
|
96
|
-
|
|
20
|
+
r as EventBroker
|
|
97
21
|
};
|
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 M=require("./index16.cjs"),k=require("./index22.cjs"),g=require("./index28.cjs"),O=require("./index29.cjs"),S=require("./index32.cjs"),y=require("./index33.cjs"),$=require("./index31.cjs"),P=require("./index15.cjs"),W=require("./index21.cjs"),q=require("./index24.cjs"),x=require("./index26.cjs");async function z(n,{confirmations:o=1,hash:d,onReplaced:h,pollingInterval:m=n.pollingInterval,retryCount:w=6,retryDelay:R=({count:f})=>~~(1<<f)*200,timeout:N=18e4}){const f=$.stringify(["waitForTransactionReceipt",n.uid,d]);let c,a,e,i=!1;const{promise:B,resolve:F,reject:v}=S.withResolvers(),A=N?setTimeout(()=>v(new k.WaitForTransactionReceiptTimeoutError({hash:d})),N):void 0,j=O.observe(f,{onReplaced:h,resolve:F,reject:v},t=>{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(o>1&&(!e.blockNumber||l-e.blockNumber+1n<o))return;u(()=>t.resolve(e));return}if(c||(i=!0,await y.withRetry(async()=>{c=await g.getAction(n,W.getTransaction,"getTransaction")({hash:d}),c.blockNumber&&(l=c.blockNumber)},{delay:R,retryCount:w}),i=!1),e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:d}),o>1&&(!e.blockNumber||l-e.blockNumber+1n<o))return;u(()=>t.resolve(e))}catch(b){if(b instanceof k.TransactionNotFoundError||b instanceof k.TransactionReceiptNotFoundError){if(!c){i=!1;return}try{a=c,i=!0;const p=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 r=p.transactions.find(({from:s,nonce:I})=>s===a.from&&I===a.nonce);if(!r||(e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:r.hash}),o>1&&(!e.blockNumber||l-e.blockNumber+1n<o)))return;let T="replaced";r.to===a.to&&r.value===a.value?T="repriced":r.from===r.to&&r.value===0n&&(T="cancelled"),u(()=>{var s;(s=t.onReplaced)==null||s.call(t,{reason:T,replacedTransaction:a,transaction:r,transactionReceipt:e}),t.resolve(e)})}catch(p){u(()=>t.reject(p))}}else u(()=>t.reject(b))}}})});return B}exports.waitForTransactionReceipt=z;
|
package/dist/index11.js
CHANGED
|
@@ -1,33 +1,96 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
1
|
+
import { BlockNotFoundError as A } from "./index16.js";
|
|
2
|
+
import { WaitForTransactionReceiptTimeoutError as M, TransactionNotFoundError as O, TransactionReceiptNotFoundError as W } from "./index22.js";
|
|
3
|
+
import { getAction as p } from "./index28.js";
|
|
4
|
+
import { observe as q } from "./index29.js";
|
|
5
|
+
import { withResolvers as z } from "./index32.js";
|
|
6
|
+
import { withRetry as v } from "./index33.js";
|
|
7
|
+
import { stringify as G } from "./index31.js";
|
|
8
|
+
import { getBlock as H } from "./index15.js";
|
|
9
|
+
import { getTransaction as J } from "./index21.js";
|
|
10
|
+
import { getTransactionReceipt as R } from "./index24.js";
|
|
11
|
+
import { watchBlockNumber as K } from "./index26.js";
|
|
12
|
+
async function D(o, {
|
|
13
|
+
confirmations: n = 1,
|
|
14
|
+
hash: m,
|
|
15
|
+
onReplaced: y,
|
|
16
|
+
pollingInterval: B = o.pollingInterval,
|
|
17
|
+
retryCount: k = 6,
|
|
18
|
+
retryDelay: N = ({ count: b }) => ~~(1 << b) * 200,
|
|
19
|
+
// exponential backoff
|
|
20
|
+
timeout: w = 18e4
|
|
21
|
+
}) {
|
|
22
|
+
const b = G(["waitForTransactionReceipt", o.uid, m]);
|
|
23
|
+
let a, c, 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 }, (e) => {
|
|
25
|
+
const j = p(o, K, "watchBlockNumber")({
|
|
26
|
+
emitMissed: !0,
|
|
27
|
+
emitOnBegin: !0,
|
|
28
|
+
poll: !0,
|
|
29
|
+
pollingInterval: B,
|
|
30
|
+
async onBlockNumber(I) {
|
|
31
|
+
const l = (f) => {
|
|
32
|
+
clearTimeout(E), j(), f(), _();
|
|
33
|
+
};
|
|
34
|
+
let u = I;
|
|
35
|
+
if (!i)
|
|
36
|
+
try {
|
|
37
|
+
if (r) {
|
|
38
|
+
if (n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
|
|
39
|
+
return;
|
|
40
|
+
l(() => e.resolve(r));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (a || (i = !0, await v(async () => {
|
|
44
|
+
a = await p(o, J, "getTransaction")({ hash: m }), a.blockNumber && (u = a.blockNumber);
|
|
45
|
+
}, {
|
|
46
|
+
delay: N,
|
|
47
|
+
retryCount: k
|
|
48
|
+
}), i = !1), r = await p(o, R, "getTransactionReceipt")({ hash: m }), n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
|
|
49
|
+
return;
|
|
50
|
+
l(() => e.resolve(r));
|
|
51
|
+
} catch (f) {
|
|
52
|
+
if (f instanceof O || f instanceof W) {
|
|
53
|
+
if (!a) {
|
|
54
|
+
i = !1;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
c = a, i = !0;
|
|
59
|
+
const d = await v(() => p(o, H, "getBlock")({
|
|
60
|
+
blockNumber: u,
|
|
61
|
+
includeTransactions: !0
|
|
62
|
+
}), {
|
|
63
|
+
delay: N,
|
|
64
|
+
retryCount: k,
|
|
65
|
+
shouldRetry: ({ error: s }) => s instanceof A
|
|
66
|
+
});
|
|
67
|
+
i = !1;
|
|
68
|
+
const t = d.transactions.find(({ from: s, nonce: x }) => s === c.from && x === c.nonce);
|
|
69
|
+
if (!t || (r = await p(o, R, "getTransactionReceipt")({
|
|
70
|
+
hash: t.hash
|
|
71
|
+
}), n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n)))
|
|
72
|
+
return;
|
|
73
|
+
let T = "replaced";
|
|
74
|
+
t.to === c.to && t.value === c.value ? T = "repriced" : t.from === t.to && t.value === 0n && (T = "cancelled"), l(() => {
|
|
75
|
+
var s;
|
|
76
|
+
(s = e.onReplaced) == null || s.call(e, {
|
|
77
|
+
reason: T,
|
|
78
|
+
replacedTransaction: c,
|
|
79
|
+
transaction: t,
|
|
80
|
+
transactionReceipt: r
|
|
81
|
+
}), e.resolve(r);
|
|
82
|
+
});
|
|
83
|
+
} catch (d) {
|
|
84
|
+
l(() => e.reject(d));
|
|
85
|
+
}
|
|
86
|
+
} else
|
|
87
|
+
l(() => e.reject(f));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return h;
|
|
93
|
+
}
|
|
30
94
|
export {
|
|
31
|
-
|
|
32
|
-
e as EthereumLocalnet
|
|
95
|
+
D as waitForTransactionReceipt
|
|
33
96
|
};
|
package/dist/index12.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("./index48.cjs"),M=require("./index41.cjs"),h=require("./index49.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/index12.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 "./index48.js";
|
|
2
|
+
import { getAddress as S } from "./index41.js";
|
|
3
|
+
import { isUri as $ } from "./index49.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/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 e=require("./index50.cjs"),a=e.defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},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=a;
|
package/dist/index13.js
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
import { defineChain as
|
|
2
|
-
const t = /* @__PURE__ */
|
|
3
|
-
id:
|
|
4
|
-
name: "
|
|
1
|
+
import { defineChain as e } from "./index50.js";
|
|
2
|
+
const t = /* @__PURE__ */ e({
|
|
3
|
+
id: 1,
|
|
4
|
+
name: "Ethereum",
|
|
5
5
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
6
6
|
rpcUrls: {
|
|
7
7
|
default: {
|
|
8
|
-
http: ["https://
|
|
8
|
+
http: ["https://cloudflare-eth.com"]
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
blockExplorers: {
|
|
12
12
|
default: {
|
|
13
|
-
name: "
|
|
14
|
-
url: "https://
|
|
15
|
-
apiUrl: "https://api.
|
|
13
|
+
name: "Etherscan",
|
|
14
|
+
url: "https://etherscan.io",
|
|
15
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
contracts: {
|
|
19
|
+
ensRegistry: {
|
|
20
|
+
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
|
|
21
|
+
},
|
|
22
|
+
ensUniversalResolver: {
|
|
23
|
+
address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
|
|
24
|
+
blockCreated: 19258213
|
|
25
|
+
},
|
|
19
26
|
multicall3: {
|
|
20
27
|
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
21
|
-
blockCreated:
|
|
28
|
+
blockCreated: 14353601
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
});
|
|
25
32
|
export {
|
|
26
|
-
t as
|
|
33
|
+
t as mainnet
|
|
27
34
|
};
|
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("./index50.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/index14.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineChain as e } from "./
|
|
1
|
+
import { defineChain as e } from "./index50.js";
|
|
2
2
|
const s = /* @__PURE__ */ e({
|
|
3
3
|
id: 11155111,
|
|
4
4
|
name: "Sepolia",
|
|
5
5
|
nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
|
|
6
6
|
rpcUrls: {
|
|
7
7
|
default: {
|
|
8
|
-
http: ["https://
|
|
8
|
+
http: ["https://sepolia.drpc.org"]
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
blockExplorers: {
|
package/dist/index23.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index27.cjs"),i={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function u(e){const d={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?r.hexToNumber(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?r.hexToNumber(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?i[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(d.authorizationList=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index27.cjs"),i={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function u(e){const d={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?r.hexToNumber(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?r.hexToNumber(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?i[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(d.authorizationList=l(e.authorizationList)),d.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof d.v=="bigint"){if(d.v===0n||d.v===27n)return 0;if(d.v===1n||d.v===28n)return 1;if(d.v>=35n)return d.v%2n===0n?1:0}})(),d.type==="legacy"&&(delete d.accessList,delete d.maxFeePerBlobGas,delete d.maxFeePerGas,delete d.maxPriorityFeePerGas,delete d.yParity),d.type==="eip2930"&&(delete d.maxFeePerBlobGas,delete d.maxFeePerGas,delete d.maxPriorityFeePerGas),d.type==="eip1559"&&delete d.maxFeePerBlobGas,d}function l(e){return e.map(d=>({contractAddress:d.address,chainId:Number(d.chainId),nonce:Number(d.nonce),r:d.r,s:d.s,yParity:Number(d.yParity)}))}exports.formatTransaction=u;exports.transactionType=i;
|
package/dist/index23.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { hexToNumber as
|
|
2
|
-
const
|
|
1
|
+
import { hexToNumber as i } from "./index27.js";
|
|
2
|
+
const r = {
|
|
3
3
|
"0x0": "legacy",
|
|
4
4
|
"0x1": "eip2930",
|
|
5
5
|
"0x2": "eip1559",
|
|
6
6
|
"0x3": "eip4844",
|
|
7
7
|
"0x4": "eip7702"
|
|
8
8
|
};
|
|
9
|
-
function
|
|
9
|
+
function m(e) {
|
|
10
10
|
const d = {
|
|
11
11
|
...e,
|
|
12
12
|
blockHash: e.blockHash ? e.blockHash : null,
|
|
13
13
|
blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
|
|
14
|
-
chainId: e.chainId ?
|
|
14
|
+
chainId: e.chainId ? i(e.chainId) : void 0,
|
|
15
15
|
gas: e.gas ? BigInt(e.gas) : void 0,
|
|
16
16
|
gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
|
|
17
17
|
maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
|
|
18
18
|
maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
|
|
19
19
|
maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
|
|
20
|
-
nonce: e.nonce ?
|
|
20
|
+
nonce: e.nonce ? i(e.nonce) : void 0,
|
|
21
21
|
to: e.to ? e.to : null,
|
|
22
22
|
transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
|
|
23
|
-
type: e.type ?
|
|
23
|
+
type: e.type ? r[e.type] : void 0,
|
|
24
24
|
typeHex: e.type ? e.type : void 0,
|
|
25
25
|
value: e.value ? BigInt(e.value) : void 0,
|
|
26
26
|
v: e.v ? BigInt(e.v) : void 0
|
|
27
27
|
};
|
|
28
|
-
return e.authorizationList && (d.authorizationList =
|
|
28
|
+
return e.authorizationList && (d.authorizationList = u(e.authorizationList)), d.yParity = (() => {
|
|
29
29
|
if (e.yParity)
|
|
30
30
|
return Number(e.yParity);
|
|
31
31
|
if (typeof d.v == "bigint") {
|
|
@@ -38,18 +38,17 @@ function l(e) {
|
|
|
38
38
|
}
|
|
39
39
|
})(), d.type === "legacy" && (delete d.accessList, delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas, delete d.yParity), d.type === "eip2930" && (delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas), d.type === "eip1559" && delete d.maxFeePerBlobGas, d;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function u(e) {
|
|
42
42
|
return e.map((d) => ({
|
|
43
43
|
contractAddress: d.address,
|
|
44
|
-
r: d.r,
|
|
45
|
-
s: d.s,
|
|
46
44
|
chainId: Number(d.chainId),
|
|
47
45
|
nonce: Number(d.nonce),
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
r: d.r,
|
|
47
|
+
s: d.s,
|
|
48
|
+
yParity: Number(d.yParity)
|
|
50
49
|
}));
|
|
51
50
|
}
|
|
52
51
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
m as formatTransaction,
|
|
53
|
+
r as transactionType
|
|
55
54
|
};
|
package/dist/index3.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>t.startsWith("0x")?t:`0x${t}`,o=t=>`Bearer ${t}`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>t.startsWith("0x")?t:`0x${t}`,o=t=>`Bearer ${t}`,a=t=>new Promise(n=>setTimeout(n,t));var e=(t=>(t.MAINNET="mainnet",t.TESTNET="testnet",t))(e||{}),r=(t=>(t.MAINNET="mainnet",t.TESTNET="testnet",t.LOCALNET="localnet",t))(r||{});exports.Authorization=o;exports.Environment=r;exports.Network=e;exports.sleep=a;exports.with0x=i;
|