Skip to content

Commit

Permalink
feat: implement BridgeDeposits
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
  • Loading branch information
tmigone authored and juanmardefago committed Feb 16, 2023
1 parent f6cd603 commit c7bb5d3
Show file tree
Hide file tree
Showing 28 changed files with 512 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/template-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

# Run scripts
- name: Prepare IPFS enabled files
run: ./node_modules/.bin/mustache ./config/ipfs.json ./src/mappings/metadataHelpers.template.ts > ./src/mappings/metadataHelpers.ts
run: ./node_modules/.bin/mustache ./config/ipfs.json ./src/mappings/helpers/metadata.template.ts > ./src/mappings/helpers/metadata.ts

- name: Prepare addresses ${{ inputs.ENVIRONMENT }}
run: ./node_modules/.bin/ts-node config/${{ inputs.CONFIG }} && ./node_modules/.bin/mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/
generated/
node_modules/
src/types/
src/mappings/metadataHelpers.ts
src/mappings/helpers/metadata.ts
.DS_STORE
yarn-error.log
subgraph.yaml
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"prep:addresses:arbitrum": "ts-node config/mainnetArbitrumAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prep:addresses:arbitrum-goerli": "ts-node config/arbitrumGoerliAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:arbitrum-goerli": "yarn prep:addresses:arbitrum-goerli && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:ipfs": "mustache ./config/ipfs.json ./src/mappings/metadataHelpers.template.ts > ./src/mappings/metadataHelpers.ts",
"prep:no-ipfs": "mustache ./config/no-ipfs.json ./src/mappings/metadataHelpers.template.ts > ./src/mappings/metadataHelpers.ts",
"prep:ipfs": "mustache ./config/ipfs.json ./src/mappings/helpers/metadata.template.ts > ./src/mappings/helpers/metadata.ts",
"prep:no-ipfs": "mustache ./config/no-ipfs.json ./src/mappings/helpers/metadata.template.ts > ./src/mappings/helpers/metadata.ts",
"lint": "yarn eslint .",
"lint-fix": "eslint . --fix",
"prettier": "prettier '**/*.ts'",
Expand Down
21 changes: 8 additions & 13 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1157,17 +1157,13 @@ type BridgeWithdrawalTransaction implements Transaction @entity {
signer: GraphAccount!
type: TransactionType!
"txHash refers to the tx on the chain corresponding to this subgraph deployment"
txHash: Bytes!
txHash: Bytes
from: Bytes
to: Bytes
amount: BigInt
l1Token: Bytes
"""
transactionIndex is the unique value that allows matching an L2 transaction with its L1 counterpart
- On L1, Arbitrum's Outbox contract emits OutBoxTransactionExecuted event with a transactionIndex property
- On L2, the Graph gateway emits WithdrawalInitiated with the transaction index as l2ToL1Id
"""
transactionIndex: Int
"transactionIndex is the unique value that allows matching an L2 transaction with its L1 counterpart"
transactionIndex: BigInt
}

"""
Expand All @@ -1185,12 +1181,10 @@ type BridgeDepositTransaction implements Transaction @entity {
to: Bytes
amount: BigInt
l1Token: Bytes
"""
retryableTicketId is the unique value that allows matching an L2 transaction with its L1 counterpart
- On L1, Arbitrum's Outbox contract emits OutBoxTransactionExecuted event with a transactionIndex property
- On L2, the Graph gateway emits WithdrawalInitiated with the transaction index as l2ToL1Id
"""
retryableTicketId: Bytes!
"retryableTicketId is the unique value that allows matching an L2 transaction with its L1 counterpart"
retryableTicketId: String
"Wether the deposit was initiated through Arbitrum's gateway router (Only available on L1 networks)"
routed: Boolean
}

enum TransactionType {
Expand All @@ -1201,6 +1195,7 @@ enum TransactionType {
MintNSignal
BurnNSignal
BridgeWithdrawal
BridgeDeposit
}

"""
Expand Down
105 changes: 0 additions & 105 deletions src/mappings/bridgeHelpers.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/mappings/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
NewPauseGuardian,
} from '../types/Controller/Controller'

import { createOrLoadGraphNetwork } from './helpers'
import { createOrLoadGraphNetwork } from './helpers/helpers'

/**
* @dev handleSetContractProxy
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/curation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
joinID,
calculatePricePerShare,
batchUpdateSubgraphSignalledTokens,
} from './helpers'
} from './helpers/helpers'
import { zeroBD } from './utils'
import { addresses } from '../../config/addresses'

Expand Down
2 changes: 1 addition & 1 deletion src/mappings/disputeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
DisputeManager,
} from '../types/DisputeManager/DisputeManager'
import { DisputeManagerStitched } from '../types/DisputeManager/DisputeManagerStitched'
import { createOrLoadGraphNetwork } from './helpers'
import { createOrLoadGraphNetwork } from './helpers/helpers'

// This handles Single query and Conflicting disputes
export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/epochManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GraphNetwork } from '../types/schema'
import { EpochRun, EpochLengthUpdate } from '../types/EpochManager/EpochManager'
import { createOrLoadEpoch, createEpoch, createOrLoadGraphNetwork } from './helpers'
import { createOrLoadEpoch, createEpoch, createOrLoadGraphNetwork } from './helpers/helpers'
import { addresses } from '../../config/addresses'

/**
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/ethereumDIDRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Bytes } from '@graphprotocol/graph-ts'
import { DIDAttributeChanged } from '../types/EthereumDIDRegistry/EthereumDIDRegistry'

import { addQm, createOrLoadGraphAccount } from './helpers'
import { fetchGraphAccountMetadata } from './metadataHelpers'
import { addQm, createOrLoadGraphAccount } from './helpers/helpers'
import { fetchGraphAccountMetadata } from './helpers/metadata'

export function handleDIDAttributeChanged(event: DIDAttributeChanged): void {
let graphAccount = createOrLoadGraphAccount(event.params.identity, event.block.timestamp)
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/gns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ import {
duplicateOrUpdateSubgraphVersionWithNewID,
duplicateOrUpdateNameSignalWithNewID,
createOrLoadGraphNetwork
} from './helpers'
import { fetchSubgraphMetadata, fetchSubgraphVersionMetadata } from './metadataHelpers'
} from './helpers/helpers'
import { fetchSubgraphMetadata, fetchSubgraphVersionMetadata } from './helpers/metadata'
import { addresses } from '../../config/addresses'

export function handleSetDefaultName(event: SetDefaultName): void {
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/graphToken.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Approval, Transfer, GraphToken } from '../types/GraphToken/GraphToken'
import { createOrLoadGraphAccount, createOrLoadGraphNetwork } from './helpers'
import { createOrLoadGraphAccount, createOrLoadGraphNetwork } from './helpers/helpers'
import { GraphNetwork } from '../types/schema'

/**
Expand Down
Loading

0 comments on commit c7bb5d3

Please # to comment.