1
This commit is contained in:
parent
5e422b109a
commit
145d173f5c
@ -19,6 +19,9 @@ const BC_TRANS_FUNC_EVOLVE = 3;
|
||||
const BC_TRANS_FUNC_PLUGIN = 4;
|
||||
const BC_TRANS_FUNC_COMMON = 5;
|
||||
|
||||
const ARBITRUM_NET_ID = 42161;
|
||||
const ARBITRUM_TEST_NET_ID = 421613;
|
||||
|
||||
exports.BC_NFT_NONE = BC_NFT_NONE;
|
||||
exports.BC_NFT_HERO = BC_NFT_HERO;
|
||||
exports.BC_NFT_EQUIP = BC_NFT_EQUIP;
|
||||
@ -39,3 +42,6 @@ exports.BC_TRANS_FUNC_MINT_SHARD = BC_TRANS_FUNC_MINT_SHARD;
|
||||
exports.BC_TRANS_FUNC_EVOLVE = BC_TRANS_FUNC_EVOLVE;
|
||||
exports.BC_TRANS_FUNC_PLUGIN = BC_TRANS_FUNC_PLUGIN;
|
||||
exports.BC_TRANS_FUNC_COMMON = BC_TRANS_FUNC_COMMON;
|
||||
|
||||
exports.ARBITRUM_NET_ID = ARBITRUM_NET_ID;
|
||||
exports.ARBITRUM_TEST_NET_ID = ARBITRUM_TEST_NET_ID;
|
||||
|
@ -36,6 +36,15 @@ class BlockChain {
|
||||
this[`${data.name}Instance`] = await this.initInstance
|
||||
(this.getUserAddress(), data.address, this.netDir + data.json);
|
||||
}
|
||||
this.currencyHash = {};
|
||||
this.currencyHash['CEG'] = this.getContractByName(contract.CEG_INSTANCE_NAME);
|
||||
if (this.netId == bcconst.ARBITRUM_NET_ID) {
|
||||
this.currencyHash['USDT'] = bcutils.toNormalAddress('0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9');
|
||||
this.currencyHash['USDC'] = bcutils.toNormalAddress('0xaf88d065e77c8cC2239327C5EDb3A432268e5831');
|
||||
} else if (this.netId == bcconst.ARBITRUM_TEST_NET_ID) {
|
||||
this.currencyHash['USDT'] = bcutils.toNormalAddress('0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D');
|
||||
this.currencyHash['USDC'] = bcutils.toNormalAddress('0x944D0A8463B2c955F90F7252bBb99A3395087155');
|
||||
}
|
||||
const chainId = await this.web3.eth.getChainId();
|
||||
if (chainId != this.netId) {
|
||||
log.warning(util.format('net id error %s %s',
|
||||
@ -85,6 +94,10 @@ class BlockChain {
|
||||
return bcutils.isValidAddress(address);
|
||||
}
|
||||
|
||||
getCurrencyAddressByName(currencyName) {
|
||||
return utils.hasKey(this.currencyHash, currencyName) ? this.currencyHash[currencyName] : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = BlockChain;
|
||||
|
@ -26,7 +26,7 @@ async function buy(session) {
|
||||
}
|
||||
}
|
||||
|
||||
const currency = bc.getContractAddressByName(currencyName);
|
||||
const currency = bc.getCurrencyAddressByName(currencyName);
|
||||
const userAddress = bc.getUserAddress();
|
||||
{
|
||||
if (!bc.isValidAddress(currency)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user