Skip to content

Commit

Permalink
Fix wrong logic on switch/add network
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Sep 6, 2024
1 parent 4f5604a commit c3004f1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/evm/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export abstract class EVMAccount extends ECIESAccount {
public async changeNetwork(chainOrRpc: RpcType | RpcId = RpcId.ETH): Promise<void> {
if (this.wallet instanceof JsonRPCWallet) {
await this.wallet.changeNetwork(chainOrRpc)
}
if (this.wallet instanceof ethers.Wallet) {
//await this.wallet.provider.send("wallet_switchEthereumChain", [{ chainId: chainId.toString(16) }]);
} else if (this.wallet instanceof ethers.Wallet) {
throw new Error('Not implemented for ethers.Wallet')
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/evm/src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ export class JsonRPCWallet extends BaseProviderWallet {
try {
await this.provider.send('wallet_switchEthereumChain', [{ chainId: chainData.chainId }])
} catch (error) {
await this.addNetwork(chainData)
if ((error as { code: number }).code === 4001) console.log('User rejected the switch chain request')
else await this.addNetwork(chainData)
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/superfluid/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Blockchain } from '@aleph-sdk/core'
* It is used to represent a Superfluid account when publishing a message on the Aleph network.
*/


export class SuperfluidAccount extends EVMAccount {
public override wallet: JsonRPCWallet
private account: EVMAccount
Expand Down

0 comments on commit c3004f1

Please sign in to comment.