mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Delete Dai/Sai migration notification (#8418)
This commit is contained in:
parent
7439cd1662
commit
eb06394dd9
@ -25,15 +25,6 @@
|
|||||||
"dismiss": {
|
"dismiss": {
|
||||||
"message": "Dismiss"
|
"message": "Dismiss"
|
||||||
},
|
},
|
||||||
"migrateSai": {
|
|
||||||
"message": "A message from Maker: The new Multi-Collateral Dai token has been released. Your old tokens are now called Sai. Please upgrade your Sai tokens to the new Dai."
|
|
||||||
},
|
|
||||||
"migrateSaiInfo": {
|
|
||||||
"message": "To dismiss this notification you can migrate your tokens or hide SAI from the token list."
|
|
||||||
},
|
|
||||||
"migrate": {
|
|
||||||
"message": "Migrate"
|
|
||||||
},
|
|
||||||
"showIncomingTransactions": {
|
"showIncomingTransactions": {
|
||||||
"message": "Show Incoming Transactions"
|
"message": "Show Incoming Transactions"
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,4 @@
|
|||||||
{
|
{
|
||||||
"migrateSai": {
|
|
||||||
"message": "Un messaggio da Maker: il nuovo Dai Multi-Collaterale è stato rilasciato. Ora i token precedenti si chiamano Sai. Aggiorna i tuoi Sai ai nuovi Dai."
|
|
||||||
},
|
|
||||||
"migrateSaiInfo": {
|
|
||||||
"message": "Per eliminare questa notifica puoi migrare i tuoi token o nascondere SAI dalla lista dei token."
|
|
||||||
},
|
|
||||||
"migrate": {
|
|
||||||
"message": "Migra"
|
|
||||||
},
|
|
||||||
"showIncomingTransactions": {
|
"showIncomingTransactions": {
|
||||||
"message": "Mostra Transazioni in Ingresso"
|
"message": "Mostra Transazioni in Ingresso"
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,6 @@ class AppStateController extends EventEmitter {
|
|||||||
this.onInactiveTimeout = onInactiveTimeout || (() => {})
|
this.onInactiveTimeout = onInactiveTimeout || (() => {})
|
||||||
this.store = new ObservableStore(Object.assign({
|
this.store = new ObservableStore(Object.assign({
|
||||||
timeoutMinutes: 0,
|
timeoutMinutes: 0,
|
||||||
mkrMigrationReminderTimestamp: null,
|
|
||||||
connectedStatusPopoverHasBeenShown: true,
|
connectedStatusPopoverHasBeenShown: true,
|
||||||
}, initState))
|
}, initState))
|
||||||
this.timer = null
|
this.timer = null
|
||||||
@ -67,12 +66,6 @@ class AppStateController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMkrMigrationReminderTimestamp (timestamp) {
|
|
||||||
this.store.updateState({
|
|
||||||
mkrMigrationReminderTimestamp: timestamp,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record that the user has seen the connected status info popover
|
* Record that the user has seen the connected status info popover
|
||||||
*/
|
*/
|
||||||
|
@ -507,7 +507,6 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
// AppStateController
|
// AppStateController
|
||||||
setLastActiveTime: nodeify(this.appStateController.setLastActiveTime, this.appStateController),
|
setLastActiveTime: nodeify(this.appStateController.setLastActiveTime, this.appStateController),
|
||||||
setMkrMigrationReminderTimestamp: nodeify(this.appStateController.setMkrMigrationReminderTimestamp, this.appStateController),
|
|
||||||
setConnectedStatusPopoverHasBeenShown: nodeify(this.appStateController.setConnectedStatusPopoverHasBeenShown, this.appStateController),
|
setConnectedStatusPopoverHasBeenShown: nodeify(this.appStateController.setConnectedStatusPopoverHasBeenShown, this.appStateController),
|
||||||
|
|
||||||
// EnsController
|
// EnsController
|
||||||
|
23
app/scripts/migrations/044.js
Normal file
23
app/scripts/migrations/044.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const version = 44
|
||||||
|
import { cloneDeep } from 'lodash'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove unused 'mkrMigrationReminderTimestamp' state from the `AppStateController`
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
version,
|
||||||
|
migrate: async function (originalVersionedData) {
|
||||||
|
const versionedData = cloneDeep(originalVersionedData)
|
||||||
|
versionedData.meta.version = version
|
||||||
|
const state = versionedData.data
|
||||||
|
versionedData.data = transformState(state)
|
||||||
|
return versionedData
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformState (state) {
|
||||||
|
if (typeof state?.AppStateController?.mkrMigrationReminderTimestamp !== 'undefined') {
|
||||||
|
delete state.AppStateController.mkrMigrationReminderTimestamp
|
||||||
|
}
|
||||||
|
return state
|
||||||
|
}
|
@ -54,6 +54,7 @@ const migrations = [
|
|||||||
require('./041').default,
|
require('./041').default,
|
||||||
require('./042').default,
|
require('./042').default,
|
||||||
require('./043').default,
|
require('./043').default,
|
||||||
|
require('./044').default,
|
||||||
]
|
]
|
||||||
|
|
||||||
export default migrations
|
export default migrations
|
||||||
|
75
test/unit/migrations/044-test.js
Normal file
75
test/unit/migrations/044-test.js
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { strict as assert } from 'assert'
|
||||||
|
import migration44 from '../../../app/scripts/migrations/044'
|
||||||
|
|
||||||
|
describe('migration #44', function () {
|
||||||
|
it('should update the version metadata', async function () {
|
||||||
|
const oldStorage = {
|
||||||
|
'meta': {
|
||||||
|
'version': 43,
|
||||||
|
},
|
||||||
|
'data': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
const newStorage = await migration44.migrate(oldStorage)
|
||||||
|
assert.deepEqual(newStorage.meta, {
|
||||||
|
'version': 44,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should delete mkrMigrationReminderTimestamp state', async function () {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {},
|
||||||
|
data: {
|
||||||
|
AppStateController: {
|
||||||
|
mkrMigrationReminderTimestamp: 'some timestamp',
|
||||||
|
bar: 'baz',
|
||||||
|
},
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const newStorage = await migration44.migrate(oldStorage)
|
||||||
|
assert.deepEqual(newStorage.data, {
|
||||||
|
AppStateController: {
|
||||||
|
bar: 'baz',
|
||||||
|
},
|
||||||
|
foo: 'bar',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should delete mkrMigrationReminderTimestamp state if it is null', async function () {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {},
|
||||||
|
data: {
|
||||||
|
AppStateController: {
|
||||||
|
mkrMigrationReminderTimestamp: null,
|
||||||
|
bar: 'baz',
|
||||||
|
},
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const newStorage = await migration44.migrate(oldStorage)
|
||||||
|
assert.deepEqual(newStorage.data, {
|
||||||
|
AppStateController: {
|
||||||
|
bar: 'baz',
|
||||||
|
},
|
||||||
|
foo: 'bar',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should do nothing if mkrMigrationReminderTimestamp state does not exist', async function () {
|
||||||
|
const oldStorage = {
|
||||||
|
meta: {},
|
||||||
|
data: {
|
||||||
|
AppStateController: {
|
||||||
|
bar: 'baz',
|
||||||
|
},
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const newStorage = await migration44.migrate(oldStorage)
|
||||||
|
assert.deepEqual(oldStorage.data, newStorage.data)
|
||||||
|
})
|
||||||
|
})
|
@ -1,78 +0,0 @@
|
|||||||
import { DateTime } from 'luxon'
|
|
||||||
import React, { PureComponent } from 'react'
|
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
import HomeNotification from '../home-notification'
|
|
||||||
|
|
||||||
export default class DaiV1MigrationNotification extends PureComponent {
|
|
||||||
static contextTypes = {
|
|
||||||
t: PropTypes.func,
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
mkrMigrationReminderTimestamp: null,
|
|
||||||
string: '',
|
|
||||||
symbol: '',
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
setMkrMigrationReminderTimestamp: PropTypes.func.isRequired,
|
|
||||||
mkrMigrationReminderTimestamp: PropTypes.string,
|
|
||||||
string: PropTypes.string,
|
|
||||||
symbol: PropTypes.string,
|
|
||||||
}
|
|
||||||
|
|
||||||
remindMeLater = () => {
|
|
||||||
const nextWeek = DateTime.utc().plus({
|
|
||||||
days: 7,
|
|
||||||
})
|
|
||||||
this.props.setMkrMigrationReminderTimestamp(nextWeek.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { t } = this.context
|
|
||||||
const { mkrMigrationReminderTimestamp, string: balanceString, symbol } = this.props
|
|
||||||
|
|
||||||
if (mkrMigrationReminderTimestamp) {
|
|
||||||
const reminderDateTime = DateTime.fromISO(mkrMigrationReminderTimestamp, {
|
|
||||||
zone: 'UTC',
|
|
||||||
})
|
|
||||||
if (reminderDateTime > DateTime.utc()) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!balanceString || !symbol) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (balanceString === '0') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<HomeNotification
|
|
||||||
descriptionText={(
|
|
||||||
<div>
|
|
||||||
{t('migrateSai')}
|
|
||||||
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
onClick={() => {
|
|
||||||
window.open('https://blog.makerdao.com/multi-collateral-dai-is-live/', '_blank', 'noopener')
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t('learnMore')}.
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
acceptText={t('migrate')}
|
|
||||||
onAccept={() => {
|
|
||||||
window.open('https://migrate.makerdao.com', '_blank', 'noopener')
|
|
||||||
}}
|
|
||||||
ignoreText={t('remindMeLater')}
|
|
||||||
onIgnore={this.remindMeLater}
|
|
||||||
infoText={t('migrateSaiInfo')}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
import { connect } from 'react-redux'
|
|
||||||
import { compose } from 'redux'
|
|
||||||
import DaiMigrationNotification from './dai-migration-notification.component'
|
|
||||||
import withTokenTracker from '../../../helpers/higher-order-components/with-token-tracker'
|
|
||||||
import { getSelectedAddress, getDaiV1Token } from '../../../selectors/selectors'
|
|
||||||
import { setMkrMigrationReminderTimestamp } from '../../../store/actions'
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
|
||||||
const {
|
|
||||||
metamask: {
|
|
||||||
mkrMigrationReminderTimestamp,
|
|
||||||
},
|
|
||||||
} = state
|
|
||||||
|
|
||||||
const userAddress = getSelectedAddress(state)
|
|
||||||
const oldDai = getDaiV1Token(state)
|
|
||||||
|
|
||||||
return {
|
|
||||||
mkrMigrationReminderTimestamp,
|
|
||||||
userAddress,
|
|
||||||
token: oldDai,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
|
||||||
return {
|
|
||||||
setMkrMigrationReminderTimestamp: (t) => dispatch(setMkrMigrationReminderTimestamp(t)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default compose(
|
|
||||||
connect(mapStateToProps, mapDispatchToProps),
|
|
||||||
withTokenTracker,
|
|
||||||
)(DaiMigrationNotification)
|
|
@ -1 +0,0 @@
|
|||||||
export { default } from './dai-migration-notification.container'
|
|
@ -5,7 +5,6 @@ import { Redirect, Route } from 'react-router-dom'
|
|||||||
import { formatDate } from '../../helpers/utils/util'
|
import { formatDate } from '../../helpers/utils/util'
|
||||||
import AssetList from '../../components/app/asset-list'
|
import AssetList from '../../components/app/asset-list'
|
||||||
import HomeNotification from '../../components/app/home-notification'
|
import HomeNotification from '../../components/app/home-notification'
|
||||||
import DaiMigrationNotification from '../../components/app/dai-migration-component'
|
|
||||||
import MultipleNotifications from '../../components/app/multiple-notifications'
|
import MultipleNotifications from '../../components/app/multiple-notifications'
|
||||||
import WalletView from '../../components/app/wallet-view'
|
import WalletView from '../../components/app/wallet-view'
|
||||||
import TransactionList from '../../components/app/transaction-list'
|
import TransactionList from '../../components/app/transaction-list'
|
||||||
@ -30,10 +29,6 @@ export default class Home extends PureComponent {
|
|||||||
t: PropTypes.func,
|
t: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
hasDaiV1Token: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
history: PropTypes.object,
|
history: PropTypes.object,
|
||||||
forgottenPassword: PropTypes.bool,
|
forgottenPassword: PropTypes.bool,
|
||||||
@ -50,7 +45,6 @@ export default class Home extends PureComponent {
|
|||||||
restoreFromThreeBox: PropTypes.func,
|
restoreFromThreeBox: PropTypes.func,
|
||||||
setShowRestorePromptToFalse: PropTypes.func,
|
setShowRestorePromptToFalse: PropTypes.func,
|
||||||
threeBoxLastUpdated: PropTypes.number,
|
threeBoxLastUpdated: PropTypes.number,
|
||||||
hasDaiV1Token: PropTypes.bool,
|
|
||||||
firstPermissionsRequestId: PropTypes.string,
|
firstPermissionsRequestId: PropTypes.string,
|
||||||
totalUnapprovedCount: PropTypes.number.isRequired,
|
totalUnapprovedCount: PropTypes.number.isRequired,
|
||||||
setConnectedStatusPopoverHasBeenShown: PropTypes.func,
|
setConnectedStatusPopoverHasBeenShown: PropTypes.func,
|
||||||
@ -114,7 +108,6 @@ export default class Home extends PureComponent {
|
|||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const {
|
const {
|
||||||
history,
|
history,
|
||||||
hasDaiV1Token,
|
|
||||||
shouldShowSeedPhraseReminder,
|
shouldShowSeedPhraseReminder,
|
||||||
isPopup,
|
isPopup,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
@ -168,11 +161,6 @@ export default class Home extends PureComponent {
|
|||||||
)
|
)
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
{
|
|
||||||
hasDaiV1Token
|
|
||||||
? <DaiMigrationNotification />
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
</MultipleNotifications>
|
</MultipleNotifications>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
} from '../../selectors/confirm-transaction'
|
} from '../../selectors/confirm-transaction'
|
||||||
import {
|
import {
|
||||||
getCurrentEthBalance,
|
getCurrentEthBalance,
|
||||||
getDaiV1Token,
|
|
||||||
getFirstPermissionRequest,
|
getFirstPermissionRequest,
|
||||||
getTotalUnapprovedCount,
|
getTotalUnapprovedCount,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors/selectors'
|
||||||
@ -60,7 +59,6 @@ const mapStateToProps = (state) => {
|
|||||||
showRestorePrompt,
|
showRestorePrompt,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
threeBoxLastUpdated,
|
threeBoxLastUpdated,
|
||||||
hasDaiV1Token: Boolean(getDaiV1Token(state)),
|
|
||||||
firstPermissionsRequestId,
|
firstPermissionsRequestId,
|
||||||
totalUnapprovedCount,
|
totalUnapprovedCount,
|
||||||
connectedStatusPopoverHasBeenShown,
|
connectedStatusPopoverHasBeenShown,
|
||||||
|
@ -220,12 +220,6 @@ export function getAddressBookEntryName (state, address) {
|
|||||||
return entry && entry.name !== '' ? entry.name : shortenAddress(address)
|
return entry && entry.name !== '' ? entry.name : shortenAddress(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDaiV1Token (state) {
|
|
||||||
const OLD_DAI_CONTRACT_ADDRESS = '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359'
|
|
||||||
const tokens = state.metamask.tokens || []
|
|
||||||
return tokens.find(({ address }) => checksumAddress(address) === OLD_DAI_CONTRACT_ADDRESS)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function accountsWithSendEtherInfoSelector (state) {
|
export function accountsWithSendEtherInfoSelector (state) {
|
||||||
const accounts = getMetaMaskAccounts(state)
|
const accounts = getMetaMaskAccounts(state)
|
||||||
const { identities } = state.metamask
|
const { identities } = state.metamask
|
||||||
|
@ -2134,16 +2134,6 @@ export function setLastActiveTime () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setMkrMigrationReminderTimestamp (timestamp) {
|
|
||||||
return (dispatch) => {
|
|
||||||
background.setMkrMigrationReminderTimestamp(timestamp, (err) => {
|
|
||||||
if (err) {
|
|
||||||
return dispatch(displayWarning(err.message))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setConnectedStatusPopoverHasBeenShown () {
|
export function setConnectedStatusPopoverHasBeenShown () {
|
||||||
return () => {
|
return () => {
|
||||||
background.setConnectedStatusPopoverHasBeenShown((err) => {
|
background.setConnectedStatusPopoverHasBeenShown((err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user