1
This commit is contained in:
parent
8328e7fc85
commit
cd6a2c216a
@ -1,5 +1,7 @@
|
||||
{
|
||||
"user_address": "0xAd2DeA1977055Db01C66e6E53309C4604AB869b8",
|
||||
"private_key": "9178a1469fc7121aafe1e5dd485f8fa21627daa4656647abddacfcc1e0dbc90e",
|
||||
"_user_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
"_private_key": "d9ed33809372932059c1ba7b336a33f406b4c55e7430daef8297134c67429d60",
|
||||
"block_server": "https://rpc-testnet.kcc.network"
|
||||
}
|
||||
|
@ -29,7 +29,12 @@ class BlockChain {
|
||||
for (const data of metaFactory.getContracts()) {
|
||||
this[`${data.name}Instance`] = await this.initInstance
|
||||
(metaFactory.getUserAddress(), data.address, data.json);
|
||||
|
||||
this[`${data.name}InstanceBuy`] = await this.initInstance
|
||||
(metaFactory.getUserAddress(), data.address, data.json);
|
||||
|
||||
}
|
||||
console.log(metaFactory.getUserAddress());
|
||||
event.emitEvent(constant.BC_INITIALIZED_EVENT);
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,36 @@ async function execCmd(session) {
|
||||
}
|
||||
}
|
||||
|
||||
async function openLuckyBox(session, params) {
|
||||
const userAddress = params[0];
|
||||
const boxId = params[1];
|
||||
const tokenIds = [];
|
||||
tokenIds.push(params[2]);
|
||||
tokenIds.push(params[3]);
|
||||
tokenIds.push(params[4]);
|
||||
|
||||
let nonce = (Math.random() * 1000) | 0;
|
||||
let signStr = bc.web3.utils.soliditySha3(
|
||||
boxId,
|
||||
tokenIds[0],
|
||||
tokenIds[1],
|
||||
tokenIds[2],
|
||||
nonce
|
||||
);
|
||||
let signature = await bc.web3.eth.sign(signStr, userAddress);
|
||||
signature = signature.replace(/00$/, "1b").replace(/01$/, "1c");
|
||||
console.log('openLuckyBox||sign: ', signature, userAddress, boxId, tokenIds, nonce);
|
||||
|
||||
const result = await bc['boxproxyInstanceBuy'].methods.openBox(
|
||||
boxId,
|
||||
tokenIds,
|
||||
nonce,
|
||||
signature
|
||||
).send({ gas: 1000000 })
|
||||
console.log(result);
|
||||
|
||||
}
|
||||
|
||||
function init() {
|
||||
app.registerHandler('GM', 'execCmd', execCmd);
|
||||
cmdHash['login'] = login;
|
||||
@ -244,6 +274,7 @@ function init() {
|
||||
cmdHash['balance'] = balance;
|
||||
cmdHash['getPastEvents'] = getPastEvents;
|
||||
cmdHash['getTrans'] = getTrans;
|
||||
cmdHash['openLuckybox'] = openLuckyBox;
|
||||
}
|
||||
|
||||
exports.init = init;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2b336a24bc4eb86d27a46d71dacab242af87c754
|
||||
Subproject commit a068fda5daa00bd4ba95625241ac980f27bc6bfe
|
Loading…
x
Reference in New Issue
Block a user