Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ function main() {

const transport = viem.custom(provider);

if (baseProvider instanceof EthereumProvider) {
await baseProvider.connect();
}

const blockchain: TestChain = {
provider,
wallet: viem.createWalletClient({
Expand Down Expand Up @@ -196,6 +192,20 @@ function main() {
glue = new ManualGlue(glueElem, unboundWallet);
}

let requestAccountsPromise: unknown = null;
const unsubscribe = glue.on("requestaccounts", (event) => {
unsubscribe();
requestAccountsPromise = glue.requestAccounts({
action: "approve",
id: event.id,
accounts: [event.accounts[0]],
});
});

if (baseProvider instanceof EthereumProvider) {
await baseProvider.connect();
}

const wsUrl = new URL(`./${uuid}`, window.location.href);
wsUrl.protocol = wsUrl.protocol == "http:" ? "ws:" : "wss:";
wsUrl.hash = "";
Expand Down Expand Up @@ -299,16 +309,6 @@ function main() {
const open = spawn(async () => {
webSocket?.removeEventListener("open", open);

let requestAccountsPromise: unknown = null;
const unsubscribe = glue.on("requestaccounts", (event) => {
unsubscribe();
requestAccountsPromise = glue.requestAccounts({
action: "approve",
id: event.id,
accounts: [event.accounts[0]],
});
});

await glue.activateChain({
chainId: "0x" + chainId.toString(16),
rpcUrl: rpcUrl.href,
Expand Down
Loading