diff --git a/publickey.json b/publickey.json index 8c9ac42..aba8204 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": "HgcdmBE1jLZDpKNt9p75vm8UCy5oyuNZYZBpReA7Q66R", + "tokenaccpubkey": "ALDYPuzk9W53tnEaU416PcdkGaXm2QcBHSAVyfAeTw5b", + "tokenlogo": "bit_up.png", + "tokenname": "DDUP" }, { - "tokenpubkey": "Br5EfPGUT9yP5QkDVkVAkzC6r75JpQSCuMKfPBE4D95X", - "tokenaccountpubkey": "DoxzTmaUixUzSPbNYQ353ZPExkaYitW26oQ96QoZGsng" + "tokenpubkey": "4PbYRiMmzNiDaNNQ8aU9cJj8JGtTHmRVB4DtH7tJBbFD", + "tokenaccpubkey": "6367umXQG2j17i5TtCKWwGxP3UhQeaFZPrKXMnxsfmqr", + "tokenlogo": "bit_mz.png", + "tokenname": "ASC" + }, + { + "tokenpubkey": "7PYPxAXpXPTCM7irxPGyTFq1tL1tmn9AwG44bG5wYV94", + "tokenaccpubkey": "78RJmchAmsFbjbhkDTfwL4vLJR3AAUifGHTczvWjMbeM", + "tokenlogo": "bit_pet.png", + "tokenname": "PET" + + }, + + { + "tokenpubkey": "5weo8mfVbeuZtLqVfDdiiiCPM1AbyYntGLFjCJsxMwx3", + "tokenaccpubkey": "Gxxqku8s84BxiajLcEuy9C4iy3ArzcG83HDSiMM8szFF", + "tokenlogo": "bit_ttc.png", + "tokenname": "TTC" + + }, + { + "tokenpubkey": "24yq6uEXs4KbFPTVLHXtdgJeYrNjZU1Vsj7RTPvnMNnr", + "tokenaccpubkey": "7UpAWpEK3wN35bhx2dhYVT8a6dgXKQX4rULHrkAhgq5J", + "tokenlogo": "bit_pyh.png", + "tokenname": "PYH" + } + ] } diff --git a/src/appwallet.js b/src/appwallet.js index 0ebbd17..1eb30d3 100755 --- a/src/appwallet.js +++ b/src/appwallet.js @@ -11,21 +11,21 @@ import { // OverlayTrigger, ProgressBar, // Tooltip, - DropdownButton, - MenuItem, } from 'react-bootstrap'; import PropTypes from 'prop-types'; import copy from 'copy-to-clipboard'; import * as web3 from '@bitconch/bitconch-web3j'; import {Settings} from './settings'; -import data from '../publickey.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/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; - var sectionStyle = { height: '250px', width: '100%', @@ -36,21 +36,48 @@ var sectionStyle = { var lineStyle = { height: '0.5px', backgroundColor: '#b8b6b6', - marginLeft:'10px' + marginLeft:'10px', + width:'100%' }; +//定义一个Section子组件 +class PropertyAdd extends React.Component{ + //接收父组件传递过来的item + render(){ + return( +
+ + +
+ + ); + } +} + +// +PropertyAdd.propTypes = { + icondisabled: PropTypes.object, + addproperty:PropTypes.function, + requestairdrop:PropTypes.function, +}; //定义一个Section子组件 class PropertySection extends React.Component{ //接收父组件传递过来的item render(){ return( -
+
-
- -
@@ -60,165 +87,176 @@ 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 = { + imageurl: this.props.tokenselected == false? SelectOff:SelectOn + } + render(){ + return( +
+ + +
+ ); + } +} + +// +PropertySelect.propTypes = { + tokenLogo: PropTypes.object, + tokenName: PropTypes.object, + selected: PropTypes.function, + switchOn: PropTypes.object, + buttonId: PropTypes.object, + tokenselected: 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){ - 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 tem = ''; - // var msg = ''; - var arrToken = []; - for(i = 0; i < data.TokenPublicKeys.length; i++) { - var tokenpubkey = new web3.PublicKey(data.TokenPublicKeys[i].tokenpubkey); - 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; - - // tem += ' 代币名称: {' + i + '} '; - - var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; - var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); - - // tem += '余额: ' + accTokenInfo.amount; - - arrToken.push({ - tokenpubkey, - tokenname, - tokensymbol, - tokensupply, - tokendecimal, - tokenaccpubkey, - accTokenInfo - }); + var TokensArray = this.props.publickey; + 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){ + 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 = '10'; + var tokenpublickey = info.TokenInfos[i].tokenpubkey; + + // tem += ' 代币名称: {' + i + '} '; + //根据tokenaccoutpublickey获取余额 + // var tokenaccpubkey = data.TokenPublicKeys[i].tokenaccountpubkey; + // var accTokenInfo = await token.accountInfo(new web3.PublicKey(tokenaccpubkey)); + + // tem += '余额: ' + accTokenInfo.amount; + + arrToken.push({ + tokenpublickey, + tokenaccpubkey, + tokenname, + tokensymbol, + tokensupply, + tokendecimal, + tokenlogo, + tokenselected, + tokenamount, + }); + + // msg += String.format( + // tem, + // acc.name + // ); + } + console.log('arrToken:',arrToken); + this.setState({tokenNameArray: arrToken}); - // msg += String.format( - // tem, - // acc.name - // ); + } catch (err) + { + this.addError(err.message); } - this.setState({ - // tokenInfo: msg, - 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}'; - - msg += String.format( - tem, - token.tokenname, - tokenacc.amount - ); - this.setState({ - tokenInfo: msg, - }); - this.props.onTokenAsset(token); - } + var tokeninfo = this.state.tokenNameArray[index]; + console.log('tokeninfo:::::::',tokeninfo); - 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)}/> + ); + }) + } +
); } } TokenAsset.propTypes = { + publickey: PropTypes.object, onTokenAsset: PropTypes.function, conn: PropTypes.object, }; @@ -723,7 +761,7 @@ class TokenInput extends React.Component { return (
- 数量 + 数量({this.props.amount}) this.handleChange(e)}/> @@ -733,6 +771,7 @@ class TokenInput extends React.Component { } } TokenInput.propTypes = { + amount:PropTypes.object, onAmount: PropTypes.function, }; @@ -900,13 +939,13 @@ class TransferModal extends React.Component {
- +
- BUS + {this.props.name}
this.props.topublickey(publicKey)}/> - this.props.transferamount(amount)}/> + this.props.transferamount(amount)} amount={this.props.amount}/>
@@ -918,12 +957,57 @@ class TransferModal extends React.Component { } TransferModal.propTypes = { + logo: PropTypes.object, + name: PropTypes.object, + amount:PropTypes.object, topublickey: PropTypes.function, transferamount: PropTypes.function, onHide: PropTypes.function, 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 = { + publickey: PropTypes.object, + 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 ( @@ -965,6 +1049,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, @@ -979,21 +1066,60 @@ export class Wallet extends React.Component { tokenNameArray: [], showText:null, showModal: false, - + addPropertyModal:false, + tokenArr: [], + displaydetail: 'none' }; constructor(props) { super(props); this.onStoreChange(); + this.getArrayFromlocal(); + } + async getArrayFromlocal(){ + var TokensArray = this.web3solAccount.publicKey.toString(); + var weekArray = await JSON.parse(localStorage.getItem(TokensArray)); + if (weekArray&&weekArray.length>0) { + this.setState({tokenNameArray: weekArray}); + this.loadlocalarr(weekArray); + } } + 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(); + tokens.tokenamount = '0'; + }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 = ''; // 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; @@ -1095,11 +1221,24 @@ 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}); } } + selectOn(){ + + } + selectOff(){ + + } + addPorpertyList(tokenarr){ + console.log('tokenarr======',tokenarr); + this.setState({tokenNameArray: tokenarr}); + } + ResetListForPorperty(){ + this.createNewTokenAccount(); + } copyPublicKey() { copy(this.web3solAccount.publicKey); this.setState({showText:'地址已复制到粘贴板',showModal: true}); @@ -1116,13 +1255,32 @@ 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(), - }); + 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 == ''){ + var newtokenaccpubkey = await token.newAccount(this.web3solAccount); + tokens.tokenaccpubkey = newtokenaccpubkey.toString(); + tokens.tokenamount = '0'; + }else{ + var accpublickey = new web3.PublicKey(tokenaccpubkey); + var newTokenAccountInfo1 = await token.accountInfo(accpublickey); + tokens.tokenamount = newTokenAccountInfo1.amount.toString(); + } + } + tokensArr.push(tokens); + } + var TokensArray = this.web3solAccount.publicKey.toString(); + localStorage.setItem(TokensArray,JSON.stringify(tokensArr)); + console.log('tokensArr == ',tokensArr); + this.setState({tokenArr: tokensArr,addPropertyModal: false}); } ); } @@ -1159,45 +1317,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) }); } ); } - transferShow(){ - this.setState({transferModal:false}); - } + 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(); } ); } @@ -1260,7 +1438,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( @@ -1276,7 +1457,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; @@ -1292,9 +1484,12 @@ export class Wallet extends React.Component { this.setState({transferModal: false})} - transfer={() => this.transferShow()} - topublickey={key => this.setRecipientPublicKey(key)} - transferamount={key => this.setRecipientAmount(key)} + 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 ? ( @@ -1304,15 +1499,21 @@ 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; - - // 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} @@ -1320,6 +1521,11 @@ export class Wallet extends React.Component { {exportSercetModal} {transferModal} {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()}/> +
@@ -1334,29 +1540,29 @@ export class Wallet extends React.Component {
- -

- this.setState({transferModal: true})} /> - - - - - - - - - - - - + this.setState({addPropertyModal: true})} icondisabled= {this.state.balance !== 0} requestairdrop={()=>this.requestAirdrop()}/> +
+
+ 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/images/main_jia.png b/src/images/main_jia.png new file mode 100644 index 0000000..58a3058 Binary files /dev/null and b/src/images/main_jia.png differ diff --git a/src/images/main_right.png b/src/images/main_right.png new file mode 100644 index 0000000..e8e4346 Binary files /dev/null and b/src/images/main_right.png differ diff --git a/src/images/selecte_off.png b/src/images/selecte_off.png new file mode 100644 index 0000000..73ced7f Binary files /dev/null and b/src/images/selecte_off.png differ diff --git a/src/images/selecte_on.png b/src/images/selecte_on.png new file mode 100644 index 0000000..7723255 Binary files /dev/null and b/src/images/selecte_on.png differ 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..c5b31d4 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) { diff --git a/src/wallet.js b/src/wallet.js index c217982..05643e9 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({ @@ -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 {
+
+ +

diff --git a/tokens.json b/tokens.json new file mode 100644 index 0000000..6a6ad00 --- /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": "846uvQMSQ28XtUF3DFLZ2EjvKMM3Xg4QXC4fbrr8ovis", + "tokenaccpubkey": "AHTdbXudWs3cG8teRgxDL3CRfa64ET2S5uqpYZmJGTpx", + "tokenlogo": "bit_up.png", + "tokenname": "DDUP" + }, + { + "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/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"