Skip to content

Commit

Permalink
Merge pull request #2051 from CityOfZion/release/2.6.2
Browse files Browse the repository at this point in the history
release: 2.6.2
  • Loading branch information
comountainclimber authored Jan 18, 2021
2 parents c0db706 + 74b3885 commit 5f7882a
Show file tree
Hide file tree
Showing 11 changed files with 650 additions and 102 deletions.
87 changes: 86 additions & 1 deletion __tests__/components/__snapshots__/Settings.test.js.snap

Large diffs are not rendered by default.

77 changes: 68 additions & 9 deletions app/actions/balancesActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import { api } from '@cityofzion/neon-js'
import { api, u, rpc, sc, wallet } from '@cityofzion/neon-js'
import { extend, isEmpty, get } from 'lodash-es'
import { createActions } from 'spunky'
import { Howl } from 'howler'
Expand All @@ -13,7 +13,12 @@ import { COIN_DECIMAL_LENGTH } from '../core/formatters'
import { toBigNumber } from '../core/math'
import { findNetworkByDeprecatedLabel } from '../core/networks'

const MAX_SCRIPT_HASH_CHUNK_SIZE = 3
const { reverseHex, hexstring2str } = u
const { Query } = rpc
const { ScriptBuilder } = sc
const { getScriptHashFromAddress } = wallet

const MAX_SCRIPT_HASH_CHUNK_SIZE = 20

type Props = {
net: string,
Expand Down Expand Up @@ -73,6 +78,62 @@ function determineIfBalanceUpdated(
})
}

const parseDecimals = VMOutput => {
if (VMOutput === '') return 0
return parseInt(VMOutput, 10)
}

const parseHexNum = hex => (hex ? parseInt(reverseHex(hex), 16) : 0)

function NumberParser(item, decimals) {
switch (item.type) {
case 'Integer':
return new u.Fixed8(item.value).div(100000000)
case 'ByteArray':
// eslint-disable-next-line
return parseHexNum(item.value) / Math.pow(10, decimals)
default:
throw new Error(`Received invalid type ${item.type}`)
}
}

const getTokenBalances = (url, scriptHashArray, address) => {
const addrScriptHash = reverseHex(getScriptHashFromAddress(address))
const sb = new ScriptBuilder()

scriptHashArray.forEach(scriptHash => {
sb.emitAppCall(scriptHash, 'symbol')
.emitAppCall(scriptHash, 'decimals')
.emitAppCall(scriptHash, 'balanceOf', [addrScriptHash])
})
return Query.invokeScript(sb.str, false)
.execute(url)
.then(res => {
const tokenList = {}
if (
res &&
res.result &&
res.result.stack &&
res.result.stack.length >= 3
) {
for (let i = 0; i < res.result.stack.length; i += 3) {
try {
const symbol = hexstring2str(res.result.stack[i].value)
const decimals = parseDecimals(res.result.stack[i + 1].value)
tokenList[symbol] = NumberParser(res.result.stack[i + 2], decimals)
} catch (e) {
throw e
}
}
}
return tokenList
})
.catch(err => {
console.error({ err })
throw err
})
}

let RETRY_COUNT = 0

async function getBalances({ net, address, isRetry = false }: Props) {
Expand Down Expand Up @@ -122,13 +183,11 @@ async function getBalances({ net, address, isRetry = false }: Props) {
// NOTE: because the RPC nodes will respond with the contract
// symbol name, we need to use our original token list
// in case two tokens have the same symbol (SWTH vs SWTH OLD)
const balanceResults = await api.nep5
.getTokenBalances(
endpoint,
chunk.map(({ scriptHash }) => scriptHash),
address,
)
.catch(e => Promise.reject(e))
const balanceResults = await getTokenBalances(
endpoint,
chunk.map(({ scriptHash }) => scriptHash),
address,
).catch(e => Promise.reject(e))

const hashBasedBalance = {}

Expand Down
14 changes: 14 additions & 0 deletions app/assets/flags/dutch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 35 additions & 3 deletions app/components/Modals/ReleaseNotesModal/ReleaseNotesModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,41 @@ const ReleaseNotesModal = ({ hideModal, theme }: Props) => (
)}
>
<div className={styles.releaseNotesContents}>
<div className={styles.release}>
<div className={styles.releaseContent}>
<small className={styles.date}>Jan 18th 2021 </small>
<h3>Patch v2.6.2</h3>

<p>
In this update you will find the following minor improvements:
<br />
<br />
<li>Fixes bug related to SWTH contract</li>
<li>
Adds dutch translation{' '}
<span aria-label="party" role="img">
🇳🇱🎉
</span>{' '}
</li>
<li>Performance enhancements</li>
<br />
View full details of this release on GitHub
<br />
</p>

<Github
onClick={() =>
electron.shell.openExternal(
'https://github.com/CityOfZion/neon-wallet/releases/tag/v2.6.2',
)
}
/>
</div>
<div className={styles.marketingImage}>
{theme === 'Light' ? <PatchLight /> : <PatchDark />}
</div>
</div>

<div className={styles.release}>
<div className={styles.releaseContent}>
<small className={styles.date}>Dec 1st 2020 </small>
Expand All @@ -67,9 +102,6 @@ const ReleaseNotesModal = ({ hideModal, theme }: Props) => (
}
/>
</div>
<div className={styles.marketingImage}>
{theme === 'Light' ? <PatchLight /> : <PatchDark />}
</div>
</div>

<div className={styles.release}>
Expand Down
2 changes: 2 additions & 0 deletions app/components/Root/IntlWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
turkish,
arabic,
russian,
dutch,
} = translations

