@gardenfi/utils 2.0.5 → 2.0.6

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.
Files changed (103) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +127 -6
  3. package/dist/index101.cjs +1 -2
  4. package/dist/index101.js +113 -3
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +75 -109
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +2 -79
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +18 -2
  11. package/dist/index105.cjs +1 -1
  12. package/dist/index105.js +15 -14
  13. package/dist/index106.cjs +1 -1
  14. package/dist/index106.js +16 -18
  15. package/dist/index107.cjs +1 -1
  16. package/dist/index107.js +220 -13
  17. package/dist/index108.cjs +2 -1
  18. package/dist/index108.js +3 -224
  19. package/dist/index115.cjs +1 -1
  20. package/dist/index115.js +1 -1
  21. package/dist/index117.cjs +1 -1
  22. package/dist/index117.js +1 -1
  23. package/dist/index18.cjs +1 -1
  24. package/dist/index18.js +8 -8
  25. package/dist/index19.cjs +1 -1
  26. package/dist/index19.js +1 -1
  27. package/dist/index21.cjs +1 -1
  28. package/dist/index21.js +1 -1
  29. package/dist/index37.cjs +1 -1
  30. package/dist/index37.js +1 -1
  31. package/dist/index40.cjs +1 -1
  32. package/dist/index40.js +1 -1
  33. package/dist/index42.cjs +1 -1
  34. package/dist/index42.js +1 -1
  35. package/dist/index47.cjs +1 -1
  36. package/dist/index47.js +1 -1
  37. package/dist/index50.cjs +2 -1
  38. package/dist/index50.js +34 -3
  39. package/dist/index51.cjs +1 -2
  40. package/dist/index51.js +5 -34
  41. package/dist/index52.cjs +1 -1
  42. package/dist/index52.js +3 -5
  43. package/dist/index55.cjs +1 -1
  44. package/dist/index55.js +1 -1
  45. package/dist/index56.cjs +1 -1
  46. package/dist/index56.js +2 -2
  47. package/dist/index62.cjs +1 -1
  48. package/dist/index62.js +1 -1
  49. package/dist/index64.cjs +1 -1
  50. package/dist/index64.js +3 -3
  51. package/dist/index69.cjs +1 -1
  52. package/dist/index69.js +3 -5
  53. package/dist/index70.cjs +1 -1
  54. package/dist/index70.js +13 -8
  55. package/dist/index71.cjs +1 -1
  56. package/dist/index71.js +41 -3
  57. package/dist/index72.cjs +1 -1
  58. package/dist/index72.js +5 -13
  59. package/dist/index73.cjs +1 -1
  60. package/dist/index73.js +8 -41
  61. package/dist/index75.cjs +1 -1
  62. package/dist/index75.js +1 -1
  63. package/dist/index79.cjs +1 -1
  64. package/dist/index79.js +11 -24
  65. package/dist/index80.cjs +1 -1
  66. package/dist/index80.js +25 -6
  67. package/dist/index81.cjs +1 -1
  68. package/dist/index81.js +6 -13
  69. package/dist/index82.cjs +1 -1
  70. package/dist/index82.js +13 -15
  71. package/dist/index83.cjs +1 -1
  72. package/dist/index83.js +15 -5
  73. package/dist/index84.cjs +1 -1
  74. package/dist/index84.js +5 -13
  75. package/dist/index85.cjs +1 -1
  76. package/dist/index85.js +12 -9
  77. package/dist/index86.cjs +1 -1
  78. package/dist/index86.js +10 -16
  79. package/dist/index87.cjs +1 -1
  80. package/dist/index87.js +15 -170
  81. package/dist/index88.cjs +1 -1
  82. package/dist/index88.js +171 -8
  83. package/dist/index89.cjs +1 -1
  84. package/dist/index89.js +37 -11
  85. package/dist/index90.cjs +1 -1
  86. package/dist/index90.js +8 -104
  87. package/dist/index91.cjs +1 -1
  88. package/dist/index91.js +5 -39
  89. package/dist/index92.cjs +1 -1
  90. package/dist/index92.js +11 -2
  91. package/dist/index93.cjs +1 -1
  92. package/dist/index93.js +2 -5
  93. package/dist/index94.cjs +1 -1
  94. package/dist/index94.js +104 -10
  95. package/dist/index95.cjs +1 -1
  96. package/dist/index95.js +1 -1
  97. package/dist/index97.cjs +1 -1
  98. package/dist/index97.js +7 -5
  99. package/dist/index98.cjs +1 -1
  100. package/dist/index98.js +5 -38
  101. package/dist/index99.cjs +1 -1
  102. package/dist/index99.js +36 -126
  103. package/package.json +1 -1
