@glowlabs-org/utils 0.2.62 → 0.2.64

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,5 +1,8 @@
1
1
  import type { ControlWallet, WalletDetails } from "../types";
2
+ import type { MintedEvent, StakedEvent } from "../types";
2
3
  export declare function WalletsRouter(baseUrl: string): {
3
4
  readonly fetchAllWallets: () => Promise<ControlWallet[]>;
4
5
  readonly fetchWalletByAddress: (wallet: string) => Promise<WalletDetails>;
6
+ readonly fetchWalletMintedEvents: (wallet: string, page?: number, limit?: number) => Promise<MintedEvent[]>;
7
+ readonly fetchWalletStakeEvents: (wallet: string, page?: number, limit?: number, regionId?: number) => Promise<StakedEvent[]>;
5
8
  };
@@ -12,8 +12,9 @@ export interface StakedEvent {
12
12
  epoch: number;
13
13
  wallet: string;
14
14
  regionId: number;
15
+ regionName: string;
15
16
  amount: string;
16
- direction: "stake" | "unstake";
17
+ direction: "stake" | "unstake" | "restake";
17
18
  ts: string;
18
19
  }
19
20
  export interface PendingTransfer {
@@ -1913,6 +1913,11 @@ function WalletsRouter(baseUrl) {
1913
1913
  }
1914
1914
  return (await res.json());
1915
1915
  };
1916
+ const buildPaginationQuery = (page, limit) => {
1917
+ const p = page ?? 1;
1918
+ const l = limit ?? 50;
1919
+ return `?page=${p}&limit=${l}`;
1920
+ };
1916
1921
  const fetchAllWallets = async () => {
1917
1922
  try {
1918
1923
  const data = await request(`/wallets/all`);
@@ -1930,11 +1935,33 @@ function WalletsRouter(baseUrl) {
1930
1935
  throw new Error(parseApiError(error));
1931
1936
  }
1932
1937
  };
1938
+ const fetchWalletMintedEvents = async (wallet, page, limit) => {
1939
+ try {
1940
+ const data = await request(`/wallets/address/${encodeURIComponent(wallet)}/events/minted${buildPaginationQuery(page, limit)}`);
1941
+ return data.events ?? [];
1942
+ }
1943
+ catch (error) {
1944
+ throw new Error(parseApiError(error));
1945
+ }
1946
+ };
1947
+ const fetchWalletStakeEvents = async (wallet, page, limit, regionId) => {
1948
+ try {
1949
+ const base = `/wallets/address/${encodeURIComponent(wallet)}/events/stake${buildPaginationQuery(page, limit)}`;
1950
+ const query = typeof regionId === "number" ? `${base}&regionId=${regionId}` : base;
1951
+ const data = await request(query);
1952
+ return data.events ?? [];
1953
+ }
1954
+ catch (error) {
1955
+ throw new Error(parseApiError(error));
1956
+ }
1957
+ };
1933
1958
  return {
1934
1959
  fetchAllWallets,
1935
1960
  fetchWalletByAddress,
1961
+ fetchWalletMintedEvents,
1962
+ fetchWalletStakeEvents,
1936
1963
  };
1937
1964
  }
1938
1965
 
1939
1966
  export { ControlRouter as C, DECIMALS_BY_TOKEN as D, ForwarderError as F, GLOW_WEIGHT_DECIMAL_PRECISION as G, HUB_URL as H, KickstarterRouter as K, MAX_WEIGHT as M, RegionRouter as R, USDG_WEIGHT_DECIMAL_PRECISION as U, WalletsRouter as W, allRegions as a, usStates as b, countries as c, FORWARDER_ABI as d, GCA_URLS as e, getAddresses as g, regionMetadata as r, useForwarder as u };
1940
- //# sourceMappingURL=wallets-router-BPRWWUbm.js.map
1967
+ //# sourceMappingURL=wallets-router-KYbgrMuV.js.map