@glowlabs-org/utils 0.1.5 → 0.2.0

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.
@@ -0,0 +1,13 @@
1
+ export declare const ERC20_ABI: {
2
+ inputs: {
3
+ name: string;
4
+ type: string;
5
+ }[];
6
+ name: string;
7
+ outputs: {
8
+ name: string;
9
+ type: string;
10
+ }[];
11
+ stateMutability: string;
12
+ type: string;
13
+ }[];
@@ -0,0 +1,99 @@
1
+ export declare const FORWARDER_ABI: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly internalType: "address";
4
+ readonly name: "_forwarder";
5
+ readonly type: "address";
6
+ }];
7
+ readonly stateMutability: "nonpayable";
8
+ readonly type: "constructor";
9
+ }, {
10
+ readonly inputs: readonly [{
11
+ readonly internalType: "address";
12
+ readonly name: "target";
13
+ readonly type: "address";
14
+ }];
15
+ readonly name: "AddressEmptyCode";
16
+ readonly type: "error";
17
+ }, {
18
+ readonly inputs: readonly [{
19
+ readonly internalType: "address";
20
+ readonly name: "account";
21
+ readonly type: "address";
22
+ }];
23
+ readonly name: "AddressInsufficientBalance";
24
+ readonly type: "error";
25
+ }, {
26
+ readonly inputs: readonly [];
27
+ readonly name: "FailedInnerCall";
28
+ readonly type: "error";
29
+ }, {
30
+ readonly inputs: readonly [{
31
+ readonly internalType: "address";
32
+ readonly name: "token";
33
+ readonly type: "address";
34
+ }];
35
+ readonly name: "SafeERC20FailedOperation";
36
+ readonly type: "error";
37
+ }, {
38
+ readonly anonymous: false;
39
+ readonly inputs: readonly [{
40
+ readonly indexed: true;
41
+ readonly internalType: "address";
42
+ readonly name: "from";
43
+ readonly type: "address";
44
+ }, {
45
+ readonly indexed: true;
46
+ readonly internalType: "address";
47
+ readonly name: "to";
48
+ readonly type: "address";
49
+ }, {
50
+ readonly indexed: true;
51
+ readonly internalType: "address";
52
+ readonly name: "token";
53
+ readonly type: "address";
54
+ }, {
55
+ readonly indexed: false;
56
+ readonly internalType: "uint256";
57
+ readonly name: "amount";
58
+ readonly type: "uint256";
59
+ }, {
60
+ readonly indexed: false;
61
+ readonly internalType: "string";
62
+ readonly name: "message";
63
+ readonly type: "string";
64
+ }];
65
+ readonly name: "Forward";
66
+ readonly type: "event";
67
+ }, {
68
+ readonly inputs: readonly [];
69
+ readonly name: "FORWARD_ADDRESS";
70
+ readonly outputs: readonly [{
71
+ readonly internalType: "address";
72
+ readonly name: "";
73
+ readonly type: "address";
74
+ }];
75
+ readonly stateMutability: "view";
76
+ readonly type: "function";
77
+ }, {
78
+ readonly inputs: readonly [{
79
+ readonly internalType: "address";
80
+ readonly name: "token";
81
+ readonly type: "address";
82
+ }, {
83
+ readonly internalType: "address";
84
+ readonly name: "to";
85
+ readonly type: "address";
86
+ }, {
87
+ readonly internalType: "uint256";
88
+ readonly name: "amount";
89
+ readonly type: "uint256";
90
+ }, {
91
+ readonly internalType: "string";
92
+ readonly name: "message";
93
+ readonly type: "string";
94
+ }];
95
+ readonly name: "forward";
96
+ readonly outputs: readonly [];
97
+ readonly stateMutability: "nonpayable";
98
+ readonly type: "function";
99
+ }];
@@ -0,0 +1,36 @@
1
+ import { BigNumber, ethers } from "ethers";
2
+ export declare enum ForwarderError {
3
+ CONTRACT_NOT_AVAILABLE = "Contract not available",
4
+ SIGNER_NOT_AVAILABLE = "Signer not available",
5
+ UNKNOWN_ERROR = "Unknown error",
6
+ INVALID_FORWARD_TYPE = "Invalid forward type",
7
+ MISSING_REQUIRED_PARAMS = "Missing required parameters"
8
+ }
9
+ export type ForwardType = "PayProtocolFeeAndMintGCTLAndStake" | "PayProtocolFee" | "MintGCTLAndStake" | "MintGCTL" | "BuySolarFarm";
10
+ export type Currency = "USDC" | "GLW" | "USDG";
11
+ export interface ForwardParams {
12
+ amount: BigNumber;
13
+ userAddress: string;
14
+ type: ForwardType;
15
+ currency?: Currency;
16
+ applicationId?: string;
17
+ farmId?: string;
18
+ regionId?: number;
19
+ }
20
+ export declare function useForwarder(signer: ethers.providers.JsonRpcSigner | undefined, CHAIN_ID: number): {
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) => Promise<string>;
25
+ mintGCTL: (amount: BigNumber, userAddress: string) => Promise<string>;
26
+ buySolarFarm: (amount: BigNumber, userAddress: string, farmId: string, currency?: Currency) => Promise<string>;
27
+ approveToken: (amount: BigNumber, currency?: Currency) => Promise<boolean>;
28
+ checkTokenAllowance: (owner: string, currency?: Currency) => Promise<BigNumber>;
29
+ checkTokenBalance: (owner: string, currency?: Currency) => Promise<BigNumber>;
30
+ estimateGasForForward: (params: ForwardParams, ethPriceInUSD: number | null) => Promise<string>;
31
+ mintTestUSDC: (amount: BigNumber, recipient: string) => Promise<string>;
32
+ constructForwardMessage: (params: ForwardParams) => string;
33
+ readonly isProcessing: boolean;
34
+ addresses: Record<"USDC" | "GLW" | "USDG" | "FORWARDER" | "FOUNDATION_WALLET", `0x${string}`>;
35
+ isSignerAvailable: boolean;
36
+ };
@@ -0,0 +1,3 @@
1
+ type ContractKeys = "USDC" | "FORWARDER" | "FOUNDATION_WALLET" | "GLW" | "USDG";
2
+ export declare const getAddresses: (CHAIN_ID: number) => Record<ContractKeys, `0x${string}`>;
3
+ export {};
@@ -1,3 +1,4 @@
1
1
  export * from "./lib/create-weekly-report/types/index";
2
2
  export * from "./constants/index";
3
3
  export { createWeeklyReport, createWeeklyReportLegacy, } from "./lib/create-weekly-report/index";
4
+ export { useForwarder } from "./lib/hooks/use-forwarder";