Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[ignore]
<PROJECT_ROOT>/lib/.*
<PROJECT_ROOT>/node_modules/@rollup/

[include]

Expand All @@ -9,4 +10,4 @@ node_modules/@solana/web3.js/module.flow.js
[lints]

[options]
esproposal.optional_chaining=enable
esproposal.optional_chaining=enable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/coverage
/intermediate
/lib
/src/polkadot/sdk-bundle.js

# Package managers:
node_modules/
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"README.md"
],
"scripts": {
"build": "rimraf lib && sucrase ./src -q -d ./lib -t flow && webpack && npm run checkpoints",
"build": "rimraf lib && rollup -c && sucrase ./src -q -d ./lib -t flow && webpack && npm run checkpoints",
"checkpoints": "cp -R ./src/zcash/zecCheckpoints lib/zcash/",
"fix": "npm run lint -- --fix",
"flow": "flow",
Expand Down Expand Up @@ -68,10 +68,11 @@
"ethereumjs-util": "5.2.0",
"hash-base": "3.0.4",
"hdkey": "1.1.1",
"inherits": "2.0.4",
"long": "4.0.0",
"process-nextick-args": "2.0.0",
"randombytes": "2.1.0",
"readable-stream": "2.3.6",
"readable-stream": "3.6.0",
"regenerator-runtime": "0.13.4",
"ripemd160": "2.0.2",
"safe-buffer": "5.2.0",
Expand Down Expand Up @@ -116,6 +117,11 @@
"@babel/preset-env": "^7.9.0",
"@babel/preset-flow": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@polkadot/keyring": "^9.5.1",
"@polkadot/util-crypto": "^9.5.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@substrate/txwrapper-polkadot": "^3.1.3",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
Expand All @@ -137,6 +143,7 @@
"prettier": "^2.2.0",
"react-native-zcash": "^0.2.2",
"rimraf": "^3.0.2",
"rollup": "^2.75.7",
"sucrase": "^3.13.0",
"updot": "^1.1.7",
"webpack": "^4.42.1",
Expand Down
19 changes: 19 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import commonJs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'

export default {
external: ['bn.js'],
input: './src/polkadot/sdk-bundle.js.flow',
output: {
file: './src/polkadot/sdk-bundle.js',
format: 'cjs'
},
plugins: [
commonJs(),
nodeResolve({
preferBuiltins: true,
// Use the browser build to avoid advanced features:
exportConditions: ['browser']
})
]
}
13 changes: 0 additions & 13 deletions src/binance/bnbEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,6 @@ export class BinanceEngine extends CurrencyEngine {
}
}

updateBalance(tk: string, balance: string) {
if (typeof this.walletLocalData.totalBalances[tk] === 'undefined') {
this.walletLocalData.totalBalances[tk] = '0'
}
if (!bns.eq(balance, this.walletLocalData.totalBalances[tk])) {
this.walletLocalData.totalBalances[tk] = balance
this.warn(`${tk}: token Address balance: ${balance}`)
this.currencyEngineCallbacks.onBalanceChanged(tk, balance)
}
this.tokenCheckBalanceStatus[tk] = 1
this.updateOnAddressesChecked()
}

async checkAccountInnerLoop() {
const address = this.walletLocalData.publicKey

Expand Down
13 changes: 13 additions & 0 deletions src/common/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,19 @@ export class CurrencyEngine {
this.walletLocalDataDirty = true
}

updateBalance(tk: string, balance: string) {
if (this.walletLocalData.totalBalances[tk] == null) {
this.walletLocalData.totalBalances[tk] = '0'
}
if (!bns.eq(balance, this.walletLocalData.totalBalances[tk])) {
this.walletLocalData.totalBalances[tk] = balance
this.warn(`${tk}: token Address balance: ${balance}`)
this.currencyEngineCallbacks.onBalanceChanged(tk, balance)
}
this.tokenCheckBalanceStatus[tk] = 1
this.updateOnAddressesChecked()
}

updateTransaction(
currencyCode: string,
edgeTransaction: EdgeTransaction,
Expand Down
23 changes: 1 addition & 22 deletions src/eos/eosEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,32 +857,11 @@ export class EosEngine extends CurrencyEngine {
`Received balance for unsupported currencyCode: ${currencyCode}`
)
}

if (!this.walletLocalData.totalBalances[currencyCode]) {
this.walletLocalData.totalBalances[currencyCode] = '0'
}
if (
!bns.eq(
this.walletLocalData.totalBalances[currencyCode],
nativeAmount
)
) {
this.walletLocalData.totalBalances[currencyCode] =
nativeAmount
this.walletLocalDataDirty = true
this.currencyEngineCallbacks.onBalanceChanged(
currencyCode,
nativeAmount
)
this.warn(
`Updated ${currencyCode} balance ${nativeAmount}`
)
}
this.updateBalance(currencyCode, nativeAmount)
}
}
}
}
this.tokenCheckBalanceStatus[token.currencyCode] = 1
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions src/ethereum/ethEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,19 +478,6 @@ export class EthereumEngine extends CurrencyEngine {
}
}

