@glowlabs-org/utils 0.1.5 → 0.2.1
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/README.md +35 -4
- package/dist/cjs/browser.d.ts +4 -0
- package/dist/cjs/constants/addresses.d.ts +4 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +825 -271
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/abis/erc20.abi.d.ts +13 -0
- package/dist/cjs/lib/abis/forwarderABI.d.ts +99 -0
- package/dist/cjs/lib/hooks/use-forwarder.d.ts +36 -0
- package/dist/esm/browser.d.ts +4 -0
- package/dist/esm/constants/addresses.d.ts +4 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +825 -272
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/abis/erc20.abi.d.ts +13 -0
- package/dist/esm/lib/abis/forwarderABI.d.ts +99 -0
- package/dist/esm/lib/hooks/use-forwarder.d.ts +36 -0
- package/package.json +1 -1
- package/src/browser.ts +4 -0
- package/src/constants/addresses.ts +40 -0
- package/src/index.ts +2 -0
- package/src/lib/abis/erc20.abi.ts +49 -0
- package/src/lib/abis/forwarderABI.ts +69 -0
- package/src/lib/hooks/use-forwarder.ts +564 -0
package/README.md
CHANGED
@@ -8,10 +8,10 @@ This repository contains utils for interacting with Glow labs data sources
|
|
8
8
|
|
9
9
|
## Requirements
|
10
10
|
|
11
|
-
-
|
11
|
+
- Node >= 16 (tested up to 20)
|
12
|
+
- Ethers v5 (peer-dependency)
|
12
13
|
- MerkletreeJS
|
13
14
|
- Viem
|
14
|
-
- Node version >= 16
|
15
15
|
|
16
16
|
## Example Usage
|
17
17
|
|
@@ -31,11 +31,42 @@ const main = async () => {
|
|
31
31
|
//Save to 37.json
|
32
32
|
fs.writeFileSync("37.json", JSON.stringify(report, null, 4));
|
33
33
|
};
|
34
|
-
|
34
|
+
```
|
35
|
+
|
36
|
+
---
|
37
|
+
|
38
|
+
### Forwarder SDK (framework-agnostic)
|
39
|
+
|
40
|
+
Below is a minimal example showing how to forward USDC using a standard `ethers` signer. The same call works in Node or in a browser (e.g. MetaMask’s `window.ethereum`).
|
41
|
+
|
42
|
+
```typescript
|
43
|
+
import { useForwarder } from "@glowlabs-org/utils";
|
44
|
+
import { Wallet, providers, utils } from "ethers";
|
35
45
|
|
36
|
-
|
46
|
+
// Use Infura, Alchemy or any JSON-RPC endpoint
|
47
|
+
const provider = new providers.JsonRpcProvider(
|
48
|
+
"https://sepolia.infura.io/v3/<API_KEY>"
|
49
|
+
);
|
50
|
+
|
51
|
+
// A local private key, or rely on a browser wallet by passing `provider.getSigner()`
|
52
|
+
const signer = new Wallet(process.env.PRIVATE_KEY!, provider);
|
53
|
+
|
54
|
+
// Chain id 11155111 = Sepolia
|
55
|
+
const forwarder = useForwarder(signer, 11155111);
|
56
|
+
|
57
|
+
await forwarder.forwardTokens({
|
58
|
+
amount: utils.parseUnits("10", 6), // 10 USDC (6 dp)
|
59
|
+
userAddress: await signer.getAddress(),
|
60
|
+
type: "PayProtocolFee",
|
61
|
+
applicationId: "123",
|
62
|
+
currency: "USDC",
|
63
|
+
});
|
64
|
+
|
65
|
+
console.log("Tx hash:", forwarder.isProcessing ? "pending…" : "sent");
|
37
66
|
```
|
38
67
|
|
68
|
+
See `src/lib/hooks/use-forwarder.ts` for all available helpers (`approveToken`, `checkTokenBalance`, `estimateGasForForward`, etc.).
|
69
|
+
|
39
70
|
## Contributions
|
40
71
|
|
41
72
|
For contributions, feel free to open a PR or raise an issue.
|
package/dist/cjs/index.d.ts
CHANGED