Skip to content

Commit

Permalink
OS-545 : fix indexing ERC20Wrapped (#426)
Browse files Browse the repository at this point in the history
* fix indexing ERC20Wrapped

* update change log

* remove redundant if
  • Loading branch information
Rekard0 authored Jul 10, 2023
1 parent b6a744f commit b01a5e4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/subgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UPCOMING]

### Changed

- Fixed wrong interface for indexing GovernanceWrappedERC20.

## [1.2.0]

### Added

- Added "v" to the version on the github deploy flow.
- Added handler for `NewURI` event on DAO.
- Added `delegatee`, `votingPower` and `delegators` to the `TokenVotingMember`.
- Added support for indexing GovernanceWrappedERC20 and underlying token.

### Changed

Expand Down
2 changes: 2 additions & 0 deletions packages/subgraph/manifest/subgraph.placeholder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ dataSources:
file: $ARAGON_OSX_MODULE/artifacts/src/plugins/governance/majority-voting/token/TokenVoting.sol/TokenVoting.json
- name: AddresslistVoting
file: $ARAGON_OSX_MODULE/artifacts/src/plugins/governance/majority-voting/addresslist/AddresslistVoting.sol/AddresslistVoting.json
- name: GovernanceWrappedERC20
file: $ARAGON_OSX_MODULE/artifacts/src/token/ERC20/governance/GovernanceWrappedERC20.sol/GovernanceWrappedERC20.json
eventHandlers:
- event: InstallationPrepared(indexed address,indexed address,bytes32,indexed address,(uint8,uint16),bytes,address,(address[],(uint8,address,address,address,bytes32)[]))
handler: handleInstallationPrepared
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aragon/osx-subgraph",
"version": "1.2.0",
"version": "1.2.1",
"description": "The Aragon OSx Subgraph",
"homepage": "https://github.com/aragon/osx",
"license": "AGPL-3.0-or-later",
Expand Down
22 changes: 19 additions & 3 deletions packages/subgraph/src/plugin/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import {
MULTISIG_INTERFACE
} from '../utils/constants';
import {supportsInterface} from '../utils/erc165';
import {fetchERC20} from '../utils/tokens/erc20';
import {
fetchERC20,
fetchWrappedERC20,
supportsERC20Wrapped
} from '../utils/tokens/erc20';

export const PERMISSION_OPERATIONS = new Map<number, string>()
.set(0, 'Grant')
Expand Down Expand Up @@ -61,8 +65,20 @@ function createTokenVotingPlugin(plugin: Address, daoId: string): void {
packageEntity.minDuration = minDuration.reverted ? null : minDuration.value;

if (!token.reverted) {
let contract = fetchERC20(token.value);
if (contract) {
let tokenAddress = token.value;
if (supportsERC20Wrapped(tokenAddress)) {
let contract = fetchWrappedERC20(tokenAddress);
if (!contract) {
return;
}

packageEntity.token = contract.id;
} else {
let contract = fetchERC20(tokenAddress);
if (!contract) {
return;
}

packageEntity.token = contract.id;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const TOKEN_VOTING_INTERFACE = '0x50eb001e';
export const ADDRESSLIST_VOTING_INTERFACE = '0x5f21eb8b';
export const ADMIN_INTERFACE = '0xa5793356';
export const MULTISIG_INTERFACE = '0x8f852786';
export const WRAPPED_ERC20_INTERFACE = '0x12cdd3ac';
export const WRAPPED_ERC20_INTERFACE = '0x0f13099a';

export const RATIO_BASE = '1000000'; // 10**6

0 comments on commit b01a5e4

Please sign in to comment.