We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1452dc0 commit b1b9e3eCopy full SHA for b1b9e3e
packages/fcl-ethereum-provider/src/accounts/account-manager.ts
@@ -1,14 +1,26 @@
1
import * as fcl from "@onflow/fcl"
2
3
export class AccountManager {
4
+ private accounts: string[] = [];
5
+
6
constructor(private user: typeof fcl.currentUser) {}
7
8
getAccounts(): string[] {
- // ... get coa address
- return []
9
+ return this.accounts;
10
+ }
11
12
+ setAccounts(accounts: string[]): void {
13
+ this.accounts = accounts;
14
}
15
16
subscribe(callback: (accounts: string[]) => void) {
- // ...
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
+ });
25
-}
26
+}
0 commit comments