Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLin0619 committed Jul 2, 2023
0 parents commit 7fde94f
Show file tree
Hide file tree
Showing 9 changed files with 519 additions and 0 deletions.
245 changes: 245 additions & 0 deletions abis/ERC6551RegistryAndReadCall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
[
{
"inputs": [
{
"internalType": "address payable",
"name": "gatewayAddress",
"type": "address"
},
{ "internalType": "string", "name": "feePayerAddress", "type": "string" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{ "inputs": [], "name": "InitializationFailed", "type": "error" },
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "implementation",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenContract",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "salt",
"type": "uint256"
}
],
"name": "AccountCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "requestAddress",
"type": "address"
}
],
"name": "ReceivedData",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "implementation",
"type": "address"
},
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
{ "internalType": "address", "name": "tokenContract", "type": "address" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{ "internalType": "uint256", "name": "salt", "type": "uint256" },
{ "internalType": "bytes", "name": "initData", "type": "bytes" }
],
"name": "abiPacketAccount",
"outputs": [{ "internalType": "bytes", "name": "packet", "type": "bytes" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "implementation",
"type": "address"
},
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
{ "internalType": "address", "name": "tokenContract", "type": "address" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{ "internalType": "uint256", "name": "salt", "type": "uint256" }
],
"name": "account",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "nftContract", "type": "address" },
{ "internalType": "uint256", "name": "nftId", "type": "uint256" },
{ "internalType": "uint256", "name": "chain_id", "type": "uint256" },
{ "internalType": "address", "name": "tba", "type": "address" }
],
"name": "addTbaAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "implementation",
"type": "address"
},
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
{ "internalType": "address", "name": "tokenContract", "type": "address" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{ "internalType": "uint256", "name": "salt", "type": "uint256" },
{ "internalType": "bytes", "name": "initData", "type": "bytes" }
],
"name": "createAccount",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "gatewayContract",
"outputs": [
{ "internalType": "contract IGateway", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint64", "name": "destGasLimit", "type": "uint64" },
{ "internalType": "uint64", "name": "destGasPrice", "type": "uint64" },
{ "internalType": "uint64", "name": "ackGasLimit", "type": "uint64" },
{ "internalType": "uint64", "name": "ackGasPrice", "type": "uint64" },
{ "internalType": "uint128", "name": "relayerFees", "type": "uint128" },
{ "internalType": "uint8", "name": "ackType", "type": "uint8" },
{ "internalType": "bool", "name": "isReadCall", "type": "bool" },
{ "internalType": "bytes", "name": "asmAddress", "type": "bytes" }
],
"name": "getRequestMetadata",
"outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "nftContract", "type": "address" },
{ "internalType": "uint256", "name": "nftId", "type": "uint256" }
],
"name": "getTbas",
"outputs": [
{ "internalType": "address[]", "name": "", "type": "address[]" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "bool", "name": "", "type": "bool" },
{ "internalType": "bytes", "name": "execData", "type": "bytes" }
],
"name": "iAck",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "uint256", "name": "", "type": "uint256" }
],
"name": "nfts",
"outputs": [
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "requestAddress",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "string", "name": "destChainId", "type": "string" },
{
"internalType": "string",
"name": "destinationContractAddress",
"type": "string"
},
{ "internalType": "bytes", "name": "requestMetadata", "type": "bytes" },
{ "internalType": "bytes", "name": "packet", "type": "bytes" }
],
"name": "sendReadRequest",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{ "internalType": "string", "name": "feePayerAddress", "type": "string" }
],
"name": "setDappMetadata",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "gateway", "type": "address" }
],
"name": "setGateway",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
8 changes: 8 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"goerli": {
"ERC6551RegistryAndReadCall": {
"address": "0x77813af45BC74aB209236b92CE2B6F2A51e58ee8",
"startBlock": 9248181
}
}
}
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "horcross",
"license": "UNLICENSED",
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ horcross",
"create-local": "graph create --node http://localhost:8020/ horcross",
"remove-local": "graph remove --node http://localhost:8020/ horcross",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 horcross",
"test": "graph test"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.51.2",
"@graphprotocol/graph-ts": "0.30.0"
},
"devDependencies": { "matchstick-as": "0.5.0" }
}
20 changes: 20 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type AccountCreated @entity(immutable: true) {
id: Bytes!
account: Bytes! # address
implementation: Bytes! # address
chainId: BigInt! # uint256
tokenContract: Bytes! # address
tokenId: BigInt! # uint256
salt: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}

type ReceivedData @entity(immutable: true) {
id: Bytes!
requestAddress: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
36 changes: 36 additions & 0 deletions src/erc-6551-registry-and-read-call.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
AccountCreated as AccountCreatedEvent,
ReceivedData as ReceivedDataEvent
} from "../generated/ERC6551RegistryAndReadCall/ERC6551RegistryAndReadCall"
import { AccountCreated, ReceivedData } from "../generated/schema"

export function handleAccountCreated(event: AccountCreatedEvent): void {
let entity = new AccountCreated(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
entity.account = event.params.account
entity.implementation = event.params.implementation
entity.chainId = event.params.chainId
entity.tokenContract = event.params.tokenContract
entity.tokenId = event.params.tokenId
entity.salt = event.params.salt

entity.blockNumber = event.block.number
entity.blockTimestamp = event.block.timestamp
entity.transactionHash = event.transaction.hash

entity.save()
}

export function handleReceivedData(event: ReceivedDataEvent): void {
let entity = new ReceivedData(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
entity.requestAddress = event.params.requestAddress

entity.blockNumber = event.block.number
entity.blockTimestamp = event.block.timestamp
entity.transactionHash = event.transaction.hash

entity.save()
}
27 changes: 27 additions & 0 deletions subgraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
specVersion: 0.0.5
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum
name: ERC6551RegistryAndReadCall
network: goerli
source:
address: "0x77813af45BC74aB209236b92CE2B6F2A51e58ee8"
abi: ERC6551RegistryAndReadCall
startBlock: 9248181
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- AccountCreated
- ReceivedData
abis:
- name: ERC6551RegistryAndReadCall
file: ./abis/ERC6551RegistryAndReadCall.json
eventHandlers:
- event: AccountCreated(address,address,uint256,address,uint256,uint256)
handler: handleAccountCreated
- event: ReceivedData(address)
handler: handleReceivedData
file: ./src/erc-6551-registry-and-read-call.ts
Loading

0 comments on commit 7fde94f

Please sign in to comment.