Skip to content

Commit 6b536a4

Browse files
authored
Merge pull request #748 from nervosnetwork/rc/v0.16.0-alpha.2
[ᚬmaster] Rc/v0.16.0 alpha.2
2 parents 1fc1a0c + 1c9709f commit 6b536a4

File tree

12 files changed

+40
-28
lines changed

12 files changed

+40
-28
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# [0.16.0-alpha.2](https://github.com/nervosnetwork/neuron/compare/v0.16.0-alpha.1...v0.16.0-alpha.2) (2019-07-26)
2+
3+
4+
### Features
5+
6+
* Update app icon ([17936c4](https://github.com/nervosnetwork/neuron/commit/17936c4))
7+
* **neuron-ui:** display balance with thousandth delimiter ([07e4370](https://github.com/nervosnetwork/neuron/commit/07e4370))
8+
9+
10+
111
# [0.16.0-alpha.1](https://github.com/nervosnetwork/neuron/compare/v0.16.0-alpha.0...v0.16.0-alpha.1) (2019-07-26)
212

313

@@ -19,4 +29,3 @@
1929
* subscribe network list from neuron-wallet in neuron-ui ([b56ae1c](https://github.com/nervosnetwork/neuron/commit/b56ae1c))
2030

2131

22-

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.16.0-alpha.1",
5+
"version": "0.16.0-alpha.2",
66
"npmClient": "yarn",
77
"useWorkspaces": true
88
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@nervosnetwork/neuron",
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
5-
"version": "0.16.0-alpha.1",
5+
"version": "0.16.0-alpha.2",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",

packages/neuron-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nervosnetwork/neuron-ui",
3-
"version": "0.16.0-alpha.1",
3+
"version": "0.16.0-alpha.2",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

packages/neuron-ui/public/favicon.ico

100755100644
661 Bytes
Binary file not shown.

packages/neuron-ui/public/icon.png

-25.2 KB
Loading

packages/neuron-ui/src/utils/formatters.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ describe(`formatters`, () => {
144144
},
145145
{
146146
source: `1234567890123456789012345678901234567890123456789012345678901234567890123400000000`,
147-
target: `12345678901234567890123456789012345678901234567890123456789012345678901234`,
147+
target: `12,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678,901,234`,
148148
},
149149
{
150150
source: `12345678901234567890123456789012345678901234567890123456789012345678901234`,
151-
target: `123456789012345678901234567890123456789012345678901234567890123456.78901234`,
151+
target: `123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456.78901234`,
152152
},
153153
{
154154
source: `1234567890123456789012345678901234567890123456789012345678901234567890123400`,
155-
target: `12345678901234567890123456789012345678901234567890123456789012345678.901234`,
155+
target: `12,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678.901234`,
156156
},
157157

158158
{
@@ -173,15 +173,15 @@ describe(`formatters`, () => {
173173
},
174174
{
175175
source: `-1234567890123456789012345678901234567890123456789012345678901234567890123400000000`,
176-
target: `-12345678901234567890123456789012345678901234567890123456789012345678901234`,
176+
target: `-12,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678,901,234`,
177177
},
178178
{
179179
source: `-12345678901234567890123456789012345678901234567890123456789012345678901234`,
180-
target: `-123456789012345678901234567890123456789012345678901234567890123456.78901234`,
180+
target: `-123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456.78901234`,
181181
},
182182
{
183183
source: `-1234567890123456789012345678901234567890123456789012345678901234567890123400`,
184-
target: `-12345678901234567890123456789012345678901234567890123456789012345678.901234`,
184+
target: `-12,345,678,901,234,567,890,123,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678.901234`,
185185
},
186186
{
187187
source: `0`,

packages/neuron-ui/src/utils/formatters.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,26 @@ export const CKBToShannonFormatter = (amount: string, uint: CapacityUnit) => {
8383

8484
export const shannonToCKBFormatter = (shannon: string) => {
8585
const sign = shannon.startsWith('-') ? '-' : ''
86-
const unsignedShannon = shannon.replace(/^-/, '')
87-
let unsignedCkbStr = [...unsignedShannon.padStart(8, '0')]
88-
.map((char, idx) => {
89-
if (idx === Math.max(unsignedShannon.length - 8, 0)) {
90-
return `.${char}`
91-
}
92-
return char
93-
})
94-
.join('')
95-
.replace(/(^0+|\.?0+$)/g, '')
96-
if (!unsignedCkbStr) {
97-
return '0'
86+
const unsignedShannon = shannon.replace(/^-?0*/, '')
87+
let unsignedCKB = ''
88+
if (unsignedShannon.length <= 8) {
89+
unsignedCKB = `0.${unsignedShannon.padStart(8, '0')}`.replace(/\.?0+$/, '')
90+
} else {
91+
const decimal = `.${unsignedShannon.slice(-8)}`.replace(/\.?0+$/, '')
92+
const int = unsignedShannon.slice(0, -8).replace(/\^0+/, '')
93+
unsignedCKB = `${(
94+
int
95+
.split('')
96+
.reverse()
97+
.join('')
98+
.match(/\d{1,3}/g) || ['0']
99+
)
100+
.join(',')
101+
.split('')
102+
.reverse()
103+
.join('')}${decimal}`
98104
}
99-
if (unsignedCkbStr.startsWith('.')) {
100-
unsignedCkbStr = `0${unsignedCkbStr}`
101-
}
102-
return sign + unsignedCkbStr
105+
return +unsignedCKB === 0 ? '0' : `${sign}${unsignedCKB}`
103106
}
104107

105108
export const localNumberFormatter = (num: string | number = 0) => {
-53.1 KB
Binary file not shown.
-4.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)