增加eth转账
This commit is contained in:
parent
92af300adb
commit
72783bd183
@ -28,20 +28,18 @@ CHAIN_CLIENT_URL=http://127.0.0.1:3006
|
||||
CRYPTOCOMPARE_API_KEY=d1ec8cd68228095debc9db2dca45771b905ce1f27f522ebfef025c236f4aef3b
|
||||
|
||||
# alchemy 相关配置
|
||||
AVAILABLE_NETWORK=arbitrum|bsc
|
||||
AVAILABLE_NETWORK=agor
|
||||
AVAILABLE_TOKENS=cec|ceg
|
||||
ARBITRUM_CHAIN_ID=421163
|
||||
ARBITRUM_CEC_ADDRESS='0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE'
|
||||
ARBITRUM_CEG_ADDRESS='0x2C7221588D4FBac2585D71618CD540e74c7413B8'
|
||||
ARBITRUM_WALLET='0x50A8e60041A206AcaA5F844a1104896224be6F39'
|
||||
BSC_CHAIN_ID=97
|
||||
BSC_CEC_ADDRESS='0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D'
|
||||
BSC_CEG_ADDRESS='0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D'
|
||||
BSC_WALLET='0x50A8e60041A206AcaA5F844a1104896224be6F39'
|
||||
AGOR_CHAIN_ID=421163
|
||||
AGOR_DEV_CEC_ADDRESS='0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE'
|
||||
AGOR_DEV_CEG_ADDRESS='0x2C7221588D4FBac2585D71618CD540e74c7413B8'
|
||||
AGOR_RELEASE_CEC_ADDRESS='0x2C7221588D4FBac2585D71618CD540e74c7413B8'
|
||||
AGOR_RELEASE_CEG_ADDRESS='0x2C7221588D4FBac2585D71618CD540e74c7413B8'
|
||||
AGOR_WALLET='0x50A8e60041A206AcaA5F844a1104896224be6F39'
|
||||
# 链端转账回调地址
|
||||
PAY_TRANSFER_CB_URL='http://127.0.0.1:3007/api/internal/update_task'
|
||||
# 链端回调hash的ket
|
||||
HASH_SALT='iG4Rpsa)6U31$H#^T85$^^3'
|
||||
|
||||
# 游戏服, 支付上报地址
|
||||
GAME_PAY_CB_URL='https://game2006api-test.kingsome.cn/webapp/index.php?c=Shop&a=buyGoodsDirect‘
|
||||
GAME_PAY_CB_URL=https://game2006api-test.kingsome.cn/webapp/index.php?c=Shop&a=buyGoodsDirect
|
@ -38,7 +38,8 @@ for (let network of networks) {
|
||||
data.chainId = parseInt(process.env[`${network.toUpperCase()}_CHAIN_ID`])
|
||||
data.wallet = process.env[`${network.toUpperCase()}_WALLET`]
|
||||
for (let sub of tokenList) {
|
||||
data.tokens[sub] = process.env[`${network.toUpperCase()}_${sub.toUpperCase()}_ADDRESS`]
|
||||
data.tokens[`${sub}_dev`] = process.env[`${network.toUpperCase()}_DEV_${sub.toUpperCase()}_ADDRESS`]
|
||||
data.tokens[`${sub}_release`] = process.env[`${network.toUpperCase()}_RELEASE_${sub.toUpperCase()}_ADDRESS`]
|
||||
}
|
||||
chainCfgs[network] = data
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ class AlchemyController extends BaseController {
|
||||
@router('post /pay/alchemy/buy')
|
||||
async beginApiPay(req, res) {
|
||||
const user = req.user
|
||||
const { network, crypto, address, fiat, fiatAmount, payWayCode, country, accountId, orderId } = req.params
|
||||
const { network, crypto, address, fiat, fiatAmount, payWayCode, country, accountId, orderId, env } = req.params
|
||||
let envStr = env || 'dev'
|
||||
if (fiat || fiatAmount || country) {
|
||||
if (!fiat || !fiatAmount || !country || !payWayCode) {
|
||||
throw new ZError(11, 'fiat, fiatAmount payWayCode and country must be provided')
|
||||
@ -36,6 +37,7 @@ class AlchemyController extends BaseController {
|
||||
address,
|
||||
network,
|
||||
crypto,
|
||||
env: envStr,
|
||||
gameAccountId: accountId,
|
||||
gameOrderId: orderId,
|
||||
})
|
||||
@ -134,10 +136,13 @@ class AlchemyController extends BaseController {
|
||||
if (!token || !chain) {
|
||||
throw new ZError(11, 'token or network not found')
|
||||
}
|
||||
if (chain.toLowerCase() === 'agor' && (token.toLowerCase() === 'ceg' || token.toLowerCase() === 'cec')) {
|
||||
if (
|
||||
(chain.toLowerCase() === 'agor' || chain.toLowerCase() === 'eth') &&
|
||||
(token.toLowerCase() === 'ceg' || token.toLowerCase() === 'cec')
|
||||
) {
|
||||
return { price: 1 }
|
||||
}
|
||||
if (chain.toLowerCase() === 'agor' && token.toLowerCase() === 'agor') {
|
||||
if ((chain.toLowerCase() === 'agor' || chain.toLowerCase() === 'eth') && token.toLowerCase() === 'agor') {
|
||||
token = 'ETH'
|
||||
chain = 'ETH'
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class AlchemyOutController extends BaseController {
|
||||
if (record.crypto != crypto || record.network != network || record.address != address) {
|
||||
return errorRes('params mismatch')
|
||||
}
|
||||
record.cryptoAmount = cryptoAmount
|
||||
record.cryptoAmount = record.network.toLowerCase() === 'agor' ? '0.001' : cryptoAmount
|
||||
record.cryptoPrice = cryptoPrice
|
||||
record.usdtAdmount = usdtAmount
|
||||
record.status = PayStatus.TRANSFERING
|
||||
|
@ -45,6 +45,9 @@ export class PayRecordClass extends BaseModule {
|
||||
@prop()
|
||||
public crypto?: string
|
||||
|
||||
@prop()
|
||||
public env?: string
|
||||
|
||||
// 法币
|
||||
@prop()
|
||||
public fiat?: string
|
||||
|
@ -40,7 +40,15 @@ export class TransferQueue {
|
||||
assert(chainCfg, `chain config not found: ${task.network}`)
|
||||
let chainId = chainCfg.chainId
|
||||
let wallet = chainCfg.wallet
|
||||
let address = chainCfg.tokens[task.crypto.toLowerCase()]
|
||||
let token = task.crypto.toLowerCase()
|
||||
let address
|
||||
if (token === 'agor') {
|
||||
address = 'eth'
|
||||
} else {
|
||||
let env = task.env ? task.env.toLowerCase() : 'dev'
|
||||
address = chainCfg.tokens[`${token}_${env}`]
|
||||
}
|
||||
|
||||
assert(address, `token address not found: ${task.crypto}`)
|
||||
let record = await TransferRecord.insertOrUpdate(
|
||||
{ recordId: task.id },
|
||||
@ -54,6 +62,7 @@ export class TransferQueue {
|
||||
$inc: { version: 1 },
|
||||
},
|
||||
)
|
||||
|
||||
let datas: any = [
|
||||
{
|
||||
chain: record.chain,
|
||||
@ -64,6 +73,16 @@ export class TransferQueue {
|
||||
type: 3,
|
||||
},
|
||||
]
|
||||
if (token === 'agor') {
|
||||
datas = [
|
||||
{
|
||||
from: record.from,
|
||||
to: record.to,
|
||||
amount: record.amount,
|
||||
type: 6,
|
||||
},
|
||||
]
|
||||
}
|
||||
let reqData = {
|
||||
taskId: record.id,
|
||||
source: 'pay',
|
||||
|
Loading…
x
Reference in New Issue
Block a user