From 78fdfa08b39f24be1b6f0e109f04d142c5fb5a2f Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 13:19:58 +0100 Subject: [PATCH 01/18] allow explore with non cosmos addresses --- src/components/common/TmSessionExplore.vue | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/common/TmSessionExplore.vue b/src/components/common/TmSessionExplore.vue index 3314a4ea1b..3926d4cabe 100644 --- a/src/components/common/TmSessionExplore.vue +++ b/src/components/common/TmSessionExplore.vue @@ -47,7 +47,7 @@ type="required" /> @@ -142,14 +142,32 @@ export default { exploreWith(address) { this.address = address this.onSubmit() - } - }, - validations() { - return { - address: { - required, - bech32Validate: this.bech32Validate, - isNotAValidatorAddress: this.isNotAValidatorAddress + }, + isEthereumAddress(address) { + if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) { + // check if it has the basic requirements of an address + return false + } else if ( + /^(0x)?[0-9a-f]{40}$/.test(address) || + /^(0x)?[0-9A-F]{40}$/.test(address) + ) { + // If it's all small caps or all all caps, return true + return true + } else { + // Otherwise check each case + return this.isChecksumAddress(address) + } + }, + addressValidate(address) { + return this.bech32Validate(address) || this.isEthereumAddress(address) + }, + validations() { + return { + address: { + required, + addressValidate: this.addressValidate, + isNotAValidatorAddress: this.isNotAValidatorAddress + } } } } From 38857864fc6d697961435016039c534cf61841b3 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 13:20:04 +0100 Subject: [PATCH 02/18] lint --- src/vuex/modules/connection.js | 2 +- .../components/ActionModal/components/ActionModal.spec.js | 8 ++++---- .../ActionModal/components/DelegationModal.spec.js | 6 +++--- .../ActionModal/components/UndelegationModal.spec.js | 2 +- .../specs/components/common/TmSessionHardware.spec.js | 2 +- tests/unit/specs/store/session.spec.js | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/vuex/modules/connection.js b/src/vuex/modules/connection.js index b6254f1a8b..7b900ac27e 100644 --- a/src/vuex/modules/connection.js +++ b/src/vuex/modules/connection.js @@ -1,7 +1,7 @@ import config from "src/../config" import { Networks } from "../../gql" -export default function ({ apollo }) { +export default function({ apollo }) { const state = { stopConnecting: false, connected: true, // TODO do connection test diff --git a/tests/unit/specs/components/ActionModal/components/ActionModal.spec.js b/tests/unit/specs/components/ActionModal/components/ActionModal.spec.js index 764c7b7110..e62bdb380e 100644 --- a/tests/unit/specs/components/ActionModal/components/ActionModal.spec.js +++ b/tests/unit/specs/components/ActionModal/components/ActionModal.spec.js @@ -6,7 +6,7 @@ import { focusParentLast } from "src/directives" const localVue = createLocalVue() localVue.use(Vuelidate) localVue.directive("focus-last", focusParentLast) -localVue.directive("focus", () => { }) +localVue.directive("focus", () => {}) let mockSimulate = jest.fn(() => 123456) let mockSend = jest.fn(() => ({ @@ -145,7 +145,7 @@ describe(`ActionModal`, () => { $store, $apollo, actionManager: { - setContext: () => { }, + setContext: () => {}, simulate: () => 12345, send: ActionManagerSend, simulateTxAPI: jest.fn(), @@ -161,7 +161,7 @@ describe(`ActionModal`, () => { }, submissionErrorPrefix: `PREFIX`, trackEvent: jest.fn(), - connectLedger: () => { }, + connectLedger: () => {}, onSendingFailed: jest.fn(), createContext: jest.fn() } @@ -618,7 +618,7 @@ describe(`ActionModal`, () => { isValidInput: jest.fn(() => true), selectedSignMethod: `local`, step: `details`, - validateChangeStep: jest.fn(() => { }) + validateChangeStep: jest.fn(() => {}) } }) diff --git a/tests/unit/specs/components/ActionModal/components/DelegationModal.spec.js b/tests/unit/specs/components/ActionModal/components/DelegationModal.spec.js index 7d6d61a0c2..ea43fbc0dd 100644 --- a/tests/unit/specs/components/ActionModal/components/DelegationModal.spec.js +++ b/tests/unit/specs/components/ActionModal/components/DelegationModal.spec.js @@ -29,7 +29,7 @@ describe(`DelegationModal`, () => { let wrapper const localVue = createLocalVue() localVue.use(Vuelidate) - localVue.directive("focus", () => { }) + localVue.directive("focus", () => {}) const state = { session: { @@ -49,8 +49,8 @@ describe(`DelegationModal`, () => { $store: { getters, state }, $apollo: { queries: { - balance: { refetch: () => { } }, - delegations: { refetch: () => { } } + balance: { refetch: () => {} }, + delegations: { refetch: () => {} } } } }, diff --git a/tests/unit/specs/components/ActionModal/components/UndelegationModal.spec.js b/tests/unit/specs/components/ActionModal/components/UndelegationModal.spec.js index 33674b19e2..1695f9b27a 100644 --- a/tests/unit/specs/components/ActionModal/components/UndelegationModal.spec.js +++ b/tests/unit/specs/components/ActionModal/components/UndelegationModal.spec.js @@ -12,7 +12,7 @@ describe(`UndelegationModal`, () => { } const localVue = createLocalVue() localVue.use(Vuelidate) - localVue.directive("focus", () => { }) + localVue.directive("focus", () => {}) beforeEach(() => { $store = { diff --git a/tests/unit/specs/components/common/TmSessionHardware.spec.js b/tests/unit/specs/components/common/TmSessionHardware.spec.js index 02441bd274..f846d46854 100644 --- a/tests/unit/specs/components/common/TmSessionHardware.spec.js +++ b/tests/unit/specs/components/common/TmSessionHardware.spec.js @@ -8,7 +8,7 @@ localVue.use(Vuex) localVue.use(Vuelidate) localVue.directive(`tooltip`, () => {}) localVue.directive(`focus`, () => {}) -localVue.directive('clipboard', () => {}) +localVue.directive("clipboard", () => {}) describe(`TmSessionHardware`, () => { let wrapper, store diff --git a/tests/unit/specs/store/session.spec.js b/tests/unit/specs/store/session.spec.js index 0256a408ec..45cb43d637 100644 --- a/tests/unit/specs/store/session.spec.js +++ b/tests/unit/specs/store/session.spec.js @@ -310,7 +310,7 @@ describe(`Module: Session`, () => { }) it(`should enable error collection`, async () => { - jest.spyOn(console, `log`).mockImplementationOnce(() => { }) + jest.spyOn(console, `log`).mockImplementationOnce(() => {}) const commit = jest.fn() const dispatch = jest.fn() await actions.setErrorCollection( @@ -326,7 +326,7 @@ describe(`Module: Session`, () => { }) it(`should disable error collection`, async () => { - jest.spyOn(console, `log`).mockImplementationOnce(() => { }) + jest.spyOn(console, `log`).mockImplementationOnce(() => {}) const commit = jest.fn() const dispatch = jest.fn() await actions.setErrorCollection( @@ -342,7 +342,7 @@ describe(`Module: Session`, () => { }) it(`should disable analytics collection`, async () => { - jest.spyOn(console, `log`).mockImplementationOnce(() => { }) + jest.spyOn(console, `log`).mockImplementationOnce(() => {}) const commit = jest.fn() const dispatch = jest.fn() await actions.setAnalyticsCollection( From d41eeaa97e6aa6a9db2e13037b9692a54ff25bad Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 13:34:21 +0100 Subject: [PATCH 03/18] fix --- src/components/common/TmSessionExplore.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/common/TmSessionExplore.vue b/src/components/common/TmSessionExplore.vue index 3926d4cabe..2cf6639e2c 100644 --- a/src/components/common/TmSessionExplore.vue +++ b/src/components/common/TmSessionExplore.vue @@ -160,14 +160,14 @@ export default { }, addressValidate(address) { return this.bech32Validate(address) || this.isEthereumAddress(address) - }, - validations() { - return { - address: { - required, - addressValidate: this.addressValidate, - isNotAValidatorAddress: this.isNotAValidatorAddress - } + } + }, + validations() { + return { + address: { + required, + addressValidate: this.addressValidate, + isNotAValidatorAddress: this.isNotAValidatorAddress } } } From 112367cd21016ffb00741542d9eb8685e1ea6d1b Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 13:51:35 +0100 Subject: [PATCH 04/18] filter only pending undelegations --- src/components/staking/Undelegations.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/staking/Undelegations.vue b/src/components/staking/Undelegations.vue index c9f952fd48..8fd0e0956b 100644 --- a/src/components/staking/Undelegations.vue +++ b/src/components/staking/Undelegations.vue @@ -1,11 +1,17 @@ @@ -26,6 +32,13 @@ export default { computed: { ...mapGetters([`address`, `network`]) }, + methods: { + filterOnlyPendingUndelegations(undelegations) { + return undelegations.filter(undelegation => { + undelegation.endTime < Date.now() + }) + } + }, apollo: { undelegations: { query() { From 92dfe8521022ed76ac34ab840e66ab6fec15fbc1 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 14:03:45 +0100 Subject: [PATCH 05/18] update snapshots --- .../__snapshots__/Undelegations.spec.js.snap | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap b/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap index 9176d75378..83d0342e7c 100644 --- a/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap +++ b/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap @@ -1,17 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Undelegations should show unbonding validators 1`] = ` -
-

- - Pending Undelegations - -

- - -
-`; +exports[`Undelegations should show unbonding validators 1`] = ``; From 2570dfc11e7be1af92a06d85bce93d9d00066270 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Fri, 20 Dec 2019 14:09:30 +0100 Subject: [PATCH 06/18] changelog --- changes/ana_livepeer-explore-mode-fe | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changes/ana_livepeer-explore-mode-fe diff --git a/changes/ana_livepeer-explore-mode-fe b/changes/ana_livepeer-explore-mode-fe new file mode 100644 index 0000000000..f16d5e73f8 --- /dev/null +++ b/changes/ana_livepeer-explore-mode-fe @@ -0,0 +1,2 @@ +[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now it is possible to also sign in with an Ethereum address @Bitcoinera +[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now the Undelegations component filters for only pending undelegations @Bitcoinera \ No newline at end of file From b8ed117a3648b17233643ff2b13aa8df91b2dffa Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Sun, 22 Dec 2019 10:58:54 +0100 Subject: [PATCH 07/18] changelog --- changes/ana_livepeer-explore-mode-fe | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changes/ana_livepeer-explore-mode-fe b/changes/ana_livepeer-explore-mode-fe index f16d5e73f8..438c8f1662 100644 --- a/changes/ana_livepeer-explore-mode-fe +++ b/changes/ana_livepeer-explore-mode-fe @@ -1,2 +1 @@ -[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now it is possible to also sign in with an Ethereum address @Bitcoinera -[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now the Undelegations component filters for only pending undelegations @Bitcoinera \ No newline at end of file +[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now it is possible to also sign in with an Ethereum address @Bitcoinera \ No newline at end of file From 32de5e5f941fe8797e932b5c2141cdb77e56fa03 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Sun, 22 Dec 2019 10:59:25 +0100 Subject: [PATCH 08/18] remove filter undelegations. change changelog --- src/components/staking/Undelegations.vue | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/staking/Undelegations.vue b/src/components/staking/Undelegations.vue index 8fd0e0956b..5d890f942c 100644 --- a/src/components/staking/Undelegations.vue +++ b/src/components/staking/Undelegations.vue @@ -1,16 +1,12 @@ @@ -32,13 +28,6 @@ export default { computed: { ...mapGetters([`address`, `network`]) }, - methods: { - filterOnlyPendingUndelegations(undelegations) { - return undelegations.filter(undelegation => { - undelegation.endTime < Date.now() - }) - } - }, apollo: { undelegations: { query() { From 81beae26983dd0b19ad575e60cf84a16d4618fd6 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Sun, 22 Dec 2019 12:23:29 +0100 Subject: [PATCH 09/18] add pendingundelegations query. use in portfolio --- src/components/staking/Undelegations.vue | 8 +++----- src/gql/index.js | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/components/staking/Undelegations.vue b/src/components/staking/Undelegations.vue index 5d890f942c..ae64ccda73 100644 --- a/src/components/staking/Undelegations.vue +++ b/src/components/staking/Undelegations.vue @@ -5,9 +5,7 @@

Pending Undelegations

- + @@ -15,7 +13,7 @@ import { mapGetters } from "vuex" import TableUndelegations from "staking/TableUndelegations" import refetchNetworkOnly from "scripts/refetch-network-only" -import { UndelegationsForDelegator, UserTransactionAdded } from "src/gql" +import { PendingUndelegationsForDelegator, UserTransactionAdded } from "src/gql" export default { name: `undelegations`, @@ -32,7 +30,7 @@ export default { undelegations: { query() { /* istanbul ignore next */ - return UndelegationsForDelegator(this.network) + return PendingUndelegationsForDelegator(this.network) }, variables() { /* istanbul ignore next */ diff --git a/src/gql/index.js b/src/gql/index.js index 6c64266433..1e8795f6c4 100644 --- a/src/gql/index.js +++ b/src/gql/index.js @@ -38,6 +38,15 @@ const ValidatorFragment = ` delegatorDelegation ` +const UndelegationFragment = ` + validator { + ${ValidatorFragment} + } + amount + startHeight + endTime +` + export const AllValidators = () => { const currentNetwork = getCurrentNetwork() // console.log(`currentNetwork`, currentNetwork) @@ -68,12 +77,15 @@ export const DelegatorValidators = schema => gql` export const UndelegationsForDelegator = schema => gql` query Undelegations($delegatorAddress: String!) { undelegations(networkId: "${schema}", delegatorAddress: $delegatorAddress) { - validator { - ${ValidatorFragment} - } - amount - startHeight - endTime + ${UndelegationFragment} + } + } +` + +export const PendingUndelegationsForDelegator = schema => gql` + query PendingUndelegations($delegatorAddress: String!) { + pendingundelegations(networkId: "${schema}", delegatorAddress: $delegatorAddress) { + ${UndelegationFragment} } } ` From 2e3209b436cbd663d3648c63743ea2d7dd825b95 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Sun, 22 Dec 2019 12:24:25 +0100 Subject: [PATCH 10/18] update snapshot --- .../__snapshots__/Undelegations.spec.js.snap | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap b/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap index 83d0342e7c..9176d75378 100644 --- a/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap +++ b/tests/unit/specs/components/staking/__snapshots__/Undelegations.spec.js.snap @@ -1,3 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Undelegations should show unbonding validators 1`] = ``; +exports[`Undelegations should show unbonding validators 1`] = ` +
+

+ + Pending Undelegations + +

+ + +
+`; From c3136c3292e0a26b34cd7c614d337b4bddf3bd97 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Sun, 22 Dec 2019 12:43:46 +0100 Subject: [PATCH 11/18] changelog --- changes/ana_livepeer-explore-mode-fe | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changes/ana_livepeer-explore-mode-fe b/changes/ana_livepeer-explore-mode-fe index 438c8f1662..f16d5e73f8 100644 --- a/changes/ana_livepeer-explore-mode-fe +++ b/changes/ana_livepeer-explore-mode-fe @@ -1 +1,2 @@ -[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now it is possible to also sign in with an Ethereum address @Bitcoinera \ No newline at end of file +[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now it is possible to also sign in with an Ethereum address @Bitcoinera +[Changed] [#3349](https://github.com/cosmos/lunie/pull/3349) Now the Undelegations component filters for only pending undelegations @Bitcoinera \ No newline at end of file From 327611f4abdf935a1fa092954ac1f2f95e1c5e87 Mon Sep 17 00:00:00 2001 From: Bitcoinera Date: Mon, 23 Dec 2019 12:45:09 +0100 Subject: [PATCH 12/18] check if undelegations exist --- src/components/staking/Undelegations.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/staking/Undelegations.vue b/src/components/staking/Undelegations.vue index ae64ccda73..df3df64b11 100644 --- a/src/components/staking/Undelegations.vue +++ b/src/components/staking/Undelegations.vue @@ -1,6 +1,6 @@