@glowlabs-org/utils 0.2.149 → 0.2.151
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/browser.js +1 -1
- package/dist/cjs/{farms-router-JTY1pnmX.js → farms-router-DWSaZD1T.js} +52 -3
- package/dist/cjs/farms-router-DWSaZD1T.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/control-api/control-router.d.ts +4 -2
- package/dist/cjs/lib/control-api/region-router.d.ts +3 -1
- package/dist/cjs/lib/types/index.d.ts +50 -0
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-C2Pkoecj.js → farms-router-Cpy_o4_u.js} +52 -3
- package/dist/esm/farms-router-Cpy_o4_u.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/control-api/control-router.d.ts +4 -2
- package/dist/esm/lib/control-api/region-router.d.ts +3 -1
- package/dist/esm/lib/types/index.d.ts +50 -0
- package/package.json +1 -1
- package/src/lib/control-api/control-router.ts +53 -8
- package/src/lib/control-api/region-router.ts +86 -0
- package/src/lib/types/index.ts +57 -0
- package/dist/cjs/farms-router-JTY1pnmX.js.map +0 -1
- package/dist/esm/farms-router-C2Pkoecj.js.map +0 -1
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-
|
|
18
|
+
var farmsRouter = require('./farms-router-DWSaZD1T.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<
|
|
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 } from "../types";
|
|
1
|
+
import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
|
|
2
2
|
export declare function RegionRouter(baseUrl: string): {
|
|
3
3
|
readonly fetchRegions: (params?: {
|
|
4
4
|
isActive?: boolean;
|
|
@@ -7,7 +7,9 @@ export declare function RegionRouter(baseUrl: string): {
|
|
|
7
7
|
readonly fetchActivationEvents: (regionId?: number) => Promise<ActivationEvent[]>;
|
|
8
8
|
readonly fetchRegionByIdOrSlug: (idOrSlug: string) => Promise<RegionDetails>;
|
|
9
9
|
readonly fetchRegionSolarFarms: (regionId: number) => Promise<SponsoredFarm[]>;
|
|
10
|
+
readonly fetchActiveSummary: () => Promise<ActiveRegionsSummaryResponse>;
|
|
10
11
|
readonly getRegionByCode: (code: string) => RegionWithMetadata | null;
|
|
12
|
+
readonly applyInstallerCertification: (payload: InstallerApplicationPayload) => Promise<InstallerApplicationResponse>;
|
|
11
13
|
readonly regions: RegionWithMetadata[];
|
|
12
14
|
readonly isLoading: boolean;
|
|
13
15
|
};
|
|
@@ -262,6 +262,9 @@ export interface ActivationEvent {
|
|
|
262
262
|
id: string;
|
|
263
263
|
regionId: number;
|
|
264
264
|
epoch: number;
|
|
265
|
+
stakeThresholdMet: boolean;
|
|
266
|
+
solarFarmRequirementMet: boolean;
|
|
267
|
+
installerRequirementMet: boolean;
|
|
265
268
|
activated: boolean;
|
|
266
269
|
ts: string;
|
|
267
270
|
}
|
|
@@ -308,6 +311,46 @@ export interface RegionDetails extends RegionWithMetadata {
|
|
|
308
311
|
carbonCreditsIssued: number;
|
|
309
312
|
carbonCreditsPerWeek: number;
|
|
310
313
|
}
|
|
314
|
+
export interface ActiveRegionSnapshot {
|
|
315
|
+
epoch: number;
|
|
316
|
+
totals: {
|
|
317
|
+
gctlStaked: string;
|
|
318
|
+
pendingUnstake: string;
|
|
319
|
+
pendingRestakeOut: string;
|
|
320
|
+
pendingRestakeIn: string;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
export interface ActiveRegionSummary {
|
|
324
|
+
id: number;
|
|
325
|
+
name: string;
|
|
326
|
+
code: string;
|
|
327
|
+
slug: string;
|
|
328
|
+
isUs: boolean;
|
|
329
|
+
gctlStaked: string;
|
|
330
|
+
glwRewardPerWeek: string;
|
|
331
|
+
rewardShare: string;
|
|
332
|
+
pendingUnstake: string;
|
|
333
|
+
pendingRestakeOut: string;
|
|
334
|
+
pendingRestakeIn: string;
|
|
335
|
+
snapshots: ActiveRegionSnapshot[];
|
|
336
|
+
}
|
|
337
|
+
export interface ActiveRegionsSummaryResponse {
|
|
338
|
+
total: {
|
|
339
|
+
totalGctlStaked: string;
|
|
340
|
+
totalGlwRewards: string;
|
|
341
|
+
};
|
|
342
|
+
regions: ActiveRegionSummary[];
|
|
343
|
+
}
|
|
344
|
+
export interface InstallerApplicationPayload {
|
|
345
|
+
wallet: string;
|
|
346
|
+
signature: string;
|
|
347
|
+
nonce: string;
|
|
348
|
+
regionId: string;
|
|
349
|
+
deadline: string;
|
|
350
|
+
}
|
|
351
|
+
export interface InstallerApplicationResponse {
|
|
352
|
+
certified: boolean;
|
|
353
|
+
}
|
|
311
354
|
export interface RegionsResponse {
|
|
312
355
|
regions: RegionWithMetadata[];
|
|
313
356
|
}
|
|
@@ -530,4 +573,11 @@ export interface FarmRewardSplitsResponse {
|
|
|
530
573
|
export interface FarmRewardSplitsErrorResponse {
|
|
531
574
|
error: string;
|
|
532
575
|
}
|
|
576
|
+
export interface HoldersCountResponse {
|
|
577
|
+
holders: number;
|
|
578
|
+
}
|
|
579
|
+
export interface RetryFailedOperationResponse {
|
|
580
|
+
success?: boolean;
|
|
581
|
+
queued?: boolean;
|
|
582
|
+
}
|
|
533
583
|
export type { MintedEvent as ControlMintedEvent };
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TRANSFER_TYPES } from './farms-router-
|
|
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-
|
|
1
|
+
import { T as TRANSFER_TYPES } from './farms-router-Cpy_o4_u.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-Cpy_o4_u.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
|
|
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,
|
|
@@ -3785,6 +3812,26 @@ function RegionRouter(baseUrl) {
|
|
|
3785
3812
|
throw new Error(parseApiError$3(error));
|
|
3786
3813
|
}
|
|
3787
3814
|
};
|
|
3815
|
+
const fetchActiveSummary = async () => {
|
|
3816
|
+
try {
|
|
3817
|
+
return await request(`/regions/active/summary`);
|
|
3818
|
+
}
|
|
3819
|
+
catch (error) {
|
|
3820
|
+
throw new Error(parseApiError$3(error));
|
|
3821
|
+
}
|
|
3822
|
+
};
|
|
3823
|
+
const applyInstallerCertification = async (payload) => {
|
|
3824
|
+
try {
|
|
3825
|
+
return await request(`/regions/installers/apply`, {
|
|
3826
|
+
method: "POST",
|
|
3827
|
+
headers: { "Content-Type": "application/json" },
|
|
3828
|
+
body: JSON.stringify(payload),
|
|
3829
|
+
});
|
|
3830
|
+
}
|
|
3831
|
+
catch (error) {
|
|
3832
|
+
throw new Error(parseApiError$3(error));
|
|
3833
|
+
}
|
|
3834
|
+
};
|
|
3788
3835
|
// Kickstarter-related logic moved to kickstarter-router.ts
|
|
3789
3836
|
// -------------------------------------------------------------------------
|
|
3790
3837
|
// Helpers (derived)
|
|
@@ -3832,7 +3879,9 @@ function RegionRouter(baseUrl) {
|
|
|
3832
3879
|
fetchActivationEvents,
|
|
3833
3880
|
fetchRegionByIdOrSlug,
|
|
3834
3881
|
fetchRegionSolarFarms,
|
|
3882
|
+
fetchActiveSummary,
|
|
3835
3883
|
getRegionByCode,
|
|
3884
|
+
applyInstallerCertification,
|
|
3836
3885
|
// Cached data & flags
|
|
3837
3886
|
get regions() {
|
|
3838
3887
|
return cachedRegions;
|
|
@@ -4213,4 +4262,4 @@ function FarmsRouter(baseUrl) {
|
|
|
4213
4262
|
}
|
|
4214
4263
|
|
|
4215
4264
|
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 };
|
|
4216
|
-
//# sourceMappingURL=farms-router-
|
|
4265
|
+
//# sourceMappingURL=farms-router-Cpy_o4_u.js.map
|