@glowlabs-org/utils 0.2.150 → 0.2.152

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.
package/dist/cjs/index.js CHANGED
@@ -15,7 +15,7 @@ var viem = require('viem');
15
15
  var merkletreejs = require('merkletreejs');
16
16
  var ethers = require('ethers');
17
17
  var Decimal = require('decimal.js');
18
- var farmsRouter = require('./farms-router-CMpG0RGM.js');
18
+ var farmsRouter = require('./farms-router-DwbBMkUd.js');
19
19
 
20
20
  const GENESIS_TIMESTAMP = 1700352000;
21
21
 
@@ -1,4 +1,4 @@
1
- import type { StakeRequest, RegionStake, WalletRegionStake, WalletRegionUnlocked, WalletRegionCommittedBalance, TransferDetails, GlwRegionRewardsResponse, MintedEventsResponse, StakeEventsResponse, FailedOperationsResponse, PendingTransfersResponse, PendingTransferType, RestakeRequest, MigrationAmountResponse } from "../types";
1
+ import type { StakeRequest, RegionStake, WalletRegionStake, WalletRegionUnlocked, WalletRegionCommittedBalance, TransferDetails, GlwRegionRewardsResponse, MintedEventsResponse, StakeEventsResponse, FailedOperationsResponse, PendingTransfersResponse, PendingTransferType, RestakeRequest, MigrationAmountResponse, RetryFailedOperationResponse, FarmRewardSplit } from "../types";
2
2
  export interface PayProtocolDepositUsingStakedControlRequest {
3
3
  wallet: string;
4
4
  regionId: number;
@@ -28,6 +28,7 @@ export declare function ControlRouter(baseUrl: string): {
28
28
  readonly fetchGctlPrice: () => Promise<string>;
29
29
  readonly fetchGlwPrice: () => Promise<string>;
30
30
  readonly fetchCirculatingSupply: () => Promise<string>;
31
+ readonly fetchHoldersCount: () => Promise<number>;
31
32
  readonly fetchLastNonce: (wallet: string) => Promise<string>;
32
33
  readonly fetchMintedEvents: (page?: number, limit?: number) => Promise<MintedEventsResponse>;
33
34
  readonly fetchStakeEvents: (page?: number, limit?: number, regionId?: number) => Promise<StakeEventsResponse>;
@@ -39,11 +40,12 @@ export declare function ControlRouter(baseUrl: string): {
39
40
  readonly fetchWalletRegionCommittedBalance: (wallet: string, regionId: number) => Promise<WalletRegionCommittedBalance>;
40
41
  readonly fetchTransferDetails: (txId: string) => Promise<TransferDetails>;
41
42
  readonly fetchGlwRegionRewards: () => Promise<GlwRegionRewardsResponse>;
43
+ readonly fetchFarmRewardSplits: (farmId: string) => Promise<FarmRewardSplit[]>;
42
44
  readonly fetchMigrationAmount: (wallet: string) => Promise<MigrationAmountResponse>;
43
45
  readonly stakeGctl: (stakeRequest: StakeRequest) => Promise<boolean>;
44
46
  readonly unstakeGctl: (unstakeRequest: StakeRequest) => Promise<boolean>;
45
47
  readonly restakeGctl: (restakeRequest: RestakeRequest) => Promise<boolean>;
46
- readonly retryFailedOperation: (operationId: string) => Promise<boolean>;
48
+ readonly retryFailedOperation: (operationId: string) => Promise<RetryFailedOperationResponse>;
47
49
  readonly payProtocolDepositUsingStakedControl: (paymentRequest: PayProtocolDepositUsingStakedControlRequest) => Promise<PayProtocolDepositUsingStakedControlResponse>;
48
50
  readonly migrateUser: (migrateRequest: MigrateUserRequest) => Promise<MigrateUserResponse>;
49
51
  readonly isStaking: boolean;
@@ -1,4 +1,4 @@
1
- import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
1
+ import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, RecentRegionActivityResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
2
2
  export declare function RegionRouter(baseUrl: string): {
3
3
  readonly fetchRegions: (params?: {
4
4
  isActive?: boolean;
@@ -8,6 +8,7 @@ export declare function RegionRouter(baseUrl: string): {
8
8
  readonly fetchRegionByIdOrSlug: (idOrSlug: string) => Promise<RegionDetails>;
9
9
  readonly fetchRegionSolarFarms: (regionId: number) => Promise<SponsoredFarm[]>;
10
10
  readonly fetchActiveSummary: () => Promise<ActiveRegionsSummaryResponse>;
11
+ readonly fetchRecentActivity: () => Promise<RecentRegionActivityResponse>;
11
12
  readonly getRegionByCode: (code: string) => RegionWithMetadata | null;
12
13
  readonly applyInstallerCertification: (payload: InstallerApplicationPayload) => Promise<InstallerApplicationResponse>;
13
14
  readonly regions: RegionWithMetadata[];
@@ -311,18 +311,17 @@ export interface RegionDetails extends RegionWithMetadata {
311
311
  carbonCreditsIssued: number;
312
312
  carbonCreditsPerWeek: number;
313
313
  }
314
- export interface ActiveRegionStakeEvent {
315
- id: string;
316
- regionId: number;
317
- wallet: string;
314
+ export interface ActiveRegionDataPoint {
318
315
  epoch: number;
319
- amount: string;
320
- direction: string;
321
- ts: string;
322
- processed: boolean;
323
- progressClaimed: string;
324
- progressMoved: string;
325
- actionSignatureData: unknown | null;
316
+ timestamp: number;
317
+ gctlStaked: string;
318
+ pendingUnstake: string;
319
+ pendingRestakeOut: string;
320
+ pendingRestakeIn: string;
321
+ netPending: string;
322
+ eventCount: number;
323
+ firstEventTimestamp?: number;
324
+ lastEventTimestamp?: number;
326
325
  }
327
326
  export interface ActiveRegionSummary {
328
327
  id: number;
@@ -330,20 +329,47 @@ export interface ActiveRegionSummary {
330
329
  code: string;
331
330
  slug: string;
332
331
  isUs: boolean;
333
- gctlStaked: string;
332
+ currentGctlStaked: string;
334
333
  glwRewardPerWeek: string;
335
334
  rewardShare: string;
336
- pendingUnstake: string;
337
- pendingRestakeOut: string;
338
- pendingRestakeIn: string;
339
- events: ActiveRegionStakeEvent[];
335
+ data: ActiveRegionDataPoint[];
340
336
  }
341
337
  export interface ActiveRegionsSummaryResponse {
338
+ metadata: {
339
+ epochs: number[];
340
+ epochTimestamps: {
341
+ [epoch: string]: number;
342
+ };
343
+ currentEpoch: number;
344
+ };
342
345
  total: {
343
346
  totalGctlStaked: string;
344
347
  totalGlwRewards: string;
345
348
  };
346
349
  regions: ActiveRegionSummary[];
350
+ aggregate: {
351
+ epochs: number[];
352
+ timestamps: number[];
353
+ totalGctlStaked: string[];
354
+ totalPendingUnstake: string[];
355
+ totalNetPending: string[];
356
+ };
357
+ }
358
+ export interface RegionActivityPeriod {
359
+ stakes: number;
360
+ unstakes: number;
361
+ restakes: number;
362
+ immediateUnstakes: number;
363
+ netChange: string;
364
+ }
365
+ export interface RegionActivity {
366
+ regionId: number;
367
+ regionName: string;
368
+ last24h: RegionActivityPeriod;
369
+ last7d: RegionActivityPeriod;
370
+ }
371
+ export interface RecentRegionActivityResponse {
372
+ activity: RegionActivity[];
347
373
  }
348
374
  export interface InstallerApplicationPayload {
349
375
  wallet: string;
@@ -577,4 +603,11 @@ export interface FarmRewardSplitsResponse {
577
603
  export interface FarmRewardSplitsErrorResponse {
578
604
  error: string;
579
605
  }
606
+ export interface HoldersCountResponse {
607
+ holders: number;
608
+ }
609
+ export interface RetryFailedOperationResponse {
610
+ success?: boolean;
611
+ queued?: boolean;
612
+ }
580
613
  export type { MintedEvent as ControlMintedEvent };
@@ -1,5 +1,5 @@
1
- import { T as TRANSFER_TYPES } from './farms-router-wk3VSuCV.js';
2
- export { C as ControlRouter, D as DECIMALS_BY_TOKEN, j as FORWARDER_ABI, F as FarmsRouter, e as ForwarderError, m as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, d as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, k as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, f as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, g as allRegions, c as configureSentry, i as countries, l as getAddresses, n as parseEthersError, p as parseViemError, r as regionMetadata, h as usStates, u as useForwarder, a as useOffchainFractions, o as waitForEthersTransactionWithRetry, w as waitForViemTransactionWithRetry } from './farms-router-wk3VSuCV.js';
1
+ import { T as TRANSFER_TYPES } from './farms-router-C0g4hf2Z.js';
2
+ export { C as ControlRouter, D as DECIMALS_BY_TOKEN, j as FORWARDER_ABI, F as FarmsRouter, e as ForwarderError, m as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, d as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, k as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, f as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, g as allRegions, c as configureSentry, i as countries, l as getAddresses, n as parseEthersError, p as parseViemError, r as regionMetadata, h as usStates, u as useForwarder, a as useOffchainFractions, o as waitForEthersTransactionWithRetry, w as waitForViemTransactionWithRetry } from './farms-router-C0g4hf2Z.js';
3
3
  import { verifyTypedData, checksumAddress } from 'viem';
4
4
  import 'ethers';
5
5
 
@@ -2584,6 +2584,9 @@ function parseApiError$4(error) {
2584
2584
  // Public Factory
2585
2585
  // --------------------------------------------------------------------------
2586
2586
  function ControlRouter(baseUrl) {
2587
+ if (!baseUrl) {
2588
+ throw new Error("CONTROL API base URL is not set");
2589
+ }
2587
2590
  // ----------------------- Internal helpers --------------------------------
2588
2591
  const request = async (path, init) => {
2589
2592
  const res = await fetch(`${baseUrl}${path}`, init);
@@ -2648,6 +2651,15 @@ function ControlRouter(baseUrl) {
2648
2651
  throw new Error(parseApiError$4(error));
2649
2652
  }
2650
2653
  };
2654
+ const fetchHoldersCount = async () => {
2655
+ try {
2656
+ const data = await request(`/holders/count`);
2657
+ return data.holders;
2658
+ }
2659
+ catch (error) {
2660
+ throw new Error(parseApiError$4(error));
2661
+ }
2662
+ };
2651
2663
  // Build pagination query helper
2652
2664
  const buildPaginationQuery = (page, limit) => {
2653
2665
  const p = page ?? 1;
@@ -2711,6 +2723,19 @@ function ControlRouter(baseUrl) {
2711
2723
  throw new Error(parseApiError$4(error));
2712
2724
  }
2713
2725
  };
2726
+ const fetchFarmRewardSplits = async (farmId) => {
2727
+ try {
2728
+ if (!farmId)
2729
+ throw new Error("Farm ID is required");
2730
+ const data = await request(`/farms/${encodeURIComponent(farmId)}/reward-splits`);
2731
+ if ("error" in data)
2732
+ throw new Error(data.error);
2733
+ return data.rewardSplits ?? [];
2734
+ }
2735
+ catch (error) {
2736
+ throw new Error(parseApiError$4(error));
2737
+ }
2738
+ };
2714
2739
  // Exposed query with error parsing
2715
2740
  const getTransferDetails = async (txId) => {
2716
2741
  try {
@@ -2875,11 +2900,11 @@ function ControlRouter(baseUrl) {
2875
2900
  level: "info",
2876
2901
  data: { baseUrl, operationId },
2877
2902
  });
2878
- await request(`/operations/failed/${operationId}/retry`, {
2903
+ const response = await request(`/operations/failed/${operationId}/retry`, {
2879
2904
  method: "POST",
2880
2905
  headers: { "Content-Type": "application/json" },
2881
2906
  });
2882
- return true;
2907
+ return response;
2883
2908
  }
2884
2909
  catch (error) {
2885
2910
  sentryCaptureException(error, {
@@ -2978,6 +3003,7 @@ function ControlRouter(baseUrl) {
2978
3003
  fetchGctlPrice,
2979
3004
  fetchGlwPrice,
2980
3005
  fetchCirculatingSupply,
3006
+ fetchHoldersCount,
2981
3007
  fetchLastNonce,
2982
3008
  fetchMintedEvents,
2983
3009
  fetchStakeEvents,
@@ -2989,6 +3015,7 @@ function ControlRouter(baseUrl) {
2989
3015
  fetchWalletRegionCommittedBalance,
2990
3016
  fetchTransferDetails: getTransferDetails,
2991
3017
  fetchGlwRegionRewards,
3018
+ fetchFarmRewardSplits,
2992
3019
  fetchMigrationAmount,
2993
3020
  // Mutations
2994
3021
  stakeGctl,
@@ -3793,6 +3820,14 @@ function RegionRouter(baseUrl) {
3793
3820
  throw new Error(parseApiError$3(error));
3794
3821
  }
3795
3822
  };
3823
+ const fetchRecentActivity = async () => {
3824
+ try {
3825
+ return await request(`/regions/active/recent-activity`);
3826
+ }
3827
+ catch (error) {
3828
+ throw new Error(parseApiError$3(error));
3829
+ }
3830
+ };
3796
3831
  const applyInstallerCertification = async (payload) => {
3797
3832
  try {
3798
3833
  return await request(`/regions/installers/apply`, {
@@ -3853,6 +3888,7 @@ function RegionRouter(baseUrl) {
3853
3888
  fetchRegionByIdOrSlug,
3854
3889
  fetchRegionSolarFarms,
3855
3890
  fetchActiveSummary,
3891
+ fetchRecentActivity,
3856
3892
  getRegionByCode,
3857
3893
  applyInstallerCertification,
3858
3894
  // Cached data & flags
@@ -4235,4 +4271,4 @@ function FarmsRouter(baseUrl) {
4235
4271
  }
4236
4272
 
4237
4273
  export { ControlRouter as C, DECIMALS_BY_TOKEN as D, FarmsRouter as F, GLOW_WEIGHT_DECIMAL_PRECISION as G, HUB_URL as H, KickstarterRouter as K, MAX_WEIGHT as M, OFF_CHAIN_PAYMENT_CURRENCIES as O, PAYMENT_CURRENCIES as P, RegionRouter as R, STAKING_DIRECTIONS as S, TRANSFER_TYPES as T, USDG_WEIGHT_DECIMAL_PRECISION as U, WalletsRouter as W, useOffchainFractions as a, REGIONS as b, configureSentry as c, KICKSTARTER_STATUS as d, ForwarderError as e, OffchainFractionsError as f, allRegions as g, usStates as h, countries as i, FORWARDER_ABI as j, OFFCHAIN_FRACTIONS_ABI as k, getAddresses as l, GCA_URLS as m, parseEthersError as n, waitForEthersTransactionWithRetry as o, parseViemError as p, regionMetadata as r, useForwarder as u, waitForViemTransactionWithRetry as w };
4238
- //# sourceMappingURL=farms-router-wk3VSuCV.js.map
4274
+ //# sourceMappingURL=farms-router-C0g4hf2Z.js.map