diff --git a/__tests__/actions/transactionHistoryActions.test.js b/__tests__/actions/transactionHistoryActions.test.js
index da0decafd..698c30de2 100644
--- a/__tests__/actions/transactionHistoryActions.test.js
+++ b/__tests__/actions/transactionHistoryActions.test.js
@@ -1,90 +1,119 @@
import React from 'react'
import { computeN3Activity } from '../../app/actions/transactionHistoryActions'
+import { ipcRenderer } from 'electron'
describe('N3ClaimTest', () => {
- const addr = 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt'
- const netwrk = 'MainNet'
- const transactions = {
- items: [{
+ const addr = 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt'
+ const netwrk = 'MainNet'
+ const transactions = {
+ items: [
+ {
+ block: 3080890,
+ hash:
+ '0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7',
+ invocations: [
+ {
block: 3080890,
- hash: "0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7",
- invocations: [{
- block: 3080890,
- hash: "0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7",
- metadata: {
- amount: 0,
- contract_name: "NeoToken",
- data: "",
- from: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- image: "http://localhost:3000/dist1ac81dc19335d81d593ebec5757d5a71.png",
- scripthash: "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
- summary: "NeoToken transfer to NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- symbol: "NEO",
- to: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt"},
- netfee: "122752",
- sender: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- sysfee: "997775",
- time: "1678191213.077000",
- type: "nep17_transfer",
- vmstate: "HALT"}],
- netfee: "122752",
- notifications: [{
- contract: "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
- event_name: "Transfer",
- state: [{
- type: "ByteString",
- value: "vhy7ee8QtmaZ7MtM2XIJ+vhZg44="
- }, {
- type: "ByteString",
- value: "vhy7ee8QtmaZ7MtM2XIJ+vhZg44="
- }, {
- type: "Integer",
- value: "0"
- }]
- }, {
- contract: "0xd2a4cff31913016155e38e474a2c06d08be276cf",
- event_name: "Transfer",
- state: [{
- type: "Any"
- }, {
- type: "ByteString",
- value: "vhy7ee8QtmaZ7MtM2XIJ+vhZg44="
- }, {
- type: "Integer",
- value: "233475354"
- }]
- }],
- sender: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- sysfee: "997775",
- time: "1678191213.077000",
- transfers: [{
- amount: "0",
- block: 3080890,
- from: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- scripthash: "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
- time: "1678191213.077000",
- to: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- transferindex: "3080890.2",
- txid: "0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7"
- }, {
- amount: "233475354",
- block: 3080890,
- from: "mint",
- scripthash: "0xd2a4cff31913016155e38e474a2c06d08be276cf",
- time: "1678191213.077000",
- to: "NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt",
- transferindex: "3080890.3",
- txid: "0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7"
- }],
- vmstate: "HALT"
- }]
- }
+ hash:
+ '0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7',
+ metadata: {
+ amount: 0,
+ contract_name: 'NeoToken',
+ data: '',
+ from: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ image:
+ 'http://localhost:3000/dist1ac81dc19335d81d593ebec5757d5a71.png',
+ scripthash: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5',
+ summary:
+ 'NeoToken transfer to NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ symbol: 'NEO',
+ to: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ },
+ netfee: '122752',
+ sender: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ sysfee: '997775',
+ time: '1678191213.077000',
+ type: 'nep17_transfer',
+ vmstate: 'HALT',
+ },
+ ],
+ netfee: '122752',
+ notifications: [
+ {
+ contract: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5',
+ event_name: 'Transfer',
+ state: [
+ {
+ type: 'ByteString',
+ value: 'vhy7ee8QtmaZ7MtM2XIJ+vhZg44=',
+ },
+ {
+ type: 'ByteString',
+ value: 'vhy7ee8QtmaZ7MtM2XIJ+vhZg44=',
+ },
+ {
+ type: 'Integer',
+ value: '0',
+ },
+ ],
+ },
+ {
+ contract: '0xd2a4cff31913016155e38e474a2c06d08be276cf',
+ event_name: 'Transfer',
+ state: [
+ {
+ type: 'Any',
+ },
+ {
+ type: 'ByteString',
+ value: 'vhy7ee8QtmaZ7MtM2XIJ+vhZg44=',
+ },
+ {
+ type: 'Integer',
+ value: '233475354',
+ },
+ ],
+ },
+ ],
+ sender: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ sysfee: '997775',
+ time: '1678191213.077000',
+ transfers: [
+ {
+ amount: '0',
+ block: 3080890,
+ from: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ scripthash: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5',
+ time: '1678191213.077000',
+ to: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ transferindex: '3080890.2',
+ txid:
+ '0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7',
+ },
+ {
+ amount: '233475354',
+ block: 3080890,
+ from: 'mint',
+ scripthash: '0xd2a4cff31913016155e38e474a2c06d08be276cf',
+ time: '1678191213.077000',
+ to: 'NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ transferindex: '3080890.3',
+ txid:
+ '0xe634006ad06edeab24160c2fb6e42f623a1e3163eea952fdfc0df186f86b50b7',
+ },
+ ],
+ vmstate: 'HALT',
+ },
+ ],
+ }
- test('should update the tx so it appears to be a Gas claim', async () => {
- const wrapper = await computeN3Activity(transactions, addr, netwrk)
- expect(wrapper[0].type).toEqual("CLAIM")
- expect(wrapper[0].metadata.summary).toEqual("GAS Claim to NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt")
- expect(wrapper[0].metadata.symbol).toEqual('GAS')
- expect(wrapper[0].metadata.amount).toEqual(2.33475354)
- })
+ test('should update the tx so it appears to be a Gas claim', async () => {
+ const wrapper = await computeN3Activity(transactions, addr, netwrk)
+ expect(wrapper[0].type).toEqual('CLAIM')
+ expect(wrapper[0].metadata.summary).toEqual(
+ 'GAS Claim to NdFBzZVMUXjdwnaDfeMK4zEVYEzjiVhFBt',
+ )
+ expect(wrapper[0].metadata.symbol).toEqual('GAS')
+ expect(wrapper[0].metadata.amount).toEqual(2.33475354)
+ })
})
diff --git a/__tests__/core/explorer.test.js b/__tests__/core/explorer.test.js
index 1aa9b8afe..508803151 100644
--- a/__tests__/core/explorer.test.js
+++ b/__tests__/core/explorer.test.js
@@ -46,22 +46,6 @@ describe('explorer tests', () => {
expect(getExplorerTxLink(networkId, explorer, txId)).toEqual(expectedUrl)
})
- test('NeoScan mainnet explorer test', () => {
- const networkId = MAIN_NETWORK_ID
- const explorer = DEPRECATED_EXPLORERS.NEO_SCAN
- const expectedUrl = `https://neoscan.io/transaction/${txId}`
-
- expect(getExplorerTxLink(networkId, explorer, txId)).toEqual(expectedUrl)
- })
-
- test('NeoScan testnet explorer test', () => {
- const networkId = TEST_NETWORK_ID
- const explorer = DEPRECATED_EXPLORERS.NEO_SCAN
- const expectedUrl = `https://neoscan-testnet.io/transaction/${txId}`
-
- expect(getExplorerTxLink(networkId, explorer, txId)).toEqual(expectedUrl)
- })
-
test('AntChain mainnet explorer test', () => {
const networkId = MAIN_NETWORK_ID
const explorer = EXPLORERS.ANT_CHAIN
@@ -133,26 +117,6 @@ describe('explorer tests', () => {
)
})
- test('NeoScan mainnet explorer test', () => {
- const networkId = MAIN_NETWORK_ID
- const explorer = DEPRECATED_EXPLORERS.NEO_SCAN
- const expectedUrl = `https://neoscan.io/address/${address}/1`
-
- expect(getExplorerAddressLink(networkId, explorer, address)).toEqual(
- expectedUrl,
- )
- })
-
- test('NeoScan testnet explorer test', () => {
- const networkId = TEST_NETWORK_ID
- const explorer = DEPRECATED_EXPLORERS.NEO_SCAN
- const expectedUrl = `https://neoscan-testnet.io/address/${address}/1`
-
- expect(getExplorerAddressLink(networkId, explorer, address)).toEqual(
- expectedUrl,
- )
- })
-
test('AntChain mainnet explorer test', () => {
const networkId = MAIN_NETWORK_ID
const explorer = EXPLORERS.ANT_CHAIN
diff --git a/app/actions/balancesActions.js b/app/actions/balancesActions.js
index 783fc4cb5..277fa4412 100644
--- a/app/actions/balancesActions.js
+++ b/app/actions/balancesActions.js
@@ -279,42 +279,30 @@ async function getBalances({ net, address, isRetry = false, chain }: Props) {
}
})
- // asset balances
- const assetBalances = await api
- .getBalanceFrom({ net, address }, api.neoscan)
- .catch(e => console.error(e))
+ const assetBalances = {}
+ const mainnetBalances = await axios.get(
+ `https://dora.coz.io/api/v1/neo2/mainnet/get_balance/${address}`,
+ )
+ mainnetBalances.data.balance.forEach(token => {
+ assetBalances[token.asset_symbol || token.symbol] = {
+ balance: token.amount,
+ hash: token.asset_hash,
+ }
+ })
const testnetBalances = await axios.get(
`https://dora.coz.io/api/v1/neo2/testnet/get_balance/${address}`,
)
const parsedTestNetBalances = {}
-
testnetBalances.data.balance.forEach(token => {
- parsedTestNetBalances[token.asset_symbol || token.symbol] = {
+ parsedTestNetBalances[token.asset] = {
balance: token.amount,
hash: token.asset_hash,
}
})
-
- const assets =
- net === 'MainNet'
- ? get(assetBalances, 'balance.assets', {})
- : parsedTestNetBalances
-
- // The API doesn't always return NEO or GAS keys if, for example, the address only has one asset
- // eslint-disable-next-line
- const neoBalance = assets.NEO
- ? net === 'MainNet'
- ? assets.NEO.balance.toString()
- : assets.NEO.balance
- : '0'
- // eslint-disable-next-line
- const gasBalance = assets.GAS
- ? net === 'MainNet'
- ? assets.GAS.balance.round(COIN_DECIMAL_LENGTH).toString()
- : assets.GAS.balance
- : '0'
-
+ const assets = net === 'MainNet' ? assetBalances : parsedTestNetBalances
+ const neoBalance = assets?.NEO?.balance ?? '0'
+ const gasBalance = assets.GAS?.balance ?? '0'
const parsedAssets = [
{ [ASSETS.NEO]: neoBalance },
{ [ASSETS.GAS]: gasBalance },
diff --git a/app/actions/nodeStorageActions.js b/app/actions/nodeStorageActions.js
index 24f1770bc..e9658a690 100644
--- a/app/actions/nodeStorageActions.js
+++ b/app/actions/nodeStorageActions.js
@@ -140,6 +140,7 @@ export const getRPCEndpoint = async (
error,
},
)
+ // TODO: update this fallback, neoscan is deprecated and this will not work
const endpoint = await api.getRPCEndpointFrom({ net }, api.neoscan)
return endpoint
} finally {
diff --git a/app/actions/voteActions.js b/app/actions/voteActions.js
index d26c94c03..937a24247 100644
--- a/app/actions/voteActions.js
+++ b/app/actions/voteActions.js
@@ -3,6 +3,7 @@ import { api, rpc } from '@cityofzion/neon-js-legacy'
import { createActions } from 'spunky'
import { getNetworkById } from '../core/deprecated'
+import { getNode, getRPCEndpoint } from './nodeStorageActions'
type Props = {
networkId: string,
@@ -15,7 +16,10 @@ export default createActions(
ID,
({ networkId, address }: Props = {}) => async () => {
const net = getNetworkById(networkId)
- const endpoint = await api.getRPCEndpointFrom({ net }, api.neoscan)
+ let endpoint = await getNode(net)
+ if (!endpoint) {
+ endpoint = await getRPCEndpoint(net)
+ }
const client = new rpc.RPCClient(endpoint)
const validators = await client.getValidators()
diff --git a/app/components/Blockchain/Transaction/Transaction.jsx b/app/components/Blockchain/Transaction/Transaction.jsx
index 6635779ce..16e20b6e4 100644
--- a/app/components/Blockchain/Transaction/Transaction.jsx
+++ b/app/components/Blockchain/Transaction/Transaction.jsx
@@ -49,14 +49,7 @@ type Props = {
}
export default function Transaction(props: Props) {
- const {
- tx: { type },
- chain,
- className,
- isPending,
- renderN2Tx,
- address,
- } = props
+ const { tx, chain, className, isPending, renderN2Tx, address } = props
const { contacts } = useContactsContext()
@@ -110,7 +103,8 @@ export default function Transaction(props: Props) {
function renderAbstract(type: string, isN3?: boolean) {
const { isPending, address } = props
- const { time, label, amount, isNetworkFee, to, from, image } = props.tx
+ const { time, label, amount, isNetworkFee, to, from, image } =
+ props.tx || {}
const contactTo = findContact(to)
const contactFrom = from && findContact(from)
const contactToExists = contactTo !== to
@@ -150,7 +144,7 @@ export default function Transaction(props: Props) {
)
}
- switch (type) {
+ switch (tx?.type) {
case TX_TYPES.CLAIM:
return
case TX_TYPES.SEND:
@@ -217,7 +211,7 @@ export default function Transaction(props: Props) {
{chain === 'neo3' && !renderN2Tx
? renderAbstractN3()
- : renderAbstract(type)}
+ : renderAbstract(tx?.type)}
{!isPending && (