@gardenfi/utils 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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: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;
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 p } from "./index29.js";
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: n = 1,
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 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")({
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 = (f) => {
32
- clearTimeout(E), j(), f(), _();
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 (n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
38
+ if (a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a))
39
39
  return;
40
- l(() => e.resolve(r));
40
+ l(() => t.resolve(r));
41
41
  return;
42
42
  }
43
- if (a || (i = !0, await v(async () => {
44
- a = await p(o, J, "getTransaction")({ hash: m }), a.blockNumber && (u = a.blockNumber);
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 p(o, R, "getTransactionReceipt")({ hash: m }), n > 1 && (!r.blockNumber || u - r.blockNumber + 1n < n))
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(() => e.resolve(r));
51
- } catch (f) {
52
- if (f instanceof O || f instanceof W) {
53
- if (!a) {
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
- c = a, i = !0;
59
- const d = await v(() => p(o, H, "getBlock")({
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 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)))
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
- t.to === c.to && t.value === c.value ? T = "repriced" : t.from === t.to && t.value === 0n && (T = "cancelled"), l(() => {
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 = e.onReplaced) == null || s.call(e, {
76
+ (s = t.onReplaced) == null || s.call(t, {
77
77
  reason: T,
78
- replacedTransaction: c,
79
- transaction: t,
78
+ replacedTransaction: n,
79
+ transaction: e,
80
80
  transactionReceipt: r
81
- }), e.resolve(r);
81
+ }), t.resolve(r);
82
82
  });
83
83
  } catch (d) {
84
- l(() => e.reject(d));
84
+ l(() => t.reject(d));
85
85
  }
86
86
  } else
87
- l(() => e.reject(f));
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("./index51.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;
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 { defineChain as e } from "./index51.js";
2
- const t = /* @__PURE__ */ e({
3
- id: 1,
4
- name: "Ethereum",
5
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
6
- rpcUrls: {
7
- default: {
8
- http: ["https://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
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
- t as mainnet
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("./index51.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;
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 "./index51.js";
2
- const s = /* @__PURE__ */ e({
3
- id: 11155111,
4
- name: "Sepolia",
5
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
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://sepolia.drpc.org"]
8
+ http: ["https://eth.merkle.io"]
9
9
  }
10
10
  },
11
11
  blockExplorers: {
12
12
  default: {
13
13
  name: "Etherscan",
14
- url: "https://sepolia.etherscan.io",
15
- apiUrl: "https://api-sepolia.etherscan.io/api"
14
+ url: "https://etherscan.io",
15
+ apiUrl: "https://api.etherscan.io/api"
16
16
  }
17
17
  },
18
18
  contracts: {
19
- multicall3: {
20
- address: "0xca11bde05977b3631167028862be2a173976ca11",
21
- blockCreated: 751532
19
+ ensRegistry: {
20
+ address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
22
21
  },
23
- ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
24
22
  ensUniversalResolver: {
25
- address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
26
- blockCreated: 5317080
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
- s as sepolia
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("./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;
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 { 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}`;
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
- r += t;
109
- }
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+-.]*)$/;
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
- C as createSiweMessage
32
+ s as sepolia
116
33
  };
package/dist/index19.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index24.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;
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 t } from "./index24.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));
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: i,
18
+ transactions: s,
20
19
  totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
21
20
  };
22
21
  }
23
22
  export {
24
- u as formatBlock
23
+ a as formatBlock
25
24
  };
package/dist/index30.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=new Map,i=new Map;let w=0;function M(e,l,C){const u=++w,n=()=>s.get(e)||[],y=()=>{const t=n();s.set(e,t.filter(o=>o.id!==u))},a=()=>{const t=i.get(e);n().length===1&&t&&t(),y()},c=n();if(s.set(e,[...c,{id:u,fns:l}]),c&&c.length>0)return a;const r={};for(const t in l)r[t]=(...o)=>{var h,p;const g=n();if(g.length!==0)for(const b of g)(p=(h=b.fns)[t])==null||p.call(h,...o)};const f=C(r);return typeof f=="function"&&i.set(e,f),a}exports.cleanupCache=i;exports.listenersCache=s;exports.observe=M;
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 o = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
2
- let y = 0;
3
- function M(t, i, w) {
4
- const l = ++y, e = () => o.get(t) || [], C = () => {
5
- const n = e();
6
- o.set(t, n.filter((c) => c.id !== l));
7
- }, f = () => {
8
- const n = h.get(t);
9
- e().length === 1 && n && n(), C();
10
- }, s = e();
11
- if (o.set(t, [
12
- ...s,
13
- { id: l, fns: i }
14
- ]), s && s.length > 0)
15
- return f;
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 i)
18
- u[n] = (...c) => {
20
+ for (const n in f)
21
+ u[n] = (...t) => {
19
22
  var p, g;
20
- const r = e();
21
- if (r.length !== 0)
22
- for (const k of r)
23
- (g = (p = k.fns)[n]) == null || g.call(p, ...c);
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(t, a), f;
29
+ return typeof a == "function" && h.set(e, a), r;
27
30
  }
28
31
  export {
29
32
  h as cleanupCache,
30
- o as listenersCache,
31
- M as observe
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("./index52.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;
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
@@ -1,4 +1,4 @@
1
- import { SizeExceedsPaddingSizeError as d } from "./index52.js";
1
+ import { SizeExceedsPaddingSizeError as d } from "./index51.js";
2
2
  function f(n, { dir: r, size: t = 32 } = {}) {
3
3
  return typeof n == "string" ? p(n, { dir: r, size: t }) : i(n, { dir: r, size: t });
4
4
  }
package/dist/index38.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.21.41";exports.version=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.22.23";exports.version=e;
package/dist/index38.js CHANGED
@@ -1,4 +1,4 @@
1
- const o = "2.21.41";
1
+ const o = "2.22.23";
2
2
  export {
3
3
  o as version
4
4
  };
package/dist/index51.cjs CHANGED
@@ -1 +1 @@
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;
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
- function n(e) {
2
- return {
3
- formatters: void 0,
4
- fees: void 0,
5
- serializers: void 0,
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
- n as defineChain
8
+ a as SizeExceedsPaddingSizeError
11
9
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
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;
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
- 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
- }
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
- a as SizeExceedsPaddingSizeError
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"),a=require("./index55.cjs"),c=require("./index56.cjs"),I=[],O=[],w=[],B=BigInt(0),f=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=f,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<<f^(t>>S)*T)%H,t&A&&(o^=f<<(f<<BigInt(r))-f);w.push(o)}const[m,E]=a.split(w,!0),y=(i,t,s)=>s>32?a.rotlBH(i,t,s):a.rotlSH(i,t,s),b=(i,t,s)=>s>32?a.rotlBL(i,t,s):a.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.number(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.exists(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.exists(this,!1),l.bytes(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.number(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.output(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;
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 { number as d, exists as k, bytes as B, output as A } from "./index54.js";
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 i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function n(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function o(e,...t){if(!n(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of 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 u(e,t){o(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}exports.bytes=o;exports.exists=s;exports.isBytes=n;exports.number=i;exports.output=u;
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(`positive integer expected, not ${e}`);
3
+ throw new Error("positive integer expected, got " + e);
4
4
  }
5
5
  function n(e) {
6
- return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
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(`Uint8Array expected of length ${t}, not of length=${e.length}`);
12
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
13
13
  }
14
- function f(e, t = !0) {
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 s(e, t) {
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(`digestInto() expects output buffer of length at least ${r}`);
24
+ throw new Error("digestInto() expects output buffer of length at least " + r);
25
25
  }
26
26
  export {
27
- o as bytes,
28
- f as exists,
29
- n as isBytes,
30
- i as number,
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 s=require("./index54.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const c=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),i=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,o=t=>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 f(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function r(t){return typeof t=="string"&&(t=f(t)),s.bytes(t),t}class p{clone(){return this._cloneInto()}}function b(t){const e=u=>t().update(r(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=i;exports.toBytes=r;exports.u32=c;exports.utf8ToBytes=f;exports.wrapConstructor=b;
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 { bytes as f } from "./index54.js";
1
+ import { abytes as o } from "./index54.js";
2
2
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
- const s = (t) => new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4)), y = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, r = (t) => t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
4
- function p(t) {
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 c(t) {
14
+ function u(t) {
9
15
  if (typeof t != "string")
10
- throw new Error(`utf8ToBytes expected string, got ${typeof t}`);
16
+ throw new Error("utf8ToBytes expected string, got " + typeof t);
11
17
  return new Uint8Array(new TextEncoder().encode(t));
12
18
  }
13
- function u(t) {
14
- return typeof t == "string" && (t = c(t)), f(t), 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 = (o) => t().update(u(o)).digest(), n = t();
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
- p as byteSwap32,
30
- y as isLE,
31
- u as toBytes,
32
- s as u32,
33
- c as utf8ToBytes,
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("./index15.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.address.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index11.cjs"),d=require("./index7.cjs"),h=require("./index8.cjs"),w=require("jwt-decode"),f=require("./index3.cjs"),g=require("./index5.cjs"),y=require("./index13.cjs");class m{constructor(r,i,e){this.API="https://api.garden.finance",this.url=new g.Url("/",r??this.API),this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??new d.MemoryStorage}verifyToken(r,i){try{const e=u(r);if(!e)return t.Ok(!1);const n=Math.floor(Date.now()/1e3)+120;if(!e.address&&!e.user_id)return t.Ok(!1);const a=e.address?e.address.toLowerCase()===i.toLowerCase():!1,s=e.user_id?e.user_id.toLowerCase()===i.toLowerCase():!1;return t.Ok(e.exp>n&&a||s)}catch{return t.Ok(!1)}}async getToken(){var s;if(!((s=this.walletClient.account)!=null&&s.address))return t.Err("Wallet client does not have an account");const r=this.store.getItem(h.StoreKeys.AUTH_TOKEN);if(r){const o=this.verifyToken(r,this.walletClient.account.address);if(o.ok&&o.val)return t.Ok(r)}const i=await this.signStatement();if(i.error)return t.Err(i.error);const e=await t.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"}});if(e.error)return t.Err(e.error);const n=e.result;if(!n)return t.Err("Failed to get token");if(!this.verifyToken(n,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(h.StoreKeys.AUTH_TOKEN,n),t.Ok(n)}async signStatement(){var l;if(!((l=this.walletClient.account)!=null&&l.address))return t.Err("Wallet client does not have a valid account");const r=new Date,i=new Date(r.getTime()+300*1e3),n=(await t.Fetcher.get(this.url.endpoint("nonce"))).result;if(!n)return t.Err("Failed to get nonce");const a=await this.walletClient.getChainId(),s=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:n,uri:"https://"+this.domain,version:"1",chainId:a,notBefore:i}),o=await this.walletClient.signMessage({account:this.walletClient.account,message:s});return t.Ok({message:s,signature:o,nonce:n})}}const u=c=>{try{return w.jwtDecode(c)}catch{return}};class k{constructor(r){if(!r.siwe&&!r.apiKey)throw new Error("Either siwe or apiKey must be provided");this.siwe=r.siwe,this.apiKey=r.apiKey}async getAuthHeaders(){if(this.siwe){const r=await this.siwe.getToken();return r.error?t.Err(r.error):t.Ok({Authorization:f.Authorization(r.val)})}return this.apiKey?t.Ok({"api-key":this.apiKey}):t.Err("No authentication method available")}}exports.Auth=k;exports.Siwe=m;exports.parseJwt=u;
package/dist/index6.js CHANGED
@@ -1,107 +1,107 @@
1
- import { Ok as n, Err as a, Fetcher as d } from "./index11.js";
1
+ import { Ok as n, Err as s, Fetcher as d } from "./index11.js";
2
2
  import { MemoryStorage as f } from "./index7.js";
3
3
  import { StoreKeys as u } from "./index8.js";
4
- import { jwtDecode as m } from "jwt-decode";
5
- import { Authorization as w } from "./index3.js";
4
+ import { jwtDecode as w } from "jwt-decode";
5
+ import { Authorization as m } from "./index3.js";
6
6
  import { Url as g } from "./index5.js";
7
- import { createSiweMessage as y } from "./index15.js";
7
+ import { createSiweMessage as y } from "./index13.js";
8
8
  class I {
9
- constructor(e, r, t) {
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();
9
+ constructor(t, i, e) {
10
+ this.API = "https://api.garden.finance", this.url = new g("/", t ?? this.API), this.walletClient = i, this.domain = (e == null ? void 0 : e.domain) || "app.garden.finance", this.domain.startsWith("https://") && (this.domain = this.domain.split("https://")[1]), this.signingStatement = (e == null ? void 0 : e.signingStatement) ?? "Garden.fi", this.store = (e == null ? void 0 : e.store) ?? new f();
11
11
  }
12
- verifyToken(e, r) {
12
+ verifyToken(t, i) {
13
13
  try {
14
- const t = p(e);
15
- if (!t) return n(!1);
16
- const i = Math.floor(Date.now() / 1e3) + 120;
17
- return n(
18
- t.exp > i && t.address.toLowerCase() === r.toLowerCase()
19
- );
14
+ const e = p(t);
15
+ if (!e) return n(!1);
16
+ const r = Math.floor(Date.now() / 1e3) + 120;
17
+ if (!e.address && !e.user_id) return n(!1);
18
+ const o = e.address ? e.address.toLowerCase() === i.toLowerCase() : !1, a = e.user_id ? e.user_id.toLowerCase() === i.toLowerCase() : !1;
19
+ return n(e.exp > r && o || a);
20
20
  } catch {
21
21
  return n(!1);
22
22
  }
23
23
  }
24
24
  async getToken() {
25
- var s;
26
- if (!((s = this.walletClient.account) != null && s.address))
27
- return a("Wallet client does not have an account");
28
- const e = this.store.getItem(u.AUTH_TOKEN);
29
- if (e) {
30
- const o = this.verifyToken(
31
- e,
25
+ var a;
26
+ if (!((a = this.walletClient.account) != null && a.address))
27
+ return s("Wallet client does not have an account");
28
+ const t = this.store.getItem(u.AUTH_TOKEN);
29
+ if (t) {
30
+ const c = this.verifyToken(
31
+ t,
32
32
  this.walletClient.account.address
33
33
  );
34
- if (o.ok && o.val) return n(e);
34
+ if (c.ok && c.val) return n(t);
35
35
  }
36
- const r = await this.signStatement();
37
- if (r.error)
38
- return a(r.error);
39
- const t = await d.post(
36
+ const i = await this.signStatement();
37
+ if (i.error)
38
+ return s(i.error);
39
+ const e = await d.post(
40
40
  this.url.endpoint("verify"),
41
41
  {
42
42
  body: JSON.stringify({
43
- ...r.val
43
+ ...i.val
44
44
  }),
45
45
  headers: {
46
46
  "Content-Type": "application/json"
47
47
  }
48
48
  }
49
49
  );
50
- if (t.error) return a(t.error);
51
- const i = t.result;
52
- if (!i) return a("Failed to get token");
53
- if (!this.verifyToken(i, this.walletClient.account.address).val)
50
+ if (e.error) return s(e.error);
51
+ const r = e.result;
52
+ if (!r) return s("Failed to get token");
53
+ if (!this.verifyToken(r, this.walletClient.account.address).val)
54
54
  throw new Error("Token verification failed");
55
- return this.store.setItem(u.AUTH_TOKEN, i), n(i);
55
+ return this.store.setItem(u.AUTH_TOKEN, r), n(r);
56
56
  }
57
57
  async signStatement() {
58
58
  var l;
59
59
  if (!((l = this.walletClient.account) != null && l.address))
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 d.get(
60
+ return s("Wallet client does not have a valid account");
61
+ const t = /* @__PURE__ */ new Date(), i = new Date(t.getTime() + 300 * 1e3), r = (await d.get(
62
62
  this.url.endpoint("nonce")
63
63
  )).result;
64
- if (!i)
65
- return a("Failed to get nonce");
66
- const h = await this.walletClient.getChainId(), s = y({
64
+ if (!r)
65
+ return s("Failed to get nonce");
66
+ const o = await this.walletClient.getChainId(), a = y({
67
67
  domain: this.domain,
68
68
  address: this.walletClient.account.address,
69
69
  statement: this.signingStatement,
70
- nonce: i,
70
+ nonce: r,
71
71
  uri: "https://" + this.domain,
72
72
  version: "1",
73
- chainId: h,
74
- notBefore: r
75
- }), o = await this.walletClient.signMessage({
73
+ chainId: o,
74
+ notBefore: i
75
+ }), c = await this.walletClient.signMessage({
76
76
  account: this.walletClient.account,
77
- message: s
77
+ message: a
78
78
  });
79
79
  return n({
80
- message: s,
81
- signature: o,
82
- nonce: i
80
+ message: a,
81
+ signature: c,
82
+ nonce: r
83
83
  });
84
84
  }
85
85
  }
86
- const p = (c) => {
86
+ const p = (h) => {
87
87
  try {
88
- return m(c);
88
+ return w(h);
89
89
  } catch {
90
90
  return;
91
91
  }
92
92
  };
93
93
  class E {
94
- constructor(e) {
95
- if (!e.siwe && !e.apiKey)
94
+ constructor(t) {
95
+ if (!t.siwe && !t.apiKey)
96
96
  throw new Error("Either siwe or apiKey must be provided");
97
- this.siwe = e.siwe, this.apiKey = e.apiKey;
97
+ this.siwe = t.siwe, this.apiKey = t.apiKey;
98
98
  }
99
99
  async getAuthHeaders() {
100
100
  if (this.siwe) {
101
- const e = await this.siwe.getToken();
102
- return e.error ? a(e.error) : n({ Authorization: w(e.val) });
101
+ const t = await this.siwe.getToken();
102
+ return t.error ? s(t.error) : n({ Authorization: m(t.val) });
103
103
  }
104
- return this.apiKey ? n({ "api-key": this.apiKey }) : a("No authentication method available");
104
+ return this.apiKey ? n({ "api-key": this.apiKey }) : s("No authentication method available");
105
105
  }
106
106
  }
107
107
  export {
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("./index13.cjs"),l=require("./index14.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;
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 "./index13.js";
4
- import { sepolia as b } from "./index14.js";
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
@@ -16,7 +16,8 @@ export declare class Siwe implements ISiwe {
16
16
  private signStatement;
17
17
  }
18
18
  export declare const parseJwt: (token: string) => {
19
- address: string;
19
+ user_id?: string;
20
+ address?: string;
20
21
  exp: number;
21
22
  } | undefined;
22
23
  export declare class Auth implements IAuth {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
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.15"
39
+ "viem": "^2.21.23"
40
40
  }
41
41
  }