Skip to content

Commit

Permalink
Merge pull request #20 from aragon/OS-1155/clean-not-used-vars-functi…
Browse files Browse the repository at this point in the history
…on-constants

feat: clean not used vars, functions and constants
  • Loading branch information
clauBv23 authored Apr 12, 2024
2 parents c355d7f + c5b389e commit 198f491
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 87 deletions.
23 changes: 0 additions & 23 deletions packages/subgraph/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
export const onERC721Received = '0x150b7a02';
export const ERC721_safeTransferFromNoData = '0x42842e0e';
export const ERC721_safeTransferFromWithData = '0xb88d4fde';
export const ERC721_transferFrom = '0x23b872dd';

export const ERC20_transfer = '0xa9059cbb';
export const ERC20_transferFrom = '0x23b872dd';

export const onERC1155Received = '0xf23a6e61'; // `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61) if it accepts the transfer.
export const onERC1155BatchReceived = '0xbc197c81'; // `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81) if it accepts the transfer(s).
export const ERC1155_safeTransferFrom = '0xf242432a'; // `bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)"))` (i.e. 0xf242432a).
export const ERC1155_safeBatchTransferFrom = '0x2eb2c2d6'; // `bytes4(keccak256("safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)"))` (i.e. 0x2eb2c2d6).

export enum TransferType {
Withdraw,
Deposit,
}

export const DECODE_OFFSET =
'0x0000000000000000000000000000000000000000000000000000000000000020';

export const ERC165_INTERFACE_ID = '01ffc9a7';
export const ERC1155_INTERFACE_ID = 'd9b67a26';

// AS does not support initializing Map with data, a chain of sets is used instead
export const VOTER_OPTIONS = new Map<number, string>()
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/src/utils/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function fetchOrCreateWrappedERC20Entity(
if (totalSupply.reverted || balanceOf.reverted || underlying.reverted) {
return null;
}
// get and save the underliying contract
// get and save the underlying contract
const underlyingContract = fetchOrCreateERC20Entity(underlying.value);
if (!underlyingContract) {
return null;
Expand Down
37 changes: 2 additions & 35 deletions packages/subgraph/src/utils/ids.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
import {bigIntToBytes32} from './bytes';
import {
generateEntityIdFromAddress,
generateEntityIdFromBytes,
generateEntityIdFromAddress, // generateEntityIdFromBytes,
} from '@aragon/osx-commons-subgraph';
import {Address, BigInt, Bytes} from '@graphprotocol/graph-ts';
import {Address} from '@graphprotocol/graph-ts';

export function generateTokenEntityId(tokenAddress: Address): string {
return generateEntityIdFromAddress(tokenAddress);
}

export function generateERC1155TransferEntityId(
txHash: Bytes,
logIndex: BigInt,
actionIndex: number,
batchIndex: number
): string {
return [
generateEntityIdFromBytes(txHash),
logIndex.toString(),
actionIndex.toString(),
batchIndex.toString(),
].join('_');
}

export function generateVoterEntityId(
memberEntityId: string,
proposalId: string
): string {
return [memberEntityId, proposalId].join('_');
}

export function generateMemberEntityId(
pluginAddress: Address,
memberAddress: Address
Expand All @@ -46,13 +23,3 @@ export function generateVoteEntityId(
): string {
return [generateEntityIdFromAddress(memberAddress), proposalId].join('_');
}

export function getProposalId(
plugin: Address,
pluginProposalId: BigInt
): string {
return plugin
.toHexString()
.concat('_')
.concat(bigIntToBytes32(pluginProposalId));
}
29 changes: 1 addition & 28 deletions packages/subgraph/tests/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
generatePluginEntityId,
generateProposalEntityId,
} from '@aragon/osx-commons-subgraph';
import {generateProposalEntityId} from '@aragon/osx-commons-subgraph';
import {Address, BigInt} from '@graphprotocol/graph-ts';

export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
Expand All @@ -28,14 +25,8 @@ export const PLUGIN_PROPOSAL_ID = ZERO;
export const STRING_DATA = 'Some String Data ...';

export const ONE_ETH = '1000000000000000000';
export const HALF_ETH = '500000000000000000';

export const ERC20_AMOUNT_HALF = '10000';
export const ERC20_AMOUNT_FULL = '20000';
export const ERC20_TOTAL_SUPPLY = '10';
export const ERC20_DECIMALS = '6';
export const TOKEN_SYMBOL = 'symbol';
export const TOKEN_NAME = 'name';

export const HOUR = '3600';
export const TWO_HOURS = '7200';
Expand All @@ -62,28 +53,10 @@ export const MIN_VOTING_POWER = TWO;
export const TOTAL_VOTING_POWER = THREE;
export const CREATED_AT = ONE;

export const ZERO_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000000';
export const ONE_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000001';
export const HALF_UINT256_BYTES32 =
'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
export const MAX_UINT256_BYTES32 =
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';

export const MAX_UINT256_NUMBER_STRING =
'115792089237316195423570985008687907853269984665640564039457584007913129639935';

export const PLUGIN_SETUP_ID =
'0xfb3fd2c4cd4e19944dd3f8437e67476240cd9e3efb2294ebd10c59c8f1d6817c';
export const APPLIED_PLUGIN_SETUP_ID =
'0x00000000cd4e19944dd3f8437e67476240cd9e3efb2294ebd10c59c8f1d6817c';

export const PROPOSAL_ENTITY_ID = generateProposalEntityId(
Address.fromString(CONTRACT_ADDRESS),
BigInt.fromString(PLUGIN_PROPOSAL_ID)
);

export const PLUGIN_ENTITY_ID = generatePluginEntityId(
Address.fromString(CONTRACT_ADDRESS)
);

0 comments on commit 198f491

Please sign in to comment.