@glowlabs-org/utils 0.2.150 → 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-CMpG0RGM.js → farms-router-DWSaZD1T.js} +30 -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/types/index.d.ts +15 -12
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-wk3VSuCV.js → farms-router-Cpy_o4_u.js} +30 -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/types/index.d.ts +15 -12
- package/package.json +1 -1
- package/src/lib/control-api/control-router.ts +53 -8
- package/src/lib/control-api/region-router.ts +53 -0
- package/src/lib/types/index.ts +17 -12
- package/dist/cjs/farms-router-CMpG0RGM.js.map +0 -1
- package/dist/esm/farms-router-wk3VSuCV.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;
|
|
@@ -311,18 +311,14 @@ export interface RegionDetails extends RegionWithMetadata {
|
|
|
311
311
|
carbonCreditsIssued: number;
|
|
312
312
|
carbonCreditsPerWeek: number;
|
|
313
313
|
}
|
|
314
|
-
export interface
|
|
315
|
-
id: string;
|
|
316
|
-
regionId: number;
|
|
317
|
-
wallet: string;
|
|
314
|
+
export interface ActiveRegionSnapshot {
|
|
318
315
|
epoch: number;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
actionSignatureData: unknown | null;
|
|
316
|
+
totals: {
|
|
317
|
+
gctlStaked: string;
|
|
318
|
+
pendingUnstake: string;
|
|
319
|
+
pendingRestakeOut: string;
|
|
320
|
+
pendingRestakeIn: string;
|
|
321
|
+
};
|
|
326
322
|
}
|
|
327
323
|
export interface ActiveRegionSummary {
|
|
328
324
|
id: number;
|
|
@@ -336,7 +332,7 @@ export interface ActiveRegionSummary {
|
|
|
336
332
|
pendingUnstake: string;
|
|
337
333
|
pendingRestakeOut: string;
|
|
338
334
|
pendingRestakeIn: string;
|
|
339
|
-
|
|
335
|
+
snapshots: ActiveRegionSnapshot[];
|
|
340
336
|
}
|
|
341
337
|
export interface ActiveRegionsSummaryResponse {
|
|
342
338
|
total: {
|
|
@@ -577,4 +573,11 @@ export interface FarmRewardSplitsResponse {
|
|
|
577
573
|
export interface FarmRewardSplitsErrorResponse {
|
|
578
574
|
error: string;
|
|
579
575
|
}
|
|
576
|
+
export interface HoldersCountResponse {
|
|
577
|
+
holders: number;
|
|
578
|
+
}
|
|
579
|
+
export interface RetryFailedOperationResponse {
|
|
580
|
+
success?: boolean;
|
|
581
|
+
queued?: boolean;
|
|
582
|
+
}
|
|
580
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,
|
|
@@ -4235,4 +4262,4 @@ function FarmsRouter(baseUrl) {
|
|
|
4235
4262
|
}
|
|
4236
4263
|
|
|
4237
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 };
|
|
4238
|
-
//# sourceMappingURL=farms-router-
|
|
4265
|
+
//# sourceMappingURL=farms-router-Cpy_o4_u.js.map
|