Enforce lower-case subdomains

This commit is contained in:
Alexis Sellier
2021-07-28 10:21:20 +02:00
parent bf363d7c05
commit 59fe1187eb
2 changed files with 8 additions and 0 deletions
+3
View File
@@ -23,6 +23,9 @@
export let subdomain: string;
export let owner: string | null;
// We only support lower-case names.
subdomain = subdomain.toLowerCase();
let fee: string;
let state = State.CheckingAvailability;
let error: string | null = null;
+5
View File
@@ -50,6 +50,8 @@ state.subscribe((s: Connection) => {
});
export async function getRegistration(name: string, config: Config): Promise<Registration | null> {
name = name.toLowerCase();
const resolver = await config.provider.getResolver(name);
if (! resolver) {
return null;
@@ -96,6 +98,8 @@ export async function registerName(name: string, owner: string, config: Config):
if (! name) return;
name = name.toLowerCase();
const commitmentJson = window.localStorage.getItem('commitment');
const commitment = commitmentJson && JSON.parse(commitmentJson);
@@ -120,6 +124,7 @@ async function commitAndRegister(name: string, owner: string, config: Config): P
if ((await config.token.balanceOf(owner)).lt(fee)) {
throw { type: Failure.InsufficientBalance, message: "Not enough RAD funds" };
}
name = name.toLowerCase();
await commit(makeCommitment(name, owner, salt), fee, minAge, config);
// Save commitment in local storage in case the user refreshes or closes