@glowlabs-org/utils 0.2.175 → 0.2.177
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/{calculate-farm-efficiency-psH9YXnF.js → calculate-farm-efficiency-DQqLqk0-.js} +74 -7
- package/dist/cjs/calculate-farm-efficiency-DQqLqk0-.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{calculate-farm-efficiency-DvqnF04d.js → calculate-farm-efficiency-BjXQqtxI.js} +74 -7
- package/dist/esm/calculate-farm-efficiency-BjXQqtxI.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/package.json +1 -1
- package/src/lib/hooks/use-forwarder.ts +12 -10
- package/src/lib/hooks/use-offchain-fractions.ts +14 -0
- package/src/utils/transaction-utils.ts +68 -5
- package/dist/cjs/calculate-farm-efficiency-psH9YXnF.js.map +0 -1
- package/dist/esm/calculate-farm-efficiency-DvqnF04d.js.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -13,8 +13,8 @@ import { parseUnits, formatUnits } from 'viem';
|
|
|
13
13
|
import { MerkleTree } from 'merkletreejs';
|
|
14
14
|
import { solidityPackedKeccak256, keccak256 } from 'ethers';
|
|
15
15
|
import Decimal from 'decimal.js';
|
|
16
|
-
import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './calculate-farm-efficiency-
|
|
17
|
-
export { C as ControlRouter, F as FarmsRouter, e as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, d as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, f as calculateFarmEfficiency, c as configureSentry, u as useForwarder, a as useOffchainFractions, b as useRewardsKernel } from './calculate-farm-efficiency-
|
|
16
|
+
import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './calculate-farm-efficiency-BjXQqtxI.js';
|
|
17
|
+
export { C as ControlRouter, F as FarmsRouter, e as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, d as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, f as calculateFarmEfficiency, c as configureSentry, u as useForwarder, a as useOffchainFractions, b as useRewardsKernel } from './calculate-farm-efficiency-BjXQqtxI.js';
|
|
18
18
|
|
|
19
19
|
const GENESIS_TIMESTAMP = 1700352000;
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -558,16 +558,18 @@ export function useForwarder(
|
|
|
558
558
|
{ from: owner }
|
|
559
559
|
);
|
|
560
560
|
} else {
|
|
561
|
-
await forwarderContract
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
561
|
+
await forwarderContract
|
|
562
|
+
.getFunction("forward")
|
|
563
|
+
.staticCall(
|
|
564
|
+
tokenAddress,
|
|
565
|
+
isAuditFees
|
|
566
|
+
? ADDRESSES.AUDIT_FEE_WALLET
|
|
567
|
+
: ADDRESSES.FOUNDATION_WALLET,
|
|
568
|
+
amount,
|
|
569
|
+
sendToCounterfactualWallet,
|
|
570
|
+
message,
|
|
571
|
+
{ from: owner }
|
|
572
|
+
);
|
|
571
573
|
}
|
|
572
574
|
} catch (staticError) {
|
|
573
575
|
sentryCaptureException(staticError, {
|
|
@@ -390,6 +390,20 @@ export function useOffchainFractions(
|
|
|
390
390
|
account: walletClient.account!,
|
|
391
391
|
});
|
|
392
392
|
await waitForViemTransactionWithRetry(publicClient, approveHash);
|
|
393
|
+
|
|
394
|
+
// Verify allowance is reflected before proceeding (RPC lag mitigation)
|
|
395
|
+
const maxAllowanceChecks = 5;
|
|
396
|
+
const allowanceCheckDelayMs = 500;
|
|
397
|
+
for (let i = 0; i < maxAllowanceChecks; i++) {
|
|
398
|
+
const updatedAllowance = await checkTokenAllowance(
|
|
399
|
+
owner,
|
|
400
|
+
fractionData.token
|
|
401
|
+
);
|
|
402
|
+
if (updatedAllowance >= requiredAmount) break;
|
|
403
|
+
if (i < maxAllowanceChecks - 1) {
|
|
404
|
+
await new Promise((r) => setTimeout(r, allowanceCheckDelayMs));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
393
407
|
}
|
|
394
408
|
|
|
395
409
|
// Run a simulation first to surface any revert reason
|
|
@@ -7,14 +7,77 @@ export function parseViemError(error: unknown): string {
|
|
|
7
7
|
|
|
8
8
|
// Check if it's a viem BaseError
|
|
9
9
|
if (error instanceof Error) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const anyError = error as any;
|
|
11
|
+
|
|
12
|
+
// Use viem's walk() method if available to find ContractFunctionRevertedError
|
|
13
|
+
if (typeof anyError.walk === "function") {
|
|
14
|
+
let foundErrorName: string | null = null;
|
|
15
|
+
anyError.walk((err: any) => {
|
|
16
|
+
if (err?.data?.errorName && !foundErrorName) {
|
|
17
|
+
foundErrorName = err.data.errorName;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (foundErrorName) {
|
|
21
|
+
return foundErrorName;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// For viem ContractFunctionRevertedError - extract the custom error name
|
|
26
|
+
// This handles Solidity custom errors like `InsufficientSharesAvailable()`
|
|
27
|
+
if (anyError.cause?.data?.errorName) {
|
|
28
|
+
return anyError.cause.data.errorName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check direct data.errorName (viem 2.x structure)
|
|
32
|
+
if (anyError.data?.errorName) {
|
|
33
|
+
return anyError.data.errorName;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Check for error name in the cause directly (some viem versions)
|
|
37
|
+
if (anyError.cause?.name && anyError.cause.name !== "Error") {
|
|
38
|
+
return anyError.cause.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// For contract revert errors with reason
|
|
42
|
+
if (anyError.cause?.reason) {
|
|
43
|
+
return anyError.cause.reason;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check metaMessages for custom error info (viem includes this sometimes)
|
|
47
|
+
if (anyError.metaMessages && Array.isArray(anyError.metaMessages)) {
|
|
48
|
+
for (const meta of anyError.metaMessages) {
|
|
49
|
+
if (typeof meta === "string" && meta.includes("Error:")) {
|
|
50
|
+
const match = meta.match(/Error:\s*(\w+)\(/);
|
|
51
|
+
if (match?.[1]) {
|
|
52
|
+
return match[1];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Check if the error message contains a custom error signature
|
|
59
|
+
// viem sometimes formats it as: reverted with the following reason: ErrorName()
|
|
60
|
+
const fullMessage = anyError.message || "";
|
|
61
|
+
const shortMessage = anyError.shortMessage || "";
|
|
62
|
+
|
|
63
|
+
// Pattern: "Error: ErrorName()" in message
|
|
64
|
+
const errorPatterns = [
|
|
65
|
+
/Error:\s*(\w+)\(\)/,
|
|
66
|
+
/reverted with the following reason:\s*(\w+)\(\)/,
|
|
67
|
+
/reverted\.\s*(\w+)\(\)/,
|
|
68
|
+
/execution reverted:\s*(\w+)/i,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
for (const pattern of errorPatterns) {
|
|
72
|
+
const match = fullMessage.match(pattern) || shortMessage.match(pattern);
|
|
73
|
+
if (match?.[1]) {
|
|
74
|
+
return match[1];
|
|
75
|
+
}
|
|
13
76
|
}
|
|
14
77
|
|
|
15
78
|
// For viem's shortMessage
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
79
|
+
if (shortMessage) {
|
|
80
|
+
return shortMessage;
|
|
18
81
|
}
|
|
19
82
|
|
|
20
83
|
// Fallback to regular message
|