mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-20 04:46:20 +00:00
4f8f1d8cd7
* Remove fields no longer present in schema. * Refactor code to work with log_cids change in eth-server. * Refactor process event to save events from logs. * Use constants for erc20 event names. * Implement watch blocks in erc20-watcher similar to uni-watcher. * Moved common methods to util. * Implement eventsInRange query in erc20-watcher. * Filter unknown event in database query. * Change dependencies version to be same in all packages. Co-authored-by: nabarun <nabarun@deepstacksoft.com>
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import { task, types } from 'hardhat/config';
|
|
import '@nomiclabs/hardhat-ethers';
|
|
import { ContractTransaction, BigNumber } from 'ethers';
|
|
|
|
const DEFAULT_APPROVE_AMOUNT = '1000000000000000000000000';
|
|
|
|
task('token-approve', 'Move tokens to recipient')
|
|
.addParam('token', 'Token contract address', undefined, types.string)
|
|
.addParam('spender', 'Spender address', undefined, types.string)
|
|
.addParam('amount', 'Token amount to transfer', DEFAULT_APPROVE_AMOUNT, types.string)
|
|
.setAction(async (args, hre) => {
|
|
const { token: tokenAddress, amount, spender } = args;
|
|
await hre.run('compile');
|
|
const Token = await hre.ethers.getContractFactory('GLDToken');
|
|
const token = Token.attach(tokenAddress);
|
|
|
|
const transaction: ContractTransaction = await token.approve(spender, BigNumber.from(amount));
|
|
const receipt = await transaction.wait();
|
|
|
|
if (receipt.events) {
|
|
const TransferEvent = receipt.events.find(el => el.event === 'Approval');
|
|
|
|
if (TransferEvent && TransferEvent.args) {
|
|
console.log('Approval Event');
|
|
console.log('owner:', TransferEvent.args.owner.toString());
|
|
console.log('spender:', TransferEvent.args.spender.toString());
|
|
console.log('value:', TransferEvent.args.value.toString());
|
|
}
|
|
}
|
|
});
|