-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.ts
23 lines (18 loc) · 902 Bytes
/
actions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { KwilConfig, KwilAction } from "../../kwil-subsquid-adapter/dist";
import { Wallet } from "ethers";
import { Utils, KwilSigner } from "@kwilteam/kwil-js";
import dotenv from "dotenv";
dotenv.config();
// create the kwil config. Default for local development is http://localhost:8080
const kwilConfig: KwilConfig = {
kwilProvider: "http://localhost:8080",
chainId: process.env.CHAIN_ID as string
};
// create the wallet for signing txs
const wallet = new Wallet(process.env.PRIVATE_KEY as string);
// create the kwilSigner
const kwilSigner = new KwilSigner(wallet, wallet.address)
// create the dbid. Because we need to call the async publicKey function, we need to wrap it in a function and call it later
const dbid = Utils.generateDBID(kwilSigner.identifier, "test_subsquid");
// create an action
export const AddData = new KwilAction(kwilConfig, "add_records", dbid, kwilSigner);