From 644fe991b9a679f80ad441e9df59cb5daa9c9243 Mon Sep 17 00:00:00 2001 From: Arthur Geron <3487334+arthurgeron@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:41:56 -0300 Subject: [PATCH] feat: get evm address from a wallet connect connector instance --- .changeset/eight-bears-prove.md | 6 ++++++ .changeset/fuel-labs-ci.md | 5 +++++ .../src/WalletConnectConnector.ts | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 .changeset/eight-bears-prove.md create mode 100644 .changeset/fuel-labs-ci.md diff --git a/.changeset/eight-bears-prove.md b/.changeset/eight-bears-prove.md new file mode 100644 index 00000000..e07b178a --- /dev/null +++ b/.changeset/eight-bears-prove.md @@ -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 diff --git a/.changeset/fuel-labs-ci.md b/.changeset/fuel-labs-ci.md new file mode 100644 index 00000000..fb7f0c95 --- /dev/null +++ b/.changeset/fuel-labs-ci.md @@ -0,0 +1,5 @@ +--- +"@fuels/connectors": patch +--- + +incremental diff --git a/packages/walletconnect-connector/src/WalletConnectConnector.ts b/packages/walletconnect-connector/src/WalletConnectConnector.ts index c001cea6..9132e456 100644 --- a/packages/walletconnect-connector/src/WalletConnectConnector.ts +++ b/packages/walletconnect-connector/src/WalletConnectConnector.ts @@ -88,6 +88,15 @@ export class WalletConnectConnector extends FuelConnector { }); } + async currentEvmAccount(): Promise { + if (!(await this.isConnected())) { + throw Error('No connected accounts'); + } + const ethAccount = getAccount(this.wagmiConfig).address || null; + + return ethAccount; + } + async setupPredicate(): Promise { if (this.customPredicate?.abi && this.customPredicate?.bytecode) { this.predicateAccount = new PredicateAccount(this.customPredicate);