@gardenfi/core 0.2.0-beta.73 → 0.2.0-beta.75

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 (267) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +16 -15
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +42 -31
  5. package/dist/index100.cjs +1 -1
  6. package/dist/index100.js +18 -32
  7. package/dist/index101.cjs +1 -1
  8. package/dist/index101.js +6 -366
  9. package/dist/index102.cjs +1 -1
  10. package/dist/index102.js +33 -21
  11. package/dist/index103.cjs +1 -1
  12. package/dist/index103.js +2 -56
  13. package/dist/index104.cjs +1 -1
  14. package/dist/index104.js +38 -3
  15. package/dist/index105.cjs +1 -1
  16. package/dist/index105.js +25 -45
  17. package/dist/index106.cjs +1 -1
  18. package/dist/index106.js +7 -26
  19. package/dist/index107.cjs +1 -1
  20. package/dist/index107.js +5 -2
  21. package/dist/index108.cjs +1 -1
  22. package/dist/index108.js +11 -2
  23. package/dist/index109.cjs +1 -1
  24. package/dist/index109.js +2 -62
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +2 -2
  27. package/dist/index110.cjs +1 -1
  28. package/dist/index110.js +55 -32
  29. package/dist/index111.cjs +1 -1
  30. package/dist/index111.js +2 -5
  31. package/dist/index112.cjs +1 -1
  32. package/dist/index112.js +40 -2
  33. package/dist/index113.cjs +1 -1
  34. package/dist/index113.js +38 -53
  35. package/dist/index114.cjs +1 -1
  36. package/dist/index114.js +18 -2
  37. package/dist/index115.cjs +1 -1
  38. package/dist/index115.js +101 -32
  39. package/dist/index116.cjs +1 -1
  40. package/dist/index116.js +17 -39
  41. package/dist/index117.cjs +1 -1
  42. package/dist/index117.js +224 -16
  43. package/dist/index118.cjs +1 -1
  44. package/dist/index118.js +4 -109
  45. package/dist/index119.cjs +1 -1
  46. package/dist/index119.js +155 -18
  47. package/dist/index120.cjs +1 -1
  48. package/dist/index120.js +2 -226
  49. package/dist/index121.cjs +1 -1
  50. package/dist/index121.js +73 -4
  51. package/dist/index122.cjs +1 -1
  52. package/dist/index122.js +55 -151
  53. package/dist/index123.cjs +1 -1
  54. package/dist/index123.js +35 -2
  55. package/dist/index124.cjs +1 -1
  56. package/dist/index124.js +5 -73
  57. package/dist/index125.cjs +1 -1
  58. package/dist/index125.js +2 -2
  59. package/dist/index126.cjs +1 -1
  60. package/dist/index126.js +8 -8
  61. package/dist/index127.cjs +1 -1
  62. package/dist/index127.js +1 -1
  63. package/dist/index130.cjs +1 -1
  64. package/dist/index130.js +2 -19
  65. package/dist/index131.cjs +1 -1
  66. package/dist/index131.js +356 -2
  67. package/dist/index132.cjs +1 -1
  68. package/dist/index132.js +206 -323
  69. package/dist/index133.cjs +1 -1
  70. package/dist/index133.js +37 -208
  71. package/dist/index134.cjs +1 -1
  72. package/dist/index134.js +59 -65
  73. package/dist/index135.cjs +1 -1
  74. package/dist/index135.js +10 -60
  75. package/dist/index136.cjs +1 -1
  76. package/dist/index136.js +45 -12
  77. package/dist/index137.cjs +1 -1
  78. package/dist/index137.js +56 -38
  79. package/dist/index138.cjs +1 -1
  80. package/dist/index138.js +19 -63
  81. package/dist/index14.cjs +1 -1
  82. package/dist/index14.js +9 -4
  83. package/dist/index141.cjs +1 -1
  84. package/dist/index141.js +3 -3
  85. package/dist/index145.cjs +1 -1
  86. package/dist/index145.js +1 -1
  87. package/dist/index148.cjs +1 -1
  88. package/dist/index148.js +1 -1
  89. package/dist/index15.cjs +1 -1
  90. package/dist/index15.js +32 -2
  91. package/dist/index16.cjs +1 -1
  92. package/dist/index16.js +10 -17
  93. package/dist/index17.cjs +1 -1
  94. package/dist/index17.js +18 -12
  95. package/dist/index18.cjs +1 -1
  96. package/dist/index18.js +15 -16
  97. package/dist/index19.cjs +1 -1
  98. package/dist/index19.js +39 -16
  99. package/dist/index20.cjs +1 -1
  100. package/dist/index20.js +25 -52
  101. package/dist/index21.cjs +1 -1
  102. package/dist/index21.js +2 -9
  103. package/dist/index22.cjs +1 -1
  104. package/dist/index22.js +138 -9
  105. package/dist/index23.cjs +1 -1
  106. package/dist/index23.js +2 -138
  107. package/dist/index24.cjs +1 -1
  108. package/dist/index24.js +9 -2
  109. package/dist/index25.cjs +1 -1
  110. package/dist/index25.js +7 -11
  111. package/dist/index26.cjs +3 -1
  112. package/dist/index26.js +27 -36
  113. package/dist/index27.cjs +1 -1
  114. package/dist/index27.js +17 -44
  115. package/dist/index28.cjs +2 -1
  116. package/dist/index28.js +24 -27
  117. package/dist/index29.cjs +1 -1
  118. package/dist/index29.js +40 -14
  119. package/dist/index30.cjs +1 -1
  120. package/dist/index30.js +197 -22
  121. package/dist/index31.cjs +1 -1
  122. package/dist/index31.js +2 -26
  123. package/dist/index32.cjs +1 -1
  124. package/dist/index32.js +2 -55
  125. package/dist/index33.cjs +1 -1
  126. package/dist/index33.js +2 -28
  127. package/dist/index34.cjs +1 -3
  128. package/dist/index34.js +11 -26
  129. package/dist/index35.cjs +1 -1
  130. package/dist/index35.js +39 -17
  131. package/dist/index36.cjs +1 -2
  132. package/dist/index36.js +40 -23
  133. package/dist/index37.cjs +1 -1
  134. package/dist/index37.js +26 -39
  135. package/dist/index38.cjs +1 -1
  136. package/dist/index38.js +15 -199
  137. package/dist/index39.cjs +1 -1
  138. package/dist/index39.js +24 -2
  139. package/dist/index40.cjs +1 -1
  140. package/dist/index40.js +26 -2
  141. package/dist/index41.cjs +1 -1
  142. package/dist/index41.js +55 -2
  143. package/dist/index42.cjs +1 -1
  144. package/dist/index42.js +27 -12
  145. package/dist/index43.cjs +1 -1
  146. package/dist/index43.js +174 -11
  147. package/dist/index44.cjs +1 -1
  148. package/dist/index44.js +2 -4
  149. package/dist/index45.cjs +1 -1
  150. package/dist/index45.js +34 -45
  151. package/dist/index46.cjs +1 -1
  152. package/dist/index46.js +9 -43
  153. package/dist/index47.cjs +1 -1
  154. package/dist/index47.js +10 -169
  155. package/dist/index48.cjs +1 -1
  156. package/dist/index48.js +11 -12
  157. package/dist/index49.cjs +1 -1
  158. package/dist/index49.js +3 -4
  159. package/dist/index5.cjs +1 -1
  160. package/dist/index5.js +48 -59
  161. package/dist/index50.cjs +1 -1
  162. package/dist/index50.js +45 -16
  163. package/dist/index51.cjs +1 -1
  164. package/dist/index51.js +40 -9
  165. package/dist/index52.cjs +1 -1
  166. package/dist/index52.js +167 -170
  167. package/dist/index53.cjs +1 -1
  168. package/dist/index53.js +12 -21
  169. package/dist/index54.cjs +1 -1
  170. package/dist/index54.js +5 -2
  171. package/dist/index55.cjs +1 -1
  172. package/dist/index55.js +17 -35
  173. package/dist/index56.cjs +1 -1
  174. package/dist/index56.js +11 -8
  175. package/dist/index57.cjs +1 -1
  176. package/dist/index57.js +19 -34
  177. package/dist/index58.cjs +1 -1
  178. package/dist/index58.js +31 -55
  179. package/dist/index59.cjs +1 -2
  180. package/dist/index59.js +2 -60
  181. package/dist/index60.cjs +6 -1
  182. package/dist/index60.js +949 -6
  183. package/dist/index61.cjs +1 -1
  184. package/dist/index61.js +2 -128
  185. package/dist/index62.cjs +1 -2
  186. package/dist/index62.js +61 -42
  187. package/dist/index63.cjs +1 -1
  188. package/dist/index63.js +33 -9
  189. package/dist/index64.cjs +1 -1
  190. package/dist/index64.js +86 -10
  191. package/dist/index65.cjs +1 -1
  192. package/dist/index65.js +55 -11
  193. package/dist/index66.cjs +2 -1
  194. package/dist/index66.js +59 -13
  195. package/dist/index67.cjs +1 -1
  196. package/dist/index67.js +3 -6
  197. package/dist/index68.cjs +1 -1
  198. package/dist/index68.js +33 -16
  199. package/dist/index69.cjs +1 -1
  200. package/dist/index69.js +126 -77
  201. package/dist/index70.cjs +2 -1
  202. package/dist/index70.js +42 -14
  203. package/dist/index71.cjs +1 -1
  204. package/dist/index71.js +8 -18
  205. package/dist/index72.cjs +1 -1
  206. package/dist/index72.js +9 -5
  207. package/dist/index73.cjs +1 -1
  208. package/dist/index73.js +11 -21
  209. package/dist/index74.cjs +1 -1
  210. package/dist/index74.js +13 -13
  211. package/dist/index75.cjs +1 -1
  212. package/dist/index75.js +7 -2
  213. package/dist/index76.cjs +1 -1
  214. package/dist/index76.js +18 -2
  215. package/dist/index77.cjs +1 -2
  216. package/dist/index77.js +76 -32
  217. package/dist/index78.cjs +1 -1
  218. package/dist/index78.js +14 -5
  219. package/dist/index79.cjs +1 -1
  220. package/dist/index79.js +18 -19
  221. package/dist/index8.cjs +1 -1
  222. package/dist/index8.js +5 -6
  223. package/dist/index80.cjs +1 -1
  224. package/dist/index80.js +19 -29
  225. package/dist/index81.cjs +1 -1
  226. package/dist/index81.js +14 -2
  227. package/dist/index82.cjs +1 -6
  228. package/dist/index82.js +9 -949
  229. package/dist/index83.cjs +1 -1
  230. package/dist/index83.js +2 -2
  231. package/dist/index84.cjs +1 -1
  232. package/dist/index84.js +2 -62
  233. package/dist/index85.cjs +2 -1
  234. package/dist/index85.js +34 -32
  235. package/dist/index86.cjs +1 -1
  236. package/dist/index86.js +5 -86
  237. package/dist/index87.cjs +1 -1
  238. package/dist/index87.js +19 -12
  239. package/dist/index88.cjs +1 -1
  240. package/dist/index88.js +34 -6
  241. package/dist/index89.cjs +1 -1
  242. package/dist/index89.js +365 -111
  243. package/dist/index90.cjs +1 -1
  244. package/dist/index90.js +21 -7
  245. package/dist/index91.cjs +1 -1
  246. package/dist/index91.js +55 -32
  247. package/dist/index92.cjs +1 -1
  248. package/dist/index92.js +3 -2
  249. package/dist/index93.cjs +1 -1
  250. package/dist/index93.js +45 -34
  251. package/dist/index94.cjs +1 -1
  252. package/dist/index94.js +26 -29
  253. package/dist/index95.cjs +1 -1
  254. package/dist/index95.js +2 -21
  255. package/dist/index96.cjs +1 -1
  256. package/dist/index96.js +2 -7
  257. package/dist/index97.cjs +1 -1
  258. package/dist/index97.js +13 -5
  259. package/dist/index98.cjs +1 -1
  260. package/dist/index98.js +6 -10
  261. package/dist/index99.cjs +1 -1
  262. package/dist/index99.js +111 -18
  263. package/dist/src/index.d.ts +1 -1
  264. package/dist/src/lib/evm/relay/evmRelay.d.ts +1 -1
  265. package/dist/src/lib/evm/relay/evmRelay.types.d.ts +1 -1
  266. package/dist/src/lib/utils.d.ts +2 -0
  267. package/package.json +2 -2
