Skip to content

Commit c02c590

Browse files
committed
WIP Debug migration to Datil
1 parent 71b41fd commit c02c590

File tree

4 files changed

+420
-822
lines changed

4 files changed

+420
-822
lines changed

pkp-update-authmethod/nodejs/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
},
2020
"dependencies": {
2121
"@dotenvx/dotenvx": "^1.0.0",
22-
"@lit-protocol/auth-helpers": "^6.0.3",
23-
"@lit-protocol/constants": "^6.0.3",
24-
"@lit-protocol/contracts-sdk": "^6.0.3",
25-
"@lit-protocol/lit-auth-client": "^6.0.3",
26-
"@lit-protocol/lit-node-client": "^6.0.3",
27-
"@lit-protocol/pkp-ethers": "^6.0.3",
22+
"@lit-protocol/auth-helpers": "^6.1.0",
23+
"@lit-protocol/constants": "^6.1.0",
24+
"@lit-protocol/contracts-sdk": "^6.1.0",
25+
"@lit-protocol/lit-auth-client": "^6.1.0",
26+
"@lit-protocol/lit-node-client": "^6.1.0",
27+
"@lit-protocol/pkp-ethers": "^6.1.0",
2828
"bs58": "^6.0.0",
2929
"ethers": "v5"
3030
}

pkp-update-authmethod/nodejs/src/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ const LIT_ACTION_B_IPFS_CID_BYTES = `0x${Buffer.from(
2525
bs58.decode(LIT_ACTION_CHECK_ADDRESS_B)
2626
).toString("hex")}`;
2727

28-
export const doTheThing = async () => {
28+
export const runTheExample = async () => {
2929
let litNodeClient: LitNodeClient;
3030

3131
try {
3232
const ethersSignerA = new ethers.Wallet(
3333
ETHEREUM_PRIVATE_KEY_A,
3434
new ethers.providers.JsonRpcProvider(
35-
"https://chain-rpc.litprotocol.com/http"
35+
"https://vesuvius-rpc.litprotocol.com/"
3636
)
3737
);
3838
const ethersSignerB = new ethers.Wallet(
3939
ETHEREUM_PRIVATE_KEY_B,
4040
new ethers.providers.JsonRpcProvider(
41-
"https://chain-rpc.litprotocol.com/http"
41+
"https://vesuvius-rpc.litprotocol.com/"
4242
)
4343
);
4444

4545
console.log("🔄 Connecting LitContracts client to network...");
4646
const litContracts = new LitContracts({
4747
signer: ethersSignerA,
48-
network: LitNetwork.Cayenne,
48+
network: LitNetwork.DatilDev,
4949
debug: false,
5050
});
5151
await litContracts.connect();
@@ -94,8 +94,9 @@ export const doTheThing = async () => {
9494

9595
console.log("🔄 Connecting LitNodeClient to Lit network...");
9696
litNodeClient = new LitNodeClient({
97-
litNetwork: LitNetwork.Cayenne,
97+
litNetwork: LitNetwork.DatilDev,
9898
debug: false,
99+
rpcUrl: "https://vesuvius-rpc.litprotocol.com/",
99100
});
100101
await litNodeClient.connect();
101102
console.log("✅ Connected LitNodeClient to Lit network");
@@ -142,13 +143,22 @@ export const doTheThing = async () => {
142143
const fundPkpTxReceipt = await (
143144
await ethersSignerA.sendTransaction({
144145
to: mintedPkp.ethAddress,
145-
value: ethers.utils.parseEther("0.0001"),
146+
value: ethers.utils.parseEther("0.001"),
146147
})
147148
).wait();
148149
console.log(
149150
`✅ Funded PKP ETH Address. Transaction hash: ${fundPkpTxReceipt.transactionHash}`
150151
);
151152

153+
console.log(
154+
`🔄 Checking Lit token balance for PKP ${mintedPkp.ethAddress}...`
155+
);
156+
const balance = await ethersSignerA.provider.getBalance(
157+
mintedPkp.ethAddress,
158+
"latest"
159+
);
160+
console.log(`✅ Got balance: ${ethers.utils.formatEther(balance)} ether`);
161+
152162
const pkpEthersWalletA = new PKPEthersWallet({
153163
litNodeClient,
154164
pkpPubKey: mintedPkp.publicKey,
@@ -161,7 +171,7 @@ export const doTheThing = async () => {
161171
);
162172
const litContractsPkpSignerA = new LitContracts({
163173
signer: pkpEthersWalletA,
164-
network: LitNetwork.Cayenne,
174+
network: LitNetwork.DatilDev,
165175
debug: false,
166176
});
167177
await litContractsPkpSignerA.connect();
@@ -176,7 +186,7 @@ export const doTheThing = async () => {
176186
LIT_ACTION_B_IPFS_CID_BYTES,
177187
[AuthMethodScope.SignAnything],
178188
{
179-
gasPrice: await ethersSignerA.provider.getGasPrice(),
189+
gasPrice: "1",
180190
gasLimit: 250_000,
181191
}
182192
)
@@ -243,7 +253,7 @@ export const doTheThing = async () => {
243253
);
244254
const litContractsPkpSignerB = new LitContracts({
245255
signer: pkpEthersWalletB,
246-
network: LitNetwork.Cayenne,
256+
network: LitNetwork.DatilDev,
247257
debug: false,
248258
});
249259
await litContractsPkpSignerB.connect();
Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
import { expect } from "chai";
2-
import * as ethers from "ethers";
3-
import { LitContracts } from "@lit-protocol/contracts-sdk";
4-
import { LitNetwork } from "@lit-protocol/constants";
52

6-
import { getEnv } from "../src/utils";
7-
import { doTheThing } from "../src";
8-
9-
const ETHEREUM_PRIVATE_KEY_A = getEnv("ETHEREUM_PRIVATE_KEY_A");
3+
import { runTheExample } from "../src";
104

115
describe("Run the example", () => {
12-
let litContracts: LitContracts;
13-
14-
before(async function () {
15-
const ethersSigner = new ethers.Wallet(
16-
ETHEREUM_PRIVATE_KEY_A,
17-
new ethers.providers.JsonRpcProvider(
18-
"https://chain-rpc.litprotocol.com/http"
19-
)
20-
);
21-
22-
litContracts = new LitContracts({
23-
signer: ethersSigner,
24-
network: LitNetwork.Cayenne,
25-
debug: false,
26-
});
27-
await litContracts.connect();
28-
});
29-
306
it("should return true if the example ran without error", async () => {
31-
const didTheThing = await doTheThing();
32-
expect(didTheThing).to.be.true;
7+
const success = await runTheExample();
8+
expect(success).to.be.true;
339
}).timeout(60_000);
3410
});

0 commit comments

Comments
 (0)