Skip to content

Commit

Permalink
fix decnx not reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
zapaz committed May 15, 2024
1 parent 461f340 commit e6640b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions svelte/src/helpers/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ const _handleChainId = (_chainId: string): void => {
};

const _handleAccounts = (accounts: Array<string>): void => {
if (accounts?.length === 0) return;
// console.log("_handleAccounts:", accounts);

metamaskSigner.set(get(metamaskProvider).getSigner(0));
metamaskSignerAddress.set(getChecksumAddress(accounts[0]));
if (accounts.length >= 1) {
metamaskSigner.set(get(metamaskProvider).getSigner(0));
metamaskSignerAddress.set(getChecksumAddress(accounts[0]));
} else {
metamaskSigner.set(undefined);
metamaskSignerAddress.set(undefined);
}
};

const metamaskConnect = async (): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions svelte/src/stores/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { JsonRpcProvider, JsonRpcSigner } from "@ethersproject/providers";

// Metamask chainId and account
const metamaskChainId: Writable<number> = writable();
const metamaskSignerAddress: Writable<string> = writable();
const metamaskProvider: Writable<JsonRpcProvider> = writable();
const metamaskSigner: Writable<JsonRpcSigner> = writable();
const metamaskSignerAddress: Writable<string|undefined> = writable();
const metamaskSigner: Writable<JsonRpcSigner|undefined> = writable();

export { metamaskChainId, metamaskSignerAddress, metamaskProvider, metamaskSigner };

0 comments on commit e6640b4

Please sign in to comment.