updateBalance(tk: string, balance: string) {
if (typeof this.walletLocalData.totalBalances[tk] === 'undefined') {
this.walletLocalData.totalBalances[tk] = '0'
}
if (!bns.eq(balance, this.walletLocalData.totalBalances[tk])) {
this.walletLocalData.totalBalances[tk] = balance
this.warn(`${tk}: token Address balance: ${balance}`)
this.currencyEngineCallbacks.onBalanceChanged(tk, balance)
}
this.tokenCheckBalanceStatus[tk] = 1
this.updateOnAddressesChecked()
}

processUnconfirmedTransaction(tx: Object) {
const fromAddress = '0x' + tx.inputs[0].addresses[0]
const toAddress = '0x' + tx.outputs[0].addresses[0]
Expand Down
14 changes: 0 additions & 14 deletions src/fio/fioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,6 @@ export class FioEngine extends CurrencyEngine {
}
}

updateBalance(tk: string, balance: string) {
if (typeof this.walletLocalData.totalBalances[tk] === 'undefined') {
this.walletLocalData.totalBalances[tk] = '0'
}
if (!bns.eq(balance, this.walletLocalData.totalBalances[tk])) {
this.walletLocalData.totalBalances[tk] = balance
this.localDataDirty()
this.warn(`${tk}: token Address balance: ${balance}`)
this.currencyEngineCallbacks.onBalanceChanged(tk, balance)
}
this.tokenCheckBalanceStatus[tk] = 1
this.updateOnAddressesChecked()
}

checkUnStakeTx(otherParams: TxOtherParams): boolean {
return (
otherParams.name ===
Expand Down
13 changes: 3 additions & 10 deletions src/hedera/hederaEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class HederaEngine extends CurrencyEngine {
}
}

async updateBalance(): Promise<void> {
async queryBalance(): Promise<void> {
if (this.accountId == null) {
return
}
Expand All @@ -249,14 +249,7 @@ export class HederaEngine extends CurrencyEngine {
.execute(this.client)
const nativeBalance: string = hbarBalance.asTinybar().toString()

this.walletLocalData.totalBalances[this.currencyInfo.currencyCode] =
nativeBalance
this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode] = 1
this.updateOnAddressesChecked()
this.currencyEngineCallbacks.onBalanceChanged(
this.currencyInfo.currencyCode,
nativeBalance
)
this.updateBalance(this.currencyInfo.currencyCode, nativeBalance)
}

async getNewTransactions() {
Expand Down Expand Up @@ -378,7 +371,7 @@ export class HederaEngine extends CurrencyEngine {
}

this.addToLoop('getNewTransactions', 1000)
this.addToLoop('updateBalance', 5000)
this.addToLoop('queryBalance', 5000)
this.addToLoop('checkAccountCreationStatus', 5000)

await super.startEngine()
Expand Down
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { eosPlugins } from './eos/index.js'
import { ethPlugins } from './ethereum/ethInfos.js'
import { makeFioPlugin } from './fio/fioPlugin'
import { makeHederaPlugin } from './hedera/hederaInfo.js'
import { makePolkadotPlugin } from './polkadot/polkadotInfo.js'
import { makeSolanaPlugin } from './solana/solanaInfo.js'
import { makeStellarPlugin } from './stellar/stellarPlugin.js'
import { makeTezosPlugin } from './tezos/tezosPlugin.js'
Expand All @@ -19,15 +20,16 @@ import { makeZcashPlugin } from './zcash/zecPlugin.js'
const plugins = {
...eosPlugins,
...ethPlugins,
binance: makeBinancePlugin,
fio: makeFioPlugin,
zcash: makeZcashPlugin,
hedera: makeHederaPlugin,
polkadot: makePolkadotPlugin,
// "ripple" is network name. XRP is just an asset:
ripple: makeRipplePlugin,
solana: makeSolanaPlugin,
stellar: makeStellarPlugin,
tezos: makeTezosPlugin,
binance: makeBinancePlugin,
hedera: makeHederaPlugin,
solana: makeSolanaPlugin
zcash: makeZcashPlugin
}

if (
Expand Down
Loading