@gardenfi/utils 2.2.1-beta.1 → 2.2.1-beta.3

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 (55) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +24 -24
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +124 -2
  5. package/dist/index11.cjs +1 -1
  6. package/dist/index11.js +34 -114
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +19 -37
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +135 -19
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +10 -137
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +2 -15
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +27 -2
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +18 -26
  19. package/dist/index18.cjs +1 -1
  20. package/dist/index18.js +102 -14
  21. package/dist/index24.cjs +1 -1
  22. package/dist/index24.js +12 -26
  23. package/dist/index25.cjs +1 -1
  24. package/dist/index25.js +58 -8
  25. package/dist/index26.cjs +16 -1
  26. package/dist/index26.js +113 -12
  27. package/dist/index27.cjs +1 -1
  28. package/dist/index27.js +32 -58
  29. package/dist/index28.cjs +1 -16
  30. package/dist/index28.js +24 -111
  31. package/dist/index29.cjs +1 -1
  32. package/dist/index29.js +7 -31
  33. package/dist/index7.cjs +1 -1
  34. package/dist/index7.js +8 -105
  35. package/dist/index8.cjs +1 -1
  36. package/dist/index8.js +22 -8
  37. package/dist/index9.cjs +1 -1
  38. package/dist/index9.js +2 -24
  39. package/dist/src/index.d.ts +2 -2
  40. package/dist/src/lib/approve.d.ts +1 -1
  41. package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
  42. package/dist/src/lib/auth/auth.types.d.ts +1 -1
  43. package/dist/src/lib/auth/passkey/passkey.d.ts +1 -1
  44. package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +1 -1
  45. package/dist/src/lib/auth/siwe/siwe.d.ts +1 -1
  46. package/dist/src/lib/blockNumber/blockNumber.d.ts +1 -1
  47. package/dist/src/lib/digestKey/digestKey.d.ts +1 -1
  48. package/dist/src/lib/fetcher/index.d.ts +1 -0
  49. package/dist/src/lib/result/index.d.ts +1 -0
  50. package/dist/src/lib/tryCatch/index.d.ts +1 -0
  51. package/dist/src/lib/{tryCatch.d.ts → tryCatch/tryCatch.d.ts} +1 -1
  52. package/package.json +1 -1
  53. /package/dist/src/lib/{fetcher.d.ts → fetcher/fetcher.d.ts} +0 -0
  54. /package/dist/src/lib/{safeParseJson.d.ts → fetcher/safeParseJson.d.ts} +0 -0
  55. /package/dist/src/lib/{result.d.ts → result/result.d.ts} +0 -0
