Skip to content

Commit b1b9e3e

Browse files
committed
Implement eth_requestAccounts
1 parent 1452dc0 commit b1b9e3e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import * as fcl from "@onflow/fcl"
22

33
export class AccountManager {
4+
private accounts: string[] = [];
5+
46
constructor(private user: typeof fcl.currentUser) {}
57

68
getAccounts(): string[] {
7-
// ... get coa address
8-
return []
9+
return this.accounts;
10+
}
11+
12+
setAccounts(accounts: string[]): void {
13+
this.accounts = accounts;
914
}
1015

1116
subscribe(callback: (accounts: string[]) => void) {
12-
// ...
17+
this.user.subscribe(async () => {
18+
const snapshot = await fcl.currentUser().snapshot();
19+
20+
const updatedAccounts = snapshot.addr ? [snapshot.addr] : [];
21+
this.setAccounts(updatedAccounts);
22+
23+
callback(this.getAccounts());
24+
});
1325
}
14-
}
26+
}

0 commit comments

Comments
 (0)