Skip to content

Commit

Permalink
feat: identify when new name is the same as existing symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Sep 26, 2024
1 parent 374e837 commit 00016b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/app/playwright/e2e/Asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ test.describe('Asset', () => {
await hasText(page, 'Asset name used as a symbol by listed asset');
});

test('should not be able to add asset with symbol used as a name by other asset', async () => {
await goToAssetPage(page);
await getByAriaLabel(page, 'Asset ID').fill(
'0x599012155ae253353c7df01f36c8f6249c94131a69a3484bdb0234e3822b5100'
);
await getByAriaLabel(page, 'Asset name').fill('RAND');
await getByAriaLabel(page, 'Asset symbol').fill(CUSTOM_ASSET_SCREEN.name);
await getByAriaLabel(page, 'Save Asset').click();
await hasText(page, 'Asset symbol already used as a name by listed asset');
});

test('should not be able to add asset with duplicate symbol', async () => {
await goToAssetPage(page);
await getByAriaLabel(page, 'Asset ID').fill(
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/systems/Asset/services/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ export class AssetService {
throw new Error('Asset name already exists');
}

if (existingAssetSymbolMap.get(input.data.name)) {
throw new Error('Asset name used as a symbol by listed asset');
}

if (existingAssetNameMap.get(input.data.symbol)) {
throw new Error('Asset symbol already used as a name by listed asset');
}

if (existingAssetSymbolMap.get(input.data.symbol)) {
throw new Error('Asset symbol already exists');
}
Expand Down

0 comments on commit 00016b2

Please sign in to comment.