Fix explorerAddressURL when no signer (#1962)

### Description

Currently, if the MP doesn't have a signer, the function will always
return null
pull/1963/head
Nam Chu Hoai 2 years ago committed by GitHub
parent 4cda702a30
commit 8f791a5eb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      typescript/sdk/src/providers/MultiProvider.ts

@ -497,12 +497,16 @@ export class MultiProvider {
*/
async tryGetExplorerAddressUrl(
chainNameOrId: ChainName | number,
_address?: string,
address?: string,
): Promise<string | null> {
const baseUrl = this.tryGetExplorerUrl(chainNameOrId);
if (!baseUrl) return null;
if (!address) {
const signer = this.tryGetSigner(chainNameOrId);
if (!baseUrl || !signer) return null;
const address = _address ?? (await signer.getAddress());
if (!signer) return null;
return `${baseUrl}/${await signer.getAddress()}`;
}
return `${baseUrl}/${address}`;
}

Loading…
Cancel
Save