Skip to content

Commit

Permalink
feat: add relation from ticket to integration contract (#45)
Browse files Browse the repository at this point in the history
- optional relation (only created if actually crafted from integration
  contract)
- removed unused imports
  • Loading branch information
mortimr authored Jun 26, 2024
1 parent f998fcc commit 8bffe98
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 43 deletions.
3 changes: 2 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ type Ticket @entity {
exitQueue: vExitQueue!

ticketId: BigInt!
origin: Integration

owner: Bytes!
size: BigInt!
Expand Down Expand Up @@ -2172,4 +2173,4 @@ type ERC20ExitSystemEvent implements SystemEvent @entity {

createdAt: BigInt!
createdAtBlock: BigInt!
}
}
2 changes: 1 addition & 1 deletion src/Cub.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Cub, Fix } from '../generated/schema';
import { AppliedFixes } from '../generated/templates/Cub/Cub';
import { entityUUID, eventUUID } from './utils/utils';
import { eventUUID } from './utils/utils';

export function handleAppliedFixes(event: AppliedFixes): void {
const cub = Cub.load(event.address);
Expand Down
1 change: 0 additions & 1 deletion src/ERC1155.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
import {
eventUUID,
entityUUID,
externalEntityUUID,
getOrCreateUnassignedCommissionSold,
_computeIntegratorCommissionOwed
} from './utils/utils';
Expand Down
11 changes: 8 additions & 3 deletions src/ERC20.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, Bytes, ethereum, log } from '@graphprotocol/graph-ts';
import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts';
import {
ERC20,
MultiPool,
Expand All @@ -10,12 +10,11 @@ import {
vPool,
ERC20BalanceSnapshot,
ERC20Snapshot,
UnassignedCommissionSold,
PoolBalance,
DepositDataEntry,
ExitDataEntry,
vExitQueue,
CommissionLoader
Ticket
} from '../generated/schema';
import { Stake as Stake_1_0_0_rc4 } from '../generated/templates/ERC20_1_0_0_rc4/Native20';
import {
Expand Down Expand Up @@ -549,6 +548,12 @@ export function handleExit(event: Exit): void {
const nextTicketIdx = exitQueue!.ticketCount.minus(BigInt.fromI32(1));
const linkedTicketId = externalEntityUUID(Address.fromBytes(exitQueue!.address), [nextTicketIdx.toString()]);
tickets.push(linkedTicketId);

const ticket = Ticket.load(linkedTicketId);
if (ticket != null) {
ticket.origin = event.address;
ticket.save();
}
}

createERC20ExitSystemEvent(event, event.address, event.params.staker, totalETH, event.params.exitedTokens);
Expand Down
7 changes: 1 addition & 6 deletions src/IntegrationRouter.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { Bytes } from '@graphprotocol/graph-ts';
import {
ChannelImplementationUpdated,
Initialized,
ProxyFactoryDeployed
} from '../generated/IntegrationRouter/IntegrationRouter';
import { ChannelImplementationUpdated, ProxyFactoryDeployed } from '../generated/IntegrationRouter/IntegrationRouter';
import { IntegrationChannel } from '../generated/schema';
import { ProxyFactory } from '../generated/templates';
import { existsChannel, getChannelName, getMetaContractForChannel } from './utils/IntegrationChannel.utils';
Expand Down
2 changes: 1 addition & 1 deletion src/MerkleVault.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MerkleVault, VaultClaim } from '../generated/schema';
import { Claimed, SetFrameSize, SetRootAndIpfsHash } from '../generated/templates/MerkleVault/MerkleVault';
import { entityUUID, eventUUID } from './utils/utils';
import { eventUUID } from './utils/utils';

export function handleSetFrameSize(event: SetFrameSize): void {
const merkleVault = MerkleVault.load(event.address);
Expand Down
1 change: 0 additions & 1 deletion src/Nexus.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
hashTreeRootSigningData
} from './ssz_deposit_message/index';
import { Address, BigInt, ByteArray, Bytes, ethereum, log, crypto, dataSource } from '@graphprotocol/graph-ts';
import { entityUUID, externalEntityUUID } from './utils/utils';
import { getOrCreateRewardSummaries } from './utils/rewards';
import { verify } from './bls12_381_verify';
import { getOrCreateTUPProxy } from './TUPProxy.mapping';
Expand Down
2 changes: 1 addition & 1 deletion src/PluggableHatcher.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SetAdmin } from '../generated/Nexus/Nexus';
import { Cub, Fix, PluggableHatcher, PluggableHatcherImplementation } from '../generated/schema';
import { Cub as CubTemplate } from '../generated/templates';
import { getOrCreateMetaContract } from './utils/MetaContract.utils';
import { entityUUID, eventUUID, externalEntityUUID } from './utils/utils';
import { entityUUID, eventUUID } from './utils/utils';

