Skip to content

Commit d4508c5

Browse files
committed
deploy on odyssey testnet
1 parent 7f40bce commit d4508c5

26 files changed

+2830
-548
lines changed

apps/interface/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<title>zkLogin on Base</title>
7+
<title>zkLogin with EIP-7702</title>
88
%sveltekit.head%
99
</head>
1010
<body data-sveltekit-preload-data="hover">

apps/interface/src/lib/SendEthCard.svelte

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,39 @@
11
<script lang="ts">
22
import { lib } from "$lib";
33
import { Ui } from "@repo/ui";
4-
import { createQuery } from "@tanstack/svelte-query";
54
import { ethers } from "ethers";
6-
import { assert } from "ts-essentials";
5+
import type { Address } from "viem";
76
import { z } from "zod";
87
import { zAddress } from "./utils";
98
109
let {
11-
jwt,
12-
signer,
13-
disabled,
10+
address,
1411
}: {
15-
jwt: string | undefined;
16-
signer: ethers.Wallet;
17-
disabled: boolean;
12+
address: Address;
1813
} = $props();
19-
20-
let balanceQuery = $derived(
21-
createQuery(
22-
{
23-
queryKey: ["balance", jwt && ethers.id(jwt)],
24-
queryFn: async () => {
25-
let raw: bigint;
26-
if (!jwt) {
27-
raw = 0n;
28-
} else {
29-
throw new Error("not implemented");
30-
// const account = await lib.jwtAccount.getAccount(jwt, signer);
31-
// raw = await signer.provider!.getBalance(account.address);
32-
}
33-
return `${ethers.formatEther(raw)} ETH`;
34-
},
35-
},
36-
lib.queries.queryClient,
37-
),
38-
);
3914
</script>
4015

4116
<Ui.Card.Root>
4217
<Ui.Card.Header>
4318
<Ui.Card.Title>Send ETH</Ui.Card.Title>
4419
</Ui.Card.Header>
4520
<Ui.Card.Content>
46-
<div>
47-
Balance: <Ui.Query query={$balanceQuery}>
48-
{#snippet success(data)}
49-
{data}
50-
{/snippet}
51-
</Ui.Query>
52-
</div>
53-
5421
<Ui.Form
5522
schema={z.object({
5623
recipient: zAddress(),
5724
amount: z.string(),
5825
})}
5926
onsubmit={async (data) => {
60-
assert(jwt, "no session");
61-
throw new Error("not implemented");
62-
// const bundlerClient = getBundlerClient(
63-
// await ethersSignerToWalletClient(signer),
64-
// );
65-
// const account = await lib.jwtAccount.getAccount(jwt, signer);
66-
// const tx = await bundlerClient.sendUserOperation({
67-
// account,
68-
// calls: [
69-
// {
70-
// to: data.recipient as Address,
71-
// value: ethers.parseEther(data.amount),
72-
// },
73-
// ],
74-
// });
75-
// console.log("tx", tx);
76-
// Ui.toast.success("Transaction sent successfully");
27+
const cred = await lib.webAuthn.getCredential();
28+
const tx = await lib.eip7702.executeTx({
29+
credentialId: cred.id,
30+
address,
31+
to: data.recipient,
32+
value: ethers.parseEther(data.amount),
33+
});
34+
console.log("tx", tx);
35+
lib.queries.invalidateAll();
36+
Ui.toast.success("Transaction sent successfully");
7737
}}
7838
>
7939
{#snippet children(form, formData)}
@@ -95,9 +55,7 @@
9555
<Ui.Form.FieldErrors />
9656
</Ui.Form.Field>
9757

98-
<Ui.Form.SubmitButton variant="default">
99-
{disabled ? "Create a session first" : "Send"}
100-
</Ui.Form.SubmitButton>
58+
<Ui.Form.SubmitButton variant="default">Send</Ui.Form.SubmitButton>
10159
{/snippet}
10260
</Ui.Form>
10361
</Ui.Card.Content>

apps/interface/src/lib/chain.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import deployments from "@repo/contracts/deployments.json";
22
import { PublicKeyRegistry__factory } from "@repo/contracts/typechain-types";
33
import { ethers } from "ethers";
4-
import { anvil } from "viem/chains";
4+
import { odysseyTestnet } from "viem/chains";
55

6-
export const chain = anvil;
7-
const RPC_URL = "http://localhost:8545";
8-
// "https://lb.drpc.org/ogrpc?network=base-sepolia&dkey=AhzA6k_e8kYDnLbUfrHiY5FOMOv-nO0R76TfFhW5UfFk";
6+
export const chain = odysseyTestnet;
7+
// const RPC_URL = "http://localhost:8545";
8+
const RPC_URL = "https://odyssey.ithaca.xyz";
99

1010
export const provider = {
1111
chainId: chain.id,
@@ -18,6 +18,6 @@ export const publicKeyRegistry = PublicKeyRegistry__factory.connect(
1818
);
1919

2020
export const relayer = new ethers.Wallet(
21-
"0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
21+
"0x4e560d1db4456119f9256bb65b4321ad54b860882c46b5ecb6ba92ca4d725dad",
2222
provider.provider,
2323
);

apps/interface/src/lib/services/Eip7702Service.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ export class Eip7702Service {
128128
async executeTx({
129129
credentialId,
130130
address,
131+
to,
132+
value,
131133
}: {
134+
to: string;
135+
value: bigint;
132136
credentialId: string;
133137
address: string;
134138
}) {
135139
const accContract = this.#toAccountContract(address);
136140
const nonce = await accContract.nonce();
137-
const to = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
138-
const value = ethers.parseEther("1");
139141
const data = "0x";
140142
const digest = ethers.AbiCoder.defaultAbiCoder().encode(
141143
["uint256", "address", "bytes", "uint256"],
@@ -193,6 +195,24 @@ export class Eip7702Service {
193195
return false;
194196
}
195197

198+
async isWebAuthnPublicKeyCorrect({
199+
address,
200+
201+
webAuthnPublicKey,
202+
}: {
203+
address: string;
204+
webAuthnPublicKey: Hex;
205+
}) {
206+
const accContract = this.#toAccountContract(address);
207+
const publicKeyOnChain = await accContract.webauthnPublicKey();
208+
return (
209+
ethers.concat([
210+
ethers.zeroPadValue(ethers.toBeArray(publicKeyOnChain.x), 32),
211+
ethers.zeroPadValue(ethers.toBeArray(publicKeyOnChain.y), 32),
212+
]) === webAuthnPublicKey
213+
);
214+
}
215+
196216
#toNonce(webAuthnPublicKey: Hex) {
197217
const parsed = parsePublicKey(webAuthnPublicKey);
198218
const hex = ethers.dataSlice(

apps/interface/src/lib/services/WebAuthnService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export class WebAuthnService {
1010
undefined,
1111
);
1212

13-
async useOrCreateCredential({ name }: { name: string }) {
13+
async getOrCreateCredential({ name }: { name: string }) {
1414
if (!this.#cred.value) {
1515
this.#cred.value = await this.#createCredential({ name });
1616
}
1717
return this.#cred.value;
1818
}
1919

20-
async useCredential() {
20+
async getCredential() {
2121
return this.#cred.value!;
2222
}
2323

0 commit comments

Comments
 (0)