From e4e6030603c03fcd2dc59f176333914f2b368d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Sat, 25 May 2019 18:24:35 +0800 Subject: [PATCH 1/9] Modify the token name Modify the token name --- src/appwallet.js | 10 ++++------ src/settings.js | 3 ++- src/store.js | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/appwallet.js b/src/appwallet.js index 0ebbd17..5bbdede 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -1171,9 +1171,7 @@ export class Wallet extends React.Component { } ); } - transferShow(){ - this.setState({transferModal:false}); - } + transferToken() { this.runModal( '发送Token', @@ -1292,7 +1290,7 @@ export class Wallet extends React.Component { this.setState({transferModal: false})} - transfer={() => this.transferShow()} + transfer={() => this.sendTransaction()} topublickey={key => this.setRecipientPublicKey(key)} transferamount={key => this.setRecipientAmount(key)} /> @@ -1344,13 +1342,13 @@ export class Wallet extends React.Component {

- this.setState({transferModal: true})} /> + this.setState({transferModal: true})} /> - + diff --git a/src/settings.js b/src/settings.js index e0d09b7..fb0d460 100644 --- a/src/settings.js +++ b/src/settings.js @@ -97,7 +97,8 @@ export class Settings extends React.Component { { [ 'https://api.bitconch.io', - 'http://47.91.255.38:8899' + 'http://47.91.255.38:8899', + 'http://47.244.209.112:8899' ].map((url, index) => {url}) } diff --git a/src/store.js b/src/store.js index 24577f0..9ad36a1 100644 --- a/src/store.js +++ b/src/store.js @@ -19,7 +19,7 @@ export class Store { } if (typeof this.networkEntryPoint !== 'string') { - this.networkEntryPoint = 'https://api.bitconch.io'; + this.networkEntryPoint = 'http://47.244.209.112:8899'; } if (!this.accountSecretKey) { From a8e692332419a7816c5812c14c1b35a052cb7813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Sat, 25 May 2019 21:02:10 +0800 Subject: [PATCH 2/9] Update appwallet.js Transfer page shows token balance --- src/appwallet.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/appwallet.js b/src/appwallet.js index 5bbdede..8281503 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -723,7 +723,7 @@ class TokenInput extends React.Component { return (
- 数量 + 数量({this.props.amount}) this.handleChange(e)}/> @@ -733,6 +733,7 @@ class TokenInput extends React.Component { } } TokenInput.propTypes = { + amount:PropTypes.object, onAmount: PropTypes.function, }; @@ -906,7 +907,7 @@ class TransferModal extends React.Component { BUS
this.props.topublickey(publicKey)}/> - this.props.transferamount(amount)}/> + this.props.transferamount(amount)} amount={this.props.amount}/>
@@ -918,6 +919,7 @@ class TransferModal extends React.Component { } TransferModal.propTypes = { + amount:PropTypes.object, topublickey: PropTypes.function, transferamount: PropTypes.function, onHide: PropTypes.function, @@ -1293,6 +1295,7 @@ export class Wallet extends React.Component { transfer={() => this.sendTransaction()} topublickey={key => this.setRecipientPublicKey(key)} transferamount={key => this.setRecipientAmount(key)} + amount={this.state.balance} /> ) : null; const showModal = this.state.showModal ? ( From c32ecbb3105f176416828a9a8f7842d00dabf368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Sun, 2 Jun 2019 23:33:43 +0800 Subject: [PATCH 3/9] Add the select token page Add the select token page --- src/appwallet.js | 380 +++++++++++++++++++++++++------------ src/images/main_jia.png | Bin 0 -> 1777 bytes src/images/main_right.png | Bin 0 -> 1885 bytes src/images/selecte_off.png | Bin 0 -> 3428 bytes src/images/selecte_on.png | Bin 0 -> 3406 bytes tokens.json | 41 ++++ 6 files changed, 302 insertions(+), 119 deletions(-) create mode 100644 src/images/main_jia.png create mode 100644 src/images/main_right.png create mode 100644 src/images/selecte_off.png create mode 100644 src/images/selecte_on.png create mode 100644 tokens.json diff --git a/src/appwallet.js b/src/appwallet.js index 8281503..82ce16a 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -11,8 +11,6 @@ import { // OverlayTrigger, ProgressBar, // Tooltip, - DropdownButton, - MenuItem, } from 'react-bootstrap'; import PropTypes from 'prop-types'; import copy from 'copy-to-clipboard'; @@ -20,9 +18,13 @@ import * as web3 from '@bitconch/bitconch-web3j'; import {Settings} from './settings'; import data from '../publickey.json'; +import info from '../tokens.json'; import Background from './images/account_backgroud.png'; import CopyIcon from './images/address_copy.png'; -import TransferIcon from './images/account_change.png'; +import TransferIcon from './images/main_right.png'; +import AddIcon from './images/main_jia.png'; +import SelectOn from './images/selecte_on.png'; +import SelectOff from './images/selecte_off.png'; const AIRDORP_QUOTA = 3000; @@ -39,6 +41,27 @@ var lineStyle = { marginLeft:'10px' }; +//定义一个Section子组件 +class PropertyAdd extends React.Component{ + //接收父组件传递过来的item + render(){ + return( +
+ +
+ + ); + } +} + +// +PropertyAdd.propTypes = { + + addproperty:PropTypes.function, +}; //定义一个Section子组件 class PropertySection extends React.Component{ //接收父组件传递过来的item @@ -50,7 +73,7 @@ class PropertySection extends React.Component{
-
@@ -60,27 +83,89 @@ class PropertySection extends React.Component{ ); } } - -// PropertySection.propTypes = { tokenLogo: PropTypes.object, tokenName: PropTypes.object, tokenAmount: PropTypes.object, transferAccounts:PropTypes.function, }; + +class PropertySelect extends React.Component{ + state = { + isSelected:false + } + //接收父组件传递过来的item + selectedButton(){ + if (this.state.isSelected == false) { + this.setState({isSelected: true}); + document.getElementById(this.props.buttonId).style.background=`url(${SelectOn})`; + document.getElementById(this.props.buttonId).style.backgroundSize='25px 25px'; + }else{ + this.setState({isSelected: false}); + document.getElementById(this.props.buttonId).style.background=`url(${SelectOff})`; + document.getElementById(this.props.buttonId).style.backgroundSize='25px 25px'; + } + + + } + render(){ + return( +
+ + +
+ + ); + } +} + +// +PropertySelect.propTypes = { + tokenLogo: PropTypes.object, + tokenName: PropTypes.object, + selected: PropTypes.function, + switchOn: PropTypes.object, + buttonId: PropTypes.object +}; +class PropertyList extends React.Component { + componentDidMount() { + console.log('sssssss:',this.props.tokenNameArray); + } + render() { + return ( +
+ { + this.props.tokenNameArray.map((obj,index) => { + console.log('obj======',obj); + return( + + ); + }) + } +
+ ); + } +} +PropertyList.propTypes = { + tokenNameArray: PropTypes.object, +}; class TokenAsset extends React.Component { state = { - value: '', - validationState: null, - tokenInfo: null, - tokenNameArray: [], + tokenNameArray: [] }; constructor(props) { super(props); this.readPublicKeyFromFile(); } + AddTokenNameArray(){ + this.props.onTokenAsset(this.state.tokenNameArray); + console.log('第一步:::::::',this.state.tokenNameArray); + } async readPublicKeyFromFile() { try { String.format = function(src){ @@ -90,35 +175,42 @@ class TokenAsset extends React.Component { return args[i]; }); }; - var i; - // var tem = ''; - // var msg = ''; var arrToken = []; - for(i = 0; i < data.TokenPublicKeys.length; i++) { - var tokenpubkey = new web3.PublicKey(data.TokenPublicKeys[i].tokenpubkey); + for(i = 0; i < info.TokenInfos.length; i++) { + console.log('tokenpubkey==',info.TokenInfos[i].tokenpubkey); + var tokenpubkey = new web3.PublicKey(info.TokenInfos[i].tokenpubkey); + //根据tokenpublickey获取token信息 var token = new web3.Token(this.props.conn, tokenpubkey); var acc = await token.tokenInfo(); var tokenname = acc.name; var tokensymbol = acc.symbol; var tokensupply = acc.supply; var tokendecimal = acc.decimals; + var tokenlogo = info.TokenInfos[i].tokenlogo; + var tokenselected = false; + var tokenaccpubkey = ''; + var tokenamount = '100'; + console.log('token:::::::',token); // tem += ' 代币名称: {' + i + '} '; - - var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; - var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); + //根据tokenaccoutpublickey获取余额 + // var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; + // var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); // tem += '余额: ' + accTokenInfo.amount; arrToken.push({ + token, tokenpubkey, + tokenaccpubkey, tokenname, tokensymbol, tokensupply, tokendecimal, - tokenaccpubkey, - accTokenInfo + tokenlogo, + tokenselected, + tokenamount, }); // msg += String.format( @@ -126,94 +218,44 @@ class TokenAsset extends React.Component { // acc.name // ); } - this.setState({ - // tokenInfo: msg, - tokenNameArray: arrToken, - }); + console.log('tokenNameArray0:::::::',arrToken); + + this.setState({tokenNameArray: arrToken}); + + } catch (err) { this.addError(err.message); } } + addSelectedToken(index){ + console.log('index:::::::',index); - async setTokenInfo(token) { - var tem = ''; - var msg = ''; - var to = new web3.Token(this.props.conn, token.tokenpubkey); - var tokenacc = await to.accountInfo(new web3.PublicKey(token.tokenaccpubkey)); - String.format = function(src){ - if (arguments.length == 0) return null; - var args = Array.prototype.slice.call(arguments, 1); - return src.replace(/\{(\d+)\}/g, function(m, i){ - return args[i]; - }); - }; - - tem += '代币名称: {0} ' + - '余额: {1}'; + var tokeninfo = this.state.tokenNameArray[index]; + console.log('tokeninfo:::::::',tokeninfo); - msg += String.format( - tem, - token.tokenname, - tokenacc.amount - ); - this.setState({ - tokenInfo: msg, - }); - this.props.onTokenAsset(token); - } - - getValidationState(value) { - const length = value.length; - if (length === 44) { - if (value.match(/^[A-Za-z0-9]+$/)) { - return 'success'; - } - return 'error'; - } else if (length > 44) { - return 'error'; - } else if (length > 0) { - return 'warning'; + if (tokeninfo.tokenselected == false) { + tokeninfo.tokenselected = true; + document.getElementById('button'+index).style.background=`url(${SelectOn})`; + document.getElementById('button'+index).style.backgroundSize='25px 25px'; + }else{ + tokeninfo.tokenselected = false; + document.getElementById('button'+index).style.background=`url(${SelectOff})`; + document.getElementById('button'+index).style.backgroundSize='25px 25px'; } - return null; - } - - handleChange(e) { - const {value} = e.target; - const validationState = this.getValidationState(value); - this.setState({ - value: value, - validationState: validationState, - }); - - this.props.onTokenAsset(validationState === 'success' ? value : null); + this.AddTokenNameArray(); } - render() { return ( - - - {/* 资产 */} - - { - this.state.tokenNameArray.map((obj, index) => {obj.tokenname}) - } - - - - - +
+ { + this.state.tokenNameArray.map((obj,index) => { + return( + this.addSelectedToken(index)}/> + ); + }) + } +
); } } @@ -926,6 +968,47 @@ TransferModal.propTypes = { transfer:PropTypes.function, }; // +class AddPropertyModal extends React.Component { + state={ + tokenNameArray:[], + } + PostPoroertyList(tokenarr){ + this.props.tokenarr(tokenarr); + console.log('第2步:::::::',tokenarr); + + } + render() { + return ( + + +
+ +
+
+ +
+
+ this.PostPoroertyList(tokenarr)}/> +
+
+ +
+
+
+
+ ); + } +} + +AddPropertyModal.propTypes = { + web3sol: PropTypes.object, + offSelect: PropTypes.function, + onSelect: PropTypes.function, + onHide: PropTypes.function, + addsure: PropTypes.function, + tokenarr: PropTypes.function, +}; +// class SettingsModal extends React.Component { render() { return ( @@ -981,13 +1064,38 @@ export class Wallet extends React.Component { tokenNameArray: [], showText:null, showModal: false, - + addPropertyModal:false, + tokenArr: [] }; constructor(props) { super(props); this.onStoreChange(); } + testtokens(){ + var arrToken = []; + for (var i = 0; i < 5; i++) { + var tokenpubkey = new web3.PublicKey(data.AccountPublicKey); + //根据tokenpublickey获取token信息 + var tokenname = 'BUS'; + var tokensymbol = 'BUS'; + var tokensupply = '1000000000000000'; + var tokendecimal = '4'; + var tokenlogo = 'account_head.png'; + var tokenselected = true; + arrToken.push({ + tokenpubkey, + tokenname, + tokensymbol, + tokensupply, + tokendecimal, + tokenlogo, + tokenselected + }); + } + this.setState({tokenArr: arrToken}); + console.log('arrrrrr==',arrToken); + } getTokenDetails(){ var i; @@ -1102,6 +1210,24 @@ export class Wallet extends React.Component { } } + selectOn(){ + + } + selectOff(){ + + } + addPorpertyList(tokenarr){ + console.log('tokenarr======',tokenarr); + this.setState({tokenNameArray: tokenarr}); + } + ResetListForPorperty(){ + let arr = this.state.tokenNameArray; + console.log('tokenNameArraylast:======',arr); + this.createNewTokenAccount(); + this.setState({tokenArr: arr,addPropertyModal: false}); + + + } copyPublicKey() { copy(this.web3solAccount.publicKey); this.setState({showText:'地址已复制到粘贴板',showModal: true}); @@ -1117,16 +1243,17 @@ export class Wallet extends React.Component { } createNewTokenAccount() { - this.runModal( - '创建Token账户', - '请稍后...', - async () => { - var newtokenaccpubkey = await this.state.tokenObj.newAccount(this.web3solAccount); - this.setState({ - newTokenAccountPublicKey: newtokenaccpubkey.toString(), - }); + for (var i = 0; i < this.state.tokenNameArray.length; i++) { + var tokens = this.state.tokenNameArray[i]; + if (tokens.tokenselected == true) { + var token = tokens.token; + console.log('获取token余额:',token); + var newtokenaccpubkey = token.newAccount(this.web3solAccount); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + var accTokenInfo = token.accountInfo(newtokenaccpubkey); + tokens.tokenamount = accTokenInfo.amount.toString(); } - ); + } } refreshBalance() { @@ -1305,6 +1432,18 @@ export class Wallet extends React.Component { onHide={() => this.setState({showModal: false})} /> ) : null; + const addPropertyModal = this.state.addPropertyModal ? ( + this.addPorpertyList(tokenarr)} + addsure = {() => this.ResetListForPorperty()} + onSelect = {() => this.selectOn()} + offSelect = {() => this.selectOff()} + onHide={() => this.setState({addPropertyModal: false})} + /> + ) : null; + const settingsModal = this.state.settingsModal ? this.setState({settingsModal: false})}/> : null; @@ -1321,6 +1460,9 @@ export class Wallet extends React.Component { {exportSercetModal} {transferModal} {showModal} + {addPropertyModal} + this.dismissError(index)}/> +
@@ -1344,20 +1486,20 @@ export class Wallet extends React.Component {

+

+ this.setState({addPropertyModal: true})}/> +
this.setState({transferModal: true})} /> - - - - - - - - - - - - + { + this.state.tokenArr.map((obj,index) => { + if (obj.tokenselected==true) { + return( + + ); + } + }) + }
); diff --git a/src/images/main_jia.png b/src/images/main_jia.png new file mode 100644 index 0000000000000000000000000000000000000000..58a30584381f4d6e2a85877ba8e6447ddbdcf1ab GIT binary patch literal 1777 zcmZ{kc{tnI8pnUe(m|=MRPAeOBC=Q~wKNE^mQ0044s z7-y_Vb&ozA z0I)AQ%3J_|Bp3iJh64by3;@*PD}VR36&0i+JY1bcDq4F^JsBdAj>iNhiWKutxD3VE z1AydBH)oU|X=){qin%~h`DV8xtf*)%IR5#E9M;(3E~>&YQT=3{8K3Lo8|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z7^nt>msi}@UaYCwW<-KJew~Q6>Y~Pdn0%B>FbsV>-&C%s^E%TcT&9d6Bv=&XkCH65 zq~IS);zRTunXK!NCRmewn>+bw2vxPt6ZnsE;nQ4+eg_ngKKk z!-M?x(w9UZwGka1KquhnL?oU@6bXQU!GDCnEFlORKe#m#jzC&if?+mD7%Y`>Irx7J z6e@unnf(6^GT^~!k-_EYg+xXaG6I)Kge1|(KqNVqh=f9+Br1gn#StjvI4BuUje|r| t%B{};!gA{YPw literal 0 HcmV?d00001 diff --git a/src/images/main_right.png b/src/images/main_right.png new file mode 100644 index 0000000000000000000000000000000000000000..e8e43464149314e6536d899dc306693dc5f882ac GIT binary patch literal 1885 zcmZ{ldo-Kb8pc0F5SMZsWKyH3yOIzku1nmN66#tl5s4<+NJJ2-E+LG%RO!TwDta0% zB`9I2c1$sp)~&5^Y0assiBhJa%qdNsFI{W?IDeeyx8D7%cklJ?z4l&vt+xml;H?Zp zzyJVH_Vw`y1|1~{RVX;hRTvI|204d4i3NarR}??T%7VF6a&^n?04or08e1cB` zK!y4rY^pE#}zr*QJG zRY6Z(RA)c2e_x!Mnwo_MV1MhMbnPUN(eVcU@|8hEJG3RY0J@%^GT>lkAKBNO8otr` zts{B;#Bq}uJ3*ZUr?j%C<=t2B(ika=dTqJwwr*7Wu>kgY|>1t{Of|88PP z;F_=V=%}6%LI1Y8aRtn#UTU0c@jhtRO^G+ka+9ms_mXAuA2%n zPGrLxb1sLsRlqL2mWhegduMQi*V+7JflL+HYHCc|CN%g&0@l%Ov+FxqVuyX=?&$l< zv9T4l>nD>VD~baN->R7&a`jSSZzs7-q7aEaqh*9j?NOOsx-TP#2cURYK6iae@uT#^$K!?o+Ykns1dGl%juAPxs1JInq|vT;b=PJ%b;9S_}cdw=4K8P%$j$Y?Jv$$ z@c~z$=sNrx`MltG;w$+)lziS~t%ZgMfmc$xq^h!n^W+@vy?VH`?AdPz&A96_+`*YQ z2}xa7D59(Pj(I|pVjggGnl&2K=8 zyi$A$n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rmm;{-1gOB&;P%ECXu-8A#3awaJkE9`W^o(%GA?Du{A zxyo6X<1)lX&BX)u>K6S)%NI9t7|#})nrUGBGS(F2RKibh&KS}{7UR#)f>NLuvUa$Z z+M|rF&tPs6S0#h0aY3i-N}7kUE(daZZD6^krRNH95d`7d*JebATn zoo!>v%kJ-W0sPA!oCt)@kP63K?uDF(WA=*Wlj<>VzEGDSM@$|3i@xws{W;(&a0zc{ zhj(|uqhW4$(LewxK@~ORp;zRU)NK^iU{FPvGE^3-4ueA3m9)Jh}79)QLi@`(ie*XVu yw>?w|s{TR2cR~m_2$A4|2|@b+v&Vn0o>+{B0`N^mv2W!-3y_JSr9rtKD(Zjitz=UG literal 0 HcmV?d00001 diff --git a/src/images/selecte_on.png b/src/images/selecte_on.png new file mode 100644 index 0000000000000000000000000000000000000000..7723255deeae25dfeb5b8aa72f66087c3c9b04df GIT binary patch literal 3406 zcmZ{nS5yniN3@9q9;ibI;p-xU<&Y-~MOjpLv>DGk@PRzQf8a$P54gSoM**W)$B1Z*b64 z^4V!s4h6Irgb@M&c$36(j;5n%DqpiZw*b{c!eoj7IUvo90DurF03bYyVxe?}uK@u5 zPyk@v4gi2<0swqCQnM+XGC*%{a7ULyN;}nQc}f8j4*AfRLgc@p*YBmpD= z(_1h%1AXac%2gVh)6G(6C9rN6BF}oK|55z`^ALvf zJAw*Not=XcJnW|O5wl@^^fjHiM0ySakX<`8cEd$U;6~8RltvcY>T-nI8T)D2Wm|1# zmhpEB3smBfp3o4f99IuHoC`Ttn7R7SKPk(^k-k;?KS-=W&Brp z4g&Xcn=l?n5D_$CgVzN`ONiHhzh)U89^QVD4iL~w&XCTC*QKJmE--)b^{-(Pl{%|z zTXyr{#KGPg;nH341=0@eK~xJ3L$g#yD%IDAex7{jqEsFIyh5&0($^|8T@||N-MaWC zHTCUrDeL|t3(JoUp~9^~;W^e$PPe)iI`zbi@cbWR8KFcy?kM6dcvN?EXXI&mO+&sq zFmnIhyJV{G_x`$4gG5t5TlV(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eRWPZAx7-C`Fe&R4d?)ro8zj{cb<-b42?&!5n;?C;(iCDr$hCD&XttC`C0G z6be&Oy#`gM6gnpEh5uvl^m24{4*vg!>zw1F6vKo6?%*4Mf!U*doxuJ+t^j9O4<{G| z0&(&3bb_EAJzcR7R|hXF*x3u~2l4a7{i|%DPJYTkKG=X@Pak(kkUtt5;^a=rn14$b aFDyoZvS>MCjPhXt0Q7Gg>sH^gi}(*m21BL* literal 0 HcmV?d00001 diff --git a/tokens.json b/tokens.json new file mode 100644 index 0000000..1d5a606 --- /dev/null +++ b/tokens.json @@ -0,0 +1,41 @@ +{ + "AccountPublicKey": "14jeK98twjZyT8meztwMjSYksUBVyDRviLpXuYq5pYcg", + "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", + "TokenInfos": [ + { + "tokenpubkey": "3QcayW1rsxtHCH2q1gVXQHhjbMgue5Lc7RogjzCDX9dG", + "tokenaccpubkey": "35pMwKysmadEY5HhnVEzPo8GqFUobrpWWbpoTJR6wQrU", + "tokenlogo": "bit_up.png", + "tokenname": "DDUP" + }, + { + "tokenpubkey": "AcDVAgeGdxLhm6iRe8GyF4EKArFaoXGdprTH6XRnaAJS", + "tokenaccpubkey": "G4bUSi5eFHDNXo6382oxEzG8ZyPWrbSkYmDdH9Vy6a3n", + "tokenlogo": "bit_mz.png", + "tokenname": "ASC" + }, + { + "tokenpubkey": "2xoCodAbbg1X1YSMA1xW4pMVGXn9WXamfQRaBsbnvgmy", + "tokenaccpubkey": "HoKFGGbNAntBezNQSjUuaQMzbiZMbNt86qHnxuHc9URF", + "tokenlogo": "bit_pet.png", + "tokenname": "PET" + + }, + + { + "tokenpubkey": "EgjNUcFfydCKtBEp5CVzGsPGNrJG9pjan9cU7ahmcM5B", + "tokenaccpubkey": "6Kdz4DAWBpp3TgQFFL8nBXvnktDRwDQtczqEBWBz2Snc", + "tokenlogo": "bit_ttc.png", + "tokenname": "TTC" + + }, + { + "tokenpubkey": "E3ffQL6jkngH4teM6YuKvcwYXN6dap7fztETeBfmVtuF", + "tokenaccpubkey": "E5MT88EwguvGAQTnom2ojTFyQeMUXhDUkKGcfwbpQDHv", + "tokenlogo": "bit_pyh.png", + "tokenname": "PYH" + + } + + ] +} From 9ca392447fdef8895405b6d48cc17437cf5083f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Mon, 3 Jun 2019 11:25:10 +0800 Subject: [PATCH 4/9] Get amount from token Get amount from token --- src/appwallet.js | 46 +++++++++++----------------------------------- tokens.json | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/appwallet.js b/src/appwallet.js index 82ce16a..02c0da2 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -191,7 +191,6 @@ class TokenAsset extends React.Component { var tokenselected = false; var tokenaccpubkey = ''; var tokenamount = '100'; - console.log('token:::::::',token); // tem += ' 代币名称: {' + i + '} '; //根据tokenaccoutpublickey获取余额 @@ -218,7 +217,9 @@ class TokenAsset extends React.Component { // acc.name // ); } - console.log('tokenNameArray0:::::::',arrToken); + var array = localStorage.getItem('tokenArray'); + + console.log('tokenNameArrayarrayarray:::::::',array); this.setState({tokenNameArray: arrToken}); @@ -1072,30 +1073,6 @@ export class Wallet extends React.Component { super(props); this.onStoreChange(); } - testtokens(){ - var arrToken = []; - for (var i = 0; i < 5; i++) { - var tokenpubkey = new web3.PublicKey(data.AccountPublicKey); - //根据tokenpublickey获取token信息 - var tokenname = 'BUS'; - var tokensymbol = 'BUS'; - var tokensupply = '1000000000000000'; - var tokendecimal = '4'; - var tokenlogo = 'account_head.png'; - var tokenselected = true; - arrToken.push({ - tokenpubkey, - tokenname, - tokensymbol, - tokensupply, - tokendecimal, - tokenlogo, - tokenselected - }); - } - this.setState({tokenArr: arrToken}); - console.log('arrrrrr==',arrToken); - } getTokenDetails(){ var i; @@ -1221,10 +1198,7 @@ export class Wallet extends React.Component { this.setState({tokenNameArray: tokenarr}); } ResetListForPorperty(){ - let arr = this.state.tokenNameArray; - console.log('tokenNameArraylast:======',arr); this.createNewTokenAccount(); - this.setState({tokenArr: arr,addPropertyModal: false}); } @@ -1242,18 +1216,20 @@ export class Wallet extends React.Component { copy(this.state.newTokenAccountPublicKey); } - createNewTokenAccount() { + async createNewTokenAccount() { for (var i = 0; i < this.state.tokenNameArray.length; i++) { var tokens = this.state.tokenNameArray[i]; if (tokens.tokenselected == true) { var token = tokens.token; - console.log('获取token余额:',token); - var newtokenaccpubkey = token.newAccount(this.web3solAccount); - tokens.tokenaccpubkey = newtokenaccpubkey.toString(); - var accTokenInfo = token.accountInfo(newtokenaccpubkey); - tokens.tokenamount = accTokenInfo.amount.toString(); + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); + alert('token publickey: ' + newTokenAccountInfo.amount.toString()); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); } } + let arr = this.state.tokenNameArray; + this.setState({tokenArr: arr,addPropertyModal: false}); + localStorage.setItem('tokenArray',this.state.tokenNameArray); } refreshBalance() { diff --git a/tokens.json b/tokens.json index 1d5a606..fccf402 100644 --- a/tokens.json +++ b/tokens.json @@ -3,35 +3,35 @@ "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", "TokenInfos": [ { - "tokenpubkey": "3QcayW1rsxtHCH2q1gVXQHhjbMgue5Lc7RogjzCDX9dG", - "tokenaccpubkey": "35pMwKysmadEY5HhnVEzPo8GqFUobrpWWbpoTJR6wQrU", + "tokenpubkey": "GNqo1XYhwyG6oFJsoNjWsGCCifBUFDcaFemNrUVymRKU", + "tokenaccpubkey": "HKkXuRhUqi2PmDYVKuMPAEYRBVnY4LTscCwXwV9cduJs", "tokenlogo": "bit_up.png", "tokenname": "DDUP" }, { - "tokenpubkey": "AcDVAgeGdxLhm6iRe8GyF4EKArFaoXGdprTH6XRnaAJS", - "tokenaccpubkey": "G4bUSi5eFHDNXo6382oxEzG8ZyPWrbSkYmDdH9Vy6a3n", + "tokenpubkey": "3S27jg5YoB8E8PfezXWLLfWFAXqMEZbWsvZN8AS7efJn", + "tokenaccpubkey": "C7Nrp1Syx8YebMQt5GJZGPa2tFd9oLcEm96jVmenuTpD", "tokenlogo": "bit_mz.png", "tokenname": "ASC" }, { - "tokenpubkey": "2xoCodAbbg1X1YSMA1xW4pMVGXn9WXamfQRaBsbnvgmy", - "tokenaccpubkey": "HoKFGGbNAntBezNQSjUuaQMzbiZMbNt86qHnxuHc9URF", + "tokenpubkey": "4WzC5uAKSBu1FGnx6QGo6mJ9hFzE9RvLDiLhUVLf1Jo9", + "tokenaccpubkey": "DA8Tyi5cUrKYYSYxH5tHMfG23ebnC3ve9WQFSB2fcR2a", "tokenlogo": "bit_pet.png", "tokenname": "PET" }, { - "tokenpubkey": "EgjNUcFfydCKtBEp5CVzGsPGNrJG9pjan9cU7ahmcM5B", - "tokenaccpubkey": "6Kdz4DAWBpp3TgQFFL8nBXvnktDRwDQtczqEBWBz2Snc", + "tokenpubkey": "2h1X56dUcZiNG8BHADSeJqguuL5NDMdyPNW28EFVPS7Z", + "tokenaccpubkey": "DHrT3b5zu8fGMCuNRe3rSMGhGFsF1JVT7ECDTtAWHmMK", "tokenlogo": "bit_ttc.png", "tokenname": "TTC" }, { - "tokenpubkey": "E3ffQL6jkngH4teM6YuKvcwYXN6dap7fztETeBfmVtuF", - "tokenaccpubkey": "E5MT88EwguvGAQTnom2ojTFyQeMUXhDUkKGcfwbpQDHv", + "tokenpubkey": "AuGnADoYcHGvUcDjBqwgsDof7NoFJg2ACAMzw6MftQGN", + "tokenaccpubkey": "ACPaCs6VtkUSL2skHhCgcNkqjNA3eeyNe4TMPzf8NZKX", "tokenlogo": "bit_pyh.png", "tokenname": "PYH" From c7f60575105a08055b9b311b1c7d343cdd5f1890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Mon, 3 Jun 2019 11:29:32 +0800 Subject: [PATCH 5/9] Update appwallet.js --- src/appwallet.js | 140 +++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 78 deletions(-) diff --git a/src/appwallet.js b/src/appwallet.js index 02c0da2..1563af1 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -91,23 +91,6 @@ PropertySection.propTypes = { }; class PropertySelect extends React.Component{ - state = { - isSelected:false - } - //接收父组件传递过来的item - selectedButton(){ - if (this.state.isSelected == false) { - this.setState({isSelected: true}); - document.getElementById(this.props.buttonId).style.background=`url(${SelectOn})`; - document.getElementById(this.props.buttonId).style.backgroundSize='25px 25px'; - }else{ - this.setState({isSelected: false}); - document.getElementById(this.props.buttonId).style.background=`url(${SelectOff})`; - document.getElementById(this.props.buttonId).style.backgroundSize='25px 25px'; - } - - - } render(){ return(
@@ -128,7 +111,8 @@ PropertySelect.propTypes = { tokenName: PropTypes.object, selected: PropTypes.function, switchOn: PropTypes.object, - buttonId: PropTypes.object + buttonId: PropTypes.object, + tokenselected: PropTypes.object }; class PropertyList extends React.Component { componentDidMount() { @@ -166,67 +150,67 @@ class TokenAsset extends React.Component { console.log('第一步:::::::',this.state.tokenNameArray); } + // async readPublicKeyFromFile() { - try { - String.format = function(src){ - if (arguments.length == 0) return null; - var args = Array.prototype.slice.call(arguments, 1); - return src.replace(/\{(\d+)\}/g, function(m, i){ - return args[i]; - }); - }; - var i; - var arrToken = []; - for(i = 0; i < info.TokenInfos.length; i++) { - console.log('tokenpubkey==',info.TokenInfos[i].tokenpubkey); - var tokenpubkey = new web3.PublicKey(info.TokenInfos[i].tokenpubkey); - //根据tokenpublickey获取token信息 - var token = new web3.Token(this.props.conn, tokenpubkey); - var acc = await token.tokenInfo(); - var tokenname = acc.name; - var tokensymbol = acc.symbol; - var tokensupply = acc.supply; - var tokendecimal = acc.decimals; - var tokenlogo = info.TokenInfos[i].tokenlogo; - var tokenselected = false; - var tokenaccpubkey = ''; - var tokenamount = '100'; - - // tem += ' 代币名称: {' + i + '} '; - //根据tokenaccoutpublickey获取余额 - // var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; - // var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); - - // tem += '余额: ' + accTokenInfo.amount; - - arrToken.push({ - token, - tokenpubkey, - tokenaccpubkey, - tokenname, - tokensymbol, - tokensupply, - tokendecimal, - tokenlogo, - tokenselected, - tokenamount, - }); - - // msg += String.format( - // tem, - // acc.name - // ); - } - var array = localStorage.getItem('tokenArray'); - - console.log('tokenNameArrayarrayarray:::::::',array); - + var array = localStorage.getItem('tokenArray'); + if (array&&array.length>0) { this.setState({tokenNameArray: arrToken}); - - - } catch (err) - { - this.addError(err.message); + }else{ + try { + String.format = function(src){ + if (arguments.length == 0) return null; + var args = Array.prototype.slice.call(arguments, 1); + return src.replace(/\{(\d+)\}/g, function(m, i){ + return args[i]; + }); + }; + var i; + var arrToken = []; + for(i = 0; i < info.TokenInfos.length; i++) { + console.log('tokenpubkey==',info.TokenInfos[i].tokenpubkey); + var tokenpubkey = new web3.PublicKey(info.TokenInfos[i].tokenpubkey); + //根据tokenpublickey获取token信息 + var token = new web3.Token(this.props.conn, tokenpubkey); + var acc = await token.tokenInfo(); + var tokenname = acc.name; + var tokensymbol = acc.symbol; + var tokensupply = acc.supply; + var tokendecimal = acc.decimals; + var tokenlogo = info.TokenInfos[i].tokenlogo; + var tokenselected = false; + var tokenaccpubkey = ''; + var tokenamount = '100'; + + // tem += ' 代币名称: {' + i + '} '; + //根据tokenaccoutpublickey获取余额 + // var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; + // var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); + + // tem += '余额: ' + accTokenInfo.amount; + + arrToken.push({ + token, + tokenpubkey, + tokenaccpubkey, + tokenname, + tokensymbol, + tokensupply, + tokendecimal, + tokenlogo, + tokenselected, + tokenamount, + }); + + // msg += String.format( + // tem, + // acc.name + // ); + } + this.setState({tokenNameArray: arrToken}); + } catch (err) + { + this.addError(err.message); + } } } addSelectedToken(index){ @@ -252,7 +236,7 @@ class TokenAsset extends React.Component { { this.state.tokenNameArray.map((obj,index) => { return( - this.addSelectedToken(index)}/> + this.addSelectedToken(index)}/> ); }) } From 12e1fbb89f83c61ad1c5fec00041f359540c64cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Thu, 6 Jun 2019 17:45:48 +0800 Subject: [PATCH 6/9] add token transfer function add token transfer function --- publickey.json | 41 ++++++++-- src/appwallet.js | 206 ++++++++++++++++++++++++++++++++++------------- src/detail.js | 54 +++++++++++++ src/store.js | 2 +- src/wallet.js | 8 +- tokens.json | 20 ++--- yarn.lock | 1 + 7 files changed, 252 insertions(+), 80 deletions(-) create mode 100644 src/detail.js create mode 100644 yarn.lock diff --git a/publickey.json b/publickey.json index 8c9ac42..1ab4fff 100644 --- a/publickey.json +++ b/publickey.json @@ -1,14 +1,41 @@ { - "AccountPublicKey": "2EdJJzcrKrB9DXypghbR1npqyZMPYEnT43oix6Abgw7S", - "AccountSecreKey": "107,143,235,119,147,182,152,17,156,227,125,249,233,187,154,227,103,199,194,228,106,30,131,224,186,254,206,128,134,22,226,90,18,89,71,189,125,161,45,49,164,0,229,88,172,190,118,118,43,92,6,164,3,212,226,196,162,140,148,167,62,70,23,165", - "TokenPublicKeys": [ + "AccountPublicKey": "14jeK98twjZyT8meztwMjSYksUBVyDRviLpXuYq5pYcg", + "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", + "TokenInfos": [ { - "tokenpubkey": "4m4GriqBUKxx41JkNwfma1SABCjP7qaevqYMzW3zwzJQ", - "tokenaccountpubkey": "JAjpqyGW23drjFz8avUPzuvnsW9ScvGyFzq2J9ydVG2k" + "tokenpubkey": "846uvQMSQ28XtUF3DFLZ2EjvKMM3Xg4QXC4fbrr8ovis", + "tokenaccpubkey": "AHTdbXudWs3cG8teRgxDL3CRfa64ET2S5uqpYZmJGTpx", + "tokenlogo": "bit_up.png", + "tokenname": "DDUP" }, { - "tokenpubkey": "Br5EfPGUT9yP5QkDVkVAkzC6r75JpQSCuMKfPBE4D95X", - "tokenaccountpubkey": "DoxzTmaUixUzSPbNYQ353ZPExkaYitW26oQ96QoZGsng" + "tokenpubkey": "LdWPWbcsErzS6dmUAbGi93tcW1qVQ7exF4ZSFDXCuZj", + "tokenaccpubkey": "A6wmUVCmN2krkdmMYDqEbBPKFg6gtjcuBARe3hrFuykC", + "tokenlogo": "bit_mz.png", + "tokenname": "ASC" + }, + { + "tokenpubkey": "2SgcGgoXQFZVvw8H6KUWWCydBiSnoVwh3wLshTr5n2LH", + "tokenaccpubkey": "2N49QZqYvHTr9RGKeQzsKnabFd5hGWE7iPLaCFSPixPf", + "tokenlogo": "bit_pet.png", + "tokenname": "PET" + + }, + + { + "tokenpubkey": "42ufWasJorufE4KBDZ658G2r3TroPF7NP33SKeX7b3e2", + "tokenaccpubkey": "83ieh9whNUk7hpTGnR4iFbcULd2QB4JDNW4VawoL9ixg", + "tokenlogo": "bit_ttc.png", + "tokenname": "TTC" + + }, + { + "tokenpubkey": "4waV9etDwxfGsPkve6jvmB13fvNe3LnM7VVXaSjvnJew", + "tokenaccpubkey": "Eqor9M8mPbHwLRqYtrjj4gfLcjRe7NZ7TxfCRUdGE8Kh", + "tokenlogo": "bit_pyh.png", + "tokenname": "PYH" + } + ] } diff --git a/src/appwallet.js b/src/appwallet.js index 1563af1..4c4c543 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -17,17 +17,16 @@ import copy from 'copy-to-clipboard'; import * as web3 from '@bitconch/bitconch-web3j'; import {Settings} from './settings'; -import data from '../publickey.json'; -import info from '../tokens.json'; +import {PropertyDetail} from './detail'; +import info from '../publickey.json'; import Background from './images/account_backgroud.png'; import CopyIcon from './images/address_copy.png'; import TransferIcon from './images/main_right.png'; import AddIcon from './images/main_jia.png'; import SelectOn from './images/selecte_on.png'; import SelectOff from './images/selecte_off.png'; - const AIRDORP_QUOTA = 3000; - +const TokensArray = 'tokenArray'; var sectionStyle = { height: '250px', width: '100%', @@ -91,16 +90,18 @@ PropertySection.propTypes = { }; class PropertySelect extends React.Component{ + state = { + imageurl: this.props.tokenselected == false? SelectOff:SelectOn + } render(){ return(
-
- ); } } @@ -152,9 +153,10 @@ class TokenAsset extends React.Component { } // async readPublicKeyFromFile() { - var array = localStorage.getItem('tokenArray'); - if (array&&array.length>0) { - this.setState({tokenNameArray: arrToken}); + var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); + if (weekArray&&weekArray.length>0) { + console.log('weekArray:',weekArray); + this.setState({tokenNameArray: weekArray}); }else{ try { String.format = function(src){ @@ -179,7 +181,8 @@ class TokenAsset extends React.Component { var tokenlogo = info.TokenInfos[i].tokenlogo; var tokenselected = false; var tokenaccpubkey = ''; - var tokenamount = '100'; + var tokenamount = '10'; + var tokenpublickey = info.TokenInfos[i].tokenpubkey; // tem += ' 代币名称: {' + i + '} '; //根据tokenaccoutpublickey获取余额 @@ -189,8 +192,7 @@ class TokenAsset extends React.Component { // tem += '余额: ' + accTokenInfo.amount; arrToken.push({ - token, - tokenpubkey, + tokenpublickey, tokenaccpubkey, tokenname, tokensymbol, @@ -206,7 +208,9 @@ class TokenAsset extends React.Component { // acc.name // ); } + console.log('arrToken:',arrToken); this.setState({tokenNameArray: arrToken}); + } catch (err) { this.addError(err.message); @@ -928,10 +932,10 @@ class TransferModal extends React.Component {
- +
- BUS + {this.props.name}
this.props.topublickey(publicKey)}/> this.props.transferamount(amount)} amount={this.props.amount}/> @@ -946,6 +950,8 @@ class TransferModal extends React.Component { } TransferModal.propTypes = { + logo: PropTypes.object, + name: PropTypes.object, amount:PropTypes.object, topublickey: PropTypes.function, transferamount: PropTypes.function, @@ -1035,6 +1041,9 @@ export class Wallet extends React.Component { tokenSymbol: null, tokenDecimal: 0, tokenAmount: 0, + tokenLogo: null, + tokenAccPubkey: null, + tokenPublicKey: null, newTokenAcountAddr: null, sourceTokenAccountPublicKey: null, destTokenAccountPublicKey: null, @@ -1050,12 +1059,44 @@ export class Wallet extends React.Component { showText:null, showModal: false, addPropertyModal:false, - tokenArr: [] + tokenArr: [], + displaydetail: 'none' }; constructor(props) { super(props); this.onStoreChange(); + this.getArrayFromlocal(); + } + async getArrayFromlocal(){ + var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); + this.setState({tokenNameArray: weekArray}); + this.loadlocalarr(weekArray); + } + async loadlocalarr(array){ + var tokensArr = []; + for (var i = 0; i < array.length; i++) { + var tokens = array[i]; + if (tokens.tokenselected == true) { + var publickey = new web3.PublicKey(tokens.tokenpublickey); + var token = new web3.Token(this.web3sol, publickey); + var tokenaccpubkey = tokens.tokenaccpubkey; + if (tokenaccpubkey.length == 0){ + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); + }else{ + var accpublickey = new web3.PublicKey(tokenaccpubkey); + const newTokenAccountInfo = await token.accountInfo(accpublickey); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); + } + + } + tokensArr.push(tokens); + + } + this.setState({tokenArr: array,addPropertyModal: false}); } getTokenDetails(){ @@ -1063,8 +1104,8 @@ export class Wallet extends React.Component { // var tem = ''; // var msg = ''; var arrTokenDetails = []; - for(i = 0; i < data.TokenDetail.length; i++) { - arrTokenDetails.push(data.TokenDetail[i]); + for(i = 0; i < info.TokenDetail.length; i++) { + arrTokenDetails.push(info.TokenDetail[i]); } alert(arrTokenDetails); return arrTokenDetails; @@ -1183,8 +1224,6 @@ export class Wallet extends React.Component { } ResetListForPorperty(){ this.createNewTokenAccount(); - - } copyPublicKey() { copy(this.web3solAccount.publicKey); @@ -1200,20 +1239,38 @@ export class Wallet extends React.Component { copy(this.state.newTokenAccountPublicKey); } - async createNewTokenAccount() { - for (var i = 0; i < this.state.tokenNameArray.length; i++) { - var tokens = this.state.tokenNameArray[i]; - if (tokens.tokenselected == true) { - var token = tokens.token; - var newtokenaccpubkey = await token.newAccount(this.web3solAccount); - const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); - alert('token publickey: ' + newTokenAccountInfo.amount.toString()); - tokens.tokenamount = newTokenAccountInfo.amount.toString(); + createNewTokenAccount() { + this.runModal( + '正在添加', + '请稍后...', + async () => { + var tokensArr = []; + for (var i = 0; i < this.state.tokenNameArray.length; i++) { + var tokens = this.state.tokenNameArray[i]; + if (tokens.tokenselected == true) { + var publickey = new web3.PublicKey(tokens.tokenpublickey); + var token = new web3.Token(this.web3sol, publickey); + var tokenaccpubkey = tokens.tokenaccpubkey; + if (tokenaccpubkey.length == 0){ + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); + }else{ + var accpublickey = new web3.PublicKey(tokenaccpubkey); + const newTokenAccountInfo = await token.accountInfo(accpublickey); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); + } + } + tokensArr.push(tokens); + + } + let arr = this.state.tokenNameArray; + console.log('arrrrrr:',arr); + localStorage.setItem(TokensArray,JSON.stringify(tokensArr)); + this.setState({tokenArr: arr,addPropertyModal: false}); } - } - let arr = this.state.tokenNameArray; - this.setState({tokenArr: arr,addPropertyModal: false}); - localStorage.setItem('tokenArray',this.state.tokenNameArray); + ); } refreshBalance() { @@ -1248,43 +1305,65 @@ export class Wallet extends React.Component { async () => { const transaction = web3.SystemProgram.move( this.web3solAccount.publicKey, - new web3.PublicKey(this.state.recipientPublicKey), - this.state.recipientAmount, + new web3.PublicKey(this.state.destTokenAccountPublicKey), + this.state.transferTokenAmount, ); - const signature = await this.web3sol.sendTransaction(this.web3solAccount, transaction); + const signature = await this.web3sol.sendTransaction(transaction,this.web3solAccount); await this.web3sol.confirmTransaction(signature); + this.setState({transferModal: false,showText:'发送成功',showModal: true}); this.setState({ balance: await this.web3sol.getBalance(this.web3solAccount.publicKey), + tokenAmount: await this.web3sol.getBalance(this.web3solAccount.publicKey) }); } ); } transferToken() { + if (this.state.destTokenAccountPublicKey == null||this.state.destTokenAccountPublicKey.length == 0) { + alert('请输入收款地址'); + return; + } + if (this.state.destTokenAccountPublicKey == null||this.state.destTokenAccountPublicKey == 0) { + alert('请输入转账金额'); + return; + } + if (this.state.destTokenAccountPublicKey == this.state.tokenAccPubkey) { + alert('不能转给自己'); + return; + } + if (this.state.tokenAccPubkey == this.web3solAccount.publicKey.toString()) { + alert('pubkey:::'+this.state.destTokenAccountPublicKey); + this.sendTransaction(); + return; + } + this.runModal( '发送Token', '请稍后...', async () => { - var sourcetokenacc = await this.state.tokenObj.accountInfo(new web3.PublicKey(this.state.sourceTokenAccountPublicKey)); + var token = await new web3.Token(this.web3sol, new web3.PublicKey(this.state.tokenPublicKey)); + var sourcetokenacc = await token.accountInfo(new web3.PublicKey(this.state.tokenAccPubkey)); if (new Number(sourcetokenacc.amount) < new Number(this.state.transferTokenAmount)) { alert('token数量不足,无法完成交易! 当前账户Token数量:' + sourcetokenacc.amount); return; } - - const sig = await this.state.tokenObj.transfer( + const sig = await token.transfer( this.web3solAccount, - new web3.PublicKey(this.state.sourceTokenAccountPublicKey), + new web3.PublicKey(this.state.tokenAccPubkey), new web3.PublicKey(this.state.destTokenAccountPublicKey), this.state.transferTokenAmount ); await this.web3sol.confirmTransaction(sig); - sourcetokenacc = await this.state.tokenObj.accountInfo(new web3.PublicKey(this.state.sourceTokenAccountPublicKey)); - var desttokenacc = await this.state.tokenObj.accountInfo(new web3.PublicKey(this.state.destTokenAccountPublicKey)); + sourcetokenacc = await token.accountInfo(new web3.PublicKey(this.state.tokenAccPubkey)); + var desttokenacc = await token.accountInfo(new web3.PublicKey(this.state.destTokenAccountPublicKey)); + this.setState({transferModal: false,showText:'发送成功',showModal: true}); this.setState({ - sourceTokenAccountTokenAmount: sourcetokenacc.amount.toString(), + tokenAmount: sourcetokenacc.amount.toString(), destTokenAccountTokenAmount: desttokenacc.amount.toString(), }); + this.getArrayFromlocal(); } ); } @@ -1347,7 +1426,10 @@ export class Wallet extends React.Component { this.setState({showText:'私钥复制到粘贴板,请妥善保管',showModal: true}); } - + copyAccountPublickey(){ + copy(this.state.tokenAccPubkey); + this.setState({showText:'收款地址已复制到粘贴板',showModal: true}); + } confirmTransaction() { this.runModal( @@ -1363,7 +1445,18 @@ export class Wallet extends React.Component { } ); } - + pushNewWindow(index){ + if (index == 999) { + this.setState({tokenName: 'BUS',tokenAmount:this.state.balance,tokenAccPubkey:this.web3solAccount.publicKey.toString(),tokenLogo: 'account_head.png',tokenPublicKey:this.web3solAccount.publicKey.toString()}); + }else{ + var token = this.state.tokenArr[index]; + this.setState({tokenName: token.tokenname,tokenAmount: token.tokenamount,tokenAccPubkey: token.tokenaccpubkey,tokenLogo: token.tokenlogo,tokenPublicKey: token.tokenpublickey}); + } + this.setState({displaydetail: 'block'}); + } + closeNewWindow(){ + this.setState({displaydetail: 'none'}); + } render() { const busyModal = this.state.busyModal ? : null; @@ -1379,10 +1472,12 @@ export class Wallet extends React.Component { this.setState({transferModal: false})} - transfer={() => this.sendTransaction()} - topublickey={key => this.setRecipientPublicKey(key)} - transferamount={key => this.setRecipientAmount(key)} - amount={this.state.balance} + transfer={() => this.transferToken()} + topublickey={key => this.setDestTokenAccountPublicKey(key)} + transferamount={key => this.setTransferTokenAmount(key)} + amount={this.state.tokenAmount} + name = {this.state.tokenName} + logo = {this.state.tokenLogo} /> ) : null; const showModal = this.state.showModal ? ( @@ -1406,13 +1501,6 @@ export class Wallet extends React.Component { const settingsModal = this.state.settingsModal ? this.setState({settingsModal: false})}/> : null; - - // const sendDisabled = this.state.recipientPublicKey === null || this.state.recipientAmount === null; - // const createDisabled = this.state.tokenSupply === 0 || this.state.tokenDecimal === 0 || this.state.tokenName === null || this.state.tokenSymbol ===null; - // const airdropDisabled = this.state.balance !== 0; - // const transferDisabled = this.state.SourceTokenAccountPubKeyInput === null || this.state.destTokenAccountPublicKey === null || this.state.transferTokenAmount === 0 || this.state.tokenObj === null; - // const createNewTokenAccountDisabled = this.state.tokenObj === null; - return (
{busyModal} @@ -1422,7 +1510,9 @@ export class Wallet extends React.Component { {showModal} {addPropertyModal} this.dismissError(index)}/> - +
+ this.closeNewWindow()} tokenname={this.state.tokenName} tokenamount={this.state.tokenAmount} tokenaccpubkey={this.state.tokenAccPubkey} rechangeamount={()=>this.setState({transferModal: true})} showcode={()=>this.copyAccountPublickey()}/> +
@@ -1450,12 +1540,12 @@ export class Wallet extends React.Component { this.setState({addPropertyModal: true})}/>
- this.setState({transferModal: true})} /> + this.pushNewWindow(999)} /> { this.state.tokenArr.map((obj,index) => { if (obj.tokenselected==true) { return( - + this.pushNewWindow(index)}/> ); } }) diff --git a/src/detail.js b/src/detail.js new file mode 100644 index 0000000..24cbfbb --- /dev/null +++ b/src/detail.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { + Button +} from 'react-bootstrap'; +import PropTypes from 'prop-types'; + +import Close from './images/show_close.png'; + +//定义一个Section子组件 +export class PropertyDetail extends React.Component { + constructor(props) { + super(props); + } + //接收父组件传递过来的item + componentDidMount() { + } + componentWillUnmount() { + } + render(){ + return( +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+ ); + } +} +PropertyDetail.propTypes = { + store: PropTypes.object, + tokenname: PropTypes.object, + tokenamount: PropTypes.object, + tokenaccpubkey: PropTypes.object, + showcode: PropTypes.function, + rechangeamount: PropTypes.function, + closedetail: PropTypes.function +}; diff --git a/src/store.js b/src/store.js index 9ad36a1..c5b31d4 100644 --- a/src/store.js +++ b/src/store.js @@ -19,7 +19,7 @@ export class Store { } if (typeof this.networkEntryPoint !== 'string') { - this.networkEntryPoint = 'http://47.244.209.112:8899'; + this.networkEntryPoint = 'http://47.244.209.112:8899'; } if (!this.accountSecretKey) { diff --git a/src/wallet.js b/src/wallet.js index c217982..607efff 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -51,8 +51,8 @@ class TokenAsset extends React.Component { // var tem = ''; // var msg = ''; var arrToken = []; - for(i = 0; i < data.TokenPublicKeys.length; i++) { - var tokenpubkey = new web3.PublicKey(data.TokenPublicKeys[i].tokenpubkey); + for(i = 0; i < data.TokenInfos.length; i++) { + var tokenpubkey = new web3.PublicKey(data.TokenInfos[i].tokenpubkey); var token = new web3.Token(this.props.conn, tokenpubkey); var acc = await token.tokenInfo(); var tokenname = acc.name; @@ -62,7 +62,7 @@ class TokenAsset extends React.Component { // tem += ' 代币名称: {' + i + '} '; - var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; + var tokenaccpubkey = data.TokenInfos[i].tokenaccpubkey; var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); // tem += '余额: ' + accTokenInfo.amount; @@ -1058,7 +1058,7 @@ export class Wallet extends React.Component { new web3.PublicKey(this.state.recipientPublicKey), this.state.recipientAmount, ); - const signature = await this.web3sol.sendTransaction(this.web3solAccount, transaction); + const signature = await this.web3sol.sendTransaction(transaction,this.web3solAccount); await this.web3sol.confirmTransaction(signature); this.setState({ diff --git a/tokens.json b/tokens.json index fccf402..6a6ad00 100644 --- a/tokens.json +++ b/tokens.json @@ -3,35 +3,35 @@ "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", "TokenInfos": [ { - "tokenpubkey": "GNqo1XYhwyG6oFJsoNjWsGCCifBUFDcaFemNrUVymRKU", - "tokenaccpubkey": "HKkXuRhUqi2PmDYVKuMPAEYRBVnY4LTscCwXwV9cduJs", + "tokenpubkey": "846uvQMSQ28XtUF3DFLZ2EjvKMM3Xg4QXC4fbrr8ovis", + "tokenaccpubkey": "AHTdbXudWs3cG8teRgxDL3CRfa64ET2S5uqpYZmJGTpx", "tokenlogo": "bit_up.png", "tokenname": "DDUP" }, { - "tokenpubkey": "3S27jg5YoB8E8PfezXWLLfWFAXqMEZbWsvZN8AS7efJn", - "tokenaccpubkey": "C7Nrp1Syx8YebMQt5GJZGPa2tFd9oLcEm96jVmenuTpD", + "tokenpubkey": "LdWPWbcsErzS6dmUAbGi93tcW1qVQ7exF4ZSFDXCuZj", + "tokenaccpubkey": "A6wmUVCmN2krkdmMYDqEbBPKFg6gtjcuBARe3hrFuykC", "tokenlogo": "bit_mz.png", "tokenname": "ASC" }, { - "tokenpubkey": "4WzC5uAKSBu1FGnx6QGo6mJ9hFzE9RvLDiLhUVLf1Jo9", - "tokenaccpubkey": "DA8Tyi5cUrKYYSYxH5tHMfG23ebnC3ve9WQFSB2fcR2a", + "tokenpubkey": "2SgcGgoXQFZVvw8H6KUWWCydBiSnoVwh3wLshTr5n2LH", + "tokenaccpubkey": "2N49QZqYvHTr9RGKeQzsKnabFd5hGWE7iPLaCFSPixPf", "tokenlogo": "bit_pet.png", "tokenname": "PET" }, { - "tokenpubkey": "2h1X56dUcZiNG8BHADSeJqguuL5NDMdyPNW28EFVPS7Z", - "tokenaccpubkey": "DHrT3b5zu8fGMCuNRe3rSMGhGFsF1JVT7ECDTtAWHmMK", + "tokenpubkey": "42ufWasJorufE4KBDZ658G2r3TroPF7NP33SKeX7b3e2", + "tokenaccpubkey": "83ieh9whNUk7hpTGnR4iFbcULd2QB4JDNW4VawoL9ixg", "tokenlogo": "bit_ttc.png", "tokenname": "TTC" }, { - "tokenpubkey": "AuGnADoYcHGvUcDjBqwgsDof7NoFJg2ACAMzw6MftQGN", - "tokenaccpubkey": "ACPaCs6VtkUSL2skHhCgcNkqjNA3eeyNe4TMPzf8NZKX", + "tokenpubkey": "4waV9etDwxfGsPkve6jvmB13fvNe3LnM7VVXaSjvnJew", + "tokenaccpubkey": "Eqor9M8mPbHwLRqYtrjj4gfLcjRe7NZ7TxfCRUdGE8Kh", "tokenlogo": "bit_pyh.png", "tokenname": "PYH" diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..e70ce1b --- /dev/null +++ b/yarn.lock @@ -0,0 +1 @@ + resolved "https://registry.npm.taobao.org/@babel/code-frame/download/@babel/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" From df7160959445608fa08b479a83332ae78acd6b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Thu, 6 Jun 2019 19:58:41 +0800 Subject: [PATCH 7/9] Update appwallet.js --- src/appwallet.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/appwallet.js b/src/appwallet.js index 4c4c543..4f27820 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -26,7 +26,6 @@ import AddIcon from './images/main_jia.png'; import SelectOn from './images/selecte_on.png'; import SelectOff from './images/selecte_off.png'; const AIRDORP_QUOTA = 3000; -const TokensArray = 'tokenArray'; var sectionStyle = { height: '250px', width: '100%', @@ -70,8 +69,8 @@ class PropertySection extends React.Component{
-
- +
+
@@ -153,6 +152,7 @@ class TokenAsset extends React.Component { } // async readPublicKeyFromFile() { + var TokensArray = this.props.publickey; var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); if (weekArray&&weekArray.length>0) { console.log('weekArray:',weekArray); @@ -250,6 +250,7 @@ class TokenAsset extends React.Component { } TokenAsset.propTypes = { + publickey: PropTypes.object, onTokenAsset: PropTypes.function, conn: PropTypes.object, }; @@ -979,7 +980,7 @@ class AddPropertyModal extends React.Component {
- this.PostPoroertyList(tokenarr)}/> + this.PostPoroertyList(tokenarr)}/>
@@ -992,6 +993,7 @@ class AddPropertyModal extends React.Component { } AddPropertyModal.propTypes = { + publickey: PropTypes.object, web3sol: PropTypes.object, offSelect: PropTypes.function, onSelect: PropTypes.function, @@ -1069,6 +1071,7 @@ export class Wallet extends React.Component { this.getArrayFromlocal(); } async getArrayFromlocal(){ + var TokensArray = this.web3solAccount.publicKey.toString(); var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); this.setState({tokenNameArray: weekArray}); this.loadlocalarr(weekArray); @@ -1249,26 +1252,24 @@ export class Wallet extends React.Component { var tokens = this.state.tokenNameArray[i]; if (tokens.tokenselected == true) { var publickey = new web3.PublicKey(tokens.tokenpublickey); - var token = new web3.Token(this.web3sol, publickey); + var token = new web3.Token(this.web3sol, publickey); var tokenaccpubkey = tokens.tokenaccpubkey; - if (tokenaccpubkey.length == 0){ - var newtokenaccpubkey = await token.newAccount(this.web3solAccount); - tokens.tokenaccpubkey = newtokenaccpubkey.toString(); - const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); + if (tokenaccpubkey == ''){ + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + var newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); + token.tokenaccpubkey = newtokenaccpubkey.toString(); tokens.tokenamount = newTokenAccountInfo.amount.toString(); }else{ var accpublickey = new web3.PublicKey(tokenaccpubkey); - const newTokenAccountInfo = await token.accountInfo(accpublickey); - tokens.tokenamount = newTokenAccountInfo.amount.toString(); + var newTokenAccountInfo1 = await token.accountInfo(accpublickey); + tokens.tokenamount = newTokenAccountInfo1.amount.toString(); } } tokensArr.push(tokens); - } - let arr = this.state.tokenNameArray; - console.log('arrrrrr:',arr); + var TokensArray = this.web3solAccount.publicKey.toString(); localStorage.setItem(TokensArray,JSON.stringify(tokensArr)); - this.setState({tokenArr: arr,addPropertyModal: false}); + this.setState({tokenArr: tokensArr,addPropertyModal: false}); } ); } @@ -1490,6 +1491,7 @@ export class Wallet extends React.Component { const addPropertyModal = this.state.addPropertyModal ? ( this.addPorpertyList(tokenarr)} addsure = {() => this.ResetListForPorperty()} From 5b2a7c0cf9edc86cf4ce2fab5ef09ac0c848fb74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Fri, 7 Jun 2019 15:04:53 +0800 Subject: [PATCH 8/9] fix the bug --- publickey.json | 20 ++++++------- src/appwallet.js | 73 +++++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/publickey.json b/publickey.json index 1ab4fff..f4e853a 100644 --- a/publickey.json +++ b/publickey.json @@ -3,35 +3,35 @@ "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", "TokenInfos": [ { - "tokenpubkey": "846uvQMSQ28XtUF3DFLZ2EjvKMM3Xg4QXC4fbrr8ovis", - "tokenaccpubkey": "AHTdbXudWs3cG8teRgxDL3CRfa64ET2S5uqpYZmJGTpx", + "tokenpubkey": "6oZbAKdhB5b9A88JGwWHo2iBrpJ9J5R59NX7W8Jnvsm7", + "tokenaccpubkey": "97i31xDcKr8wUPVcS1KsFvVkdFV75GpXJ6FfWzath6bp", "tokenlogo": "bit_up.png", "tokenname": "DDUP" }, { - "tokenpubkey": "LdWPWbcsErzS6dmUAbGi93tcW1qVQ7exF4ZSFDXCuZj", - "tokenaccpubkey": "A6wmUVCmN2krkdmMYDqEbBPKFg6gtjcuBARe3hrFuykC", + "tokenpubkey": "46MnGNzr9BaF9wk2A3yohT9sSxX6EpM23NtjPM1VvvdE", + "tokenaccpubkey": "DrGtGUjzk51FXhZtz5qDn1WFaTEaKdj1Bh8LgnL8SjSE", "tokenlogo": "bit_mz.png", "tokenname": "ASC" }, { - "tokenpubkey": "2SgcGgoXQFZVvw8H6KUWWCydBiSnoVwh3wLshTr5n2LH", - "tokenaccpubkey": "2N49QZqYvHTr9RGKeQzsKnabFd5hGWE7iPLaCFSPixPf", + "tokenpubkey": "AArx7UUapG2P6bgpCSC6WDvMDqdamgGm4RiUpuK7w41X", + "tokenaccpubkey": "AuzptxsxSTGvtMBjo2S35NYjMz6Swx6nRtZrxgmKxu2t", "tokenlogo": "bit_pet.png", "tokenname": "PET" }, { - "tokenpubkey": "42ufWasJorufE4KBDZ658G2r3TroPF7NP33SKeX7b3e2", - "tokenaccpubkey": "83ieh9whNUk7hpTGnR4iFbcULd2QB4JDNW4VawoL9ixg", + "tokenpubkey": "CddR5UEA86oDzEsxKysUxHYve5K2RFa5e83y8Jrsq8MJ", + "tokenaccpubkey": "G4meP91W5afU1P2fjVSX5a3xUU4xVhYM3jguVgvCLJAF", "tokenlogo": "bit_ttc.png", "tokenname": "TTC" }, { - "tokenpubkey": "4waV9etDwxfGsPkve6jvmB13fvNe3LnM7VVXaSjvnJew", - "tokenaccpubkey": "Eqor9M8mPbHwLRqYtrjj4gfLcjRe7NZ7TxfCRUdGE8Kh", + "tokenpubkey": "Hp7882LJmYnZMMq3r3SidyD4MvBDfqqSLCya7DKnHJo", + "tokenaccpubkey": "8gG1zUYvaQJS9VTjwQ6GoXncXauaczBUubktHDFwcHT4", "tokenlogo": "bit_pyh.png", "tokenname": "PYH" diff --git a/src/appwallet.js b/src/appwallet.js index 4f27820..54b711a 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -36,7 +36,8 @@ var sectionStyle = { var lineStyle = { height: '0.5px', backgroundColor: '#b8b6b6', - marginLeft:'10px' + marginLeft:'10px', + width:'100%' }; //定义一个Section子组件 @@ -65,7 +66,7 @@ class PropertySection extends React.Component{ //接收父组件传递过来的item render(){ return( -
+
@@ -1073,35 +1074,41 @@ export class Wallet extends React.Component { async getArrayFromlocal(){ var TokensArray = this.web3solAccount.publicKey.toString(); var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); - this.setState({tokenNameArray: weekArray}); - this.loadlocalarr(weekArray); - } - async loadlocalarr(array){ - var tokensArr = []; - for (var i = 0; i < array.length; i++) { - var tokens = array[i]; - if (tokens.tokenselected == true) { - var publickey = new web3.PublicKey(tokens.tokenpublickey); - var token = new web3.Token(this.web3sol, publickey); - var tokenaccpubkey = tokens.tokenaccpubkey; - if (tokenaccpubkey.length == 0){ - var newtokenaccpubkey = await token.newAccount(this.web3solAccount); - tokens.tokenaccpubkey = newtokenaccpubkey.toString(); - const newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); - tokens.tokenamount = newTokenAccountInfo.amount.toString(); - }else{ - var accpublickey = new web3.PublicKey(tokenaccpubkey); - const newTokenAccountInfo = await token.accountInfo(accpublickey); - tokens.tokenamount = newTokenAccountInfo.amount.toString(); - } - - } - tokensArr.push(tokens); - + if (weekArray&&weekArray.length>0) { + this.setState({tokenNameArray: weekArray}); + this.loadlocalarr(weekArray); } - this.setState({tokenArr: array,addPropertyModal: false}); } + loadlocalarr(array){ + this.runModal( + '更新账户余额', + '请稍后...', + async () => { + var tokensArr = []; + for (var i = 0; i < array.length; i++) { + var tokens = array[i]; + if (tokens.tokenselected == true) { + var publickey = new web3.PublicKey(tokens.tokenpublickey); + var token = new web3.Token(this.web3sol, publickey); + var tokenaccpubkey = tokens.tokenaccpubkey; + if (tokenaccpubkey.length == 0){ + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + const tokenInfo = await token.accountInfo(newtokenaccpubkey); + tokens.tokenamount = tokenInfo.amount.toString(); + }else{ + var accpublickey = new web3.PublicKey(tokenaccpubkey); + const newTokenAccountInfo = await token.accountInfo(accpublickey); + tokens.tokenamount = newTokenAccountInfo.amount.toString(); + } + } + tokensArr.push(tokens); + } + this.setState({tokenArr: array,addPropertyModal: false}); + } + ); + } getTokenDetails(){ var i; // var tem = ''; @@ -1210,7 +1217,7 @@ export class Wallet extends React.Component { if (array.length === 64) { var typedArray = new Uint8Array(array); await this.props.store.exportAccount(typedArray); - this.refreshBalance(); + window.location.reload(); this.setState({exportSercetModal:false}); } } @@ -1256,9 +1263,10 @@ export class Wallet extends React.Component { var tokenaccpubkey = tokens.tokenaccpubkey; if (tokenaccpubkey == ''){ var newtokenaccpubkey = await token.newAccount(this.web3solAccount); - var newTokenAccountInfo = await token.accountInfo(newtokenaccpubkey); - token.tokenaccpubkey = newtokenaccpubkey.toString(); - tokens.tokenamount = newTokenAccountInfo.amount.toString(); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + const tokenInfo = await token.accountInfo(newtokenaccpubkey); + console.log('tokenInfo.amount.toString()::',tokenInfo.amount.toString()); + tokens.tokenamount = tokenInfo.amount.toString(); }else{ var accpublickey = new web3.PublicKey(tokenaccpubkey); var newTokenAccountInfo1 = await token.accountInfo(accpublickey); @@ -1269,6 +1277,7 @@ export class Wallet extends React.Component { } var TokensArray = this.web3solAccount.publicKey.toString(); localStorage.setItem(TokensArray,JSON.stringify(tokensArr)); + console.log('tokensArr == ',tokensArr); this.setState({tokenArr: tokensArr,addPropertyModal: false}); } ); From 139d6ee88c78d630a8ac2dcebe6056183cc19cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E5=9D=A4?= <919689156@qq.com> Date: Fri, 14 Jun 2019 17:45:08 +0800 Subject: [PATCH 9/9] Adding Application Airdrop Function Adding Application Airdrop Function --- publickey.json | 20 ++++++++++---------- src/appwallet.js | 20 +++++++++++--------- src/wallet.js | 6 ++++++ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/publickey.json b/publickey.json index f4e853a..aba8204 100644 --- a/publickey.json +++ b/publickey.json @@ -3,35 +3,35 @@ "AccountSecreKey": "219,203,94,212,53,215,133,116,178,105,38,209,213,95,235,33,180,241,47,179,111,38,216,39,80,187,189,230,182,64,201,145,0,244,245,154,96,31,90,100,168,153,92,147,192,58,153,92,169,178,213,163,229,114,17,108,170,168,4,2,118,155,186,201", "TokenInfos": [ { - "tokenpubkey": "6oZbAKdhB5b9A88JGwWHo2iBrpJ9J5R59NX7W8Jnvsm7", - "tokenaccpubkey": "97i31xDcKr8wUPVcS1KsFvVkdFV75GpXJ6FfWzath6bp", + "tokenpubkey": "HgcdmBE1jLZDpKNt9p75vm8UCy5oyuNZYZBpReA7Q66R", + "tokenaccpubkey": "ALDYPuzk9W53tnEaU416PcdkGaXm2QcBHSAVyfAeTw5b", "tokenlogo": "bit_up.png", "tokenname": "DDUP" }, { - "tokenpubkey": "46MnGNzr9BaF9wk2A3yohT9sSxX6EpM23NtjPM1VvvdE", - "tokenaccpubkey": "DrGtGUjzk51FXhZtz5qDn1WFaTEaKdj1Bh8LgnL8SjSE", + "tokenpubkey": "4PbYRiMmzNiDaNNQ8aU9cJj8JGtTHmRVB4DtH7tJBbFD", + "tokenaccpubkey": "6367umXQG2j17i5TtCKWwGxP3UhQeaFZPrKXMnxsfmqr", "tokenlogo": "bit_mz.png", "tokenname": "ASC" }, { - "tokenpubkey": "AArx7UUapG2P6bgpCSC6WDvMDqdamgGm4RiUpuK7w41X", - "tokenaccpubkey": "AuzptxsxSTGvtMBjo2S35NYjMz6Swx6nRtZrxgmKxu2t", + "tokenpubkey": "7PYPxAXpXPTCM7irxPGyTFq1tL1tmn9AwG44bG5wYV94", + "tokenaccpubkey": "78RJmchAmsFbjbhkDTfwL4vLJR3AAUifGHTczvWjMbeM", "tokenlogo": "bit_pet.png", "tokenname": "PET" }, { - "tokenpubkey": "CddR5UEA86oDzEsxKysUxHYve5K2RFa5e83y8Jrsq8MJ", - "tokenaccpubkey": "G4meP91W5afU1P2fjVSX5a3xUU4xVhYM3jguVgvCLJAF", + "tokenpubkey": "5weo8mfVbeuZtLqVfDdiiiCPM1AbyYntGLFjCJsxMwx3", + "tokenaccpubkey": "Gxxqku8s84BxiajLcEuy9C4iy3ArzcG83HDSiMM8szFF", "tokenlogo": "bit_ttc.png", "tokenname": "TTC" }, { - "tokenpubkey": "Hp7882LJmYnZMMq3r3SidyD4MvBDfqqSLCya7DKnHJo", - "tokenaccpubkey": "8gG1zUYvaQJS9VTjwQ6GoXncXauaczBUubktHDFwcHT4", + "tokenpubkey": "24yq6uEXs4KbFPTVLHXtdgJeYrNjZU1Vsj7RTPvnMNnr", + "tokenaccpubkey": "7UpAWpEK3wN35bhx2dhYVT8a6dgXKQX4rULHrkAhgq5J", "tokenlogo": "bit_pyh.png", "tokenname": "PYH" diff --git a/src/appwallet.js b/src/appwallet.js index 54b711a..1eb30d3 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -47,6 +47,10 @@ class PropertyAdd extends React.Component{ return(
+ -

- this.setState({addPropertyModal: true})}/> + this.setState({addPropertyModal: true})} icondisabled= {this.state.balance !== 0} requestairdrop={()=>this.requestAirdrop()}/>
this.pushNewWindow(999)} /> diff --git a/src/wallet.js b/src/wallet.js index 607efff..05643e9 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -1095,6 +1095,9 @@ export class Wallet extends React.Component { } ); } + clearLocalStorage(){ + localStorage.clear(); + } createNewToken() { this.runModal( @@ -1331,6 +1334,9 @@ export class Wallet extends React.Component {
+
+ +