type IntlWrapperProps = {
Expand All @@ -40,6 +41,7 @@ const tranlationsMappings = {
[LANGUAGES.TURKISH.value]: turkish,
[LANGUAGES.ARABIC.value]: arabic,
[LANGUAGES.RUSSIAN.value]: russian,
[LANGUAGES.DUTCH.value]: dutch,
}

class IntlWrapper extends React.Component<IntlWrapperProps> {
Expand Down
6 changes: 6 additions & 0 deletions app/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Vietnam from '../assets/flags/vietnam.svg'
import Korea from '../assets/flags/south-korea.svg'
import UnitedArabEmirates from '../assets/flags/united-arab-emirates.svg'
import Russia from '../assets/flags/russia.svg'
import Dutch from '../assets/flags/dutch.svg'

export const NEON_WALLET_RELEASE_LINK =
'https://github.com/CityOfZion/neon-wallet/releases'
Expand Down Expand Up @@ -102,6 +103,11 @@ export const LANGUAGES = {
value: 'RUSSIAN',
renderFlag: () => <Russia alt="Русский" />,
},
DUTCH: {
label: 'Nederlands',
value: 'DUTCH',
renderFlag: () => <Dutch alt="Nederlands" />,
},
}

export const DEFAULT_LANGUAGE = LANGUAGES.ENGLISH.value
Expand Down
52 changes: 26 additions & 26 deletions app/core/tokenList.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@
}
}
},
"SWTH V2": {
"symbol": "SWTH (OLD)",
"companyName": "Switcheo",
"type": "NEP5",
"networks": {
"1": {
"name": "Switcheo Legacy V2",
"hash": "ab38352559b8b203bde5fddfa0b07d8b2525e132",
"decimals": 8,
"totalSupply": 1000000000
}
}
},
"CGL": {
"symbol": "CGL",
"companyName": "CrazyGladiator",
Expand Down Expand Up @@ -842,32 +855,6 @@
}
}
},
"SWTH V2": {
"symbol": "SWTH (OLD)",
"companyName": "Switcheo",
"type": "NEP5",
"networks": {
"1": {
"name": "Switcheo Legacy V2",
"hash": "ab38352559b8b203bde5fddfa0b07d8b2525e132",
"decimals": 8,
"totalSupply": 1000000000
}
}
},
"SWTH V3": {
"symbol": "SWTH",
"companyName": "Switcheo",
"type": "NEP5",
"networks": {
"1": {
"name": "Switcheo V3",
"hash": "3e09e602eeeb401a2fec8e8ea137d59aae54a139",
"decimals": 8,
"totalSupply": 1000000000
}
}
},
"THOR": {
"symbol": "THOR",
"companyName": "Thor Token",
Expand Down Expand Up @@ -1058,5 +1045,18 @@
},
"image":
"https://rawgit.com/CityOfZion/neo-tokens/master/assets/png/zpt.png"
},
"SWTH V3": {
"symbol": "SWTH",
"companyName": "Switcheo",
"type": "NEP5",
"networks": {
"1": {
"name": "Switcheo V3",
"hash": "3e09e602eeeb401a2fec8e8ea137d59aae54a139",
"decimals": 8,
"totalSupply": 1000000000
}
}
}
}
Loading

0 comments on commit 5f7882a

Please sign in to comment.