Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a76e44b

Browse files
committedFeb 15, 2025·
fix: remove unnecessary name preclaim
1 parent de30968 commit a76e44b

File tree

17 files changed

+19
-133
lines changed

17 files changed

+19
-133
lines changed
 

‎src/components/mobile/AccountSwitcherModal.vue

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
<Overlay class="account-switcher-modal" @click="resolve">
44
<AeCard fill="maximum">
55
<ListItemAccount
6-
v-for="(account, index) in accountsWithNamePending"
6+
v-for="(account, index) in accounts"
77
:key="account.address"
88
v-bind="account"
99
>
1010
<template slot="right">
11-
<NamePending v-if="account.namePending" />
1211
<AeRadio :checked="index === activeIdx" @change="setActiveIdx(index)" />
1312
</template>
1413
</ListItemAccount>
@@ -45,7 +44,6 @@ import { pick } from 'lodash-es';
4544
import Overlay from '../Overlay.vue';
4645
import ListItem from '../ListItem.vue';
4746
import ListItemAccount from '../ListItemAccount.vue';
48-
import NamePending from './NamePending.vue';
4947
import ListItemCircle from '../ListItemCircle.vue';
5048
import { Plus } from '../icons';
5149
import AeCard from '../AeCard.vue';
@@ -58,7 +56,6 @@ export default {
5856
Overlay,
5957
ListItem,
6058
ListItemAccount,
61-
NamePending,
6259
ListItemCircle,
6360
Plus,
6461
AeCard,
@@ -69,17 +66,7 @@ export default {
6966
props: {
7067
resolve: { type: Function, required: true },
7168
},
72-
computed: {
73-
...mapState('accounts', ['activeIdx']),
74-
...mapState('names', {
75-
accountsWithNamePending(state, { get, isPending }) {
76-
return this.accounts.map((account) => ({
77-
...account,
78-
namePending: isPending(get(account.address)),
79-
}));
80-
},
81-
}),
82-
},
69+
computed: mapState('accounts', ['activeIdx']),
8370
subscriptions() {
8471
return pick(this.$store.state.observables, ['accounts', 'totalBalance']);
8572
},
@@ -131,10 +118,6 @@ export default {
131118
align-self: center;
132119
}
133120
134-
.name-pending {
135-
margin-right: functions.rem(8px);
136-
}
137-
138121
.list-item.vault-new .list-item-circle {
139122
background-color: variables.$color-alternative;
140123
}

‎src/components/mobile/ConfirmTransactionSignModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<script>
3333
import { mapState } from 'vuex';
34-
import { Tag } from '@aeternity/aepp-sdk-next';
34+
import { Tag, isAuctionName } from '@aeternity/aepp-sdk-next';
3535
import Page from '../Page.vue';
3636
import Guide from '../Guide.vue';
3737
import AeFraction from '../AeFraction.vue';
@@ -100,7 +100,7 @@ export default {
100100
guideTemplate() {
101101
const { tag } = this.transaction;
102102
if (tag === Tag.SpendTx) return this.$t('modal.confirm-transaction-sign.guide-spend');
103-
if (tag === Tag.NameClaimTx && !+this.transaction.nameSalt) {
103+
if (tag === Tag.NameClaimTx && isAuctionName(this.transaction.name)) {
104104
return this.$t('modal.confirm-transaction-sign.guide-name-bid');
105105
}
106106
return this.$t('modal.confirm-transaction-sign.guide', {

‎src/components/mobile/NamePending.vue

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎src/lib/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const MAGNITUDE_MICRO = -6;
55
export const MAGNITUDE_PICO = -12;
66

77
export const AENS_DOMAIN = '.chain';
8-
export const MAX_AUCTION_NAME_LENGTH = 12 + AENS_DOMAIN.length;
98

109
export const NAME_LIST_ROUTE_NAMES = ['name-list', 'auction-list', 'auction-list-character-length'];
1110

‎src/locales/cn.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@
496496
"confirm-bidding": "An auction for the name {name} has already started. Would you like to make a bid?",
497497

498498
"notification": {
499-
"claim-sent": "为{name} 的名称已成功发送",
500499
"registered": "{name} 已成功注册",
501500
"bid": "You bid on {name} successfully",
502501
"unknown-error": "因为未知原因,{name} 未注册"

‎src/locales/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@
496496
"confirm-bidding": "An auction for the name {name} has already started. Would you like to make a bid?",
497497

498498
"notification": {
499-
"claim-sent": "Claim for {name} name was successfully sent",
500499
"registered": "{name} was successfully registered",
501500
"bid": "You bid on {name} successfully",
502501
"unknown-error": "{name} was not registered for unknown reason"

‎src/locales/es.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@
496496
"confirm-bidding": "An auction for the name {name} has already started. Would you like to make a bid?",
497497

498498
"notification": {
499-
"claim-sent": "La solicitud de {name} nombre se envió correctamente",
500499
"registered": "{name} se registró correctamente",
501500
"bid": "You bid on {name} successfully",
502501
"unknown-error": "{name} no se registró por un motivo desconocido"

‎src/locales/ru.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@
496496
"confirm-bidding": "Аукцион на имя {name} уже начался. Хотите сделать ставку?",
497497

498498
"notification": {
499-
"claim-sent": "Запрос на имя {name} был успешно отправлен​​",
500499
"registered": "{name} было успешно зарегистрировано",
501500
"bid": "Вы успешно поставили на {name}",
502501
"unknown-error": "{name} не было зарегистрировано по неизвестной причине"

‎src/pages/aens/AuctionDetails.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export default {
9292
async updateBids() {
9393
const { data } = await this.$store.getters.middleware
9494
// TODO: show more than 100 bids
95+
// TODO: use /v3/names/auction.chain/claims instead
96+
// TODO: remove previous bids after solving https://github.com/aeternity/ae_mdw/issues/2097
9597
.getAccountActivities(produceNameId(this.name), { limit: 100 });
9698
this.bids = data
9799
.filter(({ type }) => type === 'NameClaimEvent')

‎src/pages/aens/NameList.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
:name="entry.name"
1616
:to="{ name: 'name-details', params: { name: entry.name } }"
1717
subtitle="address"
18-
>
19-
<NamePending v-if="entry.status === 'pending'" slot="right" />
20-
</ListItemAccount>
18+
/>
2119
</AeCard>
2220
</template>
2321

@@ -48,7 +46,6 @@ import Page from '../../components/Page.vue';
4846
import NameListHeader from '../../components/mobile/NameListHeader.vue';
4947
import AeCard from '../../components/AeCard.vue';
5048
import ListItemAccount from '../../components/ListItemAccount.vue';
51-
import NamePending from '../../components/mobile/NamePending.vue';
5249
import ButtonAddFixed from '../../components/ButtonAddFixed.vue';
5350
import { MAGNITUDE } from '../../lib/constants';
5451
@@ -58,7 +55,6 @@ export default {
5855
NameListHeader,
5956
AeCard,
6057
ListItemAccount,
61-
NamePending,
6258
ButtonAddFixed,
6359
},
6460
data: () => ({ auctions: [] }),

‎src/pages/aens/NameNew.vue

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939

4040
<script>
4141
import { mapGetters } from 'vuex';
42-
import { Name } from '@aeternity/aepp-sdk-next';
43-
import { MAX_AUCTION_NAME_LENGTH } from '../../lib/constants';
42+
import { Name, isAuctionName } from '@aeternity/aepp-sdk-next';
4443
import { handleUnknownError, isNotFoundError } from '../../lib/utils';
4544
import { i18n } from '../../store/plugins/ui/languages';
4645
import Page from '../../components/Page.vue';
@@ -83,27 +82,9 @@ export default {
8382
}
8483
8584
const name = new Name(this.name, this.$store.getters.sdk.getContext());
86-
let claimTxHash;
8785
try {
88-
await name.preclaim();
89-
claimTxHash = (await name.claim({ waitMined: false })).hash;
90-
this.$store.dispatch('modals/open', {
91-
name: 'notification',
92-
text: this.$t('name.new.notification.claim-sent', { name: this.name }),
93-
});
94-
this.$router.push({ name: 'name-list' });
95-
} catch (e) {
96-
if (e.message === 'Rejected by user') return;
97-
this.error = true;
98-
handleUnknownError(e);
99-
} finally {
100-
this.busy = false;
101-
}
102-
103-
try {
104-
this.$store.dispatch('names/fetchOwned');
105-
await this.$store.getters.sdk.poll(claimTxHash);
106-
const isAuction = MAX_AUCTION_NAME_LENGTH >= this.name.length;
86+
await name.claim();
87+
const isAuction = isAuctionName(this.name);
10788
if (!isAuction) {
10889
await this.$store.dispatch('names/updatePointer', {
10990
name: this.name,
@@ -116,15 +97,17 @@ export default {
11697
? i18n.t('name.new.notification.bid', { name: this.name })
11798
: i18n.t('name.new.notification.registered', { name: this.name }),
11899
});
100+
this.$router.push({ name: 'name-list' });
119101
} catch (e) {
120102
if (e.message === 'Rejected by user') return;
103+
this.error = true;
121104
this.$store.dispatch('modals/open', {
122105
name: 'notification',
123106
text: i18n.t('name.new.notification.unknown-error', { name: this.name }),
124107
});
125108
handleUnknownError(e);
126109
} finally {
127-
this.$store.dispatch('names/fetchOwned');
110+
this.busy = false;
128111
}
129112
},
130113
},

‎src/store/plugins/ui/names.js

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import BigNumber from 'bignumber.js';
21
import Vue from 'vue';
32
import { isAddressValid, Name, produceNameId } from '@aeternity/aepp-sdk-next';
4-
import { MAGNITUDE } from '../../../lib/constants';
5-
import {
6-
handleUnknownError, isAccountNotFoundError, getAddressByNameEntry, isAensName,
7-
} from '../../../lib/utils';
3+
import { getAddressByNameEntry, isAensName } from '../../../lib/utils';
84

95
export default (store) => {
106
store.registerModule('names', {
@@ -42,9 +38,6 @@ export default (store) => {
4238
getDefault: ({ defaults }, _getters, { sdkSync: { networkId } }) => (address) => (
4339
defaults[`${address}-${networkId}`]
4440
),
45-
isPending: ({ owned }) => (name) => (
46-
!!((owned.find((t) => t.name === name)) || {}).status === 'pending'
47-
),
4841
},
4942
mutations: {
5043
set({ names }, {
@@ -109,37 +102,18 @@ export default (store) => {
109102
throw new Error(`Unknown id: ${id}`);
110103
},
111104
async fetchOwned({ rootState, rootGetters: { node, middleware }, commit }) {
112-
const getPendingNameClaimTransactions = (address) => node
113-
.getPendingAccountTransactionsByPubkey(address)
114-
.then(
115-
({ transactions }) => transactions
116-
.filter(({ tx: { type } }) => type === 'NameClaimTx')
117-
.map(({ tx }) => ({
118-
name: tx.name,
119-
owner: address,
120-
pointers: [],
121-
status: 'pending',
122-
nameFee: new BigNumber(tx.nameFee).shiftedBy(-MAGNITUDE),
123-
})),
124-
(error) => {
125-
if (!isAccountNotFoundError(error)) handleUnknownError(error);
126-
return [];
127-
},
128-
);
129-
130105
/**
131106
* Name object structure
132107
* @property {string} name - name ending with .chain
133108
* @property {string} owner - address
134109
* @property {array} pointers - array of objects with key and value
135110
* @property {number | undefined} activeFrom - block height
136111
* @property {number | undefined} expireHeight - block height
137-
* @property {'auction' | 'name' | 'pending'} status
112+
* @property {'auction' | 'name'} status
138113
* @property {BigNumber | undefined} nameFee
139114
*/
140115
const names = (await Promise.all(
141-
rootState.accounts.list.map(({ address }) => Promise.all([
142-
getPendingNameClaimTransactions(address),
116+
rootState.accounts.list.map(({ address }) =>
143117
middleware.getNames({ ownedBy: address, limit: 100, state: 'active' })
144118
.then(({ data }) => data.map(({ name, pointers, activeFrom, expireHeight }) => ({
145119
name,
@@ -148,9 +122,8 @@ export default (store) => {
148122
activeFrom,
149123
expireHeight,
150124
status: 'name',
151-
}))),
152-
])),
153-
)).flat(2);
125+
})))),
126+
)).flat(1);
154127

155128
commit('setOwned', names);
156129
},
Loading
Binary file not shown.

‎tests/e2e/specs/names/auctions.cy.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,11 @@ describe('Auctions', () => {
66
cy.get('input').type(`${name}{moveToStart}${'{rightArrow}'.repeat(4)}-`);
77
cy.get('.ae-button').click();
88

9-
cy.get('.turtle-rabbit').should('be.visible');
10-
cy.contains('Preclaim');
11-
cy.get('.ae-button-group .secondary').click();
12-
139
cy.get('.turtle-rabbit').should('be.visible');
1410
cy.matchImage();
1511
cy.get('.ae-button-group .secondary').click();
1612

17-
cy.get('.notification')
18-
.contains('You bid on')
19-
.contains('successfully')
20-
.should('be.visible')
21-
.invoke('remove');
22-
23-
cy.get('.notification')
24-
.contains('Claim for')
25-
.contains('name was successfully sent')
26-
.should('be.visible');
13+
cy.get('.notification').contains('You bid on').contains('successfully').should('be.visible');
2714
});
2815

2916
it('bids on auction', () => {

‎tests/e2e/specs/names/long-names.cy.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ describe('Long names', () => {
6060
cy.get('input').type(`${name}{moveToStart}${'{rightArrow}'.repeat(4)}-`);
6161
cy.get('.ae-button').click();
6262

63-
cy.get('.turtle-rabbit').should('be.visible');
64-
cy.matchImage({ screenshotConfig: { blackout: ['.details-raw-data code'] } });
65-
cy.get('.ae-button-group .secondary').click();
66-
6763
cy.get('.turtle-rabbit').should('be.visible');
6864
cy.matchImage();
6965
cy.get('.ae-button-group .secondary').click();
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.