@latticexyz/faucet 2.0.12-account-kit-10002da0 → 2.0.12-account-kit-9160f5e1a
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/package.json +6 -4
- package/src/createAppRouter.ts +0 -42
- package/src/createClient.ts +0 -21
- package/src/debug.ts +0 -10
- package/src/index.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/faucet",
|
|
3
|
-
"version": "2.0.12-account-kit-
|
|
3
|
+
"version": "2.0.12-account-kit-9160f5e1a",
|
|
4
4
|
"description": "Faucet API for Lattice testnet",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/src/index.js"
|
|
14
14
|
},
|
|
15
|
-
"types": "src/index.ts",
|
|
16
15
|
"bin": {
|
|
17
16
|
"faucet-server": "./dist/bin/faucet-server.js"
|
|
18
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"@fastify/compress": "^6.5.0",
|
|
21
23
|
"@fastify/cors": "^8.3.0",
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
"fastify": "^4.21.0",
|
|
27
29
|
"viem": "2.9.20",
|
|
28
30
|
"zod": "^3.22.2",
|
|
29
|
-
"@latticexyz/common": "2.0.12-account-kit-
|
|
31
|
+
"@latticexyz/common": "2.0.12-account-kit-9160f5e1a"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@types/debug": "^4.1.7",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"dev": "tsup --watch",
|
|
46
48
|
"lint": "eslint .",
|
|
47
49
|
"start": "tsx bin/faucet-server",
|
|
48
|
-
"test": "tsc --noEmit
|
|
50
|
+
"test": "tsc --noEmit",
|
|
49
51
|
"test:ci": "pnpm run test"
|
|
50
52
|
}
|
|
51
53
|
}
|
package/src/createAppRouter.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { initTRPC } from "@trpc/server";
|
|
3
|
-
import { Client, Hex, LocalAccount, formatEther, isHex } from "viem";
|
|
4
|
-
import { sendTransaction } from "@latticexyz/common";
|
|
5
|
-
import { debug } from "./debug";
|
|
6
|
-
|
|
7
|
-
export type AppContext = {
|
|
8
|
-
client: Client;
|
|
9
|
-
faucetAccount: LocalAccount<string>;
|
|
10
|
-
dripAmount: bigint;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
14
|
-
export function createAppRouter() {
|
|
15
|
-
const t = initTRPC.context<AppContext>().create();
|
|
16
|
-
|
|
17
|
-
return t.router({
|
|
18
|
-
drip: t.procedure
|
|
19
|
-
.input(
|
|
20
|
-
z.object({
|
|
21
|
-
address: z.string().refine(isHex),
|
|
22
|
-
}),
|
|
23
|
-
)
|
|
24
|
-
.mutation(async (opts): Promise<Hex> => {
|
|
25
|
-
const { client, faucetAccount, dripAmount } = opts.ctx;
|
|
26
|
-
|
|
27
|
-
const { address } = opts.input;
|
|
28
|
-
const tx = await sendTransaction(client, {
|
|
29
|
-
chain: null,
|
|
30
|
-
account: faucetAccount,
|
|
31
|
-
to: address,
|
|
32
|
-
value: dripAmount,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
debug(`Dripped ${formatEther(dripAmount)} ETH from ${faucetAccount.address} to ${address} (tx ${tx})`);
|
|
36
|
-
|
|
37
|
-
return tx;
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type AppRouter = ReturnType<typeof createAppRouter>;
|
package/src/createClient.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createTRPCProxyClient, httpBatchLink, CreateTRPCProxyClient } from "@trpc/client";
|
|
2
|
-
import type { AppRouter } from "./createAppRouter";
|
|
3
|
-
|
|
4
|
-
type CreateClientOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* tRPC endpoint URL like `https://faucet.dev.linfra.xyz/trpc`.
|
|
7
|
-
*/
|
|
8
|
-
url: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates a tRPC client to talk to a MUD faucet.
|
|
13
|
-
*
|
|
14
|
-
* @param {CreateClientOptions} options See `CreateClientOptions`.
|
|
15
|
-
* @returns {CreateTRPCProxyClient<AppRouter>} A typed tRPC client.
|
|
16
|
-
*/
|
|
17
|
-
export function createClient({ url }: CreateClientOptions): CreateTRPCProxyClient<AppRouter> {
|
|
18
|
-
return createTRPCProxyClient<AppRouter>({
|
|
19
|
-
links: [httpBatchLink({ url })],
|
|
20
|
-
});
|
|
21
|
-
}
|
package/src/debug.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import createDebug from "debug";
|
|
2
|
-
|
|
3
|
-
export const debug = createDebug("mud:faucet");
|
|
4
|
-
export const error = createDebug("mud:faucet");
|
|
5
|
-
|
|
6
|
-
// Pipe debug output to stdout instead of stderr
|
|
7
|
-
debug.log = console.debug.bind(console);
|
|
8
|
-
|
|
9
|
-
// Pipe error output to stderr
|
|
10
|
-
error.log = console.error.bind(console);
|
package/src/index.ts
DELETED