Skip to content

Commit

Permalink
feat: get evm address from a wallet connect connector instance
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Jul 18, 2024
1 parent 266b450 commit 644fe99
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/eight-bears-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-connectors/walletconnect-connector": patch
---

Wallet Connect Connector will inherently return a predicate address, instead of the actual account, due to the bridge it does between networks.
Added a method to get the actual account address that has originated the predicate, so we can validate if a predicate original from a specific evm address
5 changes: 5 additions & 0 deletions .changeset/fuel-labs-ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuels/connectors": patch
---

incremental
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export class WalletConnectConnector extends FuelConnector {
});
}

async currentEvmAccount(): Promise<string | null> {
if (!(await this.isConnected())) {
throw Error('No connected accounts');
}
const ethAccount = getAccount(this.wagmiConfig).address || null;

return ethAccount;
}

async setupPredicate(): Promise<PredicateAccount> {
if (this.customPredicate?.abi && this.customPredicate?.bytecode) {
this.predicateAccount = new PredicateAccount(this.customPredicate);
Expand Down

0 comments on commit 644fe99

Please sign in to comment.