package/dist/index8.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index5.cjs");async function u(r,c="Failed to execute"){try{const e=await r();return typeof e=="object"&&e!==null&&"ok"in e?e:t.Ok(e)}catch(e){return t.Err(c+": ",e)}}exports.executeWithTryCatch=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r extends URL{constructor(t,e){super(t,e)}endpoint(t){t.startsWith("/")||(t=`/${t}`);const e=`${this.pathname!=="/"?this.pathname:""}${t}`;return new r(e,this)}socket(){if(this.protocol==="https:")return this.origin.replace("https","wss");if(this.protocol==="http:")return this.origin.replace("http","ws");throw new Error("Invalid protocol")}addSearchParams(t){const e=new URLSearchParams(this.search);for(const s in t)e.set(s,t[s]);return new r(`${this.pathname}?${e.toString()}`,this)}}exports.Url=r;
package/dist/index8.js CHANGED
@@ -1,12 +1,26 @@
1
- import { Ok as o, Err as c } from "./index5.js";
2
- async function u(r, e = "Failed to execute") {
3
- try {
4
- const t = await r();
5
- return typeof t == "object" && t !== null && "ok" in t ? t : o(t);
6
- } catch (t) {
7
- return c(e + ": ", t);
1
+ class r extends URL {
2
+ constructor(t, s) {
3
+ super(t, s);
4
+ }
5
+ endpoint(t) {
6
+ t.startsWith("/") || (t = `/${t}`);
7
+ const s = `${this.pathname !== "/" ? this.pathname : ""}${t}`;
8
+ return new r(s, this);
9
+ }
10
+ socket() {
11
+ if (this.protocol === "https:")
12
+ return this.origin.replace("https", "wss");
13
+ if (this.protocol === "http:")
14
+ return this.origin.replace("http", "ws");
15
+ throw new Error("Invalid protocol");
16
+ }
17
+ addSearchParams(t) {
18
+ const s = new URLSearchParams(this.search);
19
+ for (const e in t)
20
+ s.set(e, t[e]);
21
+ return new r(`${this.pathname}?${s.toString()}`, this);
8
22
  }
9
23
  }
10
24
  export {
11
- u as executeWithTryCatch
25
+ r as Url
12
26
  };
package/dist/index9.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r extends URL{constructor(t,e){super(t,e)}endpoint(t){t.startsWith("/")||(t=`/${t}`);const e=`${this.pathname!=="/"?this.pathname:""}${t}`;return new r(e,this)}socket(){if(this.protocol==="https:")return this.origin.replace("https","wss");if(this.protocol==="http:")return this.origin.replace("http","ws");throw new Error("Invalid protocol")}addSearchParams(t){const e=new URLSearchParams(this.search);for(const s in t)e.set(s,t[s]);return new r(`${this.pathname}?${e.toString()}`,this)}}exports.Url=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(t=>(t.Authorization="Authorization",t.ApiKey="api-key",t))(e||{});exports.AuthHeaderEnum=e;
package/dist/index9.js CHANGED
@@ -1,26 +1,4 @@
1
- class r extends URL {
2
- constructor(t, s) {
3
- super(t, s);
4
- }
5
- endpoint(t) {
6
- t.startsWith("/") || (t = `/${t}`);
7
- const s = `${this.pathname !== "/" ? this.pathname : ""}${t}`;
8
- return new r(s, this);
9
- }
10
- socket() {
11
- if (this.protocol === "https:")
12
- return this.origin.replace("https", "wss");
13
- if (this.protocol === "http:")
14
- return this.origin.replace("http", "ws");
15
- throw new Error("Invalid protocol");
16
- }
17
- addSearchParams(t) {
18
- const s = new URLSearchParams(this.search);
19
- for (const e in t)
20
- s.set(e, t[e]);
21
- return new r(`${this.pathname}?${s.toString()}`, this);
22
- }
23
- }
1
+ var o = /* @__PURE__ */ ((i) => (i.Authorization = "Authorization", i.ApiKey = "api-key", i))(o || {});
24
2
  export {
25
- r as Url
3
+ o as AuthHeaderEnum
26
4
  };
@@ -6,8 +6,8 @@ export * from './lib/utils';
6
6
  export * from './lib/approve';
7
7
  export * from './lib/blockNumber';
8
8
  export * from './lib/eventBroker';
9
- export * from './lib/result';
9
+ export * from './lib/result/result';
10
10
  export * from './lib/digestKey/digestKey';
11
11
  export * from './lib/fetcher';
12
12
  export * from './lib/types';
13
- export * from './lib/tryCatch';
13
+ export * from './lib/tryCatch/tryCatch';
@@ -1,5 +1,5 @@
1
1
  import { TransactionReceipt, WalletClient } from 'viem';
2
- import { AsyncResult } from './result';
2
+ import { AsyncResult } from './result/result';
3
3
 
4
4
  export declare const checkAllowanceAndApprove: (amount: number, tokenAddress: string, contractAddress: string, walletClient: WalletClient) => AsyncResult<string, string>;
5
5
  export declare const waitForTransactionReceipt: (walletClient: WalletClient, hash: `0x${string}`, interval?: number, timeout?: number) => AsyncResult<TransactionReceipt, string>;
@@ -1,4 +1,4 @@
1
- import { AsyncResult, Result } from '../../result';
1
+ import { AsyncResult, Result } from '../../result/result';
2
2
  import { AuthHeader, IAuth } from '../auth.types';
3
3
 
4
4
  export declare class ApiKey implements IAuth {
@@ -1,4 +1,4 @@
1
- import { AsyncResult, Result } from '../result';
1
+ import { AsyncResult, Result } from '../result/result';
2
2
  import { IStore } from '../store/store.interface';
3
3
 
4
4
  export type SiweOpts = {
@@ -1,5 +1,5 @@
1
1
  import { AuthHeader, IAuth } from '../auth.types';
2
- import { AsyncResult, Result } from '../../result';
2
+ import { AsyncResult, Result } from '../../result/result';
3
3
 
4
4
  export declare class Passkey implements IAuth {
5
5
  private token;
@@ -1,7 +1,7 @@
1
1
  import { Url } from '../../url';
2
2
  import { PasskeyToken } from './passkey.types';
3
3
  import { IStore } from '../../store';
4
- import { AsyncResult, Result } from '../../result';
4
+ import { AsyncResult, Result } from '../../result/result';
5
5
 
6
6
  export declare class PasskeyLogin {
7
7
  private url;
@@ -2,7 +2,7 @@ import { AuthHeader, IAuth, SiweOpts } from '../auth.types';
2
2
  import { Url } from '../../url';
3
3
  import { WalletClient } from 'viem';
4
4
  import { DigestKey } from '../../digestKey/digestKey';
5
- import { AsyncResult, Result } from '../../result';
5
+ import { AsyncResult, Result } from '../../result/result';
6
6
 
7
7
  export declare class Siwe implements IAuth {
8
8
  private readonly url;
@@ -1,5 +1,5 @@
1
1
  import { WalletClient, Chain } from 'viem';
2
- import { AsyncResult, Err, Ok } from '../result';
2
+ import { AsyncResult, Err, Ok } from '../result/result';
3
3
 
4
4
  /**
5
5
  * Fetches the latest block number of EVM chain
@@ -1,4 +1,4 @@
1
- import { Err, Ok } from '../result';
1
+ import { Err, Ok } from '../result/result';
2
2
 
3
3
  export declare class DigestKey {
4
4
  private _digestKey;
@@ -0,0 +1 @@
1
+ export * from './fetcher';
@@ -0,0 +1 @@
1
+ export * from './result';
@@ -0,0 +1 @@
1
+ export * from './tryCatch';
@@ -1,4 +1,4 @@
1
- import { AsyncResult } from './result';
1
+ import { AsyncResult } from '../result/result';
2
2
 
3
3
  /**
4
4
  * A wrapper function to execute a function with try catch block.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.2.1-beta.1",
3
+ "version": "2.2.1-beta.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",