1
This commit is contained in:
parent
2f0d1c2a9a
commit
304d4f5ac7
@ -49,7 +49,7 @@ class Item extends basewrap.BaseWrap {
|
||||
}
|
||||
|
||||
randLuckBox(tokenType) {
|
||||
const itemId = factory.callMetaStatic('randLuckBox', this['id'], tokenType);
|
||||
const itemId = factory.callMetaStatic('LuckyBox', 'randLuckBox', this['id'], tokenType);
|
||||
assert(itemId > 0);
|
||||
return itemId;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ const utils = require('j7/utils');
|
||||
const bcutils = require('j7/bcutils');
|
||||
const basewrap = require('./basewrap');
|
||||
|
||||
class LuckByx extends basewrap.BaseWrap {
|
||||
class LuckyBox extends basewrap.BaseWrap {
|
||||
|
||||
static idTypeHash = {
|
||||
|
||||
@ -30,19 +30,22 @@ class LuckByx extends basewrap.BaseWrap {
|
||||
}
|
||||
|
||||
static randLuckBox(boxId, tokenType) {
|
||||
const key = this['box_id'] + '_' + this['type'];
|
||||
const key = boxId + '_' + tokenType;
|
||||
if (!utils.hasKey(LuckyBox.idTypeHash, key)) {
|
||||
console.log(1111, key);
|
||||
return 0;
|
||||
}
|
||||
const data = LuckyBox.idTypeHash[key];
|
||||
assert(data['total_space'] > 0);
|
||||
console.log(data);
|
||||
const rand = utils.randRange(0, data['total_space'] - 1);
|
||||
for (let i in data['items']) {
|
||||
const item = data['items'];
|
||||
const item = data['items'][i];
|
||||
if (rand < item['space']) {
|
||||
return item['meta']['item_id'];
|
||||
}
|
||||
}
|
||||
console.log(22222, rand);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ function init() {
|
||||
);
|
||||
registerMetaClass(resDir + 'luckyBox@luckyBox.json',
|
||||
'id',
|
||||
'luckyBox'
|
||||
'LuckyBox'
|
||||
);
|
||||
|
||||
load();
|
||||
|
@ -1,7 +1,7 @@
|
||||
const app = require('j7/app');
|
||||
const utils = require('j7/utils');
|
||||
const serviceFactory = require('./factory');
|
||||
const metaFactory = require('../metaFactory');
|
||||
const metaFactory = require('../metadata/factory');
|
||||
const bc = require('../blockchain');
|
||||
|
||||
const LIMIT_COUNT = 100;
|
||||
@ -180,11 +180,17 @@ class EventCenter {
|
||||
for (let iii = 0; iii < 3; ++iii) {
|
||||
const id = returnValues['ids'][iii];
|
||||
const type = returnValues['types'][iii];
|
||||
await this.mintNft(returnValues['to'], blockNumber, id, type);
|
||||
if (id != '0') {
|
||||
fieldList.push(
|
||||
['token_id' + (iii + 1), id]
|
||||
);
|
||||
fieldList.push(['token_type' + (iii + 1), type]),
|
||||
await this.mintNft(returnValues['to'], blockNumber, id, type);
|
||||
}
|
||||
}
|
||||
await this.conn.insert(
|
||||
't_boxopened_event',
|
||||
fieldsList
|
||||
fieldList
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class BlockChain {
|
||||
async init() {
|
||||
this.web3 = new Web3(metaFactory.getWeb3Conf()['block_server']);
|
||||
this.web3.eth.handleRevert = true;
|
||||
this.web3.eth.accounts.wallet.add(metamgr.getPrivateKey());
|
||||
this.web3.eth.accounts.wallet.add(metaFactory.getPrivateKey());
|
||||
for (const data of metaFactory.getContracts()) {
|
||||
this[`${data.name}Instance`] = await this.initInstance
|
||||
(metaFactory.getUserAddress(), data.address, data.json);
|
||||
|
@ -67,7 +67,7 @@ async function buyBoxVerifySignature(session) {
|
||||
name: 'BEBoxMall',
|
||||
version: '1',
|
||||
chainId: netId,
|
||||
verifyingContract: '0xF278ff771F9E24968083B0bA54Cb42eb4B23C2d7',
|
||||
verifyingContract: metaFactory.getMetaByKey('Contract', 'mall')['address'],
|
||||
},
|
||||
message: {
|
||||
item: session.request('type'),
|
||||
|
@ -92,7 +92,7 @@ function init() {
|
||||
'Web3'
|
||||
);
|
||||
registerMetaClass(configDir + 'contract.json',
|
||||
'',
|
||||
'name',
|
||||
'Contract'
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user