function _getOrCreatePluggableHatcher(addr: Bytes, event: ethereum.Event): PluggableHatcher {
let ph = PluggableHatcher.load(addr);
Expand Down
10 changes: 2 additions & 8 deletions src/ProxyFactory.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { ERC1155Integration, ERC20, vNFTIntegration } from '../generated/schema';
import { ERC20 } from '../generated/schema';
import {
ERC20 as ERC20Template,
ERC1155 as ERC1155Template,
vNFT as vNFTTemplate,
ERC20_1_0_0_rc4 as ERC20_1_0_0_rc4Template,
ERC1155_1_0_0_rc4 as ERC1155_1_0_0_rc4Template,
Native20_Fix_09_12_Oracle_Report
} from '../generated/templates';
import { DeployedProxy } from '../generated/templates/ProxyFactory/ProxyFactory';
import {
CHANNEL_LIQUID_1155_vPOOL_vPOOL_BYTES32,
CHANNEL_LIQUID_20_A_vPOOL_BYTES32,
CHANNEL_LIQUID_20_C_vPOOL_BYTES32,
CHANNEL_NATIVE_1155_vPOOL_BYTES32,
CHANNEL_NATIVE_20_vPOOL_BYTES32,
CHANNEL_VNFT_BYTES32,
checkChannel
} from './utils/IntegrationChannel.utils';
import { Address, BigInt } from '@graphprotocol/graph-ts';
import { addressInArray, externalEntityUUID } from './utils/utils';
import { addressInArray } from './utils/utils';
import { getOrCreateRewardSummaries } from './utils/rewards';
import { getOrCreateTUPProxy } from './TUPProxy.mapping';

Expand Down
2 changes: 1 addition & 1 deletion src/TUPProxy.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, ethereum, log } from '@graphprotocol/graph-ts';
import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts';
import { TUPProxy, TUPProxyUpgrade } from '../generated/schema';
import { AdminChanged, PauserChanged, SetFreezeTime, Upgraded } from '../generated/templates/TUPProxy/TUPProxy';
import { TUPProxy as TUPProxyTemplate } from '../generated/templates';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/IntegrationChannel.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bytes, log } from '@graphprotocol/graph-ts';
import { Bytes } from '@graphprotocol/graph-ts';
import { getOrCreateMetaContract } from './MetaContract.utils';

export const CHANNEL_NATIVE_20_vPOOL_BYTES32 = Bytes.fromHexString(
Expand Down
3 changes: 1 addition & 2 deletions src/utils/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import {
RewardSummary,
vPoolRewardEntry,
IntegrationRewardEntry,
vPool,
DepositDataEntry,
ExitDataEntry
} from '../../generated/schema';
import { entityUUID, externalEntityUUID } from './utils';
import { externalEntityUUID } from './utils';

export function getOrCreateRewardSummary(
event: ethereum.Event,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, ethereum, BigInt, Bytes, Entity, store } from '@graphprotocol/graph-ts';
import { Address, ethereum, BigInt, Bytes, store } from '@graphprotocol/graph-ts';
import {
AddedValidationKeysSystemEvent,
ChangedCoverageRecipientParameterSystemEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/vExecLayerRecipient.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SuppliedEther } from '../generated/templates/vExecLayerRecipient/vExecLayerRecipient';
import { vExecLayerRecipient, ExecLayerSuppliedEther } from '../generated/schema';
import { entityUUID, txUniqueUUID } from './utils/utils';
import { txUniqueUUID } from './utils/utils';

export function handleSuppliedEther(event: SuppliedEther): void {
const elseId = txUniqueUUID(event, [event.address.toHexString()]);
Expand Down
5 changes: 2 additions & 3 deletions src/vExitQueue.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import {
createNewExitQueueCaskSystemEvent,
createNewExitQueueTicketSystemEvent,
entityUUID,
eventUUID,
externalEntityUUID
eventUUID
} from './utils/utils';
import { Address, BigInt, store } from '@graphprotocol/graph-ts';
import { Address, BigInt } from '@graphprotocol/graph-ts';

export function handlePrintedTicket(event: PrintedTicket): void {
const exitQueue = vExitQueue.load(event.address);
Expand Down
5 changes: 2 additions & 3 deletions src/vFactory.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bytes, store, BigInt, dataSource, log, crypto, ByteArray, Address, ethereum } from '@graphprotocol/graph-ts';
import { Bytes, store, BigInt, dataSource, Address } from '@graphprotocol/graph-ts';
import {
WithdrawalChannel,
ValidationKey,
Expand All @@ -9,8 +9,7 @@ import {
FactoryDepositor,
CommonValidationKeyEntry,
DepositEvent,
PendingKeyValidationRequest,
PendingKeyValidationTracker
PendingKeyValidationRequest
} from '../generated/schema';
import {
AddedValidators,
Expand Down
2 changes: 1 addition & 1 deletion src/vNFT.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, Bytes, log } from '@graphprotocol/graph-ts';
import { Address, BigInt, Bytes } from '@graphprotocol/graph-ts';
import {
MerkleVault,
vFactory,
Expand Down
5 changes: 2 additions & 3 deletions src/vOracleAggregator.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import {
Nexus,
vFactory
} from '../generated/schema';
import { Address, BigInt, Bytes, ethereum, log, store } from '@graphprotocol/graph-ts';
import { Address, BigInt, Bytes, ethereum, store } from '@graphprotocol/graph-ts';
import {
createChangedOracleAggregatorParameterSystemEvent,
createOracleMemberVotedSystemEvent,
entityUUID,
externalEntityUUID
entityUUID
} from './utils/utils';

function getQuorum(memberCount: BigInt): BigInt {
Expand Down
5 changes: 1 addition & 4 deletions src/vPool.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Mint,
Burn,
Transfer,
Deposit,
PurchasedValidators,
Expand All @@ -27,15 +26,13 @@ import {
vFactory,
MultiPool,
ERC20,
ERC1155,
vExitQueue,
vPoolRewardEntry,
IntegrationRewardEntry,
PeriodRewardSummary,
DepositDataEntry,
ERC1155Integration
} from '../generated/schema';
import { Bytes, BigInt, Address, store, log, DataSourceContext, dataSource } from '@graphprotocol/graph-ts';
import { Bytes, BigInt, Address, store, dataSource } from '@graphprotocol/graph-ts';
import { ethereum } from '@graphprotocol/graph-ts/chain/ethereum';
import { MultiPoolRewardsSnapshot } from '../generated/schema';
import {
Expand Down

0 comments on commit 8bffe98

Please sign in to comment.