Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-10-27 - Svelte Keyed Loops
**Learning:** Svelte `{#each}` loops iterating over dynamic keys (e.g. `Object.keys`) without a keyed identifier can lead to inefficient DOM updates and state corruption in child components.
**Action:** Always verify `{#each}` loops use a unique key, especially when rendering stateful components or when the list order/content changes frequently.
8 changes: 6 additions & 2 deletions src/components/DomainPayment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@
<h4>{domainName}</h4>

<div class="years">
<IconButton on:click={() => addYears(-1)} disabled={years === 1 || feesApproved} aria-label="remove-year">
<IconButton
on:click={() => addYears(-1)}
disabled={years === 1 || feesApproved}
aria-label="remove-year"
>
<Icon icon="remove" />
</IconButton>
<span>{years} {yearsLabel}</span>
Expand All @@ -111,7 +115,7 @@
</IconButton>
</div>

<div class="coin">
<div class="coin">
<p class="title text-center">Payment token</p>
<div class="row centered">
<Select bind:value={$selectedCoin} label="Select Token" variant="outlined">
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoadingButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{:else if hasError}
<Icon icon="error" align="right" />
{:else if loading === false}
<Icon icon="done" align="right"/>
<Icon icon="done" align="right" />
{/if}
</Button>

Expand Down
14 changes: 11 additions & 3 deletions src/components/Record.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$: errors = invalid ? validator.getErrors() : [];
$: disabled = !edit;
$: validator = getValidator(klass);
$: maxLength = 'maxLength' in validator.rules ? validator.rules['maxLength'] as number : 64
$: maxLength = 'maxLength' in validator.rules ? (validator.rules['maxLength'] as number) : 64;

let edit = false;

Expand Down Expand Up @@ -99,10 +99,18 @@
</div>
{:else if editMode}
<div class="actions">
<IconButton on:click={() => toggleEdit()} disabled={!$walletConnected} aria-label="edit-record">
<IconButton
on:click={() => toggleEdit()}
disabled={!$walletConnected}
aria-label="edit-record"
>
<Icon icon="edit" />
</IconButton>
<IconButton on:click={() => (dialogOpen = true)} disabled={!$walletConnected} aria-label="delete-record">
<IconButton
on:click={() => (dialogOpen = true)}
disabled={!$walletConnected}
aria-label="delete-record"
>
<Icon icon="delete" />
</IconButton>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Records.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
{#if !records || Object.keys(records).length === 0}
<p class="no-records">No records found</p>
{:else}
{#each Object.keys(records) as key}
<!-- Keyed loop for efficient updates and state preservation -->
{#each Object.keys(records) as key (key)}
<div class="mt-1">
<RecordComponent {repository} klass={key} value={records[key]} editMode={true} />
</div>
Expand All @@ -77,7 +78,7 @@
invalid={selectRecordInvalid}
variant="outlined"
>
{#each unusedRecordsClasses as klass}
{#each unusedRecordsClasses as klass (klass)}
<Option value={klass}>{klass}</Option>
{/each}
</Select>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const profileRecords = [
RecordClassEnum.Price
].map((v) => RecordClassEnum[v]);

export const getValidator = (klass: string) => getRecordValidator(getRecordClassFrom(klass))
export const getValidator = (klass: string) => getRecordValidator(getRecordClassFrom(klass));
1 change: 0 additions & 1 deletion src/lib/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ export const getStats = async (): Promise<DomainStats> => {
};
};


export const apiError = (message: string, status = 400) => json({ error: message }, { status });
8 changes: 4 additions & 4 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface DomainPaymentParams {
}

export interface DomainFeesResponse {
feesLabel: number
fees: string
symbol: string
address: string
feesLabel: number;
fees: string;
symbol: string;
address: string;
}
9 changes: 4 additions & 5 deletions src/lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ export const explorerAddressUrl = (address: string) => {
if (address.startsWith('00'))
// Account
url += `/accounts/${address}/assets`;
else
// Contract
url += `/contracts/${address}`;
// Contract
else url += `/contracts/${address}`;

return url
}
return url;
};

export const bridgeUrl = `${config.browserUrl}/bridge`;

Expand Down
1 change: 0 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,4 @@
align-items: center;
height: 100%;
}

</style>
19 changes: 11 additions & 8 deletions src/routes/api/register/[name]/fees/[coin]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { json } from '@sveltejs/kit';
import type { DomainFeesResponse } from 'src/lib/types';

export async function GET({ params: { name, coin } }) {
return handleError(async () => {
const validCoins = metaNamesSdk.config.byoc.map(byoc => byoc.symbol.toString())
if (!(validCoins.includes(coin))) return apiError('Invalid coin');
return handleError(async () => {
const validCoins = metaNamesSdk.config.byoc.map((byoc) => byoc.symbol.toString());
if (!validCoins.includes(coin)) return apiError('Invalid coin');

const normalizedDomain = metaNamesSdk.domainRepository.domainValidator.normalize(name)
const domainFees = await metaNamesSdk.domainRepository.calculateMintFees(normalizedDomain, coin as BYOCSymbol);
const fees = { ...domainFees, fees: domainFees.fees.toString() }
const normalizedDomain = metaNamesSdk.domainRepository.domainValidator.normalize(name);
const domainFees = await metaNamesSdk.domainRepository.calculateMintFees(
normalizedDomain,
coin as BYOCSymbol
);
const fees = { ...domainFees, fees: domainFees.fees.toString() };

return json(fees);
});
return json(fees);
});
}
1 change: 0 additions & 1 deletion src/routes/profile/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
</div>

<style lang="scss">

.domains {
margin-top: 1.5rem;
margin-bottom: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/mixins.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "sass:string";
@use 'sass:string';

$amounts: (0, 1, 2, 3, 4);
$types: (top, bottom, left, right);
Expand Down
2 changes: 1 addition & 1 deletion src/theme/dark/_smui-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $text-color: #d5ccff;
@use '@material/theme/color-palette';
@use '@material/theme/index' as theme with (
$primary: #6849fe,
$secondary: #D0C7FF,
$secondary: #d0c7ff,
$surface: color.adjust(color-palette.$grey-900, $blue: +4),
$background: #363535,
$error: color-palette.$red-700
Expand Down