This repository was archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 331
add last failed tx processing #2
Open
dzhambulat
wants to merge
9
commits into
rstormsf:master
Choose a base branch
from
dzhambulat:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e501102
add last failed tx processing
dzhambulat 79c38cf
add tx check page
dzhambulat 340b848
fix return
dzhambulat 072264b
remove debug alert
dzhambulat 592661b
cleaning code and refactor
dzhambulat d704010
remove test smart contract string
dzhambulat d01e9d0
remove missed loading var
dzhambulat dc65dff
remove promise in checkTransaction
dzhambulat 6a88553
improve checkTx UI
dzhambulat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| import React from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
| import Web3Utils from 'web3-utils'; | ||
| import Form from 'react-validation/build/form'; | ||
| import Textarea from 'react-validation/build/textarea'; | ||
| import Button from 'react-validation/build/button'; | ||
| import { form, control, button } from 'react-validation'; | ||
| import { inject, observer } from "mobx-react"; | ||
| import swal from 'sweetalert'; | ||
| import generateElement from '../generateElement' | ||
| import Example from './example.json' | ||
| import ExampleCSV from './example.csv' | ||
| import { PulseLoader} from 'react-spinners'; | ||
| import {RadioGroup, Radio} from 'react-radio-group'; | ||
| import csvtojson from 'csvtojson' | ||
| import Select from 'react-select' | ||
| import '../assets/stylesheets/react-select.min.css'; | ||
| import StormMultiSenderABI from '../abis/StormMultisender' | ||
|
|
||
| const InputDataDecoder = require('ethereum-input-data-decoder'); | ||
| const decoder = new InputDataDecoder(StormMultiSenderABI); | ||
|
|
||
| const ownInput = ({ error, isChanged, isUsed, ...props }) => ( | ||
| <div> | ||
| {isChanged && isUsed && error} | ||
| <input {...props} /> | ||
| </div> | ||
| ); | ||
| const Input = control(ownInput); | ||
|
|
||
| const required = (value) => { | ||
| if (!value.toString().trim().length) { | ||
| return <span className="error">required</span>; | ||
| } | ||
| }; | ||
|
|
||
| const isAddress = (value) => { | ||
| if (!Web3Utils.isAddress(value)) { | ||
| return <span className="error">Token address is invalid</span>; | ||
| } | ||
| }; | ||
| const InvalidJSON = <div>Your JSON is invalid, please visit <a href="https://jsonlint.com/" target="_blank">Online Json Validator</a></div> | ||
|
|
||
| const isJson = (value) => { | ||
| try { | ||
| JSON.parse(value) | ||
| } catch(e) { | ||
| return InvalidJSON | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| @inject("UiStore") | ||
| @observer | ||
| export class CheckTx extends React.Component { | ||
| constructor(props){ | ||
| super(props); | ||
| this.tokenStore = props.UiStore.tokenStore; | ||
| this.txStore = props.UiStore.txStore; | ||
| this.web3Store = props.UiStore.web3Store; | ||
| this.onTxHash = this.onTxHash.bind(this); | ||
| this.onSubmit = this.onSubmit.bind(this); | ||
| this.addresses = [] | ||
| this.tokenAddress = ''; | ||
| this.txFailed = true; | ||
| } | ||
| async onTxHash(e){ | ||
|
|
||
| const status = await this.txStore.checkTransaction(e.value); | ||
| if (status == -1) | ||
| { | ||
| swal({ | ||
| content: "Your tx hash is invalid", | ||
| icon: "error", | ||
| }) | ||
| return; | ||
| } | ||
| if (!status.isError) | ||
| { | ||
| swal({ | ||
| content: "Transaction is succeded", | ||
| icon: "success", | ||
| }) | ||
| return; | ||
| } | ||
|
|
||
| swal({ | ||
| content: status.description, | ||
| icon: "error", | ||
| }) | ||
|
|
||
| const inputData = decoder.decodeData(status.inputData); | ||
| const tokenAddress = `0x${inputData.inputs[0]}`; | ||
| const addresses = [] | ||
| const recAddresses = inputData.inputs[1]; | ||
| const balances = inputData.inputs[2]; | ||
| let bindex = 0; | ||
|
|
||
| recAddresses.forEach((address)=>{ | ||
| const addr = {}; | ||
| addr[`0x${address}`] = Web3Utils.BN(balances[bindex]); | ||
| addresses.push(addr); | ||
| bindex++; | ||
| }); | ||
| await this.tokenStore.setJsonAddresses(addresses); | ||
| await this.tokenStore.setTokenAddress(tokenAddress); | ||
| this.txFailed = true; | ||
| } | ||
| onSubmit(e){ | ||
| e.preventDefault() | ||
|
|
||
| this.tokenStore.setDecimals(0) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? why decimals 0 ? |
||
| this.tokenStore.parseAddresses() | ||
| this.props.history.push('/3') | ||
| } | ||
| render () { | ||
| const txFailed = this.txFailed; | ||
| return ( | ||
| <div className="container container_bg"> | ||
|
|
||
| <div className="content"> | ||
| <div className='sweet-loading'> | ||
| <PulseLoader | ||
| color={'#123abc'} | ||
| loading={this.web3Store.loading} | ||
| /> | ||
| </div> | ||
| <h1 className="title"><strong>Check transaction status</strong></h1> | ||
| <p className="description"> | ||
| Please provide tx hash <br /> | ||
| </p> | ||
| <Form className="form" onSubmit={this.onSubmit}> | ||
| <div className="form-inline"> | ||
| <div className="form-inline-i form-inline-i_token-address"> | ||
| <label htmlFor="tx-hash" className="label">Tx Hash</label> | ||
| <Select.Creatable | ||
|
|
||
| isLoading={this.web3Store.loading} | ||
| name="form-field-name" | ||
| id="tx-hash" | ||
| onChange={this.onTxHash} | ||
| loadingPlaceholder="Checking your transaction..." | ||
| placeholder="Please select or input the tx hash" | ||
| options={this.web3Store.userTokens.slice()} | ||
| /> | ||
|
|
||
| </div> | ||
| </div> | ||
| <br/> | ||
| <Button className="button button_check" disabled>Resend Transaction</Button> | ||
| </Form> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need all of those dependencies?