Skip to content

Commit

Permalink
Remove ERC20 approval tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jan 15, 2024
1 parent cbf254d commit 79f6a6a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Unreleased
* `Governor`: fix bug caused by duplicate write of immutable entity `ProposalSupport` ([#47](https://github.com/OpenZeppelin/openzeppelin-subgraphs/pull/47))
* `ERC20`: remove approval tracking as it cannot be consistently tracked during `transferFrom` calls.

### 0.1.8-5 (2022-07-29)
* `AccessControl`: fix bug caused by duplicate write of immutable entity `AccessControl` ([#38](https://github.com/OpenZeppelin/openzeppelin-subgraphs/pull/38))
Expand Down
24 changes: 0 additions & 24 deletions src/datasources/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {

import {
Transfer as TransferEvent,
Approval as ApprovalEvent,
} from '../../generated/erc20/IERC20'

import {
Expand All @@ -24,7 +23,6 @@ import {
import {
fetchERC20,
fetchERC20Balance,
fetchERC20Approval,
} from '../fetch/erc20'

export function handleTransfer(event: TransferEvent): void {
Expand Down Expand Up @@ -70,25 +68,3 @@ export function handleTransfer(event: TransferEvent): void {
}
ev.save()
}

export function handleApproval(event: ApprovalEvent): void {
let contract = fetchERC20(event.address)

let owner = fetchAccount(event.params.owner)
let spender = fetchAccount(event.params.spender)
let approval = fetchERC20Approval(contract, owner, spender)
approval.valueExact = event.params.value
approval.value = decimals.toDecimals(event.params.value, contract.decimals)
approval.save()

// let ev = new ERC20ApprovalEvent(events.id(event))
// ev.emitter = contract.id
// ev.transaction = transactions.log(event).id
// ev.timestamp = event.block.timestamp
// ev.token = token.id
// ev.owner = owner.id
// ev.spender = spender.id
// ev.approval = approval.id
// ev.value = value.value
// ev.save()
}
17 changes: 0 additions & 17 deletions src/fetch/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Account,
ERC20Contract,
ERC20Balance,
ERC20Approval,
} from '../../generated/schema'

import {
Expand Down Expand Up @@ -62,19 +61,3 @@ export function fetchERC20Balance(contract: ERC20Contract, account: Account | nu

return balance as ERC20Balance
}

export function fetchERC20Approval(contract: ERC20Contract, owner: Account, spender: Account): ERC20Approval {
let id = contract.id.toHex().concat('/').concat(owner.id.toHex()).concat('/').concat(spender.id.toHex())
let approval = ERC20Approval.load(id)

if (approval == null) {
approval = new ERC20Approval(id)
approval.contract = contract.id
approval.owner = owner.id
approval.spender = spender.id
approval.value = constants.BIGDECIMAL_ZERO
approval.valueExact = constants.BIGINT_ZERO
}

return approval as ERC20Approval
}

0 comments on commit 79f6a6a

Please sign in to comment.