@argent/x-shared 1.45.0 → 1.46.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("starknet"),n=require("../../errors/address.cjs"),l=require("../../errors/call.cjs"),u=require("../../errors/network.cjs"),w=require("../../utils/starknet/starknet.cjs"),d=require("./address.cjs"),S=require("./network.cjs");function m(r){return r.replace(".stark","").split(".").map(s=>i.starknetId.useEncoded(s).toString(10))}function A(r){const t=S.getChainIdFromNetworkId(r);return i.starknetId.getStarknetIdContract(t)}function k(r,t){const o=A(t),s=m(r);try{const e={domain:s,hint:[]};return w.callSchema.parse({contractAddress:o,entrypoint:"domain_to_address",calldata:e})}catch(a){throw new l.CallError({code:"NOT_VALID",options:{error:a}})}}async function I(r,t,o){if(!t||!o)throw new u.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let s=null;try{s=k(r,t)}catch(c){throw new l.CallError({code:"NOT_VALID",options:{error:c}})}let a,e;try{a=await o.callContract(s),e=a[0]}catch{throw new n.AddressError({code:"STARKNAME_ERROR"})}if(d.isZeroAddress(e))throw new n.AddressError({code:"STARKNAME_NOT_FOUND",message:`${r} not found`});if(!d.isValidAddress(e))throw new n.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${r} resolved to an invalid address (${e})`});return d.normalizeAddress(e)}exports.getAddressFromStarkName=I;exports.getCallFromStarkName=k;exports.getStarknetIdContractAddressFromNetworkId=A;exports.starkNameToCallDataDomain=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("starknet"),n=require("../../errors/address.cjs"),i=require("../../errors/call.cjs"),u=require("../../errors/network.cjs"),w=require("../../utils/starknet/starknet.cjs"),d=require("./address.cjs"),S=require("./network.cjs");function l(r){return r.replace(".stark","").split(".").map(s=>c.starknetId.useEncoded(s).toString(10))}function m(r){const t=S.getChainIdFromNetworkId(r);return c.starknetId.getStarknetIdContract(t)}function A(r,t){const o=m(t),s=l(r);try{const e={domain:s,hint:[]};return w.callSchema.parse({contractAddress:o,entrypoint:"domain_to_address",calldata:e})}catch(a){throw new i.CallError({code:"NOT_VALID",options:{error:a}})}}async function I(r,t,o){if(!t||!o)throw new u.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let s=null;try{s=A(r,t)}catch(N){throw new i.CallError({code:"NOT_VALID",options:{error:N}})}let a,e;try{a=await o.callContract(s),e=a[0]}catch{throw new n.AddressError({code:"STARKNAME_ERROR"})}if(d.isZeroAddress(e))throw new n.AddressError({code:"STARKNAME_NOT_FOUND",message:`${r} not found`});if(!d.isValidAddress(e))throw new n.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${r} resolved to an invalid address (${e})`});return d.normalizeAddress(e)}exports.getAddressFromStarkName=I;exports.getCallFromStarkName=A;exports.getStarknetIdContractAddressFromNetworkId=m;exports.starkNameToCallDataDomain=l;
@@ -1,19 +1,19 @@
1
- import { starknetId as c } from "starknet";
1
+ import { starknetId as d } from "starknet";
2
2
  import { AddressError as s } from "../../errors/address.js";
3
- import { CallError as i } from "../../errors/call.js";
3
+ import { CallError as c } from "../../errors/call.js";
4
4
  import { NetworkError as l } from "../../errors/network.js";
5
5
  import { callSchema as A } from "../../utils/starknet/starknet.js";
6
6
  import { isZeroAddress as N, isValidAddress as p, normalizeAddress as f } from "./address.js";
7
7
  import { getChainIdFromNetworkId as w } from "./network.js";
