mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Improve address equality checking
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
|
||||
$: label = name && parseEnsLabel(name, config);
|
||||
$: isOwner = (org: Org): boolean => {
|
||||
return org.owner === ($session && $session.address);
|
||||
return $session ? utils.isAddressEqual(org.owner, $session.address) : false;
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import type { Field } from '@app/Form.svelte';
|
||||
import { assert } from '@app/error';
|
||||
import Error from '@app/Error.svelte';
|
||||
import { isAddressEqual } from '@app/utils';
|
||||
|
||||
import { getRegistration } from './registrar';
|
||||
import type { EnsRecord } from './resolver';
|
||||
@@ -78,7 +79,7 @@
|
||||
};
|
||||
|
||||
$: isOwner = (registration: Registration): boolean => {
|
||||
return registration.owner === ($session && $session.address);
|
||||
return $session ? isAddressEqual(registration.owner, $session.address) : false;
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
+5
-1
@@ -18,12 +18,16 @@ export interface Safe {
|
||||
threshold: number;
|
||||
}
|
||||
|
||||
export function isAddressEqual(left: string, right: string): boolean {
|
||||
return left.toLowerCase() === right.toLowerCase();
|
||||
}
|
||||
|
||||
export function formatBalance(n: BigNumber): string {
|
||||
return ethers.utils.commify(parseFloat(ethers.utils.formatUnits(n)).toFixed(2));
|
||||
}
|
||||
|
||||
export function formatAddress(addr: string): string {
|
||||
return formatHash(addr);
|
||||
return formatHash(ethers.utils.getAddress(addr));
|
||||
}
|
||||
|
||||
export function formatHash(hash: string): string {
|
||||
|
||||
Reference in New Issue
Block a user