-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: cw20 handle mint/transfer/burn/send #178
Conversation
cw20BurnEvents.forEach((burnEvent) => { | ||
if (burnEvent.amount) { | ||
addAmount = ( | ||
BigInt(addAmount) + BigInt(`-${burnEvent.amount}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
if (addBalanceHolders[event.from]) { | ||
// sub balance for sender | ||
addBalanceHolders[event.from].amount = ( | ||
BigInt(addBalanceHolders[event.from].amount) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
} | ||
} | ||
|
||
async _start(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ko làm gì thì thôi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
addBalanceHolders[event.from].last_updated_height = event.height; | ||
} else { | ||
addBalanceHolders[event.from] = { | ||
address: event.from, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cái này ko dùng
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (event.amount) { | ||
// sender | ||
if (event.from) { | ||
if (addBalanceHolders[event.from]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addBalanceHolders[event.from] = {
amount: (addBalanceHolders[event.from]?.amount || BigInt(0)) + BigInt(event.amount),
last_updated_height: event.height
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// eslint-disable-next-line no-restricted-syntax | ||
for (const cw20ContractId of ctx.params.cw20ContractIds) { | ||
// eslint-disable-next-line no-await-in-loop | ||
await this.createJob( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chỗ này đã unique theo contract id để ko bị lặp chưa?
nếu bị thì có sống ko?
}, | ||
}) | ||
async UpdateByContract(ctx: Context<IContextUpdateCw20>) { | ||
let { startBlock } = ctx.params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { startBlock, endBlock } = ctx.params;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const { endBlock } = ctx.params; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const cw20Contract of ctx.params.cw20Contracts) { | ||
if (startBlock < cw20Contract.last_updated_height) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const startUpdateBlock = _.min(startBlock, cw20Contract.last_updated_height);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
endBlock: number, | ||
trx: Knex.Transaction | ||
) { | ||
let addAmount = '0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let addAmount = BigInt(0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
); | ||
cw20MintEvents.forEach((mintEvent) => { | ||
if (mintEvent.amount) { | ||
addAmount = (BigInt(addAmount) + BigInt(mintEvent.amount)).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addAmount = addAmount + BigInt(mintEvent.amount);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}); | ||
if (Object.keys(addBalanceHolders).length > 0) { | ||
const holders = _.keyBy( | ||
await CW20Holder.query() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lấy luôn last_updated_height để check
No description provided.