Skip to content

Commit

Permalink
fix: show all bids using v2 middleware api
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jan 11, 2024
1 parent 7b820ae commit 29038fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
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
4 changes: 3 additions & 1 deletion 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 @@ -127,9 +127,11 @@ export default (store) => {
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

0 comments on commit 29038fa

Please sign in to comment.