diff --git a/apis/cosmos-reducers.js b/apis/cosmos-reducers.js
index a91371e5..460c05c9 100644
--- a/apis/cosmos-reducers.js
+++ b/apis/cosmos-reducers.js
@@ -255,24 +255,23 @@ const proposalTypeEnumDictionary = {
// map Cosmos SDK message types to Lunie message types
export function getMessageType(type) {
- // different networks use different prefixes for the transaction types like cosmos/MsgSend vs core/MsgSend in Terra
const transactionTypeSuffix = type.split('/')[1]
switch (transactionTypeSuffix) {
- case 'MsgSend':
+ case 'cosmos.bank.v1beta1.MsgSend':
return lunieMessageTypes.SEND
- case 'MsgDelegate':
+ case 'cosmos.staking.v1beta1.MsgDelegate':
return lunieMessageTypes.STAKE
- case 'MsgBeginRedelegate':
+ case 'cosmos.staking.v1beta1.MsgBeginRedelegate':
return lunieMessageTypes.RESTAKE
- case 'MsgUndelegate':
+ case 'cosmos.staking.v1beta1.MsgUndelegate':
return lunieMessageTypes.UNSTAKE
- case 'MsgWithdrawDelegationReward':
+ case 'cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward':
return lunieMessageTypes.CLAIM_REWARDS
- case 'MsgSubmitProposal':
+ case 'cosmos.gov.v1beta1.MsgSubmitProposal':
return lunieMessageTypes.SUBMIT_PROPOSAL
- case 'MsgVote':
+ case 'cosmos.gov.v1beta1.MsgVote':
return lunieMessageTypes.VOTE
- case 'MsgDeposit':
+ case 'cosmos.gov.v1beta1.MsgDeposit':
return lunieMessageTypes.DEPOSIT
default:
return lunieMessageTypes.UNKNOWN
@@ -319,34 +318,35 @@ export function unstakeDetailsReducer(message) {
export function claimRewardsDetailsReducer(message, transaction) {
return {
- from: message.validators,
+ from: message.value.validators,
amounts: claimRewardsAmountReducer(transaction),
}
}
export function claimRewardsAmountReducer(transaction) {
- const transactionClaimEvents =
- transaction.events &&
- transaction.events.filter((event) => event.type === `transfer`)
- if (!transactionClaimEvents) {
- return [{ denom: '', amount: 0 }]
- }
- // filter out unsuccessful messages
- if (transaction.logs) {
- transaction.logs.forEach((log, index) => {
- if (log.success !== true) {
- transactionClaimEvents.splice(index, 1)
+ const transactionClaimEvents = []
+
+ transaction.logs.forEach((log) => {
+ log.events.forEach((event) => {
+ if (event.type === `transfer`) {
+ transactionClaimEvents.push(event)
}
})
- }
- // if transactionClaimEvents is empty after the successful transaction check, we default it
+ })
+
if (transactionClaimEvents.length === 0) {
return [{ denom: '', amount: 0 }]
}
- const amountAttributes = transactionClaimEvents
- .map((tx) => tx.attributes)
- .find((attributes) => attributes.length > 0)
- .filter((attribute) => attribute.key === `amount`)
+
+ const amountAttributes = []
+ transactionClaimEvents.forEach((event) => {
+ event.attributes.forEach((attribute) => {
+ if (attribute.key === `amount`) {
+ amountAttributes.push(attribute)
+ }
+ })
+ })
+
const allClaimedRewards = amountAttributes
.map((amount) => amount.value)
.map((rewardValue) => rewardCoinReducer(rewardValue))
@@ -430,10 +430,10 @@ export function transactionDetailsReducer(type, message, transaction) {
export function claimRewardsMessagesAggregator(claimMessages) {
// reduce all withdraw messages to one one collecting the validators from all the messages
const onlyValidatorsAddressesArray = claimMessages.map(
- (msg) => msg.value.validator_address
+ (msg) => msg.validator_address
)
return {
- type: `xxx/MsgWithdrawDelegationReward`, // prefix omited as not important
+ '@type': `/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward`, // prefix omited as not important
value: {
validators: onlyValidatorsAddressesArray,
},
@@ -528,7 +528,7 @@ export function transactionReducer(transaction) {
} = transaction.tx.body.messages.reduce(
({ claimMessages, otherMessages }, message) => {
// we need to aggregate all withdraws as we display them together in one transaction
- if (getMessageType(message.type) === lunieMessageTypes.CLAIM_REWARDS) {
+ if (getMessageType(message['@type']) === lunieMessageTypes.CLAIM_REWARDS) {
claimMessages.push(message)
} else {
otherMessages.push(message)
@@ -547,15 +547,15 @@ export function transactionReducer(transaction) {
? otherMessages.concat(claimMessage) // add aggregated claim message
: otherMessages
const returnedMessages = allMessages.map(
- ({ value: message, type }, messageIndex) => ({
+ (message, messageIndex) => ({
id: transaction.txhash,
- type: getMessageType(type),
+ type: getMessageType(message['@type']),
hash: transaction.txhash,
networkId: network.id,
key: `${transaction.txhash}_${messageIndex}`,
height: transaction.height,
details: transactionDetailsReducer(
- getMessageType(type),
+ getMessageType(message['@type']),
message,
transaction
),
@@ -570,7 +570,7 @@ export function transactionReducer(transaction) {
).events
),
rawMessage: {
- type,
+ // type,
message,
},
})
diff --git a/apis/cosmos-source.js b/apis/cosmos-source.js
index 1e077260..6073685a 100644
--- a/apis/cosmos-source.js
+++ b/apis/cosmos-source.js
@@ -96,52 +96,51 @@ export default class CosmosAPI {
return slashingParams.params.signed_blocks_window
}
- async getTransactions(address, pageNumber = 0) {
- // // getting page count
- // const [senderPage, recipientPage] = await Promise.all([
- // this.getPageCount(`/cosmos/tx/v1beta1/txs?message.sender=${address}`),
- // this.getPageCount(`/cosmos/tx/v1beta1/txs?transfer.recipient=${address}`),
- // ])
-
- // const requests = [
- // this.loadPaginatedTxs(
- // `/cosmos/tx/v1beta1/txs?message.sender=${address}`,
- // senderPage - pageNumber
- // ),
- // this.loadPaginatedTxs(
- // `/cosmos/tx/v1beta1/txs?transfer.recipient=${address}`,
- // recipientPage - pageNumber
- // ),
- // ]
+ async getTransactions(address, pageNumber = 1) {
+ // getting page count
+ const [senderPage, recipientPage] = await Promise.all([
+ this.getPageCount(`/cosmos/tx/v1beta1/txs?events=message.sender='${address}'`),
+ this.getPageCount(`/cosmos/tx/v1beta1/txs?events=message.action='send'&events=transfer.recipient='${address}'`),
+ ])
+
+ const requests = [
+ this.loadPaginatedTxs(
+ `/cosmos/tx/v1beta1/txs?events=message.sender='${address}'`,
+ senderPage - pageNumber + 1
+ ),
+ this.loadPaginatedTxs(
+ `/cosmos/tx/v1beta1/txs?events=message.action='send'&events=transfer.recipient='${address}'`,
+ recipientPage - pageNumber + 1
+ ),
+ ]
// /*
// if it's a first requests we need to load two pages, instead of one,
// cause last page could contain less records than any other (even 1)
// To do this asynchronously we need to do it with Promise.all
// and not wait until last page is loaded
// */
- // if (!pageNumber) {
- // if (senderPage - pageNumber > 1) {
- // requests.push(
- // this.loadPaginatedTxs(
- // `/cosmos/tx/v1beta1/txs?message.sender=${address}`,
- // senderPage - pageNumber - 1
- // )
- // )
- // }
- // if (recipientPage - pageNumber > 1) {
- // requests.push(
- // this.loadPaginatedTxs(
- // `/cosmos/tx/v1beta1/txs?transfer.recipient=${address}`,
- // recipientPage - pageNumber - 1
- // )
- // )
- // }
- // }
-
- // const txs = await Promise.all(requests).then(([...results]) =>
- // [].concat(...results)
- // )
- const txs = await this.axios.get(`https://api.cosmostation.io/v1/account/txs/${address}`)
+ if (pageNumber === 1) {
+ if (senderPage - pageNumber > 0) {
+ requests.push(
+ this.loadPaginatedTxs(
+ `/cosmos/tx/v1beta1/txs?events=message.sender='${address}'`,
+ senderPage - pageNumber
+ )
+ )
+ }
+ if (recipientPage - pageNumber > 0) {
+ requests.push(
+ this.loadPaginatedTxs(
+ `/cosmos/tx/v1beta1/txs?events=message.action='send'&events=transfer.recipient='${address}'`,
+ recipientPage - pageNumber
+ )
+ )
+ }
+ }
+
+ const txs = await Promise.all(requests).then(([...results]) =>
+ [].concat(...results)
+ )
return this.reducers.transactionsReducer(txs)
}
@@ -187,7 +186,7 @@ export default class CosmosAPI {
}
return this.reducers.delegationReducer(
- selfDelegation,
+ selfDelegation.delegation_response,
validator,
delegationEnum.ACTIVE
).amount
@@ -508,7 +507,6 @@ export default class CosmosAPI {
`cosmos/staking/v1beta1/delegations/${address}`
).catch(console.log) || []
- console.log(delegations)
return delegations.length ? delegations
.map((delegation) =>
this.reducers.delegationReducer(
@@ -557,8 +555,7 @@ export default class CosmosAPI {
).catch(() => {
return []
})
-
- return delegations.map((delegation) =>
+ return delegations.result.map((delegation) =>
this.reducers.delegationReducer(
delegation,
validator,
@@ -591,14 +588,16 @@ export default class CosmosAPI {
if (page < 1) {
return []
}
- const pagination = `&limit=${PAGE_RECORDS_COUNT}&page=${page}`
- const { txs } = await this.get(`${url}${pagination}`)
- return txs || []
+
+ let offset = (page - 1) * PAGE_RECORDS_COUNT
+ const pagination = `&pagination.limit=${PAGE_RECORDS_COUNT}&pagination.offset=${offset}`
+ const { tx_responses } = await this.get(`${url}${pagination}`)
+ return tx_responses || []
}
async getPageCount(url) {
- const page = await this.get(url + `&limit=${PAGE_RECORDS_COUNT}`)
- return page.page_total
+ const response = await this.get(url + `&pagination.limit=${PAGE_RECORDS_COUNT}`)
+ return Math.ceil(response.pagination.total / PAGE_RECORDS_COUNT)
}
}
diff --git a/assets/images/transactions/Claim Rewards.svg b/assets/images/transactions/ClaimRewards.svg
similarity index 100%
rename from assets/images/transactions/Claim Rewards.svg
rename to assets/images/transactions/ClaimRewards.svg
diff --git a/components/address/ImportNameStep.vue b/components/address/ImportNameStep.vue
index f1ca61a9..b447b01b 100644
--- a/components/address/ImportNameStep.vue
+++ b/components/address/ImportNameStep.vue
@@ -20,18 +20,18 @@
type="text"
placeholder="Must have at least 3 characters"
/>
-
-
-
-
@@ -69,6 +74,7 @@ export default {
},
data: () => ({
fieldSeed: undefined,
+ loading: false,
}),
mounted() {
this.fieldSeed = this.seed
@@ -77,6 +83,7 @@ export default {
onSubmit() {
this.$v.$touch()
if (this.$v.fieldSeed.$invalid || this.$v.fieldSeed.$invalid) return
+ this.loading = true
this.$emit('submit', this.fieldSeed)
},
},
diff --git a/components/address/NewSeedStep.vue b/components/address/NewSeedStep.vue
index 442e1fc9..66d64072 100644
--- a/components/address/NewSeedStep.vue
+++ b/components/address/NewSeedStep.vue
@@ -1,8 +1,8 @@
-
+
diff --git a/components/transactions/TransactionItem.vue b/components/transactions/TransactionItem.vue
index 16c91b6a..5a5e1e32 100644
--- a/components/transactions/TransactionItem.vue
+++ b/components/transactions/TransactionItem.vue
@@ -118,7 +118,8 @@ export default {
},
imagePath() {
try {
- return require(`../../assets/images/transactions/${this.transactionCaption}.svg`)
+ const imgName = this.transactionCaption.replace(/\s+/g, '')
+ return require(`../../assets/images/transactions/${imgName}.svg`)
} catch {
return require('../../assets/images/transactions/Unknown.svg')
}
diff --git a/layouts/session.vue b/layouts/session.vue
index b5d5a19e..b7364ae7 100644
--- a/layouts/session.vue
+++ b/layouts/session.vue
@@ -2,9 +2,6 @@