Skip to content

Commit

Permalink
界面优化——感谢西蒙斯!
Browse files Browse the repository at this point in the history
  • Loading branch information
robotchangzhang committed Oct 15, 2022
1 parent e5fe2cb commit 11908de
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 127 deletions.
7 changes: 7 additions & 0 deletions bootstrap.min.css

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
[
{
"network": "eth",
"rpc": "http:///mainnet.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
"rpc": "https://mainnet.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
"ws": "wss://mainnet.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
"chainid": "1",
"apiurl": "https://api.etherscan.com/api?module=contract&action=getsourcecode&address="
},
{
"network": "Avalanche C",
"rpc": "https://avalanche-mainnet.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
"ws": "",
"chainid": "43114",
"apiurl": "https://api.snowtrace.io/api?module=contract&action=getsourcecode&address="
},
{
"network": "Goerli",
"rpc": "http:///goerli.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
"ws": "",
"chainid": "5",
"apiurl": "https://api-goerli.etherscan.io/api?module=contract&action=getsourcecode&address="
},
{
"network": "ropsten",
"rpc": "https://ropsten.infura.io/v3/e1d0b7dea53643a194cadb6ed123f88e",
Expand Down
21 changes: 11 additions & 10 deletions dealContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ async function getContract(url, address) {
}

async function startEx(apiurl, tokenaddress) {
console.log('good!')
let sourcecode = await getContract(apiurl, tokenaddress);
console.log(sourcecode)
// 获取开源智能合约的ABI
if (sourcecode[0] && sourcecode[1].ABI!= "Contract source code not verified") {
if (sourcecode[0] && sourcecode[1].ABI != "Contract source code not verified") {
var stringABI = sourcecode[1].ABI;
//将string abi 转换成json;
var jsonabi = JSON.parse(stringABI);
Expand All @@ -41,10 +43,9 @@ async function startEx(apiurl, tokenaddress) {
2、写函数,不需要主币支付费用  "stateMutability": "nonpayable",
3、写函数,需要主币支付费用  "stateMutability": "payable",
*/
return fenxiabi(jsonabi);
return fenxiabi(jsonabi);
}
else
{
else {
return [false]
}
//console.log(sourcecode);
Expand All @@ -54,20 +55,20 @@ function fenxiabi(jsonabi) {
var viewabi = new Map();
var payableabi = new Map();
var nonpayable = new Map();
var i=0;
var i = 0;
jsonabi.forEach(element => {
if (element.type == 'function') {
if (element.stateMutability == 'view') {
element.id = i;
viewabi.set(element.name + ":" +i, element);
viewabi.set(element.name + ":" + i, element);
}
else if (element.stateMutability == 'nonpayable') {
element.id = i;
nonpayable.set(element.name + ":" +i, element);
nonpayable.set(element.name + ":" + i, element);
}
else if (element.stateMutability == 'payable') {
element.id = i;
payableabi.set(element.name + ":" +i, element);
payableabi.set(element.name + ":" + i, element);
}
i++;
}
Expand All @@ -88,9 +89,9 @@ function fenxiabi(jsonabi) {
}

async function start(value) {
return await startEx(value.apiurl,value.contractaddress);
return await startEx(value.apiurl, value.contractaddress);
}

module.exports = {
start,start
start, start
}
33 changes: 30 additions & 3 deletions duoxiancheng.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,25 @@ function qianggou(value) {
var nftaddress = value.nftaddress;
var neth = value.neth;
for (priKey of priKeys) {
qianggouNFT(priKey, nftaddress, inputdata, neth, gas, gaslimit);

okvalue = [].concat(inputdata);
addressNo0x = util.privateToAddress(priKey).toString('hex')
address = "0x" + addressNo0x;
try {
//只能替换第一个匹配的
//okvalue[0] = okvalue[0].replace("myaddress", addressNo0x)
//okvalue[0] = okvalue[0].replace("地址", addressNo0x)
//用正则才能全部替换
okvalue[0] = okvalue[0].replace(new RegExp("myaddress",'g'),addressNo0x);
okvalue[0] = okvalue[0].replace(new RegExp("我的地址",'g'),addressNo0x);
okvalue[0] = okvalue[0].replace(new RegExp("地址",'g'),addressNo0x);
}
catch (e) {
;
}

console.log("okvalue[0]:"+okvalue)
qianggouNFT(priKey, nftaddress, okvalue[0], neth, gas, gaslimit);
//break;
}

Expand Down Expand Up @@ -256,7 +274,15 @@ async function abishiyong(value) {
address = "0x" + util.privateToAddress(priKey).toString('hex');
for (var i = 0; i < okvalue.length; i++) {
try {
okvalue[i] = okvalue[i].replace("myaddress", address)

//只能替换第一个匹配的
//okvalue[0] = okvalue[0].replace("myaddress", addressNo0x)
//okvalue[0] = okvalue[0].replace("地址", addressNo0x)
//用正则才能全部替换
okvalue[i] = okvalue[i].replace(new RegExp("myaddress",'g'),addressNo0x);
okvalue[i] = okvalue[i].replace(new RegExp("我的地址",'g'),addressNo0x);
okvalue[i] = okvalue[i].replace(new RegExp("地址",'g'),addressNo0x);

}
catch (e) {
;
Expand Down Expand Up @@ -287,6 +313,7 @@ module.exports = {
test: test,
qianggou: qianggou,
setmainWindow: setmainWindow,
abishiyong: abishiyong
abishiyong: abishiyong,
accounts: priKeys.map(_key => { console.log("0x" + util.privateToAddress(_key).toString('hex')); return "0x" + util.privateToAddress(_key).toString('hex'); })
}

Loading

0 comments on commit 11908de

Please sign in to comment.