package/dist/index5.js CHANGED
@@ -1,51 +1,40 @@
1
- import { Url as k, fetchEVMBlockNumber as v, with0x as u, checkAllowanceAndApprove as I, Authorization as h } from "@gardenfi/utils";
1
+ import { Url as _, with0x as c, checkAllowanceAndApprove as k, Authorization as p } from "@gardenfi/utils";
2
2
  import { getContract as A } from "viem";
3
- import { Err as r, Fetcher as f, Ok as y, trim0x as b } from "@catalogfi/utils";
4
- import { ParseSwapStatus as N } from "./index7.js";
5
- import { AtomicSwapABI as T } from "./index13.js";
6
- import { SwapStatus as x } from "./index6.js";
7
- class J {
8
- constructor(t, s, a) {
9
- this.url = new k("/relayer", s), this.auth = a, this.order = t;
3
+ import { Err as e, Fetcher as h, Ok as y, trim0x as v } from "@catalogfi/utils";
4
+ import { AtomicSwapABI as I } from "./index13.js";
5
+ class z {
6
+ constructor(t, o, r) {
7
+ this.url = new _("/relayer", o), this.auth = r, this.order = t;
10
8
  }
11
- async init(t, s) {
12
- if (!t.account) return r("No account found");
9
+ async init(t) {
10
+ if (!t.account) return e("No account found");
13
11
  if (t.account.address.toLowerCase() !== this.order.source_swap.initiator.toLowerCase())
14
- return r("Account address and order initiator mismatch");
15
- if (!s) {
16
- const o = await v(t);
17
- if (o.error) return r(o.error);
18
- s = o.val;
19
- }
20
- if (N(
21
- this.order.source_swap,
22
- s
23
- ) !== x.Idle) return r("Invalid swap status");
24
- const { create_order: e, source_swap: i } = this.order;
25
- if (!i.amount || !i.redeemer || !e.timelock || !e.secret_hash)
26
- return r("Invalid order");
27
- const w = u(e.secret_hash), g = BigInt(e.timelock), l = u(i.redeemer), d = BigInt(i.amount);
12
+ return e("Account address and order initiator mismatch");
13
+ const { create_order: o, source_swap: r } = this.order;
14
+ if (!r.amount || !r.redeemer || !o.timelock || !o.secret_hash)
15
+ return e("Invalid order");
16
+ const n = c(o.secret_hash), f = BigInt(o.timelock), g = c(r.redeemer), u = BigInt(r.amount);
28
17
  try {
29
- const o = await this.auth.getToken();
30
- if (o.error) return r(o.error);
31
- const m = A({
32
- address: u(this.order.source_swap.asset),
33
- abi: T,
18
+ const a = await this.auth.getToken();
19
+ if (a.error) return e(a.error);
20
+ const d = A({
21
+ address: c(this.order.source_swap.asset),
22
+ abi: I,
34
23
  client: t
35
- }), S = await m.read.token(), p = await I(
36
- Number(d),
37
- S,
24
+ }), w = await d.read.token(), m = await k(
25
+ Number(u),
26
+ w,
38
27
  this.order.source_swap.asset,
39
28
  t
40
29
  );
41
- if (p.error) return r(p.error);
42
- const n = await m.read.eip712Domain(), _ = await t.signTypedData({
30
+ if (m.error) return e(m.error);
31
+ const i = await d.read.eip712Domain(), l = await t.signTypedData({
43
32
  account: t.account,
44
33
  domain: {
45
- name: n[1],
46
- version: n[2],
47
- chainId: Number(n[3]),
48
- verifyingContract: n[4]
34
+ name: i[1],
35
+ version: i[2],
36
+ chainId: Number(i[3]),
37
+ verifyingContract: i[4]
49
38
  },
50
39
  types: {
51
40
  Initiate: [
@@ -57,54 +46,54 @@ class J {
57
46
  },
58
47
  primaryType: "Initiate",
59
48
  message: {
60
- redeemer: l,
61
- timelock: g,
62
- amount: d,
63
- secretHash: w
49
+ redeemer: g,
50
+ timelock: f,
51
+ amount: u,
52
+ secretHash: n
64
53
  }
65
- }), c = await f.post(
54
+ }), s = await h.post(
66
55
  this.url.endpoint("initiate"),
67
56
  {
68
57
  body: JSON.stringify({
69
- order_id: e.create_id,
70
- signature: _,
58
+ order_id: o.create_id,
59
+ signature: l,
71
60
  perform_on: "Source"
72
61
  }),
73
62
  headers: {
74
- Authorization: h(o.val),
63
+ Authorization: p(a.val),
75
64
  "Content-Type": "application/json"
76
65
  }
77
66
  }
78
67
  );
79
- return c.error ? r(c.error) : c.result ? y(c.result) : r("Init: No result found");
80
- } catch (o) {
81
- return console.log("init error :", o), r(String(o));
68
+ return s.error ? e(s.error) : s.result ? y(s.result) : e("Init: No result found");
69
+ } catch (a) {
70
+ return console.log("init error :", a), e(String(a));
82
71
  }
83
72
  }
84
- async redeem(t, s) {
73
+ async redeem(t, o) {
85
74
  try {
86
- const a = await this.auth.getToken();
87
- if (a.error) return r(a.error);
88
- const e = await f.post(
75
+ const r = await this.auth.getToken();
76
+ if (r.error) return e(r.error);
77
+ const n = await h.post(
89
78
  this.url.endpoint("redeem"),
90
79
  {
91
80
  body: JSON.stringify({
92
81
  order_id: t,
93
- secret: b(s),
82
+ secret: v(o),
94
83
  perform_on: "Destination"
95
84
  }),
96
85
  headers: {
97
- Authorization: h(a.val),
86
+ Authorization: p(r.val),
98
87
  "Content-Type": "application/json"
99
88
  }
100
89
  }
101
90
  );
102
- return e.error ? r(e.error) : e.result ? y(e.result) : r("Redeem: No result found");
103
- } catch (a) {
104
- return r(String(a));
91
+ return n.error ? e(n.error) : n.result ? y(n.result) : e("Redeem: No result found");
92
+ } catch (r) {
93
+ return e(String(r));
105
94
  }
106
95
  }
107
96
  }
108
97
  export {
109
- J as EvmRelay
98
+ z as EvmRelay
110
99
  };
package/dist/index50.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(o,n){return({exclude:t,format:f})=>({exclude:t,format:e=>{const r=n(e);if(t)for(const i of t)delete r[i];return{...r,...f(e)}},type:o})}exports.defineFormatter=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./index53.cjs"),f=require("./index68.cjs"),x=require("./index39.cjs"),z=Array.from({length:256},(e,n)=>n.toString(16).padStart(2,"0"));function H(e,n={}){return typeof e=="number"||typeof e=="bigint"?d(e,n):typeof e=="string"?m(e,n):typeof e=="boolean"?b(e,n):u(e,n)}function b(e,n={}){const t=`0x${Number(e)}`;return typeof n.size=="number"?(x.assertSize(t,{size:n.size}),f.pad(t,{size:n.size})):t}function u(e,n={}){let t="";for(let i=0;i<e.length;i++)t+=z[e[i]];const r=`0x${t}`;return typeof n.size=="number"?(x.assertSize(r,{size:n.size}),f.pad(r,{dir:"right",size:n.size})):r}function d(e,n={}){const{signed:t,size:r}=n,i=BigInt(e);let o;r?t?o=(1n<<BigInt(r)*8n-1n)-1n:o=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const c=typeof o=="bigint"&&t?-o-1n:0;if(o&&i>o||i<c){const s=typeof e=="bigint"?"n":"";throw new y.IntegerOutOfRangeError({max:o?`${o}${s}`:void 0,min:`${c}${s}`,signed:t,size:r,value:`${e}${s}`})}const g=`0x${(t&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?f.pad(g,{size:r}):g}const T=new TextEncoder;function m(e,n={}){const t=T.encode(e);return u(t,n)}exports.boolToHex=b;exports.bytesToHex=u;exports.numberToHex=d;exports.stringToHex=m;exports.toHex=H;
package/dist/index50.js CHANGED
@@ -1,19 +1,48 @@
1
- function a(e, f) {
2
- return ({ exclude: t, format: n }) => ({
3
- exclude: t,
4
- format: (r) => {
5
- const o = f(r);
6
- if (t)
7
- for (const m of t)
8
- delete o[m];
9
- return {
10
- ...o,
11
- ...n(r)
12
- };
13
- },
14
- type: e
15
- });
1
+ import { IntegerOutOfRangeError as x } from "./index53.js";
2
+ import { pad as s } from "./index68.js";
3
+ import { assertSize as c } from "./index39.js";
4
+ const b = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
5
+ function B(n, e = {}) {
6
+ return typeof n == "number" || typeof n == "bigint" ? y(n, e) : typeof n == "string" ? $(n, e) : typeof n == "boolean" ? z(n, e) : m(n, e);
7
+ }
8
+ function z(n, e = {}) {
9
+ const t = `0x${Number(n)}`;
10
+ return typeof e.size == "number" ? (c(t, { size: e.size }), s(t, { size: e.size })) : t;
11
+ }
12
+ function m(n, e = {}) {
13
+ let t = "";
14
+ for (let i = 0; i < n.length; i++)
15
+ t += b[n[i]];
16
+ const r = `0x${t}`;
17
+ return typeof e.size == "number" ? (c(r, { size: e.size }), s(r, { dir: "right", size: e.size })) : r;
18
+ }
19
+ function y(n, e = {}) {
20
+ const { signed: t, size: r } = e, i = BigInt(n);
21
+ let o;
22
+ r ? t ? o = (1n << BigInt(r) * 8n - 1n) - 1n : o = 2n ** (BigInt(r) * 8n) - 1n : typeof n == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
23
+ const g = typeof o == "bigint" && t ? -o - 1n : 0;
24
+ if (o && i > o || i < g) {
25
+ const f = typeof n == "bigint" ? "n" : "";
26
+ throw new x({
27
+ max: o ? `${o}${f}` : void 0,
28
+ min: `${g}${f}`,
29
+ signed: t,
30
+ size: r,
31
+ value: `${n}${f}`
32
+ });
33
+ }
34
+ const u = `0x${(t && i < 0 ? (1n << BigInt(r * 8)) + BigInt(i) : i).toString(16)}`;
35
+ return r ? s(u, { size: r }) : u;
36
+ }
37
+ const d = /* @__PURE__ */ new TextEncoder();
38
+ function $(n, e = {}) {
39
+ const t = d.encode(n);
40
+ return m(t, e);
16
41
  }
17
42
  export {
18
- a as defineFormatter
43
+ z as boolToHex,
44
+ m as bytesToHex,
45
+ y as numberToHex,
46
+ $ as stringToHex,
47
+ B as toHex
19
48
  };
package/dist/index51.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(n,{args:a,eventName:t}={}){return{...n,blockHash:n.blockHash?n.blockHash:null,blockNumber:n.blockNumber?BigInt(n.blockNumber):null,logIndex:n.logIndex?Number(n.logIndex):null,transactionHash:n.transactionHash?n.transactionHash:null,transactionIndex:n.transactionIndex?Number(n.transactionIndex):null,...t?{args:a,eventName:t}:{}}}exports.formatLog=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index66.cjs"),u=require("./index69.cjs"),f=require("./index65.cjs"),g=require("./index50.cjs");function c(n,e="hex"){const i=o(n),s=u.createCursor(new Uint8Array(i.length));return i.encode(s),e==="hex"?g.bytesToHex(s.bytes):s.bytes}function o(n){return Array.isArray(n)?p(n.map(e=>o(e))):y(n)}function p(n){const e=n.reduce((t,h)=>t+h.length,0),i=l(e);return{length:e<=55?1+e:1+i+e,encode(t){e<=55?t.pushByte(192+e):(t.pushByte(247+i),i===1?t.pushUint8(e):i===2?t.pushUint16(e):i===3?t.pushUint24(e):t.pushUint32(e));for(const{encode:h}of n)h(t)}}}function y(n){const e=typeof n=="string"?f.hexToBytes(n):n,i=l(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(t){e.length===1&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+i),i===1?t.pushUint8(e.length):i===2?t.pushUint16(e.length):i===3?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}function l(n){if(n<2**8)return 1;if(n<2**16)return 2;if(n<2**24)return 3;if(n<2**32)return 4;throw new r.BaseError("Length is too large.")}exports.toRlp=c;
package/dist/index51.js CHANGED
@@ -1,14 +1,45 @@
1
- function r(n, { args: t, eventName: a } = {}) {
1
+ import { BaseError as l } from "./index66.js";
2
+ import { createCursor as r } from "./index69.js";
3
+ import { hexToBytes as g } from "./index65.js";
4
+ import { bytesToHex as u } from "./index50.js";
5
+ function m(n, e = "hex") {
6
+ const i = s(n), h = r(new Uint8Array(i.length));
7
+ return i.encode(h), e === "hex" ? u(h.bytes) : h.bytes;
8
+ }
9
+ function s(n) {
10
+ return Array.isArray(n) ? p(n.map((e) => s(e))) : y(n);
11
+ }
12
+ function p(n) {
13
+ const e = n.reduce((t, f) => t + f.length, 0), i = o(e);
14
+ return {
15
+ length: e <= 55 ? 1 + e : 1 + i + e,
16
+ encode(t) {
17
+ e <= 55 ? t.pushByte(192 + e) : (t.pushByte(247 + i), i === 1 ? t.pushUint8(e) : i === 2 ? t.pushUint16(e) : i === 3 ? t.pushUint24(e) : t.pushUint32(e));
18
+ for (const { encode: f } of n)
19
+ f(t);
20
+ }
21
+ };
22
+ }
23
+ function y(n) {
24
+ const e = typeof n == "string" ? g(n) : n, i = o(e.length);
2
25
  return {
3
- ...n,
4
- blockHash: n.blockHash ? n.blockHash : null,
5
- blockNumber: n.blockNumber ? BigInt(n.blockNumber) : null,
6
- logIndex: n.logIndex ? Number(n.logIndex) : null,
7
- transactionHash: n.transactionHash ? n.transactionHash : null,
8
- transactionIndex: n.transactionIndex ? Number(n.transactionIndex) : null,
9
- ...a ? { args: t, eventName: a } : {}
26
+ length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + i + e.length,
27
+ encode(t) {
28
+ e.length === 1 && e[0] < 128 ? t.pushBytes(e) : e.length <= 55 ? (t.pushByte(128 + e.length), t.pushBytes(e)) : (t.pushByte(183 + i), i === 1 ? t.pushUint8(e.length) : i === 2 ? t.pushUint16(e.length) : i === 3 ? t.pushUint24(e.length) : t.pushUint32(e.length), t.pushBytes(e));
29
+ }
10
30
  };
11
31
  }
32
+ function o(n) {
33
+ if (n < 2 ** 8)
34
+ return 1;
35
+ if (n < 2 ** 16)
36
+ return 2;
37
+ if (n < 2 ** 24)
38
+ return 3;
39
+ if (n < 2 ** 32)
40
+ return 4;
41
+ throw new l("Length is too large.");
42
+ }
12
43
  export {
13
- r as formatLog
44
+ m as toRlp
14
45
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./index84.cjs"),J=require("./index85.cjs"),j=require("./index86.cjs");var d=_.errors,u=J.native,h=d.tfJSON,S=d.TfTypeError,b=d.TfPropertyTypeError,v=d.tfSubError,w=d.getValueTypeName,g={arrayOf:function(n,r){n=l(n),r=r||{};function t(f,i){return!u.Array(f)||u.Nil(f)||r.minLength!==void 0&&f.length<r.minLength||r.maxLength!==void 0&&f.length>r.maxLength||r.length!==void 0&&f.length!==r.length?!1:f.every(function(a,o){try{return c(n,a,i)}catch(m){throw v(m,o)}})}return t.toJSON=function(){var f="["+h(n)+"]";return r.length!==void 0?f+="{"+r.length+"}":(r.minLength!==void 0||r.maxLength!==void 0)&&(f+="{"+(r.minLength===void 0?0:r.minLength)+","+(r.maxLength===void 0?1/0:r.maxLength)+"}"),f},t},maybe:function e(n){n=l(n);function r(t,f){return u.Nil(t)||n(t,f,e)}return r.toJSON=function(){return"?"+h(n)},r},map:function(n,r){n=l(n),r&&(r=l(r));function t(f,i){if(!u.Object(f)||u.Nil(f))return!1;for(var a in f){try{r&&c(r,a,i)}catch(m){throw v(m,a,"key")}try{var o=f[a];c(n,o,i)}catch(m){throw v(m,a)}}return!0}return r?t.toJSON=function(){return"{"+h(r)+": "+h(n)+"}"}:t.toJSON=function(){return"{"+h(n)+"}"},t},object:function(n){var r={};for(var t in n)r[t]=l(n[t]);function f(i,a){if(!u.Object(i)||u.Nil(i))return!1;var o;try{for(o in r){var m=r[o],E=i[o];c(m,E,a)}}catch(L){throw v(L,o)}if(a){for(o in i)if(!r[o])throw new b(void 0,o)}return!0}return f.toJSON=function(){return h(r)},f},anyOf:function(){var n=[].slice.call(arguments).map(l);function r(t,f){return n.some(function(i){try{return c(i,t,f)}catch{return!1}})}return r.toJSON=function(){return n.map(h).join("|")},r},allOf:function(){var n=[].slice.call(arguments).map(l);function r(t,f){return n.every(function(i){try{return c(i,t,f)}catch{return!1}})}return r.toJSON=function(){return n.map(h).join(" & ")},r},quacksLike:function(n){function r(t){return n===w(t)}return r.toJSON=function(){return n},r},tuple:function(){var n=[].slice.call(arguments).map(l);function r(t,f){return u.Nil(t)||u.Nil(t.length)||f&&t.length!==n.length?!1:n.every(function(i,a){try{return c(i,t[a],f)}catch(o){throw v(o,a)}})}return r.toJSON=function(){return"("+n.map(h).join(", ")+")"},r},value:function(n){function r(t){return t===n}return r.toJSON=function(){return n},r}};g.oneOf=g.anyOf;function l(e){if(u.String(e))return e[0]==="?"?g.maybe(e.slice(1)):u[e]||g.quacksLike(e);if(e&&u.Object(e)){if(u.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return g.arrayOf(e[0])}return g.object(e)}else if(u.Function(e))return e;return g.value(e)}function c(e,n,r,t){if(u.Function(e)){if(e(n,r))return!0;throw new S(t||e,n)}return c(l(e),n,r)}for(var O in u)c[O]=u[O];for(O in g)c[O]=g[O];var s=j.__require();for(O in s)c[O]=s[O];c.compile=l;c.TfTypeError=S;c.TfPropertyTypeError=b;var N=c;exports.typeforce_1=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index70.cjs"),G=require("./index71.cjs"),R=require("./index72.cjs"),S=require("./index73.cjs"),B=require("./index74.cjs"),L=require("./index49.cjs"),h=require("./index75.cjs"),t=require("./index50.cjs"),b=require("./index51.cjs"),V=require("./index76.cjs"),z=require("./index77.cjs"),C=require("./index78.cjs"),v=require("./index79.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;