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