Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Use HEAD when checking for Safe
Alexis Sellier committed 4 years ago
commit 52385e03b2c0f35749d33a889f8d81b478f3fa9f
parent 044ec510b8f908ec1f6743975bc530d318fa5d58
1 file changed +10 -1
modified src/utils.ts
@@ -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;