Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix showing bids of a name auction #1527

Merged
merged 2 commits into from
Jan 11, 2024
Merged
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
19 changes: 11 additions & 8 deletions src/pages/aens/AuctionDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<script>
import BigNumber from 'bignumber.js';
import { pick } from 'lodash-es';
import { TxBuilderHelper } from '@aeternity/aepp-sdk';
import blocksToRelativeTime from '../../filters/blocksToRelativeTime';
import Page from '../../components/Page.vue';
import AeSpinner from '../../components/AeSpinner.vue';
Expand Down Expand Up @@ -90,15 +91,17 @@ export default {
methods: {
async updateAuctionEntry() {
const sdk = await Promise.resolve(this.$store.state.sdk);
const { info: { auctionEnd, bids } } = await sdk.middleware.api.getNameById(this.name);
const { info: { auctionEnd } } = await sdk.middleware.api.getNameById(this.name);
this.auctionEnd = auctionEnd;
this.bids = await Promise.all(bids.map(async (txId) => {
const { tx } = await sdk.middleware.api.getTxByIndex(txId);
return {
nameFee: new BigNumber(tx.nameFee).shiftedBy(-MAGNITUDE),
accountId: tx.accountId,
};
}));
const nameId = TxBuilderHelper.produceNameId(this.name);
// TODO: show more than 100 bids
this.bids = (await sdk.middleware2.api.getAccountActivities(nameId, { limit: 100 })).data
.filter(({ type }) => type === 'NameClaimEvent')
.filter(({ payload: { sourceTxType } }) => sourceTxType === 'NameClaimTx')
.map(({ payload: { tx: { accountId, nameFee } } }) => ({
nameFee: new BigNumber(nameFee).shiftedBy(-MAGNITUDE),
accountId,
}));
},
blocksToRelativeTime,
},
Expand Down
12 changes: 7 additions & 5 deletions src/store/plugins/initSdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default (store) => {
};

const acceptCb = (_, { accept }) => accept();
const [sdk, middleware] = await Promise.all([
const [sdk, middleware, middleware2] = await Promise.all([
Ae.compose(ChainNode, Transaction, Contract, Aens, WalletRPC, { methods })({
nodes: [{
name: network.name,
Expand Down Expand Up @@ -114,22 +114,24 @@ export default (store) => {
},
}),
(async () => {
const specUrl = `${network.middlewareUrl}/swagger/swagger.json`;
const specUrl = `${network.middlewareUrl}/api`;
const spec = await fetchJson(specUrl);
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/503
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/1670
if (/^https:\/\/(mainnet|testnet)\.aeternity\.io\/mdw$/.test(network.middlewareUrl)) {
spec.basePath = '/mdw/';
}
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/160
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/1668
delete spec.schemes;
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/508
// TODO: remove after resolving https://github.com/aeternity/ae_mdw/issues/1669
spec.paths['/name/pointees/{id}'] = spec.paths['/names/pointees/{id}'];
delete spec.paths['/names/pointees/{id}'];
return genSwaggerClient(specUrl, { spec });
})(),
genSwaggerClient(`${network.middlewareUrl}/v2/api`),
]);
sdk.selectNode(network.name);
sdk.middleware = middleware;
sdk.middleware2 = middleware2;
return sdk;
};

Expand Down
Loading