Skip to content

Commit

Permalink
Solana and EVM - Support lightMode flag from core
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Jul 22, 2024
1 parent c0b4acf commit 03886a4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Unreleased

- added: (Solana/Ethereum) Add optional `lightMode` support to disable transaction query
- added: Add optional `testPrivateKeys` function to `parseUriCommon`
- changed: (Zcash) Updated address explorer
- changed: (Tron) Special case the `usdt-trc20` uri prefix
- changed: Upgrade edge-core-js to v2.9.0
- fixed: Prevent fatal error reporting for missing txlist json file
- fixed: (Zcash) Use additional insufficient funds check before sending amount to synchronizer

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"chai": "^4.2.0",
"clipanion": "^4.0.0-rc.2",
"crypto-browserify": "^3.12.0",
"edge-core-js": "^2.5.0",
"edge-core-js": "^2.9.0",
"esbuild-loader": "^2.20.0",
"eslint": "^8.19.0",
"eslint-config-standard-kit": "0.15.1",
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum/EthereumEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class EthereumEngine extends CurrencyEngine<
SafeEthWalletInfo
> {
otherData!: EthereumWalletOtherData
lightMode: boolean
initOptions: EthereumInitOptions
networkInfo: EthereumNetworkInfo
ethNetwork: EthereumNetwork
Expand All @@ -113,6 +114,7 @@ export class EthereumEngine extends CurrencyEngine<
currencyInfo: EdgeCurrencyInfo
) {
super(env, tools, walletInfo, opts)
this.lightMode = opts.lightMode ?? false
this.initOptions = initOptions
this.networkInfo = env.networkInfo
this.ethNetwork = new EthereumNetwork(this)
Expand Down
26 changes: 19 additions & 7 deletions src/ethereum/EthereumNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,26 @@ export class EthereumNetwork {

// Send an empty tokenTxs network update if no network adapters
// qualify for 'fetchTxs':
if (this.qualifyNetworkAdapters('fetchTxs').length === 0) {
if (
this.qualifyNetworkAdapters('fetchTxs').length === 0 ||
this.ethEngine.lightMode
) {
const tokenTxs: {
[currencyCode: string]: EdgeTransactionsBlockHeightTuple
} = {
[this.ethEngine.currencyInfo.currencyCode]: {
blockHeight: params.startBlock,
edgeTransactions: []
}
}
for (const token of Object.values(this.ethEngine.allTokensMap)) {
tokenTxs[token.currencyCode] = {
blockHeight: params.startBlock,
edgeTransactions: []
}
}
return {
tokenTxs: {
[this.ethEngine.currencyInfo.currencyCode]: {
blockHeight: params.startBlock,
edgeTransactions: []
}
},
tokenTxs,
server: 'none'
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/solana/SolanaEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class SolanaEngine extends CurrencyEngine<
SolanaTools,
SafeSolanaWalletInfo
> {
lightMode: boolean
networkInfo: SolanaNetworkInfo
base58PublicKey: string
feePerSignature: string
Expand All @@ -90,9 +91,10 @@ export class SolanaEngine extends CurrencyEngine<
env: PluginEnvironment<SolanaNetworkInfo>,
tools: SolanaTools,
walletInfo: SafeSolanaWalletInfo,
opts: any // EdgeCurrencyEngineOptions
opts: EdgeCurrencyEngineOptions
) {
super(env, tools, walletInfo, opts)
this.lightMode = opts.lightMode ?? false
this.networkInfo = env.networkInfo
this.chainCode = tools.currencyInfo.currencyCode
this.fetchCors = getFetchCors(env.io)
Expand Down Expand Up @@ -547,9 +549,16 @@ export class SolanaEngine extends CurrencyEngine<
this.queryBlockhash().catch(() => {})

this.addToLoop('queryBalance', ACCOUNT_POLL_MILLISECONDS).catch(() => {})
this.addToLoop('queryTransactions', TRANSACTION_POLL_MILLISECONDS).catch(
() => {}
)
if (this.lightMode) {
this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode] = 1
for (const edgeToken of Object.values(this.allTokensMap)) {
this.tokenCheckTransactionsStatus[edgeToken.currencyCode] = 1
}
} else {
this.addToLoop('queryTransactions', TRANSACTION_POLL_MILLISECONDS).catch(
() => {}
)
}
await super.startEngine()
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3987,10 +3987,10 @@ [email protected]:
bindings "^1.2.1"
nan "^2.0.9"

edge-core-js@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/edge-core-js/-/edge-core-js-2.5.0.tgz#9dc013c4f59a7a3fb1c88880eb600c4ef3e44e4f"
integrity sha512-sY0lJDIECanLx/muNGRXz3BUcfd3c76gCFA2BZu/4coE2O5o5GK4QnNB64uKPw6XBNrLfDhP1IcrclHDDgcOUQ==
edge-core-js@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/edge-core-js/-/edge-core-js-2.9.0.tgz#99a73c9b7903637f3551ef8cfb771e821193145c"
integrity sha512-hRxiJSe0NZtiokb4zmDr4fFnAspGN6i8dsVqRfOGeOzyJwm/1yo0K1lx70A1pkXHmNIrsirrp80wPcmLVSvl+Q==
dependencies:
aes-js "^3.1.0"
base-x "^4.0.0"
Expand Down

0 comments on commit 03886a4

Please sign in to comment.