-
-
Save patitonar/2168ba78e70f2ed472d3abddb796c1bd to your computer and use it in GitHub Desktop.
Use erc20 and erc677 abi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ERC20Asset } from '@burner-wallet/assets' | |
import { ERC677_ABI } from '../../../../../commons' | |
/** | |
* @dev Use the default erc20 abi from ERC20Asset to correctly listen and display the Transfer events. | |
* The erc677 abi is used to send tokens by calling transferAndCall method. | |
*/ | |
export default class ERC677Asset extends ERC20Asset { | |
private _erc677contract | |
constructor(params) { | |
super({ type: 'erc677', ...params }) | |
this._erc677contract = null | |
} | |
getErc677Contract() { | |
if (!this._erc677contract) { | |
const Contract = this.getWeb3().eth.Contract | |
this._erc677contract = new Contract(ERC677_ABI, this.address) | |
} | |
return this._erc677contract | |
} | |
async _send({ from, to, value }) { | |
const receipt = await this.getErc677Contract() | |
.methods.transferAndCall(to, value, '0x') | |
.send({ from }) | |
return { | |
...receipt, | |
txHash: receipt.transactionHash, | |
id: `${receipt.transactionHash}-${receipt.events.Transfer.logIndex}` | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment