修改投放badge的方法, nftid由合约自动生成

This commit is contained in:
zhl 2023-04-23 13:22:44 +08:00
parent 09965d5eb6
commit 18d1293862
6 changed files with 37395 additions and 10272 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -40,20 +40,21 @@ export class DistributorReactor {
async mintNft({ async mintNft({
address, address,
to, to,
nftList, count,
encodeABI = false, encodeABI = false,
}: { }: {
address?: string address?: string
to: string to: string
nftList: string[] count: number
encodeABI?: boolean encodeABI?: boolean
}) { }) {
const contract = address ? new this.web3.eth.Contract(abi, address, { from: this.account.address }) : this.contract const contract = address ? new this.web3.eth.Contract(abi, address, { from: this.account.address }) : this.contract
const countStr = count + ''
if (encodeABI) { if (encodeABI) {
return contract.methods.mintToUser(to, nftList).encodeABI() return contract.methods.mintToUser(to, countStr).encodeABI()
} }
let gas = await contract.methods.mintToUser(to, nftList).estimateGas({ from: this.account.address }) let gas = await contract.methods.mintToUser(to, countStr).estimateGas({ from: this.account.address })
let res = await contract.methods.mintToUser(to, nftList).send({ gas: gas | 0 }) let res = await contract.methods.mintToUser(to, countStr).send({ gas: gas | 0 })
return res return res
} }
/** /**

View File

@ -13,8 +13,10 @@ class ChainController extends BaseController {
async addChainRequest(req, res) { async addChainRequest(req, res) {
// data是一个数组!! // data是一个数组!!
const { data, type, taskId, force, max } = req.params const { data, type, taskId, force, max } = req.params
console.log(`income chain request:: taskId: ${taskId}, type: ${type}`)
console.log(JSON.stringify(data))
let maxTryCount = max !== undefined ? parseInt(max) : parseInt(process.env.CHAIN_MAX_TRY) let maxTryCount = max !== undefined ? parseInt(max) : parseInt(process.env.CHAIN_MAX_TRY)
let chainTask: DocumentType<ChainTaskClass> = await ChainTask.insertOrUpdate({ taskId }, { type, data }) let chainTask: DocumentType<ChainTaskClass> = await ChainTask.insertOrUpdate({ taskId }, { type, taskData: data })
if ((!chainTask.newRecord && force) || chainTask.newRecord) { if ((!chainTask.newRecord && force) || chainTask.newRecord) {
for (let sub of data) { for (let sub of data) {
@ -31,6 +33,7 @@ class ChainController extends BaseController {
new ChainQueue().addTaskToQueue(subTask) new ChainQueue().addTaskToQueue(subTask)
} }
} }
chainTask.newRecord = false
await chainTask.save() await chainTask.save()
return chainTask.toJson() return chainTask.toJson()
} }

View File

@ -32,7 +32,6 @@ export enum ReqTaskStatus {
} }
@dbconn() @dbconn()
@index({ scheduleId: 1 }, { unique: true })
@modelOptions({ @modelOptions({
schemaOptions: { collection: 'chain_request_task', timestamps: true }, schemaOptions: { collection: 'chain_request_task', timestamps: true },
options: { allowMixed: Severity.ALLOW }, options: { allowMixed: Severity.ALLOW },