-
Notifications
You must be signed in to change notification settings - Fork 156
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
Migrations: ensure native currency names & symbols #1468
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -781,14 +781,6 @@ const migrations = { | |
|
||
initial.main.tokens.known = knownTokens | ||
|
||
const nameNotSet = (chainId) => { | ||
const meta = initial.main.networksMeta.ethereum[chainId] | ||
return meta && !meta.nativeCurrency.name | ||
} | ||
|
||
if (nameNotSet(100)) initial.main.networksMeta.ethereum[100].nativeCurrency.name = 'xDAI' | ||
if (nameNotSet(137)) initial.main.networksMeta.ethereum[137].nativeCurrency.name = 'Matic' | ||
|
||
return initial | ||
}, | ||
33: (initial) => { | ||
|
@@ -856,6 +848,54 @@ const migrations = { | |
} | ||
} | ||
|
||
return initial | ||
}, | ||
34: (initial) => { | ||
// Add any missing nativeCurrency name values | ||
// Base Görli (84531) value added in #33 | ||
const nativeCurrencyMap = { | ||
1: { | ||
name: 'Ether', | ||
symbol: 'ETH' | ||
}, | ||
5: { | ||
name: 'Görli Ether', | ||
symbol: 'görETH' | ||
}, | ||
10: { | ||
name: 'Ether', | ||
symbol: 'ETH' | ||
}, | ||
100: { | ||
name: 'xDAI', | ||
symbol: 'xDAI' | ||
}, | ||
137: { | ||
name: 'Matic', | ||
symbol: 'MATIC' | ||
}, | ||
42161: { | ||
name: 'Ether', | ||
symbol: 'ETH' | ||
}, | ||
11155111: { | ||
name: 'Sepolia Ether', | ||
symbol: 'sepETH' | ||
} | ||
} | ||
|
||
Object.values(initial.main.networks.ethereum).forEach((network) => { | ||
const { id } = network | ||
const { name = '', symbol = '' } = nativeCurrencyMap[id] || {} | ||
const nativeCurrency = initial.main.networksMeta.ethereum[id].nativeCurrency | ||
|
||
initial.main.networksMeta.ethereum[id].nativeCurrency = { | ||
...nativeCurrency, | ||
name: nativeCurrency.name || name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Using the spread should assign the name from nativeCurrency if it exists, couldn't we set the default data first and then spread on top? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually not sure this works - tests fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would assign the name to what was in |
||
symbol: nativeCurrency.symbol || symbol | ||
} | ||
}) | ||
|
||
return initial | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we assume that this chain exists in
networksMeta
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1476