mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 11:50:42 +08:00
Use HEAD when checking for Safe
This commit is contained in:
+10
-1
@@ -151,7 +151,7 @@ export function formatProjectHash(multihash: Uint8Array): string {
|
||||
|
||||
// Identify an address by checking whether it's a contract or an externally-owned address.
|
||||
export async function identifyAddress(address: string, config: Config): Promise<AddressType> {
|
||||
const safe = await getSafe(address, config);
|
||||
const safe = await isSafe(address, config);
|
||||
if (safe) {
|
||||
return AddressType.Safe;
|
||||
}
|
||||
@@ -173,6 +173,15 @@ export async function resolveLabel(label: string, config: Config): Promise<strin
|
||||
return config.provider.resolveName(`${label}.${config.registrar.domain}`);
|
||||
}
|
||||
|
||||
// Check whether a Gnosis Safe exists at an address.
|
||||
export async function isSafe(address: string, config: Config): Promise<boolean> {
|
||||
if (! config.safe.api) return false;
|
||||
|
||||
const response = await fetch(`${config.safe.api}/safes/${address}`, { method: 'HEAD' });
|
||||
|
||||
return response.ok;
|
||||
}
|
||||
|
||||
// Get a Gnosis Safe at an address.
|
||||
export async function getSafe(address: string, config: Config): Promise<Safe | null> {
|
||||
if (! config.safe.api) return null;
|
||||
|
||||
Reference in New Issue
Block a user