diff options
author | Fabio Berger <me@fabioberger.com> | 2018-01-29 19:45:50 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-01-29 19:45:50 +0800 |
commit | 609342be7af3a33ca354bbf9385b1fa187b872d0 (patch) | |
tree | d9f2d83a6db5529857c474606aef26b7f161affa /packages/website/ts | |
parent | 52394884dad9d4ff7f13891ebba013000ae32484 (diff) | |
download | dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar.gz dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar.bz2 dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar.lz dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar.xz dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.tar.zst dexon-sol-tools-609342be7af3a33ca354bbf9385b1fa187b872d0.zip |
Add flash message instructing user to confirm tx on Ledger
Diffstat (limited to 'packages/website/ts')
-rw-r--r-- | packages/website/ts/blockchain.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 71927ef3b..13c997ba6 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -247,6 +247,7 @@ export class Blockchain { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.token.setProxyAllowanceAsync( token.address, this._userAddress, @@ -256,6 +257,7 @@ export class Blockchain { const allowance = amountInBaseUnits; } public async transferAsync(token: Token, toAddress: string, amountInBaseUnits: BigNumber): Promise<void> { + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.token.transferAsync( token.address, this._userAddress, @@ -312,6 +314,7 @@ export class Blockchain { const shouldThrowOnInsufficientBalanceOrAllowance = true; + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.exchange.fillOrderAsync( signedOrder, fillTakerTokenAmount, @@ -327,6 +330,7 @@ export class Blockchain { return filledTakerTokenAmount; } public async cancelOrderAsync(signedOrder: SignedOrder, cancelTakerTokenAmount: BigNumber): Promise<BigNumber> { + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerTokenAmount); const receipt = await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); const logs: Array<LogWithDecodedArgs<ExchangeContractEventArgs>> = receipt.logs as any; @@ -399,6 +403,7 @@ export class Blockchain { if (_.isUndefined(makerAddress)) { throw new Error('Tried to send a sign request but user has no associated addresses'); } + this._showFlashMessageIfLedger(); const ecSignature = await this._zeroEx.signOrderHashAsync(orderHash, makerAddress); const signatureData = _.extend({}, ecSignature, { hash: orderHash, @@ -410,6 +415,7 @@ export class Blockchain { utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); const mintableContract = await this._instantiateContractIfExistsAsync(MintableArtifacts, token.address); + this._showFlashMessageIfLedger(); await mintableContract.mint(constants.MINT_AMOUNT, { from: this._userAddress, }); @@ -423,6 +429,7 @@ export class Blockchain { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.etherToken.depositAsync(etherTokenAddress, amount, this._userAddress); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); } @@ -430,6 +437,7 @@ export class Blockchain { utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses); + this._showFlashMessageIfLedger(); const txHash = await this._zeroEx.etherToken.withdrawAsync(etherTokenAddress, amount, this._userAddress); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); } @@ -766,4 +774,9 @@ export class Blockchain { } } } + private _showFlashMessageIfLedger() { + if (!_.isUndefined(this._ledgerSubprovider)) { + this._dispatcher.showFlashMessage('Confirm the transaction on your Ledger Nano S'); + } + } } // tslint:disable:max-file-line-count |