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

Workaround to fix COSMOS REST api bug #3239

Merged
merged 4 commits into from
Dec 3, 2019
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
1 change: 1 addition & 0 deletions changes/mario_3237-wrong-denom-unstake-workaround
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Fixed] [#3237](https://github.com/cosmos/lunie/issues/3237) Workaround to fix wrong denom NDEFINED showed in Staking and Restaking transactions @mariopino
11 changes: 9 additions & 2 deletions src/scripts/transaction-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ export const isPendingUndelegation = tx =>
!isNaN(tx.liquidDate) && tx.type === messageType.UNDELEGATE

export const getCoin = transaction => {
let coin
if (Array.isArray(transaction.value.amount)) {
return transaction.value.amount[0]
coin = transaction.value.amount[0]
} else {
return transaction.value.amount
coin = transaction.value.amount
}
// Workaround to fix COSMOS REST api bug, see https://github.com/luniehq/lunie/issues/3237
// and https://github.com/cosmos/cosmos-sdk/issues/5353
if (coin.denom === `undefined`) {
coin.denom = `uatom`
}
return coin
}

// We currently don't support MultiCoin transactions in the design. For simplicity we display only the first outgoing or incomming denomination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ describe(`BeginRedelegateMessageDetails`, () => {
type: `cosmos-sdk/MsgBeginRedelegate`
}

let buggyTx = tx;
buggyTx.value.amount[0].denom = "undefined"

it(`renders a redelegate transaction message`, () => {
wrapper = shallowMount(BeginRedelegateMessageDetails, {
propsData: {
Expand All @@ -39,4 +42,15 @@ describe(`BeginRedelegateMessageDetails`, () => {
})
expect(wrapper.element).toMatchSnapshot()
})

it(`renders a transaction message with undefined denom`, () => {
wrapper = shallowMount(BeginRedelegateMessageDetails, {
propsData: {
transaction: buggyTx,
validators: {}
},
stubs: [`router-link`]
})
expect(wrapper.html()).toContain("ATOM")
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ describe(`DelegateMessageDetails`, () => {
height: 2000000,
value: {
validator_address: `cosmos1`,
amount: [
{
amount: "10000000000",
denom: "uatom"
}
]
amount: {
amount: "10000000000",
denom: "uatom"
}
},
fee: {
amount: "37",
Expand Down