@glowlabs-org/utils 0.2.22 → 0.2.25

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,4 +1,4 @@
1
- import { BigNumber, ethers } from "ethers";
1
+ import { type BigNumberish, type Signer } from "ethers";
2
2
  export declare enum ForwarderError {
3
3
  CONTRACT_NOT_AVAILABLE = "Contract not available",
4
4
  SIGNER_NOT_AVAILABLE = "Signer not available",
@@ -9,7 +9,7 @@ export declare enum ForwarderError {
9
9
  export type ForwardType = "PayProtocolFeeAndMintGCTLAndStake" | "PayProtocolFee" | "MintGCTLAndStake" | "MintGCTL" | "BuySolarFarm" | "PayAuditFees";
10
10
  export type Currency = "USDC" | "GLW" | "USDG";
11
11
  export interface ForwardParams {
12
- amount: BigNumber;
12
+ amount: bigint;
13
13
  userAddress: string;
14
14
  type: ForwardType;
15
15
  currency?: Currency;
@@ -17,19 +17,19 @@ export interface ForwardParams {
17
17
  farmId?: string;
18
18
  regionId?: number;
19
19
  }
20
- export declare function useForwarder(signer: ethers.providers.JsonRpcSigner | undefined, CHAIN_ID: number): {
20
+ export declare function useForwarder(signer: Signer | undefined, CHAIN_ID: number): {
21
21
  forwardTokens: (params: ForwardParams) => Promise<string>;
22
- payProtocolFeeAndMintGCTLAndStake: (amount: BigNumber, userAddress: string, applicationId: string, regionId?: number, currency?: Currency) => Promise<string>;
23
- payProtocolFee: (amount: BigNumber, userAddress: string, applicationId: string, currency?: Currency) => Promise<string>;
24
- mintGCTLAndStake: (amount: BigNumber, userAddress: string, regionId?: number, currency?: Currency) => Promise<string>;
25
- mintGCTL: (amount: BigNumber, userAddress: string, currency?: Currency) => Promise<string>;
26
- buySolarFarm: (amount: BigNumber, userAddress: string, farmId: string, currency?: Currency) => Promise<string>;
27
- payAuditFees: (amount: BigNumber, userAddress: string, applicationId: string) => Promise<string>;
28
- approveToken: (amount: BigNumber, currency?: Currency) => Promise<boolean>;
29
- checkTokenAllowance: (owner: string, currency?: Currency) => Promise<BigNumber>;
30
- checkTokenBalance: (owner: string, currency?: Currency) => Promise<BigNumber>;
22
+ payProtocolFeeAndMintGCTLAndStake: (amount: bigint, userAddress: string, applicationId: string, regionId?: number, currency?: Currency) => Promise<string>;
23
+ payProtocolFee: (amount: bigint, userAddress: string, applicationId: string, currency?: Currency) => Promise<string>;
24
+ mintGCTLAndStake: (amount: bigint, userAddress: string, regionId?: number, currency?: Currency) => Promise<string>;
25
+ mintGCTL: (amount: bigint, userAddress: string, currency?: Currency) => Promise<string>;
26
+ buySolarFarm: (amount: bigint, userAddress: string, farmId: string, currency?: Currency) => Promise<string>;
27
+ payAuditFees: (amount: bigint, userAddress: string, applicationId: string) => Promise<string>;
28
+ approveToken: (amount: BigNumberish, currency?: Currency) => Promise<boolean>;
29
+ checkTokenAllowance: (owner: string, currency?: Currency) => Promise<bigint>;
30
+ checkTokenBalance: (owner: string, currency?: Currency) => Promise<bigint>;
31
31
  estimateGasForForward: (params: ForwardParams, ethPriceInUSD: number | null) => Promise<string>;
32
- mintTestUSDC: (amount: BigNumber, recipient: string) => Promise<string>;
32
+ mintTestUSDC: (amount: bigint, recipient: string) => Promise<string>;
33
33
  constructForwardMessage: (params: ForwardParams) => string;
34
34
  readonly isProcessing: boolean;
35
35
  addresses: Record<"USDC" | "GLW" | "USDG" | "FORWARDER" | "FOUNDATION_WALLET" | "USDG_REDEMPTION" | "IMPACT_CATALYST" | "AUDIT_FEE_WALLET", `0x${string}`>;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ethers = require('ethers');
4
+ var viem = require('viem');
4
5
 
5
6
  const HUB_URL = "https://glow.org";
6
7
  const GCA_URLS = ["http://95.217.194.59:35015"];
@@ -259,7 +260,7 @@ function useForwarder(signer, CHAIN_ID) {
259
260
  // Returns a contract instance for Forwarder
260
261
  function getForwarderContract() {
261
262
  assertSigner(signer);
262
- return new ethers.ethers.Contract(ADDRESSES.FORWARDER, FORWARDER_ABI, signer);
263
+ return new ethers.Contract(ADDRESSES.FORWARDER, FORWARDER_ABI, signer);
263
264
  }
264
265
  /**
265
266
  * Construct the message for the forward call based on type and parameters
@@ -320,7 +321,7 @@ function useForwarder(signer, CHAIN_ID) {
320
321
  default:
321
322
  throw new Error(`Currency ${currency} not yet supported. Only USDC, GLW, and USDG are currently supported.`);
322
323
  }
323
- return new ethers.ethers.Contract(tokenAddress, ERC20_ABI, signer);
324
+ return new ethers.Contract(tokenAddress, ERC20_ABI, signer);
324
325
  }
325
326
  /**
326
327
  * Check current token allowance for the forwarder contract
@@ -407,9 +408,9 @@ function useForwarder(signer, CHAIN_ID) {
407
408
  }
408
409
  // Check allowance and approve if necessary
409
410
  const allowance = await tokenContract.allowance(owner, ADDRESSES.FORWARDER);
410
- if (allowance.lt(amount)) {
411
+ if (allowance < amount) {
411
412
  try {
412
- const approveTx = await tokenContract.approve(ADDRESSES.FORWARDER, ethers.ethers.constants.MaxUint256);
413
+ const approveTx = await tokenContract.approve(ADDRESSES.FORWARDER, ethers.MaxUint256);
413
414
  await approveTx.wait();
414
415
  }
415
416
  catch (approveError) {
@@ -431,14 +432,19 @@ function useForwarder(signer, CHAIN_ID) {
431
432
  default:
432
433
  throw new Error(`Unsupported currency for forwarding: ${currency}`);
433
434
  }
434
- // Run a static call first to surface any revert reason
435
+ // Run a static call first to surface any revert reason (ethers v6)
435
436
  try {
436
- // If PayAuditFees, call forward() even for USDC
437
437
  if (!isAuditFees && currency === "USDC") {
438
- await forwarderContract.callStatic.swapUSDCAndForwardUSDG(amount, ADDRESSES.FOUNDATION_WALLET, message, { from: owner });
438
+ await forwarderContract
439
+ .getFunction("swapUSDCAndForwardUSDG")
440
+ .staticCall(amount, ADDRESSES.FOUNDATION_WALLET, message, {
441
+ from: owner,
442
+ });
439
443
  }
440
444
  else {
441
- await forwarderContract.callStatic.forward(tokenAddress, isAuditFees
445
+ await forwarderContract
446
+ .getFunction("forward")
447
+ .staticCall(tokenAddress, isAuditFees
442
448
  ? ADDRESSES.AUDIT_FEE_WALLET
443
449
  : ADDRESSES.FOUNDATION_WALLET, amount, message, { from: owner });
444
450
  }
@@ -449,10 +455,10 @@ function useForwarder(signer, CHAIN_ID) {
449
455
  // Execute the forward transaction
450
456
  let tx;
451
457
  if (!isAuditFees && currency === "USDC") {
452
- tx = await forwarderContract.swapUSDCAndForwardUSDG(amount, ADDRESSES.FOUNDATION_WALLET, message);
458
+ tx = await forwarderContract.getFunction("swapUSDCAndForwardUSDG")(amount, ADDRESSES.FOUNDATION_WALLET, message);
453
459
  }
454
460
  else {
455
- tx = await forwarderContract.forward(tokenAddress, isAuditFees
461
+ tx = await forwarderContract.getFunction("forward")(tokenAddress, isAuditFees
456
462
  ? ADDRESSES.AUDIT_FEE_WALLET
457
463
  : ADDRESSES.FOUNDATION_WALLET, amount, message);
458
464
  }
@@ -589,17 +595,23 @@ function useForwarder(signer, CHAIN_ID) {
589
595
  default:
590
596
  throw new Error(`Unsupported currency for gas estimation: ${currency}`);
591
597
  }
592
- const gasPrice = await signer.getGasPrice();
593
- const estimatedGas =
594
- // If PayAuditFees, always use forward() even with USDC
595
- !isAuditFees && currency === "USDC"
596
- ? await forwarderContract.estimateGas.swapUSDCAndForwardUSDG(amount, ADDRESSES.FOUNDATION_WALLET, message)
597
- : await forwarderContract.estimateGas.forward(tokenAddress, isAuditFees
598
+ const feeData = await signer.provider?.getFeeData();
599
+ const gasPrice = feeData?.gasPrice ?? feeData?.maxFeePerGas ?? 0n;
600
+ if (gasPrice === 0n) {
601
+ throw new Error("Could not fetch gas price to estimate cost.");
602
+ }
603
+ const estimatedGas = !isAuditFees && currency === "USDC"
604
+ ? await forwarderContract
605
+ .getFunction("swapUSDCAndForwardUSDG")
606
+ .estimateGas(amount, ADDRESSES.FOUNDATION_WALLET, message)
607
+ : await forwarderContract
608
+ .getFunction("forward")
609
+ .estimateGas(tokenAddress, isAuditFees
598
610
  ? ADDRESSES.AUDIT_FEE_WALLET
599
611
  : ADDRESSES.FOUNDATION_WALLET, amount, message);
600
- const estimatedCost = estimatedGas.mul(gasPrice);
612
+ const estimatedCost = estimatedGas * gasPrice;
601
613
  if (ethPriceInUSD) {
602
- const estimatedCostInEth = ethers.ethers.utils.formatEther(estimatedCost);
614
+ const estimatedCostInEth = viem.formatEther(estimatedCost);
603
615
  const estimatedCostInUSD = (parseFloat(estimatedCostInEth) * ethPriceInUSD).toFixed(2);
604
616
  return estimatedCostInUSD;
605
617
  }
@@ -1715,4 +1727,4 @@ exports.getAddresses = getAddresses;
1715
1727
  exports.regionMetadata = regionMetadata;
1716
1728
  exports.usStates = usStates;
1717
1729
  exports.useForwarder = useForwarder;
1718
- //# sourceMappingURL=region-router-BPm37uYd.js.map
1730
+ //# sourceMappingURL=region-router-C3X3im0d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region-router-C3X3im0d.js","sources":["../../src/constants/urls.ts","../../src/constants/weights.ts","../../src/lib/abis/forwarderABI.ts","../../src/lib/abis/erc20.abi.ts","../../src/constants/addresses.ts","../../src/lib/hooks/use-forwarder.ts","../../src/lib/control-api/control-router.ts","../../src/lib/region-metadata.ts","../../src/lib/control-api/region-router.ts"],"sourcesContent":["export const HUB_URL = \"https://glow.org\";\n\nexport const GCA_URLS = [\"http://95.217.194.59:35015\"];\n","/**\n * @dev This is actually not as intuitive as it seems.\n * Glow actually has 18 decimals, but glow weight is based on the amount of protocol fees (USDC) that the farm paid\n * Therefore, the weight is based on the amount of USDC that was paid, which has 8 decimals\n */\nexport const GLOW_WEIGHT_DECIMAL_PRECISION = 8;\n\n/**\n * @dev This is actually not as intuitive as it seems.\n * USDG weight is based on the amount of carbon credits produced, but the max value of a weight is ((2*64)-1) / 5 so we need to choose sensible precision to make sure that number never overflows\n */\nexport const USDG_WEIGHT_DECIMAL_PRECISION = 8;\n\nexport const MAX_WEIGHT: bigint =\n (BigInt(2) ** BigInt(64) - BigInt(1)) / BigInt(5);\n","export const FORWARDER_ABI = [\n {\n inputs: [\n { internalType: \"contract USDG\", name: \"_usdg\", type: \"address\" },\n { internalType: \"contract IERC20\", name: \"_usdc\", type: \"address\" },\n ],\n stateMutability: \"payable\",\n type: \"constructor\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"target\", type: \"address\" }],\n name: \"AddressEmptyCode\",\n type: \"error\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"account\", type: \"address\" }],\n name: \"AddressInsufficientBalance\",\n type: \"error\",\n },\n { inputs: [], name: \"FailedInnerCall\", type: \"error\" },\n { inputs: [], name: \"MaxLengthExceeded\", type: \"error\" },\n { inputs: [], name: \"ReentrancyGuardReentrantCall\", type: \"error\" },\n {\n inputs: [{ internalType: \"address\", name: \"token\", type: \"address\" }],\n name: \"SafeERC20FailedOperation\",\n type: \"error\",\n },\n { inputs: [], name: \"ZeroAmount\", type: \"error\" },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"from\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"to\", type: \"address\" },\n {\n indexed: true,\n internalType: \"address\",\n name: \"token\",\n type: \"address\",\n },\n {\n indexed: false,\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\",\n },\n {\n indexed: false,\n internalType: \"string\",\n name: \"message\",\n type: \"string\",\n },\n ],\n name: \"Forward\",\n type: \"event\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"token\", type: \"address\" },\n { internalType: \"address\", name: \"to\", type: \"address\" },\n { internalType: \"uint256\", name: \"amount\", type: \"uint256\" },\n { internalType: \"string\", name: \"message\", type: \"string\" },\n ],\n name: \"forward\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"i_USDC\",\n outputs: [{ internalType: \"contract IERC20\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"i_USDG\",\n outputs: [{ internalType: \"contract USDG\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"nextNonce\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"amount\", type: \"uint256\" },\n { internalType: \"address\", name: \"to\", type: \"address\" },\n { internalType: \"string\", name: \"message\", type: \"string\" },\n ],\n name: \"swapUSDCAndForwardUSDG\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n","export const ERC20_ABI = [\n {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transfer\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"account\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"mint\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n];\n","type ContractKeys =\n | \"USDC\"\n | \"FORWARDER\"\n | \"FOUNDATION_WALLET\"\n | \"GLW\"\n | \"USDG\"\n | \"USDG_REDEMPTION\"\n | \"IMPACT_CATALYST\"\n | \"AUDIT_FEE_WALLET\";\n\n// Contract-specific addresses\nconst mainnetAddresses: Record<ContractKeys, `0x${string}`> = {\n AUDIT_FEE_WALLET: \"0x3ff5af3333ddc6048d98849ec5e67868494693c9\",\n IMPACT_CATALYST: \"0x552Fbb4E0269fd5036daf72Ec006AAF6C958F4Fa\",\n USDG_REDEMPTION: \"0x1c2cA537757e1823400F857EdBe72B55bbAe0F08\",\n USDG: \"0xe010ec500720bE9EF3F82129E7eD2Ee1FB7955F2\",\n GLW: \"0xf4fbC617A5733EAAF9af08E1Ab816B103388d8B6\",\n USDC: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n FORWARDER: \"0x0000000000000000000000000000000000000000\", // TODO: Update with actual mainnet address\n FOUNDATION_WALLET: \"0x0000000000000000000000000000000000000000\", // TODO: Update with actual mainnet foundation wallet\n};\n\nconst sepoliaAddresses: Record<ContractKeys, `0x${string}`> = {\n AUDIT_FEE_WALLET: \"0x3ff5af3333ddc6048d98849ec5e67868494693c9\",\n IMPACT_CATALYST: \"0xb793Ed3CD94357f0e1933b0bd19F921b99f4C72a\",\n USDG_REDEMPTION: \"0x04829038A6664C16eC994BFb87754Fa621e51135\",\n USDG: \"0xda78313A3fF949890112c1B746AB1c75d1b1c17B\",\n GLW: \"0x2039161fcE4C8e5CF5FE64e17Fd290E8dFF3c9BD\",\n USDC: \"0x93c898be98cd2618ba84a6dccf5003d3bbe40356\",\n FORWARDER: \"0x1fb285dDFCbC0456d655F8DC7C637E33c5568858\",\n FOUNDATION_WALLET: \"0x5e230FED487c86B90f6508104149F087d9B1B0A7\",\n};\n\nexport const getAddresses = (\n CHAIN_ID: number\n): Record<ContractKeys, `0x${string}`> => {\n switch (CHAIN_ID) {\n case 1:\n return mainnetAddresses;\n case 11155111:\n return sepoliaAddresses;\n default:\n console.warn(\n `Unsupported chain ID: ${CHAIN_ID}, falling back to mainnet addresses`\n );\n return mainnetAddresses;\n }\n};\n\nexport const DECIMALS_BY_TOKEN: Record<string, number> = {\n USDC: 6,\n USDG: 6,\n GLW: 18,\n};\n","import { Contract, MaxUint256, type BigNumberish, type Signer } from \"ethers\";\nimport { FORWARDER_ABI } from \"../abis/forwarderABI\";\nimport { ERC20_ABI } from \"../abis/erc20.abi\";\nimport { getAddresses } from \"../../constants/addresses\";\nimport { formatEther } from \"viem\";\n\nexport enum ForwarderError {\n CONTRACT_NOT_AVAILABLE = \"Contract not available\",\n SIGNER_NOT_AVAILABLE = \"Signer not available\",\n UNKNOWN_ERROR = \"Unknown error\",\n INVALID_FORWARD_TYPE = \"Invalid forward type\",\n MISSING_REQUIRED_PARAMS = \"Missing required parameters\",\n}\n\n// Forward types based on API router documentation\nexport type ForwardType =\n | \"PayProtocolFeeAndMintGCTLAndStake\"\n | \"PayProtocolFee\"\n | \"MintGCTLAndStake\"\n | \"MintGCTL\"\n | \"BuySolarFarm\"\n | \"PayAuditFees\";\n\n// Currency types\nexport type Currency = \"USDC\" | \"GLW\" | \"USDG\";\n\n// Forward parameters interface\nexport interface ForwardParams {\n amount: bigint;\n userAddress: string;\n type: ForwardType;\n currency?: Currency;\n applicationId?: string;\n farmId?: string;\n regionId?: number;\n}\n\n// Utility to extract the most useful revert reason from an ethers error object\nfunction parseEthersError(error: unknown): string {\n if (!error) return \"Unknown error\";\n const possibleError: any = error;\n\n // If the error originates from a callStatic it will often be found at `error?.error?.body`\n if (possibleError?.error?.body) {\n try {\n const body = JSON.parse(possibleError.error.body);\n // Hardhat style errors\n if (body?.error?.message) return body.error.message as string;\n } catch {}\n }\n\n // Found on MetaMask/Alchemy shape errors\n if (possibleError?.data?.message) return possibleError.data.message as string;\n if (possibleError?.error?.message)\n return possibleError.error.message as string;\n\n // Standard ethers v5 message\n if (possibleError?.reason) return possibleError.reason as string;\n if (possibleError?.message) return possibleError.message as string;\n\n return ForwarderError.UNKNOWN_ERROR;\n}\n\n// Type-guard style helper to ensure a signer exists throughout the rest of the function.\nfunction assertSigner(\n maybeSigner: Signer | undefined\n): asserts maybeSigner is Signer {\n if (!maybeSigner) {\n throw new Error(ForwarderError.SIGNER_NOT_AVAILABLE);\n }\n}\n\nexport function useForwarder(signer: Signer | undefined, CHAIN_ID: number) {\n // Use dynamic addresses based on chain configuration\n const ADDRESSES = getAddresses(CHAIN_ID);\n\n // Framework-agnostic processing flag\n let isProcessing = false;\n const setIsProcessing = (value: boolean) => {\n isProcessing = value;\n };\n\n // Returns a contract instance for Forwarder\n function getForwarderContract() {\n assertSigner(signer);\n return new Contract(ADDRESSES.FORWARDER, FORWARDER_ABI, signer);\n }\n\n /**\n * Construct the message for the forward call based on type and parameters\n */\n function constructForwardMessage(params: ForwardParams): string {\n const { type, applicationId, farmId, regionId, userAddress } = params;\n\n switch (type) {\n case \"PayProtocolFeeAndMintGCTLAndStake\":\n if (!applicationId) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `PayProtocolFeeAndMintGCTLAndStake::${applicationId}`;\n\n case \"PayProtocolFee\":\n if (!applicationId) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `PayProtocolFee::${applicationId}`;\n\n case \"MintGCTLAndStake\":\n if (!regionId) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `MintGCTLAndStake::${regionId}`;\n\n case \"MintGCTL\":\n if (!userAddress) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `MintGCTL::${userAddress}`;\n\n case \"BuySolarFarm\":\n if (!farmId) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `BuySolarFarm::${farmId}`;\n\n case \"PayAuditFees\":\n if (!applicationId) {\n throw new Error(ForwarderError.MISSING_REQUIRED_PARAMS);\n }\n return `PayAuditFees::${applicationId}`;\n\n default:\n throw new Error(ForwarderError.INVALID_FORWARD_TYPE);\n }\n }\n\n /**\n * Get the appropriate token contract based on currency\n */\n function getTokenContract(currency: Currency = \"USDC\") {\n assertSigner(signer);\n\n let tokenAddress: string;\n switch (currency) {\n case \"USDC\":\n tokenAddress = ADDRESSES.USDC;\n break;\n case \"GLW\":\n tokenAddress = ADDRESSES.GLW;\n break;\n case \"USDG\":\n tokenAddress = ADDRESSES.USDG;\n break;\n default:\n throw new Error(\n `Currency ${currency} not yet supported. Only USDC, GLW, and USDG are currently supported.`\n );\n }\n\n return new Contract(tokenAddress, ERC20_ABI, signer);\n }\n\n /**\n * Check current token allowance for the forwarder contract\n * @param owner The wallet address to check allowance for\n * @param currency The currency to check allowance for\n */\n async function checkTokenAllowance(\n owner: string,\n currency: Currency = \"USDC\"\n ): Promise<bigint> {\n assertSigner(signer);\n\n try {\n const tokenContract = getTokenContract(currency);\n if (!tokenContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n const allowance: bigint = await tokenContract.allowance(\n owner,\n ADDRESSES.FORWARDER\n );\n return allowance;\n } catch (error) {\n throw new Error(parseEthersError(error));\n }\n }\n\n /**\n * Check user's token balance\n * @param owner The wallet address to check balance for\n * @param currency The currency to check balance for\n */\n async function checkTokenBalance(\n owner: string,\n currency: Currency = \"USDC\"\n ): Promise<bigint> {\n assertSigner(signer);\n\n try {\n const tokenContract = getTokenContract(currency);\n if (!tokenContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n const balance: bigint = await tokenContract.balanceOf(owner);\n return balance;\n } catch (error) {\n throw new Error(parseEthersError(error));\n }\n }\n\n /**\n * Approve tokens for the forwarder contract\n * @param amount Amount to approve (BigNumber)\n * @param currency The currency to approve\n */\n async function approveToken(\n amount: BigNumberish,\n currency: Currency = \"USDC\"\n ): Promise<boolean> {\n assertSigner(signer);\n\n try {\n const tokenContract = getTokenContract(currency);\n if (!tokenContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n setIsProcessing(true);\n\n // Approve only the specific amount needed\n const approveTx = await tokenContract.approve(\n ADDRESSES.FORWARDER,\n amount\n );\n await approveTx.wait();\n\n return true;\n } catch (error) {\n throw new Error(parseEthersError(error));\n } finally {\n setIsProcessing(false);\n }\n }\n\n /**\n * Forward tokens through the forwarder contract with type-specific handling\n * @param params Forward parameters including type, amount, and required fields\n */\n async function forwardTokens(params: ForwardParams): Promise<string> {\n assertSigner(signer);\n\n try {\n const forwarderContract = getForwarderContract();\n if (!forwarderContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n setIsProcessing(true);\n\n const { amount, currency = \"USDC\" } = params;\n const tokenContract = getTokenContract(currency);\n if (!tokenContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n const owner = await signer.getAddress();\n\n // Construct the appropriate message for this forward type\n const message = constructForwardMessage(params);\n\n // Special handling: PayAuditFees can ONLY be USDC, and must call forward()\n const isAuditFees = params.type === \"PayAuditFees\";\n if (isAuditFees && currency !== \"USDC\") {\n throw new Error(\"PayAuditFees only supports USDC\");\n }\n\n // Check allowance and approve if necessary\n const allowance: bigint = await tokenContract.allowance(\n owner,\n ADDRESSES.FORWARDER\n );\n\n if (allowance < amount) {\n try {\n const approveTx = await tokenContract.approve(\n ADDRESSES.FORWARDER,\n MaxUint256\n );\n await approveTx.wait();\n } catch (approveError) {\n throw new Error(\n parseEthersError(approveError) || \"Token approval failed\"\n );\n }\n }\n\n // Get the token address based on currency\n let tokenAddress: string;\n switch (currency) {\n case \"USDC\":\n tokenAddress = ADDRESSES.USDC;\n break;\n case \"USDG\":\n tokenAddress = ADDRESSES.USDG;\n break;\n case \"GLW\":\n tokenAddress = ADDRESSES.GLW;\n break;\n default:\n throw new Error(`Unsupported currency for forwarding: ${currency}`);\n }\n\n // Run a static call first to surface any revert reason (ethers v6)\n try {\n if (!isAuditFees && currency === \"USDC\") {\n await forwarderContract\n .getFunction(\"swapUSDCAndForwardUSDG\")\n .staticCall(amount, ADDRESSES.FOUNDATION_WALLET, message, {\n from: owner,\n });\n } else {\n await forwarderContract\n .getFunction(\"forward\")\n .staticCall(\n tokenAddress,\n isAuditFees\n ? ADDRESSES.AUDIT_FEE_WALLET\n : ADDRESSES.FOUNDATION_WALLET,\n amount,\n message,\n { from: owner }\n );\n }\n } catch (staticError) {\n throw new Error(parseEthersError(staticError));\n }\n\n // Execute the forward transaction\n let tx;\n if (!isAuditFees && currency === \"USDC\") {\n tx = await forwarderContract.getFunction(\"swapUSDCAndForwardUSDG\")(\n amount,\n ADDRESSES.FOUNDATION_WALLET,\n message\n );\n } else {\n tx = await forwarderContract.getFunction(\"forward\")(\n tokenAddress,\n isAuditFees\n ? ADDRESSES.AUDIT_FEE_WALLET\n : ADDRESSES.FOUNDATION_WALLET,\n amount,\n message\n );\n }\n await tx.wait();\n\n return tx.hash;\n } catch (txError: any) {\n throw new Error(parseEthersError(txError));\n } finally {\n setIsProcessing(false);\n }\n }\n\n /**\n * Forward tokens for protocol fee payment and GCTL minting with staking\n */\n async function payProtocolFeeAndMintGCTLAndStake(\n amount: bigint,\n userAddress: string,\n applicationId: string,\n regionId?: number,\n currency: Currency = \"USDC\"\n ): Promise<string> {\n assertSigner(signer);\n\n // GCTL minting only supports USDC and USDG\n if (currency === \"GLW\") {\n throw new Error(\n \"GCTL minting is not supported with GLW payment. Use USDC or USDG.\"\n );\n }\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"PayProtocolFeeAndMintGCTLAndStake\",\n currency,\n applicationId,\n regionId,\n });\n }\n\n /**\n * Forward tokens for protocol fee payment only\n */\n async function payProtocolFee(\n amount: bigint,\n userAddress: string,\n applicationId: string,\n currency: Currency = \"USDC\"\n ): Promise<string> {\n assertSigner(signer);\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"PayProtocolFee\",\n currency,\n applicationId,\n });\n }\n\n /**\n * Forward USDC to mint GCTL and stake to a region\n */\n async function mintGCTLAndStake(\n amount: bigint,\n userAddress: string,\n regionId?: number,\n currency: Currency = \"USDC\"\n ): Promise<string> {\n assertSigner(signer);\n\n // GCTL minting only supports USDC and USDG\n if (currency === \"GLW\") {\n throw new Error(\n \"GCTL minting is not supported with GLW payment. Use USDC or USDG.\"\n );\n }\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"MintGCTLAndStake\",\n currency,\n regionId,\n });\n }\n\n /**\n * Forward USDC to mint GCTL (existing functionality, keeping for compatibility)\n */\n async function mintGCTL(\n amount: bigint,\n userAddress: string,\n currency: Currency = \"USDC\"\n ): Promise<string> {\n assertSigner(signer);\n\n // GCTL minting only supports USDC and USDG\n if (currency === \"GLW\") {\n throw new Error(\n \"GCTL minting is not supported with GLW payment. Use USDC or USDG.\"\n );\n }\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"MintGCTL\",\n currency,\n });\n }\n\n /**\n * Forward tokens to pay audit fees (USDC only, calls forward())\n */\n async function payAuditFees(\n amount: bigint,\n userAddress: string,\n applicationId: string\n ): Promise<string> {\n assertSigner(signer);\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"PayAuditFees\",\n currency: \"USDC\",\n applicationId,\n });\n }\n\n /**\n * Forward tokens to buy a solar farm\n */\n async function buySolarFarm(\n amount: bigint,\n userAddress: string,\n farmId: string,\n currency: Currency = \"USDC\"\n ): Promise<string> {\n assertSigner(signer);\n\n return forwardTokens({\n amount,\n userAddress,\n type: \"BuySolarFarm\",\n currency,\n farmId,\n });\n }\n\n /**\n * Estimate gas for forwarding with type-specific handling\n * @param params Forward parameters\n * @param ethPriceInUSD Current ETH price in USD (for cost estimation)\n */\n async function estimateGasForForward(\n params: ForwardParams,\n ethPriceInUSD: number | null\n ): Promise<string> {\n assertSigner(signer);\n\n try {\n const forwarderContract = getForwarderContract();\n if (!forwarderContract)\n throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n const { amount, currency = \"USDC\" } = params;\n const isAuditFees = params.type === \"PayAuditFees\";\n if (isAuditFees && currency !== \"USDC\") {\n throw new Error(\"PayAuditFees only supports USDC\");\n }\n\n // Construct the appropriate message for this forward type\n const message = constructForwardMessage(params);\n\n // Get token address\n let tokenAddress: string;\n switch (currency) {\n case \"USDC\":\n tokenAddress = ADDRESSES.USDC;\n break;\n case \"USDG\":\n tokenAddress = ADDRESSES.USDG;\n break;\n case \"GLW\":\n tokenAddress = ADDRESSES.GLW;\n break;\n default:\n throw new Error(\n `Unsupported currency for gas estimation: ${currency}`\n );\n }\n\n const feeData = await signer.provider?.getFeeData();\n const gasPrice =\n feeData?.gasPrice ?? feeData?.maxFeePerGas ?? (0n as bigint);\n if (gasPrice === 0n) {\n throw new Error(\"Could not fetch gas price to estimate cost.\");\n }\n const estimatedGas: bigint =\n !isAuditFees && currency === \"USDC\"\n ? await forwarderContract\n .getFunction(\"swapUSDCAndForwardUSDG\")\n .estimateGas(amount, ADDRESSES.FOUNDATION_WALLET, message)\n : await forwarderContract\n .getFunction(\"forward\")\n .estimateGas(\n tokenAddress,\n isAuditFees\n ? ADDRESSES.AUDIT_FEE_WALLET\n : ADDRESSES.FOUNDATION_WALLET,\n amount,\n message\n );\n const estimatedCost: bigint = estimatedGas * gasPrice;\n\n if (ethPriceInUSD) {\n const estimatedCostInEth = formatEther(estimatedCost);\n const estimatedCostInUSD = (\n parseFloat(estimatedCostInEth) * ethPriceInUSD\n ).toFixed(2);\n return estimatedCostInUSD;\n } else {\n throw new Error(\n \"Could not fetch the ETH price to calculate cost in USD.\"\n );\n }\n } catch (error: any) {\n throw new Error(parseEthersError(error));\n }\n }\n\n /**\n * Mint test USDC (only works on testnets with mintable USDC contracts)\n * @param amount Amount of USDC to mint (BigNumber, 6 decimals)\n * @param recipient Address to mint USDC to\n */\n async function mintTestUSDC(\n amount: bigint,\n recipient: string\n ): Promise<string> {\n assertSigner(signer);\n if (CHAIN_ID !== 11155111) {\n throw new Error(\"Minting test USDC is only supported on Sepolia\");\n }\n\n try {\n const usdcContract = getTokenContract(\"USDC\"); // Use getTokenContract for consistency\n if (!usdcContract) throw new Error(ForwarderError.CONTRACT_NOT_AVAILABLE);\n\n setIsProcessing(true);\n\n // Try to call mint function (common for test tokens)\n const tx = await usdcContract.mint(recipient, amount);\n await tx.wait();\n\n return tx.hash;\n } catch (error: any) {\n // If mint function doesn't exist or fails, provide helpful error\n const errorMessage = parseEthersError(error);\n if (errorMessage.includes(\"mint\")) {\n throw new Error(\"This USDC contract doesn't support minting\");\n }\n throw new Error(errorMessage);\n } finally {\n setIsProcessing(false);\n }\n }\n\n return {\n // New methods for different forward types\n forwardTokens,\n payProtocolFeeAndMintGCTLAndStake,\n payProtocolFee,\n mintGCTLAndStake,\n mintGCTL,\n buySolarFarm,\n payAuditFees,\n\n // Token operations\n approveToken,\n checkTokenAllowance,\n checkTokenBalance,\n\n // Utility methods\n estimateGasForForward,\n mintTestUSDC,\n constructForwardMessage,\n\n // State\n get isProcessing() {\n return isProcessing;\n },\n addresses: ADDRESSES,\n\n // Signer availability\n isSignerAvailable: !!signer,\n };\n}\n","\"use strict\";\n\nimport type {\n MintedEvent,\n StakedEvent,\n PendingTransfer,\n FailedOperation,\n GctlPrice,\n StakeRequest,\n RegionStake,\n WalletRegionStake,\n WalletRegionUnlocked,\n Region,\n TransferDetails,\n GlwPrice,\n} from \"../types\";\n\n// --------------------------------------------------------------------------\n\n/**\n * Extract a useful error message from an unknown error value.\n */\nfunction parseApiError(error: unknown): string {\n if (!error) return \"Unknown error\";\n if (error instanceof Error) return error.message;\n const possible: any = error;\n return possible?.error?.message ?? possible?.message ?? \"Unknown error\";\n}\n\n// --------------------------------------------------------------------------\n// Public Factory\n// --------------------------------------------------------------------------\n\nexport function ControlRouter(baseUrl: string) {\n // ----------------------- Internal helpers --------------------------------\n const request = async <T>(path: string, init?: RequestInit): Promise<T> => {\n const res = await fetch(`${baseUrl}${path}`, init);\n if (!res.ok) {\n const errData = await res.json().catch(() => ({}));\n throw new Error(errData?.error || `Request to ${path} failed`);\n }\n return (await res.json()) as T;\n };\n\n // ----------------------- GETters -----------------------------------------\n const fetchGctlBalance = async (wallet: string): Promise<string> => {\n try {\n const data = await request<{ gctl_balance: string }>(\n `/balance/${wallet}`\n );\n return (data?.gctl_balance ?? \"0\").toString();\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchGctlPrice = async (): Promise<string> => {\n try {\n const data = await request<GctlPrice>(`/price`);\n return data.currentPriceUsdc;\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchGlwPrice = async (): Promise<string> => {\n try {\n const data = await request<GlwPrice>(`/price/glw`);\n return data.currentPriceUsdc;\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n // Build pagination query helper\n const buildPaginationQuery = (page?: number, limit?: number) => {\n const p = page ?? 1;\n const l = limit ?? 50;\n return `?page=${p}&limit=${l}`;\n };\n\n const fetchMintedEvents = async (\n page?: number,\n limit?: number\n ): Promise<MintedEvent[]> => {\n try {\n const data = await request<{ events: MintedEvent[] }>(\n `/events/minted${buildPaginationQuery(page, limit)}`\n );\n return data.events ?? [];\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchStakeEvents = async (\n page?: number,\n limit?: number\n ): Promise<StakedEvent[]> => {\n try {\n const data = await request<{ events: StakedEvent[] }>(\n `/events/stake${buildPaginationQuery(page, limit)}`\n );\n return data.events ?? [];\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchPendingTransfers = async (\n page?: number,\n limit?: number\n ): Promise<PendingTransfer[]> => {\n try {\n const data = await request<{ transfers: PendingTransfer[] }>(\n `/transfers/pending${buildPaginationQuery(page, limit)}`\n );\n return data.transfers ?? [];\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchTransferDetails = async (\n txId: string\n ): Promise<TransferDetails> => {\n try {\n return await request<TransferDetails>(`/transfer/${txId}`);\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchFailedOperations = async (\n page?: number,\n limit?: number\n ): Promise<FailedOperation[]> => {\n try {\n const data = await request<{ operations: FailedOperation[] }>(\n `/operations/failed${buildPaginationQuery(page, limit)}`\n );\n return data.operations ?? [];\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n // Exposed query with error parsing\n const getTransferDetails = async (txId: string): Promise<TransferDetails> => {\n try {\n return await fetchTransferDetails(txId);\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchRegions = async (): Promise<Region[]> => {\n const data = await request<{ regions: Region[] }>(`/regions`);\n return data.regions.filter((r) => r.id !== 998 && r.id !== 999) ?? [];\n };\n\n const fetchRegionStake = async (regionId: number): Promise<RegionStake> => {\n try {\n return await request<RegionStake>(`/region/${regionId}/stake`);\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchWalletRegionStake = async (\n wallet: string,\n regionId: number\n ): Promise<WalletRegionStake> => {\n try {\n return await request<WalletRegionStake>(\n `/wallet/${wallet}/region/${regionId}/stake`\n );\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n const fetchWalletRegionUnlocked = async (\n wallet: string,\n regionId: number\n ): Promise<WalletRegionUnlocked> => {\n try {\n return await request<WalletRegionUnlocked>(\n `/wallet/${wallet}/region/${regionId}/unlocked`\n );\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n // ----------------------- Mutations ---------------------------------------\n let isStaking = false;\n let isUnstaking = false;\n let isRetryingFailedOperation = false;\n\n const stakeGctl = async (\n wallet: string,\n regionId: number,\n amount: string\n ): Promise<boolean> => {\n isStaking = true;\n try {\n const stakeRequest: StakeRequest = { wallet, regionId, amount };\n await request(`/stake`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(stakeRequest),\n });\n return true;\n } catch (error) {\n throw new Error(parseApiError(error));\n } finally {\n isStaking = false;\n }\n };\n\n const unstakeGctl = async (\n wallet: string,\n regionId: number,\n amount: string\n ): Promise<boolean> => {\n isUnstaking = true;\n try {\n const unstakeRequest: StakeRequest = { wallet, regionId, amount };\n await request(`/unstake`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(unstakeRequest),\n });\n return true;\n } catch (error) {\n throw new Error(parseApiError(error));\n } finally {\n isUnstaking = false;\n }\n };\n\n const retryFailedOperation = async (\n operationId: string\n ): Promise<boolean> => {\n isRetryingFailedOperation = true;\n try {\n await request(`/operations/failed/${operationId}/retry`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n });\n return true;\n } catch (error) {\n throw new Error(parseApiError(error));\n } finally {\n isRetryingFailedOperation = false;\n }\n };\n\n // --------------------------- Public API ----------------------------------\n return {\n // Queries\n fetchGctlBalance,\n fetchGctlPrice,\n fetchGlwPrice,\n fetchMintedEvents,\n fetchStakeEvents,\n fetchPendingTransfers,\n fetchFailedOperations,\n fetchRegions,\n fetchRegionStake,\n fetchWalletRegionStake,\n fetchWalletRegionUnlocked,\n fetchTransferDetails: getTransferDetails,\n\n // Mutations\n stakeGctl,\n unstakeGctl,\n retryFailedOperation,\n\n // Processing flags\n get isStaking() {\n return isStaking;\n },\n get isUnstaking() {\n return isUnstaking;\n },\n get isRetryingFailedOperation() {\n return isRetryingFailedOperation;\n },\n } as const;\n}\n","import type { RegionMetadata } from \"./types\";\n// Region metadata for kickstarter campaigns\n\nexport const regionMetadata: Record<string, RegionMetadata> = {\n // US States\n \"US-AL\": {\n code: \"US-AL\",\n name: \"Alabama\",\n description: \"The Heart of Dixie is ready for solar transformation\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-AK\": {\n code: \"US-AK\",\n name: \"Alaska\",\n description: \"The Last Frontier embracing renewable energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-AZ\": {\n code: \"US-AZ\",\n name: \"Arizona\",\n description: \"The Grand Canyon State with abundant sunshine\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-AR\": {\n code: \"US-AR\",\n name: \"Arkansas\",\n description: \"The Natural State going solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-CA\": {\n code: \"US-CA\",\n name: \"California\",\n description: \"The Golden State leading solar innovation\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-CO\": {\n code: \"US-CO\",\n name: \"Colorado\",\n description: \"The Centennial State with high-altitude solar potential\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-CT\": {\n code: \"US-CT\",\n name: \"Connecticut\",\n description: \"The Constitution State embracing clean energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-DE\": {\n code: \"US-DE\",\n name: \"Delaware\",\n description: \"The First State to go solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-FL\": {\n code: \"US-FL\",\n name: \"Florida\",\n description: \"The Sunshine State living up to its name\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-GA\": {\n code: \"US-GA\",\n name: \"Georgia\",\n description: \"The Peach State harvesting solar energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-HI\": {\n code: \"US-HI\",\n name: \"Hawaii\",\n description: \"The Aloha State with year-round solar potential\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-ID\": {\n code: \"US-ID\",\n name: \"Idaho\",\n description: \"The Gem State shining with solar power\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-IL\": {\n code: \"US-IL\",\n name: \"Illinois\",\n description: \"The Prairie State powering up with solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-IN\": {\n code: \"US-IN\",\n name: \"Indiana\",\n description: \"The Hoosier State joining the solar revolution\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-IA\": {\n code: \"US-IA\",\n name: \"Iowa\",\n description: \"The Hawkeye State expanding beyond wind to solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-KS\": {\n code: \"US-KS\",\n name: \"Kansas\",\n description: \"The Sunflower State growing solar energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-KY\": {\n code: \"US-KY\",\n name: \"Kentucky\",\n description: \"The Bluegrass State transitioning to clean energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-LA\": {\n code: \"US-LA\",\n name: \"Louisiana\",\n description: \"The Pelican State soaring with solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-ME\": {\n code: \"US-ME\",\n name: \"Maine\",\n description: \"The Pine Tree State branching into solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MD\": {\n code: \"US-MD\",\n name: \"Maryland\",\n description: \"The Old Line State drawing new energy lines\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MA\": {\n code: \"US-MA\",\n name: \"Massachusetts\",\n description: \"The Bay State leading in solar innovation\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MI\": {\n code: \"US-MI\",\n name: \"Michigan\",\n description: \"The Great Lakes State harnessing solar power\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MN\": {\n code: \"US-MN\",\n name: \"Minnesota\",\n description: \"The North Star State guiding solar adoption\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MS\": {\n code: \"US-MS\",\n name: \"Mississippi\",\n description: \"The Magnolia State blooming with solar energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MO\": {\n code: \"US-MO\",\n name: \"Missouri\",\n description: \"The Show-Me State showing solar leadership\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-MT\": {\n code: \"US-MT\",\n name: \"Montana\",\n description: \"Big Sky Country with big solar potential\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NE\": {\n code: \"US-NE\",\n name: \"Nebraska\",\n description: \"The Cornhusker State cultivating solar power\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NV\": {\n code: \"US-NV\",\n name: \"Nevada\",\n description: \"The Silver State striking solar gold\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NH\": {\n code: \"US-NH\",\n name: \"New Hampshire\",\n description: \"The Granite State building solid solar foundation\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NJ\": {\n code: \"US-NJ\",\n name: \"New Jersey\",\n description: \"The Garden State growing solar gardens\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NM\": {\n code: \"US-NM\",\n name: \"New Mexico\",\n description: \"The Land of Enchantment enchanted by solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NY\": {\n code: \"US-NY\",\n name: \"New York\",\n description: \"The Empire State building a solar empire\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-NC\": {\n code: \"US-NC\",\n name: \"North Carolina\",\n description: \"The Tar Heel State stepping into solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-ND\": {\n code: \"US-ND\",\n name: \"North Dakota\",\n description: \"The Peace Garden State cultivating solar peace\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-OH\": {\n code: \"US-OH\",\n name: \"Ohio\",\n description: \"The Buckeye State branching into solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-OK\": {\n code: \"US-OK\",\n name: \"Oklahoma\",\n description: \"The Sooner State adopting solar sooner\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-OR\": {\n code: \"US-OR\",\n name: \"Oregon\",\n description: \"The Beaver State building solar dams\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-PA\": {\n code: \"US-PA\",\n name: \"Pennsylvania\",\n description: \"The Keystone State unlocking solar potential\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-RI\": {\n code: \"US-RI\",\n name: \"Rhode Island\",\n description: \"The Ocean State riding the solar wave\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-SC\": {\n code: \"US-SC\",\n name: \"South Carolina\",\n description: \"The Palmetto State basking in solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-SD\": {\n code: \"US-SD\",\n name: \"South Dakota\",\n description: \"Mount Rushmore State carving out solar future\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-TN\": {\n code: \"US-TN\",\n name: \"Tennessee\",\n description: \"The Volunteer State volunteering for solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-TX\": {\n code: \"US-TX\",\n name: \"Texas\",\n description: \"The Lone Star State shining with solar power\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-UT\": {\n code: \"US-UT\",\n name: \"Utah\",\n description: \"The Beehive State buzzing with solar activity\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-VT\": {\n code: \"US-VT\",\n name: \"Vermont\",\n description: \"The Green Mountain State going greener\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-VA\": {\n code: \"US-VA\",\n name: \"Virginia\",\n description: \"The Old Dominion embracing new energy\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-WA\": {\n code: \"US-WA\",\n name: \"Washington\",\n description: \"The Evergreen State staying green with solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-WV\": {\n code: \"US-WV\",\n name: \"West Virginia\",\n description: \"The Mountain State reaching new heights\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-WI\": {\n code: \"US-WI\",\n name: \"Wisconsin\",\n description: \"The Badger State digging into solar\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n \"US-WY\": {\n code: \"US-WY\",\n name: \"Wyoming\",\n description: \"The Equality State equalizing energy access\",\n isUs: true,\n flag: \"🇺🇸\",\n },\n\n // Countries\n CA: {\n code: \"CA\",\n name: \"Canada\",\n description: \"The Great White North embracing solar energy\",\n isUs: false,\n flag: \"🇨🇦\",\n },\n MX: {\n code: \"MX\",\n name: \"Mexico\",\n description: \"Abundant sunshine powering the future\",\n isUs: false,\n flag: \"🇲🇽\",\n },\n BR: {\n code: \"BR\",\n name: \"Brazil\",\n description: \"The largest South American market for solar\",\n isUs: false,\n flag: \"🇧🇷\",\n },\n AR: {\n code: \"AR\",\n name: \"Argentina\",\n description: \"Pampas and sunshine creating energy independence\",\n isUs: false,\n flag: \"🇦🇷\",\n },\n CL: {\n code: \"CL\",\n name: \"Chile\",\n description: \"The Atacama Desert's solar potential unleashed\",\n isUs: false,\n flag: \"🇨🇱\",\n },\n CO: {\n code: \"CO\",\n name: \"Colombia\",\n description: \"Equatorial sunshine year-round\",\n isUs: false,\n flag: \"🇨🇴\",\n },\n PE: {\n code: \"PE\",\n name: \"Peru\",\n description: \"From the Andes to the Amazon with solar\",\n isUs: false,\n flag: \"🇵🇪\",\n },\n GB: {\n code: \"GB\",\n name: \"United Kingdom\",\n description: \"Leading Europe's renewable transition\",\n isUs: false,\n flag: \"🇬🇧\",\n },\n FR: {\n code: \"FR\",\n name: \"France\",\n description: \"La République embracing solar liberté\",\n isUs: false,\n flag: \"🇫🇷\",\n },\n DE: {\n code: \"DE\",\n name: \"Germany\",\n description: \"Engineering excellence in solar deployment\",\n isUs: false,\n flag: \"🇩🇪\",\n },\n IT: {\n code: \"IT\",\n name: \"Italy\",\n description: \"Mediterranean sunshine powering the boot\",\n isUs: false,\n flag: \"🇮🇹\",\n },\n ES: {\n code: \"ES\",\n name: \"Spain\",\n description: \"Iberian peninsula's solar powerhouse\",\n isUs: false,\n flag: \"🇪🇸\",\n },\n PT: {\n code: \"PT\",\n name: \"Portugal\",\n description: \"Atlantic coast harnessing solar waves\",\n isUs: false,\n flag: \"🇵🇹\",\n },\n NL: {\n code: \"NL\",\n name: \"Netherlands\",\n description: \"Low lands, high solar ambitions\",\n isUs: false,\n flag: \"🇳🇱\",\n },\n BE: {\n code: \"BE\",\n name: \"Belgium\",\n description: \"The heart of Europe goes solar\",\n isUs: false,\n flag: \"🇧🇪\",\n },\n CH: {\n code: \"CH\",\n name: \"Switzerland\",\n description: \"Alpine heights capturing pure sunlight\",\n isUs: false,\n flag: \"🇨🇭\",\n },\n AT: {\n code: \"AT\",\n name: \"Austria\",\n description: \"Mountain valleys filled with solar panels\",\n isUs: false,\n flag: \"🇦🇹\",\n },\n SE: {\n code: \"SE\",\n name: \"Sweden\",\n description: \"Nordic innovation in solar technology\",\n isUs: false,\n flag: \"🇸🇪\",\n },\n NO: {\n code: \"NO\",\n name: \"Norway\",\n description: \"Fjords reflecting solar possibilities\",\n isUs: false,\n flag: \"🇳🇴\",\n },\n DK: {\n code: \"DK\",\n name: \"Denmark\",\n description: \"Viking spirit conquering solar frontiers\",\n isUs: false,\n flag: \"🇩🇰\",\n },\n FI: {\n code: \"FI\",\n name: \"Finland\",\n description: \"Land of midnight sun going solar\",\n isUs: false,\n flag: \"🇫🇮\",\n },\n PL: {\n code: \"PL\",\n name: \"Poland\",\n description: \"Central Europe's emerging solar market\",\n isUs: false,\n flag: \"🇵🇱\",\n },\n CZ: {\n code: \"CZ\",\n name: \"Czech Republic\",\n description: \"Bohemian innovation in renewable energy\",\n isUs: false,\n flag: \"🇨🇿\",\n },\n GR: {\n code: \"GR\",\n name: \"Greece\",\n description: \"Aegean sunshine powering ancient lands\",\n isUs: false,\n flag: \"🇬🇷\",\n },\n TR: {\n code: \"TR\",\n name: \"Turkey\",\n description: \"Bridge between continents powered by sun\",\n isUs: false,\n flag: \"🇹🇷\",\n },\n IN: {\n code: \"IN\",\n name: \"India\",\n description: \"World's fastest growing solar market\",\n isUs: false,\n flag: \"🇮🇳\",\n },\n CN: {\n code: \"CN\",\n name: \"China\",\n description: \"Global solar manufacturing leader\",\n isUs: false,\n flag: \"🇨🇳\",\n },\n JP: {\n code: \"JP\",\n name: \"Japan\",\n description: \"Rising sun powering technological innovation\",\n isUs: false,\n flag: \"🇯🇵\",\n },\n KR: {\n code: \"KR\",\n name: \"South Korea\",\n description: \"High-tech nation embracing green energy\",\n isUs: false,\n flag: \"🇰🇷\",\n },\n AU: {\n code: \"AU\",\n name: \"Australia\",\n description: \"Outback sunshine creating energy abundance\",\n isUs: false,\n flag: \"🇦🇺\",\n },\n NZ: {\n code: \"NZ\",\n name: \"New Zealand\",\n description: \"Clean, green Aotearoa\",\n isUs: false,\n flag: \"🇳🇿\",\n },\n ZA: {\n code: \"ZA\",\n name: \"South Africa\",\n description: \"African sunshine lighting the continent\",\n isUs: false,\n flag: \"🇿🇦\",\n },\n EG: {\n code: \"EG\",\n name: \"Egypt\",\n description: \"Desert sun powering ancient civilizations\",\n isUs: false,\n flag: \"🇪🇬\",\n },\n NG: {\n code: \"NG\",\n name: \"Nigeria\",\n description: \"West Africa's solar giant awakening\",\n isUs: false,\n flag: \"🇳🇬\",\n },\n KE: {\n code: \"KE\",\n name: \"Kenya\",\n description: \"East African solar innovation hub\",\n isUs: false,\n flag: \"🇰🇪\",\n },\n MA: {\n code: \"MA\",\n name: \"Morocco\",\n description: \"Saharan edge harnessing desert power\",\n isUs: false,\n flag: \"🇲🇦\",\n },\n SA: {\n code: \"SA\",\n name: \"Saudi Arabia\",\n description: \"Oil kingdom transitioning to solar\",\n isUs: false,\n flag: \"🇸🇦\",\n },\n AE: {\n code: \"AE\",\n name: \"United Arab Emirates\",\n description: \"Desert emirates building solar oases\",\n isUs: false,\n flag: \"🇦🇪\",\n },\n IL: {\n code: \"IL\",\n name: \"Israel\",\n description: \"Innovation nation powered by sunshine\",\n isUs: false,\n flag: \"🇮🇱\",\n },\n SG: {\n code: \"SG\",\n name: \"Singapore\",\n description: \"City-state maximizing rooftop solar\",\n isUs: false,\n flag: \"🇸🇬\",\n },\n ID: {\n code: \"ID\",\n name: \"Indonesia\",\n description: \"Archipelago nation harnessing tropical sun\",\n isUs: false,\n flag: \"🇮🇩\",\n },\n TH: {\n code: \"TH\",\n name: \"Thailand\",\n description: \"Land of smiles powered by solar\",\n isUs: false,\n flag: \"🇹🇭\",\n },\n VN: {\n code: \"VN\",\n name: \"Vietnam\",\n description: \"Southeast Asian solar manufacturing hub\",\n isUs: false,\n flag: \"🇻🇳\",\n },\n PH: {\n code: \"PH\",\n name: \"Philippines\",\n description: \"7,000 islands unified by solar power\",\n isUs: false,\n flag: \"🇵🇭\",\n },\n};\n\n// Helper to get all regions as array\nexport const allRegions = Object.values(regionMetadata);\n\n// Helper to get US states\nexport const usStates = allRegions.filter((r) => r.isUs);\n\n// Helper to get countries\nexport const countries = allRegions.filter((r) => !r.isUs);\n","\"use strict\";\n\nimport { regionMetadata } from \"../region-metadata\";\nimport type {\n Region,\n RegionWithMetadata,\n ActivationConfig,\n CreateRegionPayload,\n} from \"../types\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction parseApiError(error: unknown): string {\n if (!error) return \"Unknown error\";\n if (error instanceof Error) return error.message;\n const possible: any = error;\n return possible?.error?.message ?? possible?.message ?? \"Unknown error\";\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function RegionRouter(baseUrl: string) {\n if (!baseUrl) throw new Error(\"CONTROL API base URL is not set\");\n\n const request = async <T>(path: string, init?: RequestInit): Promise<T> => {\n const res = await fetch(`${baseUrl}${path}`, init);\n if (!res.ok) {\n const errData = await res.json().catch(() => ({}));\n throw new Error(errData?.error || `Request to ${path} failed`);\n }\n return (await res.json()) as T;\n };\n\n // -------------------------------------------------------------------------\n // Local cache / state flags\n // -------------------------------------------------------------------------\n let cachedRegions: Region[] = [];\n let isLoading = false;\n let isCreatingRegion = false;\n\n // -------------------------------------------------------------------------\n // Queries\n // -------------------------------------------------------------------------\n const fetchRegions = async (): Promise<Region[]> => {\n isLoading = true;\n try {\n const data = await request<{ regions: Region[] }>(`/regions`);\n cachedRegions = data.regions ?? [];\n return cachedRegions;\n } catch (error) {\n throw new Error(parseApiError(error));\n } finally {\n isLoading = false;\n }\n };\n\n const fetchActivationConfig = async (\n regionCode: string\n ): Promise<ActivationConfig> => {\n try {\n return await request<ActivationConfig>(\n `/regions/activation-config?code=${regionCode}`\n );\n } catch (error) {\n throw new Error(parseApiError(error));\n }\n };\n\n // -------------------------------------------------------------------------\n // Mutations\n // -------------------------------------------------------------------------\n const createRegion = async (payload: CreateRegionPayload): Promise<void> => {\n isCreatingRegion = true;\n try {\n await request(`/regions/create`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n });\n // Refresh the local cache after successful creation\n await fetchRegions();\n } catch (error) {\n throw new Error(parseApiError(error));\n } finally {\n isCreatingRegion = false;\n }\n };\n\n // -------------------------------------------------------------------------\n // Helpers (derived)\n // -------------------------------------------------------------------------\n\n const getRegionByCode = (code: string): RegionWithMetadata | null => {\n const metadata = regionMetadata[code];\n if (!metadata) return null;\n\n const existingRegion = cachedRegions.find(\n (r) => r.name.toLowerCase() === metadata.name.toLowerCase()\n );\n\n if (existingRegion) {\n return {\n ...existingRegion,\n code: metadata.code,\n description: metadata.description,\n flag: metadata.flag,\n };\n }\n\n // Placeholder if region does not yet exist in DB\n return {\n id: -1,\n name: metadata.name,\n code: metadata.code,\n description: metadata.description,\n flag: metadata.flag,\n isUs: metadata.isUs,\n isActive: false,\n stake: \"0\",\n stakeProgress: 0,\n solarFarmCount: 0,\n solarFarmProgress: 0,\n installerCount: 0,\n installerProgress: 0,\n };\n };\n\n // -------------------------------------------------------------------------\n // Public API\n // -------------------------------------------------------------------------\n return {\n // Data access\n fetchRegions,\n fetchActivationConfig,\n getRegionByCode,\n createRegion,\n\n // Cached data & flags\n get regions() {\n return cachedRegions;\n },\n get isLoading() {\n return isLoading;\n },\n get isCreatingRegion() {\n return isCreatingRegion;\n },\n } as const;\n}\n"],"names":["ForwarderError","Contract","MaxUint256","formatEther","parseApiError"],"mappings":";;;;;AAAO,MAAM,OAAO,GAAG;AAEhB,MAAM,QAAQ,GAAG,CAAC,4BAA4B;;ACFrD;;;;AAIG;AACI,MAAM,6BAA6B,GAAG;AAE7C;;;AAGG;AACI,MAAM,6BAA6B,GAAG;AAEtC,MAAM,UAAU,GACrB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;;ACd3C,MAAM,aAAa,GAAG;AAC3B,IAAA;AACE,QAAA,MAAM,EAAE;YACN,EAAE,YAAY,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YACjE,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;AACpE,SAAA;AACD,QAAA,eAAe,EAAE,SAAS;AAC1B,QAAA,IAAI,EAAE,aAAa;AACpB,KAAA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AqB;QACrB,eAAe;QACf,YAAY;;AAGZ,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,OAAO,aAAa;QACtB,CAAC;AACD,QAAA,IAAI,SAAS,GAAA;AACX,YAAA,OAAO,SAAS;QAClB,CAAC;AACD,QAAA,IAAI,gBAAgB,GAAA;AAClB,YAAA,OAAO,gBAAgB;QACzB,CAAC;KACO;AACZ;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,4 @@
1
- export { C as ControlRouter, D as DECIMALS_BY_TOKEN, d as FORWARDER_ABI, F as ForwarderError, e as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, M as MAX_WEIGHT, R as RegionRouter, U as USDG_WEIGHT_DECIMAL_PRECISION, a as allRegions, c as countries, g as getAddresses, r as regionMetadata, b as usStates, u as useForwarder } from './region-router-CTH4KcMq.js';
1
+ export { C as ControlRouter, D as DECIMALS_BY_TOKEN, d as FORWARDER_ABI, F as ForwarderError, e as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, M as MAX_WEIGHT, R as RegionRouter, U as USDG_WEIGHT_DECIMAL_PRECISION, a as allRegions, c as countries, g as getAddresses, r as regionMetadata, b as usStates, u as useForwarder } from './region-router-VXTuF9Up.js';
2
2
  import 'ethers';
3
+ import 'viem';
3
4
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/dist/esm/index.js CHANGED
@@ -11,10 +11,10 @@ import zlib from 'zlib';
11
11
  import { EventEmitter } from 'events';
12
12
  import { parseUnits, formatUnits } from 'viem';
13
13
  import { MerkleTree } from 'merkletreejs';
14
- import { ethers, BigNumber } from 'ethers';
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 './region-router-CTH4KcMq.js';
17
- export { C as ControlRouter, R as RegionRouter, u as useForwarder } from './region-router-CTH4KcMq.js';
16
+ import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './region-router-VXTuF9Up.js';
17
+ export { C as ControlRouter, R as RegionRouter, u as useForwarder } from './region-router-VXTuF9Up.js';
18
18
 
19
19
  const GENESIS_TIMESTAMP = 1700352000;
20
20
 
@@ -18693,7 +18693,7 @@ const NUMERIC_REGEX = /^(?:\d+\.?\d*|\.\d+)$/;
18693
18693
 
18694
18694
  const leafTypes = ["address", "uint256", "uint256"];
18695
18695
  function hashLeaf({ address, glowWeight, usdcWeight, }) {
18696
- const hash = ethers.utils.solidityKeccak256(leafTypes, [
18696
+ const hash = solidityPackedKeccak256(leafTypes, [
18697
18697
  address,
18698
18698
  glowWeight,
18699
18699
  usdcWeight,
@@ -18788,14 +18788,14 @@ async function createWeeklyReportLegacy(args) {
18788
18788
  glowWeight: leaf.glowWeight,
18789
18789
  usdcWeight: leaf.usdgWeight,
18790
18790
  }));
18791
- const tree = new MerkleTree(leaves, ethers.utils.keccak256, { sort: true });
18791
+ const tree = new MerkleTree(leaves, keccak256, { sort: true });
18792
18792
  const root = tree.getHexRoot();
18793
- const totalGlowWeightFinalizedLeavesSum = finalLeaves.reduce((acc, { glowWeight }) => acc.add(glowWeight), ethers.BigNumber.from(0));
18794
- const totalGCCWeightFinalizedLeavesSum = finalLeaves.reduce((acc, { usdgWeight }) => acc.add(usdgWeight), ethers.BigNumber.from(0));
18795
- if (totalGlowWeightFinalizedLeavesSum.toBigInt() > MAX_WEIGHT) {
18793
+ const totalGlowWeightFinalizedLeavesSum = finalLeaves.reduce((acc, { glowWeight }) => acc + BigInt(glowWeight), 0n);
18794
+ const totalGCCWeightFinalizedLeavesSum = finalLeaves.reduce((acc, { usdgWeight }) => acc + BigInt(usdgWeight), 0n);
18795
+ if (totalGlowWeightFinalizedLeavesSum > MAX_WEIGHT) {
18796
18796
  throw new Error("Total glow weight is greater than max weight");
18797
18797
  }
18798
- if (totalGCCWeightFinalizedLeavesSum.toBigInt() > MAX_WEIGHT) {
18798
+ if (totalGCCWeightFinalizedLeavesSum > MAX_WEIGHT) {
18799
18799
  throw new Error("Total gcc weight is greater than max weight");
18800
18800
  }
18801
18801
  const headlineStats = {
@@ -18826,21 +18826,21 @@ async function createWeeklyReportLegacy(args) {
18826
18826
  proof,
18827
18827
  };
18828
18828
  });
18829
- let forLoopedGlowWeightSum = ethers.BigNumber.from(0);
18829
+ let forLoopedGlowWeightSum = 0n;
18830
18830
  for (const leafProof of farmsWithMerkleProofs) {
18831
- forLoopedGlowWeightSum = forLoopedGlowWeightSum.add(BigNumber.from(leafProof.glowWeight));
18831
+ forLoopedGlowWeightSum += BigInt(leafProof.glowWeight);
18832
18832
  }
18833
- if (!forLoopedGlowWeightSum.eq(totalGlowWeightFinalizedLeavesSum)) {
18833
+ if (forLoopedGlowWeightSum !== totalGlowWeightFinalizedLeavesSum) {
18834
18834
  console.error("Glow Weight Sum Mismatch:");
18835
18835
  console.error("Sum from loop:", forLoopedGlowWeightSum.toString());
18836
18836
  console.error("Sum from reduce:", totalGlowWeightFinalizedLeavesSum.toString());
18837
18837
  throw new Error("Glow weight sum is not equal");
18838
18838
  }
18839
- let forLoopedGCCWeightSum = ethers.BigNumber.from(0);
18839
+ let forLoopedGCCWeightSum = 0n;
18840
18840
  for (const leafProof of farmsWithMerkleProofs) {
18841
- forLoopedGCCWeightSum = forLoopedGCCWeightSum.add(BigNumber.from(leafProof.usdgWeight));
18841
+ forLoopedGCCWeightSum += BigInt(leafProof.usdgWeight);
18842
18842
  }
18843
- if (!forLoopedGCCWeightSum.eq(totalGCCWeightFinalizedLeavesSum)) {
18843
+ if (forLoopedGCCWeightSum !== totalGCCWeightFinalizedLeavesSum) {
18844
18844
  console.error("USDG Weight Sum Mismatch:");
18845
18845
  console.error("Sum from loop:", forLoopedGCCWeightSum.toString());
18846
18846
  console.error("Sum from reduce:", totalGCCWeightFinalizedLeavesSum.toString());
@@ -19021,17 +19021,17 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19021
19021
  usdcWeight: leaf.usdgWeight, // Note: Parameter name inconsistency (usdc vs usdg)
19022
19022
  }));
19023
19023
  // Build the Merkle tree.
19024
- const merkleTree = new MerkleTree(hashedLeaves, ethers.utils.keccak256, {
19024
+ const merkleTree = new MerkleTree(hashedLeaves, keccak256, {
19025
19025
  sort: true, // Ensure consistent tree structure.
19026
19026
  });
19027
19027
  const merkleRoot = merkleTree.getHexRoot(); // Get the root hash.
19028
19028
  // Calculate the total weights across all finalized leaves.
19029
- const totalGlowWeight = finalizedLeaves.reduce((acc, { glowWeight }) => acc.add(glowWeight), ethers.BigNumber.from(0));
19030
- const totalUSDGWeight = finalizedLeaves.reduce((acc, { usdgWeight }) => acc.add(usdgWeight), ethers.BigNumber.from(0));
19029
+ const totalGlowWeight = finalizedLeaves.reduce((acc, { glowWeight }) => acc + BigInt(glowWeight), 0n);
19030
+ const totalUSDGWeight = finalizedLeaves.reduce((acc, { usdgWeight }) => acc + BigInt(usdgWeight), 0n);
19031
19031
  // Total Weight Overflow Checks: Ensure sums don't exceed maximum.
19032
- if (totalGlowWeight.toBigInt() > MAX_WEIGHT)
19032
+ if (totalGlowWeight > MAX_WEIGHT)
19033
19033
  throw new Error("Total glow weight overflow");
19034
- if (totalUSDGWeight.toBigInt() > MAX_WEIGHT)
19034
+ if (totalUSDGWeight > MAX_WEIGHT)
19035
19035
  throw new Error("Total USDG weight overflow");
19036
19036
  // Generate Merkle proofs for each leaf and verify them.
19037
19037
  const leavesWithProofs = finalizedLeaves.map((leaf) => {
@@ -19048,15 +19048,15 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19048
19048
  });
19049
19049
  // --- Sanity Checks on Final Weights ---
19050
19050
  // Verify that summing weights from leavesWithProofs matches the earlier reduce calculation.
19051
- const glowSumProofLoop = leavesWithProofs.reduce((acc, l) => acc.add(l.glowWeight), ethers.BigNumber.from(0));
19052
- if (!glowSumProofLoop.eq(totalGlowWeight)) {
19051
+ const glowSumProofLoop = leavesWithProofs.reduce((acc, l) => acc + BigInt(l.glowWeight), 0n);
19052
+ if (glowSumProofLoop !== totalGlowWeight) {
19053
19053
  console.error("Glow Weight Sum Mismatch (Post-73):");
19054
19054
  console.error("Sum from loop:", glowSumProofLoop.toString());
19055
19055
  console.error("Sum from reduce:", totalGlowWeight.toString());
19056
19056
  throw new Error("Glow sum mismatch");
19057
19057
  }
19058
- const usdgSumProofLoop = leavesWithProofs.reduce((acc, l) => acc.add(l.usdgWeight), ethers.BigNumber.from(0));
19059
- if (!usdgSumProofLoop.eq(totalUSDGWeight)) {
19058
+ const usdgSumProofLoop = leavesWithProofs.reduce((acc, l) => acc + BigInt(l.usdgWeight), 0n);
19059
+ if (usdgSumProofLoop !== totalUSDGWeight) {
19060
19060
  console.error("USDG Weight Sum Mismatch (Post-73):");
19061
19061
  console.error("Sum from loop:", usdgSumProofLoop.toString());
19062
19062
  console.error("Sum from reduce:", totalUSDGWeight.toString());
@@ -19068,7 +19068,7 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19068
19068
  return acc.plus(fromBigInt(adj, USDG_WEIGHT_DECIMAL_PRECISION));
19069
19069
  }, new Decimal(0));
19070
19070
  // Convert total USDG weight back to human-readable decimal for deviation check.
19071
- const totalUSDGWeightHuman = new Decimal(formatUnits(BigInt(totalUSDGWeight.toString()), USDG_WEIGHT_DECIMAL_PRECISION));
19071
+ const totalUSDGWeightHuman = new Decimal(formatUnits(totalUSDGWeight, USDG_WEIGHT_DECIMAL_PRECISION));
19072
19072
  // Check deviation between total adjusted credits used and the final sum of USDG weights.
19073
19073
  if (greaterThanMaxDeviation(totalExpectedCredits.toNumber(), totalUSDGWeightHuman.toNumber(), 0.001 // 0.1% tolerance
19074
19074
  )) {
@@ -19079,7 +19079,7 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19079
19079
  throw new Error("totalExpectedCredits vs USDG weight deviation >0.1% ");
19080
19080
  }
19081
19081
  // Convert total Glow weight back to human-readable decimal.
19082
- const totalGlowWeightHuman = new Decimal(formatUnits(BigInt(totalGlowWeight.toString()), GLOW_WEIGHT_DECIMAL_PRECISION));
19082
+ const totalGlowWeightHuman = new Decimal(formatUnits(totalGlowWeight, GLOW_WEIGHT_DECIMAL_PRECISION));
19083
19083
  // Sum the original weekly protocol fee payments from farm data.
19084
19084
  const totalProtocolFeePayments = farms.reduce((acc, f) => acc + f.weeklyPayment, 0);
19085
19085
  // Check deviation between total glow weight and total protocol fees paid.
@@ -19097,7 +19097,7 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19097
19097
  weekNumber: week,
19098
19098
  totalCreditsProduced: formatUnits(totalCreditsProduced18dp, 18), // Original reported total
19099
19099
  totalCreditsProducedBN: totalCreditsProduced18dp.toString(),
19100
- totalGlowWeightInFinalized: totalGlowWeight.toString(), // Total weight as BigNumber string
19100
+ totalGlowWeightInFinalized: totalGlowWeight.toString(), // Total weight as bigint string
19101
19101
  totalGlowWeightHuman: totalGlowWeightHuman.toString(), // Total weight as human-readable decimal
19102
19102
  totalUSDGWeightInFinalized: totalUSDGWeight.toString(),
19103
19103
  totalUSDGWeightHuman: totalUSDGWeightHuman.toString(),