package/dist/index80.js CHANGED
@@ -1,9 +1,28 @@
1
- import { checksumAddress as e } from "./index53.js";
2
- import { keccak256 as o } from "./index56.js";
3
- function d(r) {
4
- const s = o(`0x${r.substring(4)}`).substring(26);
5
- return e(`0x${s}`);
1
+ import { InvalidAddressError as s } from "./index54.js";
2
+ import { isAddress as a } from "./index58.js";
3
+ function e(n) {
4
+ if (typeof n == "string") {
5
+ if (!a(n, { strict: !1 }))
6
+ throw new s({ address: n });
7
+ return {
8
+ address: n,
9
+ type: "json-rpc"
10
+ };
11
+ }
12
+ if (!a(n.address, { strict: !1 }))
13
+ throw new s({ address: n.address });
14
+ return {
15
+ address: n.address,
16
+ nonceManager: n.nonceManager,
17
+ sign: n.sign,
18
+ experimental_signAuthorization: n.experimental_signAuthorization,
19
+ signMessage: n.signMessage,
20
+ signTransaction: n.signTransaction,
21
+ signTypedData: n.signTypedData,
22
+ source: "custom",
23
+ type: "local"
24
+ };
6
25
  }
7
26
  export {
8
- d as publicKeyToAddress
27
+ e as toAccount
9
28
  };
package/dist/index81.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index73.cjs"),s=require("./index24.cjs"),a=require("./index72.cjs");let l=!1;async function g({hash:t,privateKey:i,to:e="object"}){const{r:u,s:c,recovery:r}=o.secp256k1.sign(t.slice(2),i.slice(2),{lowS:!0,extraEntropy:l}),n={r:s.numberToHex(u,{size:32}),s:s.numberToHex(c,{size:32}),v:r?28n:27n,yParity:r};return e==="bytes"||e==="hex"?a.serializeSignature({...n,to:e}):n}exports.sign=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index53.cjs"),c=require("./index56.cjs");function t(e){const s=c.keccak256(`0x${e.substring(4)}`).substring(26);return r.checksumAddress(`0x${s}`)}exports.publicKeyToAddress=t;
package/dist/index81.js CHANGED
@@ -1,16 +1,9 @@
1
- import { secp256k1 as u } from "./index73.js";
2
- import { numberToHex as i } from "./index24.js";
3
- import { serializeSignature as a } from "./index72.js";
4
- let m = !1;
5
- async function y({ hash: n, privateKey: s, to: r = "object" }) {
6
- const { r: o, s: c, recovery: e } = u.sign(n.slice(2), s.slice(2), { lowS: !0, extraEntropy: m }), t = {
7
- r: i(o, { size: 32 }),
8
- s: i(c, { size: 32 }),
9
- v: e ? 28n : 27n,
10
- yParity: e
11
- };
12
- return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
1
+ import { checksumAddress as e } from "./index53.js";
2
+ import { keccak256 as o } from "./index56.js";
3
+ function d(r) {
4
+ const s = o(`0x${r.substring(4)}`).substring(26);
5
+ return e(`0x${s}`);
13
6
  }
14
7
  export {
15
- y as sign
8
+ d as publicKeyToAddress
16
9
  };
package/dist/index82.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index86.cjs"),c=require("./index81.cjs");async function u(r){const{contractAddress:t,chainId:e,nonce:n,privateKey:a,to:i="object"}=r,o=await c.sign({hash:s.hashAuthorization({contractAddress:t,chainId:e,nonce:n}),privateKey:a,to:i});return i==="object"?{contractAddress:t,chainId:e,nonce:n,...o}:o}exports.experimental_signAuthorization=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index71.cjs"),s=require("./index24.cjs"),a=require("./index70.cjs");let l=!1;async function g({hash:t,privateKey:i,to:e="object"}){const{r:u,s:c,recovery:r}=o.secp256k1.sign(t.slice(2),i.slice(2),{lowS:!0,extraEntropy:l}),n={r:s.numberToHex(u,{size:32}),s:s.numberToHex(c,{size:32}),v:r?28n:27n,yParity:r};return e==="bytes"||e==="hex"?a.serializeSignature({...n,to:e}):n}exports.sign=g;
package/dist/index82.js CHANGED
@@ -1,18 +1,16 @@
1
- import { hashAuthorization as c } from "./index86.js";
2
- import { sign as s } from "./index81.js";
3
- async function m(e) {
4
- const { contractAddress: t, chainId: n, nonce: o, privateKey: a, to: r = "object" } = e, i = await s({
5
- hash: c({ contractAddress: t, chainId: n, nonce: o }),
6
- privateKey: a,
7
- to: r
8
- });
9
- return r === "object" ? {
10
- contractAddress: t,
11
- chainId: n,
12
- nonce: o,
13
- ...i
14
- } : i;
1
+ import { secp256k1 as u } from "./index71.js";
2
+ import { numberToHex as i } from "./index24.js";
3
+ import { serializeSignature as a } from "./index70.js";
4
+ let m = !1;
5
+ async function y({ hash: n, privateKey: s, to: r = "object" }) {
6
+ const { r: o, s: c, recovery: e } = u.sign(n.slice(2), s.slice(2), { lowS: !0, extraEntropy: m }), t = {
7
+ r: i(o, { size: 32 }),
8
+ s: i(c, { size: 32 }),
9
+ v: e ? 28n : 27n,
10
+ yParity: e
11
+ };
12
+ return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
15
13
  }
16
14
  export {
17
- m as experimental_signAuthorization
15
+ y as sign
18
16
  };
package/dist/index83.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index69.cjs"),n=require("./index81.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index87.cjs"),c=require("./index82.cjs");async function u(r){const{contractAddress:t,chainId:e,nonce:n,privateKey:a,to:i="object"}=r,o=await c.sign({hash:s.hashAuthorization({contractAddress:t,chainId:e,nonce:n}),privateKey:a,to:i});return i==="object"?{contractAddress:t,chainId:e,nonce:n,...o}:o}exports.experimental_signAuthorization=u;
package/dist/index83.js CHANGED
@@ -1,8 +1,18 @@
1
- import { hashMessage as e } from "./index69.js";
2
- import { sign as o } from "./index81.js";
3
- async function i({ message: s, privateKey: a }) {
4
- return await o({ hash: e(s), privateKey: a, to: "hex" });
1
+ import { hashAuthorization as c } from "./index87.js";
2
+ import { sign as s } from "./index82.js";
3
+ async function m(e) {
4
+ const { contractAddress: t, chainId: n, nonce: o, privateKey: a, to: r = "object" } = e, i = await s({
5
+ hash: c({ contractAddress: t, chainId: n, nonce: o }),
6
+ privateKey: a,
7
+ to: r
8
+ });
9
+ return r === "object" ? {
10
+ contractAddress: t,
11
+ chainId: n,
12
+ nonce: o,
13
+ ...i
14
+ } : i;
5
15
  }
6
16
  export {
7
- i as signMessage
17
+ m as experimental_signAuthorization
8
18
  };
package/dist/index84.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index87.cjs"),o=require("./index81.cjs");async function u(i){const{privateKey:r,transaction:e,serializer:n=c.serializeTransaction}=i,a=e.type==="eip4844"?{...e,sidecars:!1}:e,s=await o.sign({hash:t.keccak256(n(a)),privateKey:r});return n(e,s)}exports.signTransaction=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index72.cjs"),n=require("./index82.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
package/dist/index84.js CHANGED
@@ -1,16 +1,8 @@
1
- import { keccak256 as e } from "./index56.js";
2
- import { serializeTransaction as o } from "./index87.js";
3
- import { sign as c } from "./index81.js";
4
- async function u(n) {
5
- const { privateKey: a, transaction: r, serializer: i = o } = n, t = r.type === "eip4844" ? {
6
- ...r,
7
- sidecars: !1
8
- } : r, s = await c({
9
- hash: e(i(t)),
10
- privateKey: a
11
- });
12
- return i(r, s);
1
+ import { hashMessage as e } from "./index72.js";
2
+ import { sign as o } from "./index82.js";
3
+ async function i({ message: s, privateKey: a }) {
4
+ return await o({ hash: e(s), privateKey: a, to: "hex" });
13
5
  }
14
6
  export {
15
- u as signTransaction
7
+ i as signMessage
16
8
  };
package/dist/index85.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index74.cjs"),s=require("./index81.cjs");async function i(e){const{privateKey:t,...a}=e;return await s.sign({hash:n.hashTypedData(a),privateKey:t,to:"hex"})}exports.signTypedData=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index88.cjs"),o=require("./index82.cjs");async function u(i){const{privateKey:r,transaction:e,serializer:n=c.serializeTransaction}=i,a=e.type==="eip4844"?{...e,sidecars:!1}:e,s=await o.sign({hash:t.keccak256(n(a)),privateKey:r});return n(e,s)}exports.signTransaction=u;
package/dist/index85.js CHANGED
@@ -1,13 +1,16 @@
1
- import { hashTypedData as o } from "./index74.js";
2
- import { sign as r } from "./index81.js";
3
- async function p(t) {
4
- const { privateKey: a, ...e } = t;
5
- return await r({
6
- hash: o(e),
7
- privateKey: a,
8
- to: "hex"
1
+ import { keccak256 as e } from "./index56.js";
2
+ import { serializeTransaction as o } from "./index88.js";
3
+ import { sign as c } from "./index82.js";
4
+ async function u(n) {
5
+ const { privateKey: a, transaction: r, serializer: i = o } = n, t = r.type === "eip4844" ? {
6
+ ...r,
7
+ sidecars: !1
8
+ } : r, s = await c({
9
+ hash: e(i(t)),
10
+ privateKey: a
9
11
  });
12
+ return i(r, s);
10
13
  }
11
14
  export {
12
- p as signTypedData
15
+ u as signTransaction
13
16
  };
package/dist/index86.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index76.cjs"),u=require("./index55.cjs"),r=require("./index24.cjs"),a=require("./index95.cjs"),h=require("./index56.cjs");function x(n){const{chainId:e,contractAddress:c,nonce:t,to:s}=n,o=h.keccak256(i.concatHex(["0x05",a.toRlp([e?r.numberToHex(e):"0x",c,t?r.numberToHex(t):"0x"])]));return s==="bytes"?u.hexToBytes(o):o}exports.hashAuthorization=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index74.cjs"),s=require("./index82.cjs");async function i(e){const{privateKey:t,...a}=e;return await s.sign({hash:n.hashTypedData(a),privateKey:t,to:"hex"})}exports.signTypedData=i;
package/dist/index86.js CHANGED
@@ -1,19 +1,13 @@
1
- import { concatHex as i } from "./index76.js";
2
- import { hexToBytes as s } from "./index55.js";
3
- import { numberToHex as n } from "./index24.js";
4
- import { toRlp as a } from "./index95.js";
5
- import { keccak256 as f } from "./index56.js";
6
- function b(e) {
7
- const { chainId: o, contractAddress: c, nonce: t, to: m } = e, r = f(i([
8
- "0x05",
9
- a([
10
- o ? n(o) : "0x",
11
- c,
12
- t ? n(t) : "0x"
13
- ])
14
- ]));
15
- return m === "bytes" ? s(r) : r;
1
+ import { hashTypedData as o } from "./index74.js";
2
+ import { sign as r } from "./index82.js";
3
+ async function p(t) {
4
+ const { privateKey: a, ...e } = t;
5
+ return await r({
6
+ hash: o(e),
7
+ privateKey: a,
8
+ to: "hex"
9
+ });
16
10
  }
17
11
  export {
18
- b as hashAuthorization
12
+ p as signTypedData
19
13
  };
package/dist/index87.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index29.cjs"),G=require("./index59.cjs"),R=require("./index60.cjs"),S=require("./index61.cjs"),B=require("./index63.cjs"),L=require("./index76.cjs"),h=require("./index46.cjs"),t=require("./index24.cjs"),b=require("./index95.cjs"),V=require("./index105.cjs"),z=require("./index103.cjs"),C=require("./index65.cjs"),v=require("./index106.cjs");function k(e,o){const s=C.getTransactionType(e);return s==="eip1559"?_(e,o):s==="eip2930"?j(e,o):s==="eip4844"?Y(e,o):s==="eip7702"?w(e,o):M(e,o)}function w(e,o){const{authorizationList:s,chainId:i,gas:r,nonce:c,to:a,value:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP7702(e);const f=v.serializeAccessList(H),u=V.serializeAuthorizationList(s);return L.concatHex(["0x04",b.toRlp([t.toHex(i),c?t.toHex(c):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",r?t.toHex(r):"0x",a??"0x",x?t.toHex(x):"0x",d??"0x",f,u,...T(e,o)])])}function Y(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerBlobGas:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP4844(e);let f=e.blobVersionedHashes,u=e.sidecars;if(e.blobs&&(typeof f>"u"||typeof u>"u")){const m=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(y=>t.bytesToHex(y)),P=e.kzg,p=G.blobsToCommitments({blobs:m,kzg:P});if(typeof f>"u"&&(f=S.commitmentsToVersionedHashes({commitments:p})),typeof u>"u"){const y=R.blobsToProofs({blobs:m,commitments:p,kzg:P});u=B.toBlobSidecars({blobs:m,commitments:p,proofs:y})}}const I=v.serializeAccessList(H),A=[t.toHex(s),r?t.toHex(r):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",d??"0x",I,x?t.toHex(x):"0x",f??[],...T(e,o)],q=[],g=[],E=[];if(u)for(let m=0;m<u.length;m++){const{blob:P,commitment:p,proof:y}=u[m];q.push(P),g.push(p),E.push(y)}return L.concatHex(["0x03",u?b.toRlp([A,q,g,E]):b.toRlp(A)])}function _(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerGas:x,maxPriorityFeePerGas:l,accessList:n,data:H}=e;z.assertTransactionEIP1559(e);const d=v.serializeAccessList(n),f=[t.toHex(s),r?t.toHex(r):"0x",l?t.toHex(l):"0x",x?t.toHex(x):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",H??"0x",d,...T(e,o)];return L.concatHex(["0x02",b.toRlp(f)])}function j(e,o){const{chainId:s,gas:i,data:r,nonce:c,to:a,value:x,accessList:l,gasPrice:n}=e;z.assertTransactionEIP2930(e);const H=v.serializeAccessList(l),d=[t.toHex(s),c?t.toHex(c):"0x",n?t.toHex(n):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x",H,...T(e,o)];return L.concatHex(["0x01",b.toRlp(d)])}function M(e,o){const{chainId:s=0,gas:i,data:r,nonce:c,to:a,value:x,gasPrice:l}=e;z.assertTransactionLegacy(e);let n=[c?t.toHex(c):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x"];if(o){const H=(()=>{if(o.v>=35n)return(o.v-35n)/2n>0?o.v:27n+(o.v===35n?0n:1n);if(s>0)return BigInt(s*2)+BigInt(35n+o.v-27n);const u=27n+(o.v===27n?0n:1n);if(o.v!==u)throw new F.InvalidLegacyVError({v:o.v});return u})(),d=h.trim(o.r),f=h.trim(o.s);n=[...n,t.toHex(H),d==="0x00"?"0x":d,f==="0x00"?"0x":f]}else s>0&&(n=[...n,t.toHex(s),"0x","0x"]);return b.toRlp(n)}function T(e,o){const s=o??e,{v:i,yParity:r}=s;if(typeof s.r>"u")return[];if(typeof s.s>"u")return[];if(typeof i>"u"&&typeof r>"u")return[];const c=h.trim(s.r),a=h.trim(s.s);return[typeof r=="number"?r?t.toHex(1):"0x":i===0n?"0x":i===1n?t.toHex(1):i===27n?"0x":t.toHex(1),c==="0x00"?"0x":c,a==="0x00"?"0x":a]}exports.serializeTransaction=k;exports.toYParitySignatureArray=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index76.cjs"),u=require("./index55.cjs"),r=require("./index24.cjs"),a=require("./index95.cjs"),h=require("./index56.cjs");function x(n){const{chainId:e,contractAddress:c,nonce:t,to:s}=n,o=h.keccak256(i.concatHex(["0x05",a.toRlp([e?r.numberToHex(e):"0x",c,t?r.numberToHex(t):"0x"])]));return s==="bytes"?u.hexToBytes(o):o}exports.hashAuthorization=x;
package/dist/index87.js CHANGED
@@ -1,174 +1,19 @@
1
- import { InvalidLegacyVError as H } from "./index29.js";
2
- import { blobsToCommitments as g } from "./index59.js";
3
- import { blobsToProofs as B } from "./index60.js";
4
- import { commitmentsToVersionedHashes as V } from "./index61.js";
5
- import { toBlobSidecars as C } from "./index63.js";
6
- import { concatHex as h } from "./index76.js";
7
- import { trim as T } from "./index46.js";
8
- import { toHex as o, bytesToHex as k } from "./index24.js";
9
- import { toRlp as y } from "./index95.js";
10
- import { serializeAuthorizationList as w } from "./index105.js";
11
- import { assertTransactionEIP7702 as S, assertTransactionEIP4844 as _, assertTransactionEIP1559 as R, assertTransactionEIP2930 as Y, assertTransactionLegacy as j } from "./index103.js";
12
- import { getTransactionType as q } from "./index65.js";
13
- import { serializeAccessList as v } from "./index106.js";
14
- function te(e, r) {
15
- const i = q(e);
16
- return i === "eip1559" ? K(e, r) : i === "eip2930" ? M(e, r) : i === "eip4844" ? J(e, r) : i === "eip7702" ? D(e, r) : N(e, r);
17
- }
18
- function D(e, r) {
19
- const { authorizationList: i, chainId: s, gas: n, nonce: c, to: f, value: a, maxFeePerGas: x, maxPriorityFeePerGas: t, accessList: p, data: l } = e;
20
- S(e);
21
- const d = v(p), m = w(i);
22
- return h([
23
- "0x04",
24
- y([
25
- o(s),
26
- c ? o(c) : "0x",
27
- t ? o(t) : "0x",
28
- x ? o(x) : "0x",
29
- n ? o(n) : "0x",
30
- f ?? "0x",
31
- a ? o(a) : "0x",
32
- l ?? "0x",
33
- d,
34
- m,
35
- ...I(e, r)
1
+ import { concatHex as i } from "./index76.js";
2
+ import { hexToBytes as s } from "./index55.js";
3
+ import { numberToHex as n } from "./index24.js";
4
+ import { toRlp as a } from "./index95.js";
5
+ import { keccak256 as f } from "./index56.js";
6
+ function b(e) {
7
+ const { chainId: o, contractAddress: c, nonce: t, to: m } = e, r = f(i([
8
+ "0x05",
9
+ a([
10
+ o ? n(o) : "0x",
11
+ c,
12
+ t ? n(t) : "0x"
36
13
  ])
37
- ]);
38
- }
39
- function J(e, r) {
40
- const { chainId: i, gas: s, nonce: n, to: c, value: f, maxFeePerBlobGas: a, maxFeePerGas: x, maxPriorityFeePerGas: t, accessList: p, data: l } = e;
41
- _(e);
42
- let d = e.blobVersionedHashes, m = e.sidecars;
43
- if (e.blobs && (typeof d > "u" || typeof m > "u")) {
44
- const u = typeof e.blobs[0] == "string" ? e.blobs : e.blobs.map((P) => k(P)), z = e.kzg, b = g({
45
- blobs: u,
46
- kzg: z
47
- });
48
- if (typeof d > "u" && (d = V({
49
- commitments: b
50
- })), typeof m > "u") {
51
- const P = B({ blobs: u, commitments: b, kzg: z });
52
- m = C({ blobs: u, commitments: b, proofs: P });
53
- }
54
- }
55
- const L = v(p), E = [
56
- o(i),
57
- n ? o(n) : "0x",
58
- t ? o(t) : "0x",
59
- x ? o(x) : "0x",
60
- s ? o(s) : "0x",
61
- c ?? "0x",
62
- f ? o(f) : "0x",
63
- l ?? "0x",
64
- L,
65
- a ? o(a) : "0x",
66
- d ?? [],
67
- ...I(e, r)
68
- ], A = [], F = [], G = [];
69
- if (m)
70
- for (let u = 0; u < m.length; u++) {
71
- const { blob: z, commitment: b, proof: P } = m[u];
72
- A.push(z), F.push(b), G.push(P);
73
- }
74
- return h([
75
- "0x03",
76
- m ? (
77
- // If sidecars are enabled, envelope turns into a "wrapper":
78
- y([E, A, F, G])
79
- ) : (
80
- // If sidecars are disabled, standard envelope is used:
81
- y(E)
82
- )
83
- ]);
84
- }
85
- function K(e, r) {
86
- const { chainId: i, gas: s, nonce: n, to: c, value: f, maxFeePerGas: a, maxPriorityFeePerGas: x, accessList: t, data: p } = e;
87
- R(e);
88
- const l = v(t), d = [
89
- o(i),
90
- n ? o(n) : "0x",
91
- x ? o(x) : "0x",
92
- a ? o(a) : "0x",
93
- s ? o(s) : "0x",
94
- c ?? "0x",
95
- f ? o(f) : "0x",
96
- p ?? "0x",
97
- l,
98
- ...I(e, r)
99
- ];
100
- return h([
101
- "0x02",
102
- y(d)
103
- ]);
104
- }
105
- function M(e, r) {
106
- const { chainId: i, gas: s, data: n, nonce: c, to: f, value: a, accessList: x, gasPrice: t } = e;
107
- Y(e);
108
- const p = v(x), l = [
109
- o(i),
110
- c ? o(c) : "0x",
111
- t ? o(t) : "0x",
112
- s ? o(s) : "0x",
113
- f ?? "0x",
114
- a ? o(a) : "0x",
115
- n ?? "0x",
116
- p,
117
- ...I(e, r)
118
- ];
119
- return h([
120
- "0x01",
121
- y(l)
122
- ]);
123
- }
124
- function N(e, r) {
125
- const { chainId: i = 0, gas: s, data: n, nonce: c, to: f, value: a, gasPrice: x } = e;
126
- j(e);
127
- let t = [
128
- c ? o(c) : "0x",
129
- x ? o(x) : "0x",
130
- s ? o(s) : "0x",
131
- f ?? "0x",
132
- a ? o(a) : "0x",
133
- n ?? "0x"
134
- ];
135
- if (r) {
136
- const p = (() => {
137
- if (r.v >= 35n)
138
- return (r.v - 35n) / 2n > 0 ? r.v : 27n + (r.v === 35n ? 0n : 1n);
139
- if (i > 0)
140
- return BigInt(i * 2) + BigInt(35n + r.v - 27n);
141
- const m = 27n + (r.v === 27n ? 0n : 1n);
142
- if (r.v !== m)
143
- throw new H({ v: r.v });
144
- return m;
145
- })(), l = T(r.r), d = T(r.s);
146
- t = [
147
- ...t,
148
- o(p),
149
- l === "0x00" ? "0x" : l,
150
- d === "0x00" ? "0x" : d
151
- ];
152
- } else i > 0 && (t = [
153
- ...t,
154
- o(i),
155
- "0x",
156
- "0x"
157
- ]);
158
- return y(t);
159
- }
160
- function I(e, r) {
161
- const i = r ?? e, { v: s, yParity: n } = i;
162
- if (typeof i.r > "u")
163
- return [];
164
- if (typeof i.s > "u")
165
- return [];
166
- if (typeof s > "u" && typeof n > "u")
167
- return [];
168
- const c = T(i.r), f = T(i.s);
169
- return [typeof n == "number" ? n ? o(1) : "0x" : s === 0n ? "0x" : s === 1n ? o(1) : s === 27n ? "0x" : o(1), c === "0x00" ? "0x" : c, f === "0x00" ? "0x" : f];
14
+ ]));
15
+ return m === "bytes" ? s(r) : r;
170
16
  }
171
17
  export {
172
- te as serializeTransaction,
173
- I as toYParitySignatureArray
18
+ b as hashAuthorization
174
19
  };
package/dist/index88.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 F=require("./index29.cjs"),G=require("./index59.cjs"),R=require("./index60.cjs"),S=require("./index61.cjs"),B=require("./index63.cjs"),L=require("./index76.cjs"),h=require("./index46.cjs"),t=require("./index24.cjs"),b=require("./index95.cjs"),V=require("./index104.cjs"),z=require("./index102.cjs"),C=require("./index65.cjs"),v=require("./index105.cjs");function k(e,o){const s=C.getTransactionType(e);return s==="eip1559"?_(e,o):s==="eip2930"?j(e,o):s==="eip4844"?Y(e,o):s==="eip7702"?w(e,o):M(e,o)}function w(e,o){const{authorizationList:s,chainId:i,gas:r,nonce:c,to:a,value:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP7702(e);const f=v.serializeAccessList(H),u=V.serializeAuthorizationList(s);return L.concatHex(["0x04",b.toRlp([t.toHex(i),c?t.toHex(c):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",r?t.toHex(r):"0x",a??"0x",x?t.toHex(x):"0x",d??"0x",f,u,...T(e,o)])])}function Y(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerBlobGas:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP4844(e);let f=e.blobVersionedHashes,u=e.sidecars;if(e.blobs&&(typeof f>"u"||typeof u>"u")){const m=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(y=>t.bytesToHex(y)),P=e.kzg,p=G.blobsToCommitments({blobs:m,kzg:P});if(typeof f>"u"&&(f=S.commitmentsToVersionedHashes({commitments:p})),typeof u>"u"){const y=R.blobsToProofs({blobs:m,commitments:p,kzg:P});u=B.toBlobSidecars({blobs:m,commitments:p,proofs:y})}}const I=v.serializeAccessList(H),A=[t.toHex(s),r?t.toHex(r):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",d??"0x",I,x?t.toHex(x):"0x",f??[],...T(e,o)],q=[],g=[],E=[];if(u)for(let m=0;m<u.length;m++){const{blob:P,commitment:p,proof:y}=u[m];q.push(P),g.push(p),E.push(y)}return L.concatHex(["0x03",u?b.toRlp([A,q,g,E]):b.toRlp(A)])}function _(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerGas:x,maxPriorityFeePerGas:l,accessList:n,data:H}=e;z.assertTransactionEIP1559(e);const d=v.serializeAccessList(n),f=[t.toHex(s),r?t.toHex(r):"0x",l?t.toHex(l):"0x",x?t.toHex(x):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",H??"0x",d,...T(e,o)];return L.concatHex(["0x02",b.toRlp(f)])}function j(e,o){const{chainId:s,gas:i,data:r,nonce:c,to:a,value:x,accessList:l,gasPrice:n}=e;z.assertTransactionEIP2930(e);const H=v.serializeAccessList(l),d=[t.toHex(s),c?t.toHex(c):"0x",n?t.toHex(n):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x",H,...T(e,o)];return L.concatHex(["0x01",b.toRlp(d)])}function M(e,o){const{chainId:s=0,gas:i,data:r,nonce:c,to:a,value:x,gasPrice:l}=e;z.assertTransactionLegacy(e);let n=[c?t.toHex(c):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x"];if(o){const H=(()=>{if(o.v>=35n)return(o.v-35n)/2n>0?o.v:27n+(o.v===35n?0n:1n);if(s>0)return BigInt(s*2)+BigInt(35n+o.v-27n);const u=27n+(o.v===27n?0n:1n);if(o.v!==u)throw new F.InvalidLegacyVError({v:o.v});return u})(),d=h.trim(o.r),f=h.trim(o.s);n=[...n,t.toHex(H),d==="0x00"?"0x":d,f==="0x00"?"0x":f]}else s>0&&(n=[...n,t.toHex(s),"0x","0x"]);return b.toRlp(n)}function T(e,o){const s=o??e,{v:i,yParity:r}=s;if(typeof s.r>"u")return[];if(typeof s.s>"u")return[];if(typeof i>"u"&&typeof r>"u")return[];const c=h.trim(s.r),a=h.trim(s.s);return[typeof r=="number"?r?t.toHex(1):"0x":i===0n?"0x":i===1n?t.toHex(1):i===27n?"0x":t.toHex(1),c==="0x00"?"0x":c,a==="0x00"?"0x":a]}exports.serializeTransaction=k;exports.toYParitySignatureArray=T;
package/dist/index88.js CHANGED
@@ -1,11 +1,174 @@
1
- function n(e) {
2
- return {
3
- formatters: void 0,
4
- fees: void 0,
5
- serializers: void 0,
6
- ...e
7
- };
1
+ import { InvalidLegacyVError as H } from "./index29.js";
2
+ import { blobsToCommitments as g } from "./index59.js";
3
+ import { blobsToProofs as B } from "./index60.js";
4
+ import { commitmentsToVersionedHashes as V } from "./index61.js";
5
+ import { toBlobSidecars as C } from "./index63.js";
6
+ import { concatHex as h } from "./index76.js";
7
+ import { trim as T } from "./index46.js";
8
+ import { toHex as o, bytesToHex as k } from "./index24.js";
9
+ import { toRlp as y } from "./index95.js";
10
+ import { serializeAuthorizationList as w } from "./index104.js";
11
+ import { assertTransactionEIP7702 as S, assertTransactionEIP4844 as _, assertTransactionEIP1559 as R, assertTransactionEIP2930 as Y, assertTransactionLegacy as j } from "./index102.js";
12
+ import { getTransactionType as q } from "./index65.js";
13
+ import { serializeAccessList as v } from "./index105.js";
14
+ function te(e, r) {
15
+ const i = q(e);
16
+ return i === "eip1559" ? K(e, r) : i === "eip2930" ? M(e, r) : i === "eip4844" ? J(e, r) : i === "eip7702" ? D(e, r) : N(e, r);
17
+ }
18
+ function D(e, r) {
19
+ const { authorizationList: i, chainId: s, gas: n, nonce: c, to: f, value: a, maxFeePerGas: x, maxPriorityFeePerGas: t, accessList: p, data: l } = e;
20
+ S(e);
21
+ const d = v(p), m = w(i);
22
+ return h([
23
+ "0x04",
24
+ y([
25
+ o(s),
26
+ c ? o(c) : "0x",
27
+ t ? o(t) : "0x",
28
+ x ? o(x) : "0x",
29
+ n ? o(n) : "0x",
30
+ f ?? "0x",
31
+ a ? o(a) : "0x",
32
+ l ?? "0x",
33
+ d,
34
+ m,
35
+ ...I(e, r)
36
+ ])
37
+ ]);
38
+ }
39
+ function J(e, r) {
40
+ const { chainId: i, gas: s, nonce: n, to: c, value: f, maxFeePerBlobGas: a, maxFeePerGas: x, maxPriorityFeePerGas: t, accessList: p, data: l } = e;
41
+ _(e);
42
+ let d = e.blobVersionedHashes, m = e.sidecars;
43
+ if (e.blobs && (typeof d > "u" || typeof m > "u")) {
44
+ const u = typeof e.blobs[0] == "string" ? e.blobs : e.blobs.map((P) => k(P)), z = e.kzg, b = g({
45
+ blobs: u,
46
+ kzg: z
47
+ });
48
+ if (typeof d > "u" && (d = V({
49
+ commitments: b
50
+ })), typeof m > "u") {
51
+ const P = B({ blobs: u, commitments: b, kzg: z });
52
+ m = C({ blobs: u, commitments: b, proofs: P });
53
+ }
54
+ }
55
+ const L = v(p), E = [
56
+ o(i),
57
+ n ? o(n) : "0x",
58
+ t ? o(t) : "0x",
59
+ x ? o(x) : "0x",
60
+ s ? o(s) : "0x",
61
+ c ?? "0x",
62
+ f ? o(f) : "0x",
63
+ l ?? "0x",
64
+ L,
65
+ a ? o(a) : "0x",
66
+ d ?? [],
67
+ ...I(e, r)
68
+ ], A = [], F = [], G = [];
69
+ if (m)
70
+ for (let u = 0; u < m.length; u++) {
71
+ const { blob: z, commitment: b, proof: P } = m[u];
72
+ A.push(z), F.push(b), G.push(P);
73
+ }
74
+ return h([
75
+ "0x03",
76
+ m ? (
77
+ // If sidecars are enabled, envelope turns into a "wrapper":
78
+ y([E, A, F, G])
79
+ ) : (
80
+ // If sidecars are disabled, standard envelope is used:
81
+ y(E)
82
+ )
83
+ ]);
84
+ }
85
+ function K(e, r) {
86
+ const { chainId: i, gas: s, nonce: n, to: c, value: f, maxFeePerGas: a, maxPriorityFeePerGas: x, accessList: t, data: p } = e;
87
+ R(e);
88
+ const l = v(t), d = [
89
+ o(i),
90
+ n ? o(n) : "0x",
91
+ x ? o(x) : "0x",
92
+ a ? o(a) : "0x",
93
+ s ? o(s) : "0x",
94
+ c ?? "0x",
95
+ f ? o(f) : "0x",
96
+ p ?? "0x",
97
+ l,
98
+ ...I(e, r)
99
+ ];
100
+ return h([
101
+ "0x02",
102
+ y(d)
103
+ ]);
104
+ }
105
+ function M(e, r) {
106
+ const { chainId: i, gas: s, data: n, nonce: c, to: f, value: a, accessList: x, gasPrice: t } = e;
107
+ Y(e);
108
+ const p = v(x), l = [
109
+ o(i),
110
+ c ? o(c) : "0x",
111
+ t ? o(t) : "0x",
112
+ s ? o(s) : "0x",
113
+ f ?? "0x",
114
+ a ? o(a) : "0x",
115
+ n ?? "0x",
116
+ p,
117
+ ...I(e, r)
118
+ ];
119
+ return h([
120
+ "0x01",
121
+ y(l)
122
+ ]);
123
+ }
124
+ function N(e, r) {
125
+ const { chainId: i = 0, gas: s, data: n, nonce: c, to: f, value: a, gasPrice: x } = e;
126
+ j(e);
127
+ let t = [
128
+ c ? o(c) : "0x",
129
+ x ? o(x) : "0x",
130
+ s ? o(s) : "0x",
131
+ f ?? "0x",
132
+ a ? o(a) : "0x",
133
+ n ?? "0x"
134
+ ];
135
+ if (r) {
136
+ const p = (() => {
137
+ if (r.v >= 35n)
138
+ return (r.v - 35n) / 2n > 0 ? r.v : 27n + (r.v === 35n ? 0n : 1n);
139
+ if (i > 0)
140
+ return BigInt(i * 2) + BigInt(35n + r.v - 27n);
141
+ const m = 27n + (r.v === 27n ? 0n : 1n);
142
+ if (r.v !== m)
143
+ throw new H({ v: r.v });
144
+ return m;
145
+ })(), l = T(r.r), d = T(r.s);
146
+ t = [
147
+ ...t,
148
+ o(p),
149
+ l === "0x00" ? "0x" : l,
150
+ d === "0x00" ? "0x" : d
151
+ ];
152
+ } else i > 0 && (t = [
153
+ ...t,
154
+ o(i),
155
+ "0x",
156
+ "0x"
157
+ ]);
158
+ return y(t);
159
+ }
160
+ function I(e, r) {
161
+ const i = r ?? e, { v: s, yParity: n } = i;
162
+ if (typeof i.r > "u")
163
+ return [];
164
+ if (typeof i.s > "u")
165
+ return [];
166
+ if (typeof s > "u" && typeof n > "u")
167
+ return [];
168
+ const c = T(i.r), f = T(i.s);
169
+ return [typeof n == "number" ? n ? o(1) : "0x" : s === 0n ? "0x" : s === 1n ? o(1) : s === 27n ? "0x" : o(1), c === "0x00" ? "0x" : c, f === "0x00" ? "0x" : f];
8
170
  }
9
171
  export {
10
- n as defineChain
172
+ te as serializeTransaction,
173
+ I as toYParitySignatureArray
11
174
  };
package/dist/index89.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index43.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.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;exports.SliceOffsetOutOfBoundsError=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index79.cjs"),O=require("./index69.cjs"),n=require("./index47.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;