Skip to content

Commit

Permalink
Tx replace refactor (#1045)
Browse files Browse the repository at this point in the history
* bump deps

* flushPromises after render

* Remove unused constants

* bump rc

* Delete customPropTypes.js

* REPLACE_STRATEGY_PROPTYPE

* bump @glif/react-components

* Update Send.test.tsx.snap

* Remove useReset hook

* Remove unused utils

* Use createPath from react-components

* Use createHash from react-components

* bump @glif/react-components

* Use urlParams from react-components
  • Loading branch information
navFooh authored Jun 6, 2022
1 parent 122c7dc commit 6ed1280
Show file tree
Hide file tree
Showing 42 changed files with 151 additions and 845 deletions.
2 changes: 1 addition & 1 deletion __mocks__/@zondax/filecoin-signing-tools.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createHash from '../../utils/createHash'
import { createHash } from '@glif/react-components'

const generateMnemonic = jest
.fn()
Expand Down
10 changes: 7 additions & 3 deletions components/Wallet/Replace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
MessagePending,
TxState,
useWallet,
useWalletProvider
useWalletProvider,
navigate
} from '@glif/react-components'

import { navigate } from '../../utils/urlParams'
import { PAGE } from '../../constants'
import { logger } from '../../logger'

Expand Down Expand Up @@ -228,10 +228,14 @@ export enum ReplaceStrategy {
CANCEL = 'CANCEL'
}

const REPLACE_STRATEGY_PROPTYPE = PropTypes.oneOf(
Object.values(ReplaceStrategy) as Array<ReplaceStrategy>
)

interface ReplaceProps {
strategy: ReplaceStrategy
}

Replace.propTypes = {
strategy: PropTypes.string.isRequired
strategy: REPLACE_STRATEGY_PROPTYPE.isRequired
}
2 changes: 2 additions & 0 deletions components/Wallet/Send.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe('Send', () => {
</Tree>
)

await flushPromises()

// Get HTML elements
const header = getByRole(result.container, 'heading')
const [recipient, params] = getAllByRole(result.container, 'textbox')
Expand Down
4 changes: 2 additions & 2 deletions components/Wallet/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
LoginOption,
TxState,
WalletProviderOpts,
PendingMsgContextType
PendingMsgContextType,
navigate
} from '@glif/react-components'

import { navigate } from '../../utils/urlParams'
import { PAGE } from '../../constants'

export const Send = ({ walletProviderOpts, pendingMsgContext }: SendProps) => {
Expand Down
75 changes: 75 additions & 0 deletions components/Wallet/__snapshots__/Send.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,31 @@ exports[`Send it allows a user to send a message 1`] = `
color: var(--gray-dark) !important;
}
.c7 .select-wrapper {
position: relative;
}
.c7 .select-wrapper select {
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.c7 .select-wrapper .select-arrow {
position: absolute;
pointer-events: none;
top: 50%;
right: 1.2em;
width: 0.6em;
height: 0.6em;
border-right: 1.5px solid var(--black);
border-bottom: 1.5px solid var(--black);
-webkit-transform: translateY(-0.35em) rotate(45deg);
-ms-transform: translateY(-0.35em) rotate(45deg);
transform: translateY(-0.35em) rotate(45deg);
}
.c8 .toggle-wrapper {
position: relative;
padding: 0.5em 0;
Expand Down Expand Up @@ -982,6 +1007,31 @@ exports[`Send snapshots after enter recipient state 1`] = `
color: var(--purple-medium);
}
.c5 .select-wrapper {
position: relative;
}
.c5 .select-wrapper select {
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.c5 .select-wrapper .select-arrow {
position: absolute;
pointer-events: none;
top: 50%;
right: 1.2em;
width: 0.6em;
height: 0.6em;
border-right: 1.5px solid var(--black);
border-bottom: 1.5px solid var(--black);
-webkit-transform: translateY(-0.35em) rotate(45deg);
-ms-transform: translateY(-0.35em) rotate(45deg);
transform: translateY(-0.35em) rotate(45deg);
}
.c4 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -1494,6 +1544,31 @@ exports[`Send snapshots initial state 1`] = `
color: var(--purple-medium);
}
.c5 .select-wrapper {
position: relative;
}
.c5 .select-wrapper select {
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.c5 .select-wrapper .select-arrow {
position: absolute;
pointer-events: none;
top: 50%;
right: 1.2em;
width: 0.6em;
height: 0.6em;
border-right: 1.5px solid var(--black);
border-bottom: 1.5px solid var(--black);
-webkit-transform: translateY(-0.35em) rotate(45deg);
-ms-transform: translateY(-0.35em) rotate(45deg);
transform: translateY(-0.35em) rotate(45deg);
}
.c4 {
display: -webkit-box;
display: -webkit-flex;
Expand Down
8 changes: 3 additions & 5 deletions components/Wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import {
useWalletProvider,
useWallet,
hasLedgerError,
reportLedgerConfigError
reportLedgerConfigError,
generateRouteWithRequiredUrlParams,
navigate
} from '@glif/react-components'

import { logger } from '../../logger'
import {
generateRouteWithRequiredUrlParams,
navigate
} from '../../utils/urlParams'
import { PAGE } from '../../constants'

const Cards = styled.div`
Expand Down
5 changes: 3 additions & 2 deletions components/WalletPageLoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
LoginOption,
NetworkConnection,
useWallet,
useWalletProvider
useWalletProvider,
resetWallet,
navigate
} from '@glif/react-components'
import { useRouter } from 'next/router'

import { resetWallet, navigate } from '../utils/urlParams'
import { GLIF_DISCORD, PAGE } from '../constants'
import WalletPage from './WalletPage'

Expand Down
17 changes: 0 additions & 17 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { FilecoinNumber } from '@glif/filecoin-number'

/* WALLET TYPES */
export const LEDGER = 'LEDGER'
export const HD_WALLET = 'HD_WALLET'
Expand All @@ -23,29 +21,14 @@ export const GLIF_TWITTER = 'https://twitter.com/glifio'
/* NETWORK VARS */
export const MAINNET = 'f'
export const TESTNET = 't'

export const MAINNET_PATH_CODE = 461
export const TESTNET_PATH_CODE = 1

export const EXEC_ACTOR = 'f01'

/* TX METHOD TYPES */
export const SEND = 'SEND'
export const PROPOSE = 'PROPOSE'
export const EXEC = 'EXEC'
/* FILECOIN APP VERSION MIN */
export const LEDGER_VERSION_MAJOR = 0
export const LEDGER_VERSION_MINOR = 20
export const LEDGER_VERSION_PATCH = 0

/* GAS CONSTANTS */
export const emptyGasInfo = {
estimatedTransactionFee: new FilecoinNumber('0', 'attofil'),
gasPremium: new FilecoinNumber('0', 'attofil'),
gasFeeCap: new FilecoinNumber('0', 'attofil'),
gasLimit: new FilecoinNumber('0', 'attofil')
}

/* PAGES */
/* eslint-disable no-unused-vars */
export enum PAGE {
Expand Down
94 changes: 0 additions & 94 deletions customPropTypes.js

This file was deleted.

Loading

0 comments on commit 6ed1280

Please sign in to comment.