-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3853 from MetaMask/i3580-InternationalizeCurrency
Internationalize currency
- Loading branch information
Showing
12 changed files
with
1,235 additions
and
1,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"metamask": { | ||
"isInitialized": true, | ||
"isUnlocked": true, | ||
"featureFlags": {"betaUI": true}, | ||
"rpcTarget": "https://rawtestrpc.metamask.io/", | ||
"identities": { | ||
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": { | ||
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", | ||
"name": "Send Account 1" | ||
}, | ||
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": { | ||
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb", | ||
"name": "Send Account 2" | ||
}, | ||
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": { | ||
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d", | ||
"name": "Send Account 3" | ||
}, | ||
"0xd85a4b6a394794842887b8284293d69163007bbb": { | ||
"address": "0xd85a4b6a394794842887b8284293d69163007bbb", | ||
"name": "Send Account 4" | ||
} | ||
}, | ||
"unapprovedTxs": {}, | ||
"currentCurrency": "USD", | ||
"conversionRate": 19855, | ||
"conversionDate": 1489013762, | ||
"noActiveNotices": true, | ||
"frequentRpcList": [], | ||
"network": "3", | ||
"accounts": { | ||
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": { | ||
"code": "0x", | ||
"balance": "0x47c9d71831c76efe", | ||
"nonce": "0x1b", | ||
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825" | ||
}, | ||
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": { | ||
"code": "0x", | ||
"balance": "0x37452b1315889f80", | ||
"nonce": "0xa", | ||
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb" | ||
}, | ||
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": { | ||
"code": "0x", | ||
"balance": "0x30c9d71831c76efe", | ||
"nonce": "0x1c", | ||
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d" | ||
}, | ||
"0xd85a4b6a394794842887b8284293d69163007bbb": { | ||
"code": "0x", | ||
"balance": "0x0", | ||
"nonce": "0x0", | ||
"address": "0xd85a4b6a394794842887b8284293d69163007bbb" | ||
} | ||
}, | ||
"addressBook": [ | ||
{ | ||
"address": "0x06195827297c7a80a443b6894d3bdb8824b43896", | ||
"name": "Address Book Account 1" | ||
} | ||
], | ||
"tokens": [], | ||
"transactions": {}, | ||
"selectedAddressTxList": [], | ||
"unapprovedMsgs": {}, | ||
"unapprovedMsgCount": 0, | ||
"unapprovedPersonalMsgs": {}, | ||
"unapprovedPersonalMsgCount": 0, | ||
"keyringTypes": [ | ||
"Simple Key Pair", | ||
"HD Key Tree" | ||
], | ||
"keyrings": [ | ||
{ | ||
"type": "HD Key Tree", | ||
"accounts": [ | ||
"fdea65c8e26263f6d9a1b5de9555d2931a33b825", | ||
"c5b8dbac4c1d3f152cdeb400e2313f309c410acb", | ||
"2f8d4a878cfa04a6e60d46362f5644deab66572d" | ||
] | ||
}, | ||
{ | ||
"type": "Simple Key Pair", | ||
"accounts": [ | ||
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825" | ||
] | ||
} | ||
], | ||
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", | ||
"currentCurrency": "PHP", | ||
"provider": { | ||
"type": "testnet" | ||
}, | ||
"shapeShiftTxList": [], | ||
"lostAccounts": [], | ||
"send": { | ||
"gasLimit": null, | ||
"gasPrice": null, | ||
"gasTotal": "0xb451dc41b578", | ||
"tokenBalance": null, | ||
"from": "", | ||
"to": "", | ||
"amount": "0x0", | ||
"memo": "", | ||
"errors": {}, | ||
"maxModeOn": false, | ||
"editingTransactionId": null | ||
}, | ||
"currentLocale": "en" | ||
}, | ||
"appState": { | ||
"menuOpen": false, | ||
"currentView": { | ||
"name": "accountDetail", | ||
"detailView": null, | ||
"context": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc" | ||
}, | ||
"accountDetail": { | ||
"subview": "transactions" | ||
}, | ||
"modal": { | ||
"modalState": {}, | ||
"previousModalState": {} | ||
}, | ||
"transForward": true, | ||
"isLoading": false, | ||
"warning": null, | ||
"scrollToBottom": false, | ||
"forgottenPassword": null | ||
}, | ||
"identities": {} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const reactTriggerChange = require('../../lib/react-trigger-change') | ||
const { | ||
timeout, | ||
queryAsync, | ||
findAsync, | ||
} = require('../../lib/util') | ||
|
||
QUnit.module('currency localization') | ||
|
||
QUnit.test('renders localized currency', (assert) => { | ||
const done = assert.async() | ||
runCurrencyLocalizationTest(assert).then(done).catch((err) => { | ||
assert.notOk(err, `Error was thrown: ${err.stack}`) | ||
done() | ||
}) | ||
}) | ||
|
||
async function runCurrencyLocalizationTest(assert, done) { | ||
console.log('*** start runCurrencyLocalizationTest') | ||
const selectState = await queryAsync($, 'select') | ||
selectState.val('currency localization') | ||
reactTriggerChange(selectState[0]) | ||
await timeout(1000) | ||
const txView = await queryAsync($, '.tx-view') | ||
const heroBalance = await findAsync($(txView), '.hero-balance') | ||
const fiatAmount = await findAsync($(heroBalance), '.fiat-amount') | ||
assert.equal(fiatAmount[0].textContent, '₱102,707.97') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const assert = require('assert') | ||
const currencyFormatter = require('currency-formatter') | ||
const infuraConversion = require('../../ui/app/infura-conversion.json') | ||
|
||
describe('currencyFormatting', function () { | ||
it('be able to format any infura currency', function (done) { | ||
const number = 10000 | ||
|
||
infuraConversion.objects.forEach((conversion) => { | ||
const code = conversion.quote.code.toUpperCase() | ||
const result = currencyFormatter.format(number, { code }) | ||
|
||
switch (code) { | ||
case 'USD': | ||
assert.equal(result, '$10,000.00') | ||
break | ||
case 'JPY': | ||
assert.equal(result, '¥10,000') | ||
break | ||
default: | ||
assert.ok(result, `Currency ${code} formatted as ${result}`) | ||
} | ||
}) | ||
|
||
done() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.