Интеграция страницы ValidationLog с сервером

This commit is contained in:
DwCay
2022-07-12 19:21:39 +03:00
parent 7ad29e8fe0
commit 8489bc375c
6 changed files with 79 additions and 233 deletions

View File

@@ -12,12 +12,15 @@ class Store {
_userData = {}
_transactionInfo = {}
constructor() {
makeAutoObservable(this);
this.fetchNodeInfo()
reaction(() => this.tokenKey, () => this.fetchNewAccountData())
reaction(() => this.tokenKey, () => this.fetchTransactionInfo())
};
fetchNewAccountData() {
@@ -35,6 +38,14 @@ class Store {
.then(()=>this.fetchNewAccountData())
}
fetchTransactionInfo() {
fetchWrapper.getAuth(`http://3.125.47.101/api/account/transactions/b444b7ff3118cf2a30cbd54cfcdb8fd5d805017a?moduleID=1001&assetID=11`, {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
})
.then((res)=>this.saveInfoTransaction(res))
}
userDataFetchChange(res) {
this._userData = res;
}
@@ -43,6 +54,10 @@ class Store {
return this._userData
}
get transactionInfo() {
return this._transactionInfo
}
savePassPhrase(phrase) {
this._passPhrase = phrase
}
@@ -51,6 +66,10 @@ class Store {
this._accountData = data;
};
saveInfoTransaction(transaction) {
this._transactionInfo = transaction
}
fetchNodeInfo() {
getNodeInfo()
.then((info) => this.fetchNodeInfoSuccess(info))

View File

@@ -0,0 +1,39 @@
import {makeAutoObservable, reaction} from "mobx";
import {registrationStore} from "./store";
const labelMap = {
firstname: 'First name',
secondname: 'Second name',
gender: "Gender",
birthdate: "Birthdate"
};
class ValidationLogStore {
_transactionData = [];
constructor() {
makeAutoObservable(this)
reaction(() => ({data: registrationStore.transactionInfo}), ({data}) => {
this._transactionData = data.data;
})
}
get transactionData() {
return this._transactionData.map(item=>{
return {
id: item.id,
assets: item.asset.features.map(asset=>{
return {
transaction_id: item.id,
address: item.asset.recipientAddress,
value: asset.value,
label: labelMap[asset.label],
}
})
}
})
}
}
export const validationLogStore = new ValidationLogStore()