8
- function h(r) {
9
- return r.replace(".stark", "").split(".").map((n) => c.useEncoded(n).toString(10));
8
+ function h(t) {
9
+ return t.replace(".stark", "").split(".").map((n) => d.useEncoded(n).toString(10));
10
10
  }
11
- function I(r) {
12
- const t = w(r);
13
- return c.getStarknetIdContract(t);
11
+ function I(t) {
12
+ const r = w(t);
13
+ return d.getStarknetIdContract(r);
14
14
  }
15
- function S(r, t) {
16
- const e = I(t), n = h(r);
15
+ function S(t, r) {
16
+ const e = I(r), n = h(t);
17
17
  try {
18
18
  const o = { domain: n, hint: [] };
19
19
  return A.parse({
@@ -22,24 +22,24 @@ function S(r, t) {
22
22
  calldata: o
23
23
  });
24
24
  } catch (a) {
25
- throw new i({
25
+ throw new c({
26
26
  code: "NOT_VALID",
27
27
  options: { error: a }
28
28
  });
29
29
  }
30
30
  }
31
- async function g(r, t, e) {
32
- if (!t || !e)
31
+ async function g(t, r, e) {
32
+ if (!r || !e)
33
33
  throw new l({
34
34
  code: "NO_NETWORK_OR_MULTICALL"
35
35
  });
36
36
  let n = null;
37
37
  try {
38
- n = S(r, t);
39
- } catch (d) {
40
- throw new i({
38
+ n = S(t, r);
39
+ } catch (m) {
40
+ throw new c({
41
41
  code: "NOT_VALID",
42
- options: { error: d }
42
+ options: { error: m }
43
43
  });
44
44
  }
45
45
  let a, o;
@@ -53,12 +53,12 @@ async function g(r, t, e) {
53
53
  if (N(o))
54
54
  throw new s({
55
55
  code: "STARKNAME_NOT_FOUND",
56
- message: `${r} not found`
56
+ message: `${t} not found`
57
57
  });
58
58
  if (!p(o))
59
59
  throw new s({
60
60
  code: "STARKNAME_INVALID_ADDRESS",
61
- message: `${r} resolved to an invalid address (${o})`
61
+ message: `${t} resolved to an invalid address (${o})`
62
62
  });
63
63
  return f(o);
64
64
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../../errors/address.cjs"),d=require("../../address.cjs"),o=require("../../starknetId.cjs"),n=require("../../getAddressFromStarkName.cjs"),i=require("../../argentName.cjs"),A=require("../../getAddressFromArgentName.cjs");class c{constructor(e,r,t){this.httpService=e,this.baseUrl=r,this.allowedArgentNameNetworkId=t}async parseAddressOrDomain(e,r,t){if(d.isAddress(e))return d.normalizeAddress(e);try{return await this.getAddressFromDomainName(e,r,t)}catch{throw new s.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(e,r,t){if(o.isStarknetId(e))return n.getAddressFromStarkName(e,r,t);if(i.isArgentName(e)){if(r!==this.allowedArgentNameNetworkId)throw new s.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return A.getAddressFromArgentName(e,this.httpService,this.baseUrl)}throw new s.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}exports.StarknetAddressService=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../../errors/address.cjs"),d=require("../../address.cjs"),a=require("../../starknetId.cjs"),o=require("../../getAddressFromStarkName.cjs"),n=require("../../argentName.cjs"),i=require("../../getAddressFromArgentName.cjs");class A{constructor(e,r,t){this.httpService=e,this.baseUrl=r,this.allowedArgentNameNetworkId=t}async parseAddressOrDomain(e,r,t){if(d.isAddress(e))return d.normalizeAddress(e);try{return await this.getAddressFromDomainName(e,r,t)}catch{throw new s.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(e,r,t){if(a.isStarknetId(e))return o.getAddressFromStarkName(e,r,t);if(n.isArgentName(e)){if(r!==this.allowedArgentNameNetworkId)throw new s.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return i.getAddressFromArgentName(e,this.httpService,this.baseUrl)}throw new s.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}exports.StarknetAddressService=A;
@@ -1,16 +1,16 @@
1
1
  import { AddressError as s } from "../../../../errors/address.js";
2
- import { isAddress as i, normalizeAddress as m } from "../../address.js";
3
- import { isStarknetId as a } from "../../starknetId.js";
4
- import { getAddressFromStarkName as d } from "../../getAddressFromStarkName.js";
5
- import { isArgentName as n } from "../../argentName.js";
6
- import { getAddressFromArgentName as A } from "../../getAddressFromArgentName.js";
2
+ import { isAddress as o, normalizeAddress as i } from "../../address.js";
3
+ import { isStarknetId as m } from "../../starknetId.js";
4
+ import { getAddressFromStarkName as a } from "../../getAddressFromStarkName.js";
5
+ import { isArgentName as d } from "../../argentName.js";
6
+ import { getAddressFromArgentName as n } from "../../getAddressFromArgentName.js";
7
7
  class p {
8
8
  constructor(e, r, t) {
9
9
  this.httpService = e, this.baseUrl = r, this.allowedArgentNameNetworkId = t;
10
10
  }
11
11
  async parseAddressOrDomain(e, r, t) {
12
- if (i(e))
13
- return m(e);
12
+ if (o(e))
13
+ return i(e);
14
14
  try {
15
15
  return await this.getAddressFromDomainName(e, r, t);
16
16
  } catch {
@@ -18,15 +18,15 @@ class p {
18
18
  }
19
19
  }
20
20
  async getAddressFromDomainName(e, r, t) {
21
- if (a(e))
22
- return d(e, r, t);
23
- if (n(e)) {
21
+ if (m(e))
22
+ return a(e, r, t);
23
+ if (d(e)) {
24
24
  if (r !== this.allowedArgentNameNetworkId)
25
25
  throw new s({
26
26
  code: "ARGENT_NAME_INVALID_NETWORK",
27
27
  message: `Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`
28
28
  });
29
- return A(e, this.httpService, this.baseUrl);
29
+ return n(e, this.httpService, this.baseUrl);
30
30
  }
31
31
  throw new s({
32
32
  code: "NO_ADDRESS_FROM_DOMAIN"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=(o,e,t)=>{const r=new Error(o);r.name="FetcherError",r.url=e.url,r.status=e.status,r.statusText=e.statusText,r.responseText=t;try{const s=JSON.parse(t);r.responseJson=s}catch{}return r},n=async(o,e)=>{const t=await fetch(o,e),r=await t.text();if(!t.ok)throw c("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw c("An error occurred while parsing",t,r)}},a=async(o,e)=>{const t=await fetch(o,{method:"POST",...e}),r=await t.text();if(!t.ok)throw c("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw c("An error occurred while parsing",t,r)}};exports.fetchData=n;exports.fetcherError=c;exports.postData=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=(o,e,t)=>{const r=new Error(o);r.name="FetcherError",r.url=e.url,r.status=e.status,r.statusText=e.statusText,r.responseText=t;try{const c=JSON.parse(t);r.responseJson=c}catch{}return r},n=async(o,e)=>{const t=await fetch(o,e),r=await t.text();if(!t.ok)throw s("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw s("An error occurred while parsing",t,r)}},a=async(o,e)=>{const t=await fetch(o,{method:"POST",...e}),r=await t.text();if(!t.ok)throw s("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw s("An error occurred while parsing",t,r)}};exports.fetchData=n;exports.fetcherError=s;exports.postData=a;
@@ -1,20 +1,20 @@
1
- const n = (o, e, t) => {
1
+ const s = (o, e, t) => {
2
2
  const r = new Error(o);
3
3
  r.name = "FetcherError", r.url = e.url, r.status = e.status, r.statusText = e.statusText, r.responseText = t;
4
4
  try {
5
- const s = JSON.parse(t);
6
- r.responseJson = s;
5
+ const n = JSON.parse(t);
6
+ r.responseJson = n;
7
7
  } catch {
8
8
  }
9
9
  return r;
10
10
  }, c = async (o, e) => {
11
11
  const t = await fetch(o, e), r = await t.text();
12
12
  if (!t.ok)
13
- throw n("An error occurred while fetching", t, r);
13
+ throw s("An error occurred while fetching", t, r);
14
14
  try {
15
15
  return JSON.parse(r);
16
16
  } catch {
17
- throw n("An error occurred while parsing", t, r);
17
+ throw s("An error occurred while parsing", t, r);
18
18
  }
19
19
  }, a = async (o, e) => {
20
20
  const t = await fetch(o, {
@@ -22,15 +22,15 @@ const n = (o, e, t) => {
22
22
  ...e
23
23
  }), r = await t.text();
24
24
  if (!t.ok)
25
- throw n("An error occurred while fetching", t, r);
25
+ throw s("An error occurred while fetching", t, r);
26
26
  try {
27
27
  return JSON.parse(r);
28
28
  } catch {
29
- throw n("An error occurred while parsing", t, r);
29
+ throw s("An error occurred while parsing", t, r);
30
30
  }
31
31
  };
32
32
  export {
33
33
  c as fetchData,
34
- n as fetcherError,
34
+ s as fetcherError,
35
35
  a as postData
36
36
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("url-join"),o=require("./fetcher.cjs"),c=async(t,r)=>{try{const{time:e}=await o.fetchData(n(t,"time"),{headers:r});return e}catch{throw new Error("failed to request time")}},a=async(t,r)=>{const e=await c(t,r);return Math.floor(e)};exports.getBackendTimeNowSeconds=a;exports.getBackendTimeSeconds=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("url-join"),r=require("./fetcher.cjs"),n=async(e,t)=>{try{const{time:c}=await r.fetchData(o(e,"time"),{headers:t});return c}catch{throw new Error("failed to request time")}},a=async(e,t)=>{const c=await n(e,t);return Math.floor(c)};exports.getBackendTimeNowSeconds=a;exports.getBackendTimeSeconds=n;
@@ -1,17 +1,17 @@
1
- import o from "url-join";
1
+ import r from "url-join";
2
2
  import { fetchData as n } from "./fetcher.js";
3
- const a = async (t, r) => {
3
+ const a = async (e, t) => {
4
4
  try {
5
- const { time: e } = await n(o(t, "time"), {
6
- headers: r
5
+ const { time: o } = await n(r(e, "time"), {
6
+ headers: t
7
7
  });
8
- return e;
8
+ return o;
9
9
  } catch {
10
10
  throw new Error("failed to request time");
11
11
  }
12
- }, s = async (t, r) => {
13
- const e = await a(t, r);
14
- return Math.floor(e);
12
+ }, s = async (e, t) => {
13
+ const o = await a(e, t);
14
+ return Math.floor(o);
15
15
  };
16
16
  export {
17
17
  s as getBackendTimeNowSeconds,
@@ -12,6 +12,7 @@ export * from './onchainRecovery';
12
12
  export * from './platform';
13
13
  export * from './signer';
14
14
  export * from './staking';
15
+ export * from './storage';
15
16
  export * from './tokens';
16
17
  export * from './transactions';
17
18
  export * from './utils';
@@ -0,0 +1,14 @@
1
+ import { IObjectStore, IRepository } from '../interface';
2
+ export declare class MockFnObjectStore<T> implements IObjectStore<T> {
3
+ namespace: string;
4
+ get: import('vitest').Mock<(...args: any[]) => any>;
5
+ set: import('vitest').Mock<(...args: any[]) => any>;
6
+ subscribe: import('vitest').Mock<(...args: any[]) => any>;
7
+ }
8
+ export declare class MockFnRepository<T> implements IRepository<T> {
9
+ namespace: string;
10
+ get: import('vitest').Mock<(...args: any[]) => any>;
11
+ upsert: import('vitest').Mock<(...args: any[]) => any>;
12
+ subscribe: import('vitest').Mock<(...args: any[]) => any>;
13
+ remove: import('vitest').Mock<(...args: any[]) => any>;
14
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("lodash-es");function f(t){return{compareFn:g.isEqual,mergeFn:(i,n)=>n,...t}}function h(t,i={}){const{compareFn:n,mergeFn:u}=f(i);return t.reduce((r,e)=>r.some(o=>n(o,e))?r.map(o=>n(o,e)?u(o,e):o):[...r,e],[])}function p(t,i,n={}){const{compareFn:u,mergeFn:r}=f(n),e=n.insertMode??"push",o=h(t,n);return i.reduce((s,a)=>{const c=s.findIndex(d=>u(d,a));return c===-1?e==="unshift"?[a,...s]:[...s,a]:[...s.slice(0,c),r(s[c],a),...s.slice(c+1)]},o)}function l(t){const i=r=>r;return{defaults:[],serialize:i,deserialize:i,compare:(r,e)=>r===e,merge:(r,e)=>e,...t}}exports.mergeArrayStableWith=p;exports.optionsWithDefaults=l;
@@ -0,0 +1,10 @@
1
+ import { IRepositoryOptions } from './interface';
2
+ interface OptionFunctions<T> {
3
+ compareFn?: (a: T, b: T) => boolean;
4
+ mergeFn?: (a: T, b: T) => T;
5
+ }
6
+ export declare function mergeArrayStableWith<T>(source: T[], other: T[], options?: OptionFunctions<T> & {
7
+ insertMode?: "unshift" | "push";
8
+ }): T[];
9
+ export declare function optionsWithDefaults<T, O extends IRepositoryOptions<T>>(options: O): Required<IRepositoryOptions<T>> & O;
10
+ export {};
@@ -0,0 +1,38 @@
1
+ import { isEqual as d } from "lodash-es";
2
+ function a(t) {
3
+ return {
4
+ compareFn: d,
5
+ mergeFn: (i, e) => e,
6
+ ...t
7
+ };
8
+ }
9
+ function g(t, i = {}) {
10
+ const { compareFn: e, mergeFn: u } = a(i);
11
+ return t.reduce((r, n) => r.some((o) => e(o, n)) ? r.map((o) => e(o, n) ? u(o, n) : o) : [...r, n], []);
12
+ }
13
+ function h(t, i, e = {}) {
14
+ const { compareFn: u, mergeFn: r } = a(e), n = e.insertMode ?? "push", o = g(t, e);
15
+ return i.reduce((s, c) => {
16
+ const f = s.findIndex((p) => u(p, c));
17
+ return f === -1 ? n === "unshift" ? [c, ...s] : [...s, c] : [
18
+ ...s.slice(0, f),
19
+ r(s[f], c),
20
+ ...s.slice(f + 1)
21
+ ];
22
+ }, o);
23
+ }
24
+ function F(t) {
25
+ const i = (r) => r;
26
+ return {
27
+ defaults: [],
28
+ serialize: i,
29
+ deserialize: i,
30
+ compare: (r, n) => r === n,
31
+ merge: (r, n) => n,
32
+ ...t
33
+ };
34
+ }
35
+ export {
36
+ h as mergeArrayStableWith,
37
+ F as optionsWithDefaults
38
+ };
@@ -0,0 +1,3 @@
1
+ export type * from './interface';
2
+ export * from './utils';
3
+ export * from './base';
@@ -0,0 +1,91 @@
1
+ import { SelectorFn } from '../tokens';
2
+ /**
3
+ * Represents a value of type T or a Promise of type T.
4
+ */
5
+ export type AllowPromise<T> = T | Promise<T>;
6
+ /**
7
+ * Represents a value of type T or an array of type T.
8
+ */
9
+ export type AllowArray<T> = T | T[];
10
+ /**
11
+ * A function that takes an array of values of type T and returns an array of values of type T.
12
+ */
13
+ export type SetterFn<T> = (value: T[]) => T[];
14
+ /**
15
+ * Represents a change in storage, including the old and new values.
16
+ */
17
+ export interface StorageChange<T = any> {
18
+ /** Optional. The new value of the item, if there is a new value. */
19
+ newValue?: T;
20
+ /** Optional. The old value of the item, if there was an old value. */
21
+ oldValue?: T;
22
+ }
23
+ /**
24
+ * Represents options for creating a new repository.
25
+ */
26
+ export interface IRepositoryOptions<T> {
27
+ /** The namespace for the repository. */
28
+ namespace: string;
29
+ /** Optional. The default values for the repository. */
30
+ defaults?: T[];
31
+ /** Optional. A function that serializes a value of type T. */
32
+ serialize?: (value: T[]) => any;
33
+ /** Optional. A function that deserializes a value to type T. */
34
+ deserialize?: (value: any) => AllowPromise<T[]>;
35
+ /** Optional. A function that compares two values of type T and returns a boolean. */
36
+ compare?: (a: T, b: T) => boolean;
37
+ /** Optional. A function that merges two values of type T. */
38
+ merge?: (oldValue: T, newValue: T) => T;
39
+ }
40
+ export type UpsertResult = {
41
+ created: number;
42
+ updated: number;
43
+ };
44
+ /**
45
+ * Represents a repository for managing data of type T.
46
+ */
47
+ export interface IRepository<T> {
48
+ /** The namespace for the repository. */
49
+ namespace: string;
50
+ /**
51
+ * Retrieves items from the repository based on the provided selector function.
52
+ * @param selector - Optional. A function that filters the items to be retrieved.
53
+ * @returns A Promise that resolves to an array of items of type T.
54
+ */
55
+ get(selector?: SelectorFn<T>): Promise<T[]>;
56
+ /**
57
+ * Inserts or updates items in the repository.
58
+ * @param value - An array of items, a single item, or a setter function that operates on an array of items.
59
+ * @returns A Promise that resolves to a boolean indicating whether the operation succeeded.
60
+ */
61
+ upsert(value: AllowArray<T> | SetterFn<T>, insertMode?: "push" | "unshift"): Promise<UpsertResult>;
62
+ /**
63
+ * Removes items from the repository based on the provided value or selector function.
64
+ * @param value - An array of items, a single item, or a selector function that filters the items to be removed.
65
+ * @returns A Promise that resolves to an array of removed items of type T.
66
+ */
67
+ remove(value: AllowArray<T> | SelectorFn<T>): Promise<T[]>;
68
+ /**
69
+ * Subscribes to changes in the repository.
70
+ * @param callback - A function that gets called when there are changes in the repository.
71
+ * @returns A function that can be called to unsubscribe from the changes.
72
+ */
73
+ subscribe(callback: (changeSet: StorageChange<T[]>) => AllowPromise<void>): () => void;
74
+ }
75
+ export interface IObjectStoreOptions<T> {
76
+ namespace: string;
77
+ /** Optional. The default values for the repository. */
78
+ defaults?: T;
79
+ /** Optional. A function that serializes a value of type T. */
80
+ serialize?: (value: T) => any;
81
+ /** Optional. A function that deserializes a value to type T. */
82
+ deserialize?: (value: any) => AllowPromise<T>;
83
+ /** Optional. A function that merges two values of type T. */
84
+ merge?: (oldValue: T, newValue: Partial<T>) => T;
85
+ }
86
+ export interface IObjectStore<T> {
87
+ namespace: string;
88
+ get(): Promise<T>;
89
+ set(value: Partial<T>): Promise<void>;
90
+ subscribe(callback: (value: StorageChange<Partial<T>>) => AllowPromise<void>): () => void;
91
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e,f,r,i){if(typeof e=="object"&&e!==null)for(const t in e)typeof e[t]=="object"&&e[t]!==null?n(e[t],f,r,i):(!i||i.includes(t))&&e[t]===f&&(e[t]=r);else Array.isArray(e)&&e.forEach((t,l)=>{typeof t=="object"&&t!==null?n(t,f,r,i):t===f&&(e[l]=r)})}function c(e,f){if(typeof e=="object"&&e!==null){for(const r in e)if(typeof e[r]=="object"&&e[r]!==null){if(c(e[r],f))return!0}else if(e[r]===f)return!0}else if(Array.isArray(e)){for(const r of e)if(typeof r=="object"&&r!==null){if(c(r,f))return!0}else if(r===f)return!0}return!1}exports.containsValue=c;exports.replaceValueRecursively=n;
@@ -0,0 +1,5 @@
1
+ /** Function to recursively replace the value in an object or array
2
+ * Optionally, the replacement can be limited to specific keys
3
+ */
4
+ export declare function replaceValueRecursively(obj: any, oldValue: any, newValue: any, keys?: string[]): void;
5
+ export declare function containsValue(obj: any, value: any): boolean;
@@ -0,0 +1,30 @@
1
+ function n(r, t, f, i) {
2
+ if (typeof r == "object" && r !== null)
3
+ for (const e in r)
4
+ typeof r[e] == "object" && r[e] !== null ? n(r[e], t, f, i) : (!i || i.includes(e)) && r[e] === t && (r[e] = f);
5
+ else Array.isArray(r) && r.forEach((e, l) => {
6
+ typeof e == "object" && e !== null ? n(e, t, f, i) : e === t && (r[l] = f);
7
+ });
8
+ }
9
+ function c(r, t) {
10
+ if (typeof r == "object" && r !== null) {
11
+ for (const f in r)
12
+ if (typeof r[f] == "object" && r[f] !== null) {
13
+ if (c(r[f], t))
14
+ return !0;
15
+ } else if (r[f] === t)
16
+ return !0;
17
+ } else if (Array.isArray(r)) {
18
+ for (const f of r)
19
+ if (typeof f == "object" && f !== null) {
20
+ if (c(f, t))
21
+ return !0;
22
+ } else if (f === t)
23
+ return !0;
24
+ }
25
+ return !1;
26
+ }
27
+ export {
28
+ c as containsValue,
29
+ n as replaceValueRecursively
30
+ };
@@ -30,7 +30,7 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
30
30
  products: import('zod').objectOutputType<{
31
31
  productId: import('zod').ZodOptional<import('zod').ZodString>;
32
32
  name: import('zod').ZodString;
33
- manageUrl: import('zod').ZodString;
33
+ manageUrl: import('zod').ZodOptional<import('zod').ZodString>;
34
34
  type: import('zod').ZodUnion<[import('zod').ZodLiteral<"concentratedLiquidityPosition">, import('zod').ZodLiteral<"collateralizedDebtPosition">, import('zod').ZodLiteral<"delegatedTokens">, import('zod').ZodLiteral<"strkDelegatedStaking">, import('zod').ZodLiteral<"staking">]>;
35
35
  groups: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodObject<{
36
36
  name: import('zod').ZodOptional<import('zod').ZodString>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),a=require("../../../chains/starknet/address.cjs"),h=require("./defiPositionType.model.cjs"),b=require("../../../utils/schemas.cjs"),u=e.z.object({status:e.z.literal("initialising")}).or(e.z.object({status:e.z.literal("initialised"),balances:e.z.array(e.z.object({tokenAddress:a.addressSchemaArgentBackend,tokenBalance:e.z.string()}))})),o=e.z.object({id:e.z.number(),address:a.addressSchema,brandColor:e.z.string().optional(),name:e.z.string(),symbol:e.z.string(),decimals:e.z.number(),iconUrl:e.z.string().optional(),sendable:e.z.boolean(),popular:e.z.boolean(),refundable:e.z.boolean(),listed:e.z.boolean(),tradable:e.z.boolean(),category:e.z.union([e.z.literal("tokens"),e.z.literal("currencies"),e.z.literal("savings")]),pricingId:e.z.number().optional(),dappId:e.z.string().optional(),marketData:e.z.object({marketCap:e.z.number(),marketCap24hChange:e.z.number(),dailyVolume:e.z.number(),rank:e.z.number()}).optional(),tags:e.z.array(e.z.string()).optional()}),k=e.z.object({tokens:e.z.array(o)}),D=o,p=e.z.object({pricingId:e.z.number(),ethValue:e.z.string(),ccyValue:e.z.string(),ethDayChange:e.z.string(),ccyDayChange:e.z.string()}),y=e.z.object({prices:e.z.array(p)}),t=e.z.object({tokenAddress:a.addressSchemaArgentBackend,principal:e.z.string(),accruedFees:e.z.string(),minPrice:e.z.string(),maxPrice:e.z.string(),currentPrice:e.z.string()}),i=e.z.object({id:e.z.string(),investmentId:e.z.string().optional(),tokenAddress:a.addressSchema.optional(),totalBalances:e.z.record(e.z.string())}),n=i.extend({tokenId:e.z.string(),data:e.z.object({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),token0:t,token1:t})}),P=e.z.array(n),s=i.extend({data:e.z.object({apy:e.z.string()}),investmentId:e.z.string().optional(),totalBalances:e.z.record(e.z.string())}),f=e.z.array(s),r=i.extend({data:e.z.object({apy:e.z.string().optional(),group:e.z.number().optional(),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean()})}),j=e.z.array(r),c=i.extend({id:e.z.string(),data:e.z.object({delegatingTo:a.addressSchema}),totalBalances:e.z.record(e.z.string())}),T=e.z.array(c),d=i.extend({investmentId:e.z.string(),data:e.z.object({stakerInfo:e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().optional(),address:a.addressSchema}),accruedRewards:e.z.string(),stakedAmount:e.z.string(),pendingWithdrawal:e.z.object({amount:e.z.string(),withdrawableAfter:e.z.number()}).optional(),apy:e.z.string().optional()})}),I=e.z.array(d),z=n.or(r).or(c).or(s).or(d),l=e.z.array(z),m=b.createSchemaWithWarnings({productId:e.z.string().optional(),name:e.z.string(),manageUrl:e.z.string(),type:h.defiPositionTypeSchema,groups:e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional()})).optional(),positions:l}),g=e.z.object({dappId:e.z.string(),products:e.z.array(m)}),A=e.z.object({dapps:e.z.array(g)}),S=e.z.object({name:e.z.string().optional(),tokenAddress:a.addressSchema,amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),C=e.z.object({accountAddress:a.addressSchema,chain:e.z.string(),airdrops:e.z.array(S)});exports.apiAccountTokenBalancesSchema=u;exports.apiAirdropSchema=S;exports.apiCollateralizedDebtPositionSchema=r;exports.apiCollateralizedDebtPositionsSchema=j;exports.apiConcentratedLiquidityPositionSchema=n;exports.apiConcentratedLiquidityPositionsSchema=P;exports.apiDefiDecompositionProduct=m;exports.apiDefiDecompositionProducts=l;exports.apiDefiDecompositionSchema=g;exports.apiDefiDecompositionToken=t;exports.apiDefiPositionSchema=z;exports.apiDefiPositionsSchema=A;exports.apiDelegatedTokensArraySchema=T;exports.apiDelegatedTokensSchema=c;exports.apiPriceDataResponseSchema=y;exports.apiPriceDetailsSchema=p;exports.apiStakingPositionSchema=s;exports.apiStakingPositionsSchema=f;exports.apiStrkDelegatedStakingPositionsSchema=I;exports.apiStrkDelegatedStakingSchema=d;exports.apiTokenInfoResponseSchema=D;exports.apiTokenInfoSchema=o;exports.apiTokensInfoResponseSchema=k;exports.apiUnclaimedRewardsSchema=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),a=require("../../../chains/starknet/address.cjs"),h=require("./defiPositionType.model.cjs"),b=require("../../../utils/schemas.cjs"),u=e.z.object({status:e.z.literal("initialising")}).or(e.z.object({status:e.z.literal("initialised"),balances:e.z.array(e.z.object({tokenAddress:a.addressSchemaArgentBackend,tokenBalance:e.z.string()}))})),o=e.z.object({id:e.z.number(),address:a.addressSchema,brandColor:e.z.string().optional(),name:e.z.string(),symbol:e.z.string(),decimals:e.z.number(),iconUrl:e.z.string().optional(),sendable:e.z.boolean(),popular:e.z.boolean(),refundable:e.z.boolean(),listed:e.z.boolean(),tradable:e.z.boolean(),category:e.z.union([e.z.literal("tokens"),e.z.literal("currencies"),e.z.literal("savings")]),pricingId:e.z.number().optional(),dappId:e.z.string().optional(),marketData:e.z.object({marketCap:e.z.number(),marketCap24hChange:e.z.number(),dailyVolume:e.z.number(),rank:e.z.number()}).optional(),tags:e.z.array(e.z.string()).optional()}),k=e.z.object({tokens:e.z.array(o)}),D=o,d=e.z.object({pricingId:e.z.number(),ethValue:e.z.string(),ccyValue:e.z.string(),ethDayChange:e.z.string(),ccyDayChange:e.z.string()}),y=e.z.object({prices:e.z.array(d)}),t=e.z.object({tokenAddress:a.addressSchemaArgentBackend,principal:e.z.string(),accruedFees:e.z.string(),minPrice:e.z.string(),maxPrice:e.z.string(),currentPrice:e.z.string()}),i=e.z.object({id:e.z.string(),investmentId:e.z.string().optional(),tokenAddress:a.addressSchema.optional(),totalBalances:e.z.record(e.z.string())}),n=i.extend({tokenId:e.z.string(),data:e.z.object({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),token0:t,token1:t})}),P=e.z.array(n),s=i.extend({data:e.z.object({apy:e.z.string()}),investmentId:e.z.string().optional(),totalBalances:e.z.record(e.z.string())}),f=e.z.array(s),r=i.extend({data:e.z.object({apy:e.z.string().optional(),group:e.z.number().optional(),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean()})}),j=e.z.array(r),c=i.extend({id:e.z.string(),data:e.z.object({delegatingTo:a.addressSchema}),totalBalances:e.z.record(e.z.string())}),T=e.z.array(c),p=i.extend({investmentId:e.z.string(),data:e.z.object({stakerInfo:e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().optional(),address:a.addressSchema}),accruedRewards:e.z.string(),stakedAmount:e.z.string(),pendingWithdrawal:e.z.object({amount:e.z.string(),withdrawableAfter:e.z.number()}).optional(),apy:e.z.string().optional()})}),I=e.z.array(p),z=n.or(r).or(c).or(s).or(p),l=e.z.array(z),m=b.createSchemaWithWarnings({productId:e.z.string().optional(),name:e.z.string(),manageUrl:e.z.string().optional(),type:h.defiPositionTypeSchema,groups:e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional()})).optional(),positions:l}),g=e.z.object({dappId:e.z.string(),products:e.z.array(m)}),A=e.z.object({dapps:e.z.array(g)}),S=e.z.object({name:e.z.string().optional(),tokenAddress:a.addressSchema,amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),C=e.z.object({accountAddress:a.addressSchema,chain:e.z.string(),airdrops:e.z.array(S)});exports.apiAccountTokenBalancesSchema=u;exports.apiAirdropSchema=S;exports.apiCollateralizedDebtPositionSchema=r;exports.apiCollateralizedDebtPositionsSchema=j;exports.apiConcentratedLiquidityPositionSchema=n;exports.apiConcentratedLiquidityPositionsSchema=P;exports.apiDefiDecompositionProduct=m;exports.apiDefiDecompositionProducts=l;exports.apiDefiDecompositionSchema=g;exports.apiDefiDecompositionToken=t;exports.apiDefiPositionSchema=z;exports.apiDefiPositionsSchema=A;exports.apiDelegatedTokensArraySchema=T;exports.apiDelegatedTokensSchema=c;exports.apiPriceDataResponseSchema=y;exports.apiPriceDetailsSchema=d;exports.apiStakingPositionSchema=s;exports.apiStakingPositionsSchema=f;exports.apiStrkDelegatedStakingPositionsSchema=I;exports.apiStrkDelegatedStakingSchema=p;exports.apiTokenInfoResponseSchema=D;exports.apiTokenInfoSchema=o;exports.apiTokensInfoResponseSchema=k;exports.apiUnclaimedRewardsSchema=C;