Skip to content

Commit

Permalink
New version subgraph + updated README (#11)
Browse files Browse the repository at this point in the history
* Initialize subgraph

* lock

* Reverted snippet README.md
  • Loading branch information
gabrielfior authored Sep 30, 2024
1 parent 3ef3ae3 commit 6312ced
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 98 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Repository holding the contracts made by Gnosis Labs team.
| Contract Name | Description | Mainnet Address | TheGraph |
|----------------------------|-------------------------------------------------------|-------------------------------------------||-------------------------------------------|
| OmenThumbnailMapping | Manages IPFS hashes for market thumbnails on Omen 2.0 | [0xe0cf08311F03850497B0ed6A2cf067f1750C3eFc](https://gnosisscan.io/address/0xe0cf08311f03850497b0ed6a2cf067f1750c3efc#code) | [omen-thumbnailmapping](https://thegraph.com/studio/subgraph/omen-thumbnailmapping/) |
| OmenAgentResultMapping | Maps prediction results to markets on Omen 2.0 | [0xbe1F6944496923683ca849fc0cC93fD10523cB83](https://gnosisscan.io/address/0xbe1F6944496923683ca849fc0cC93fD10523cB83#code) | [omen-agentresultmapping](https://thegraph.com/studio/subgraph/omen-agentresultmapping/) |
| OmenAgentResultMapping | Maps prediction results to markets on Omen 2.0 | [0xbe1F6944496923683ca849fc0cC93fD10523cB83](https://gnosisscan.io/address/0x260E1077dEA98e738324A6cEfB0EE9A272eD471a#code) | [omen-agentresultmapping](https://thegraph.com/studio/subgraph/omen-agentresultmapping/) |


## Set up contracts development
Expand Down
174 changes: 93 additions & 81 deletions graphs/omen-agentresultmapping/abis/OmenAgentResultMapping.json
Original file line number Diff line number Diff line change
@@ -1,127 +1,139 @@
[
{ "type": "constructor", "inputs": [], "stateMutability": "nonpayable" },
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
{
"type": "function",
"name": "addPrediction",
"anonymous": false,
"inputs": [
{ "name": "marketAddress", "type": "address", "internalType": "address" },
{
"name": "prediction",
"type": "tuple",
"internalType": "struct Prediction",
"indexed": true,
"internalType": "address",
"name": "marketAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint16",
"name": "estimatedProbabilityBps",
"type": "uint16"
},
{
"indexed": true,
"internalType": "address",
"name": "publisherAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32[]",
"name": "txHashes",
"type": "bytes32[]"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "ipfsHash",
"type": "bytes32"
}
],
"name": "PredictionAdded",
"type": "event"
},
{
"inputs": [
{ "internalType": "address", "name": "marketAddress", "type": "address" },
{
"components": [
{
"internalType": "address",
"name": "publisherAddress",
"type": "address",
"internalType": "address"
"type": "address"
},
{ "name": "ipfsHash", "type": "bytes32", "internalType": "bytes32" },
{ "name": "txHash", "type": "bytes32", "internalType": "bytes32" },
{ "internalType": "bytes32", "name": "ipfsHash", "type": "bytes32" },
{
"internalType": "bytes32[]",
"name": "txHashes",
"type": "bytes32[]"
},
{
"internalType": "uint16",
"name": "estimatedProbabilityBps",
"type": "uint16",
"internalType": "uint16"
"type": "uint16"
}
]
],
"internalType": "struct Prediction",
"name": "prediction",
"type": "tuple"
}
],
"name": "addPrediction",
"outputs": [],
"stateMutability": "nonpayable"
"stateMutability": "nonpayable",
"type": "function"
},
{
"type": "function",
"name": "getPredictionByIndex",
"inputs": [
{ "name": "marketAddress", "type": "address", "internalType": "address" },
{ "name": "index", "type": "uint256", "internalType": "uint256" }
{ "internalType": "address", "name": "marketAddress", "type": "address" },
{ "internalType": "uint256", "name": "index", "type": "uint256" }
],
"name": "getPredictionByIndex",
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct Prediction",
"components": [
{
"internalType": "address",
"name": "publisherAddress",
"type": "address",
"internalType": "address"
"type": "address"
},
{ "name": "ipfsHash", "type": "bytes32", "internalType": "bytes32" },
{ "name": "txHash", "type": "bytes32", "internalType": "bytes32" },
{ "internalType": "bytes32", "name": "ipfsHash", "type": "bytes32" },
{
"internalType": "bytes32[]",
"name": "txHashes",
"type": "bytes32[]"
},
{
"internalType": "uint16",
"name": "estimatedProbabilityBps",
"type": "uint16",
"internalType": "uint16"
"type": "uint16"
}
]
],
"internalType": "struct Prediction",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view"
"stateMutability": "view",
"type": "function"
},
{
"type": "function",
"name": "getPredictions",
"inputs": [
{ "name": "marketAddress", "type": "address", "internalType": "address" }
{ "internalType": "address", "name": "marketAddress", "type": "address" }
],
"name": "getPredictions",
"outputs": [
{
"name": "",
"type": "tuple[]",
"internalType": "struct Prediction[]",
"components": [
{
"internalType": "address",
"name": "publisherAddress",
"type": "address",
"internalType": "address"
"type": "address"
},
{ "internalType": "bytes32", "name": "ipfsHash", "type": "bytes32" },
{
"internalType": "bytes32[]",
"name": "txHashes",
"type": "bytes32[]"
},
{ "name": "ipfsHash", "type": "bytes32", "internalType": "bytes32" },
{ "name": "txHash", "type": "bytes32", "internalType": "bytes32" },
{
"internalType": "uint16",
"name": "estimatedProbabilityBps",
"type": "uint16",
"internalType": "uint16"
"type": "uint16"
}
]
}
],
"stateMutability": "view"
},
{
"type": "event",
"name": "PredictionAdded",
"inputs": [
{
"name": "marketAddress",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "estimatedProbabilityBps",
"type": "uint16",
"indexed": false,
"internalType": "uint16"
},
{
"name": "publisherAddress",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "txHash",
"type": "bytes32",
"indexed": false,
"internalType": "bytes32"
},
{
"name": "ipfsHash",
"type": "bytes32",
"indexed": false,
"internalType": "bytes32"
],
"internalType": "struct Prediction[]",
"name": "",
"type": "tuple[]"
}
],
"anonymous": false
"stateMutability": "view",
"type": "function"
}
]
4 changes: 2 additions & 2 deletions graphs/omen-agentresultmapping/networks.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"gnosis": {
"OmenAgentResultMapping": {
"address": "0xbe1F6944496923683ca849fc0cC93fD10523cB83",
"startBlock": 36085528
"address": "0x260E1077dEA98e738324A6cEfB0EE9A272eD471a",
"startBlock": 36267341
}
}
}
2 changes: 1 addition & 1 deletion graphs/omen-agentresultmapping/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type PredictionAdded @entity(immutable: true) {
marketAddress: Bytes! # address
estimatedProbabilityBps: Int! # uint16
publisherAddress: Bytes! # address
txHash: Bytes! # bytes32
txHashes: [Bytes!]! # bytes32[]
ipfsHash: Bytes! # bytes32
blockNumber: BigInt!
blockTimestamp: BigInt!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function handlePredictionAdded(event: PredictionAddedEvent): void {
entity.marketAddress = event.params.marketAddress
entity.estimatedProbabilityBps = event.params.estimatedProbabilityBps
entity.publisherAddress = event.params.publisherAddress
entity.txHash = event.params.txHash
entity.txHashes = event.params.txHashes
entity.ipfsHash = event.params.ipfsHash

entity.blockNumber = event.block.number
Expand Down
6 changes: 3 additions & 3 deletions graphs/omen-agentresultmapping/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ dataSources:
name: OmenAgentResultMapping
network: gnosis
source:
address: "0xbe1F6944496923683ca849fc0cC93fD10523cB83"
address: "0x260E1077dEA98e738324A6cEfB0EE9A272eD471a"
abi: OmenAgentResultMapping
startBlock: 36085528
startBlock: 36267341
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -21,6 +21,6 @@ dataSources:
- name: OmenAgentResultMapping
file: ./abis/OmenAgentResultMapping.json
eventHandlers:
- event: PredictionAdded(indexed address,uint16,indexed address,bytes32,bytes32)
- event: PredictionAdded(indexed address,uint16,indexed address,bytes32[],bytes32)
handler: handlePredictionAdded
file: ./src/omen-agent-result-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function createPredictionAddedEvent(
marketAddress: Address,
estimatedProbabilityBps: i32,
publisherAddress: Address,
txHash: Bytes,
txHashes: Array<Bytes>,
ipfsHash: Bytes
): PredictionAdded {
let predictionAddedEvent = changetype<PredictionAdded>(newMockEvent())
Expand All @@ -32,7 +32,10 @@ export function createPredictionAddedEvent(
)
)
predictionAddedEvent.parameters.push(
new ethereum.EventParam("txHash", ethereum.Value.fromFixedBytes(txHash))
new ethereum.EventParam(
"txHashes",
ethereum.Value.fromFixedBytesArray(txHashes)
)
)
predictionAddedEvent.parameters.push(
new ethereum.EventParam("ipfsHash", ethereum.Value.fromFixedBytes(ipfsHash))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ describe("Describe entity assertions", () => {
let publisherAddress = Address.fromString(
"0x0000000000000000000000000000000000000001"
)
let txHash = Bytes.fromI32(1234567890)
let txHashes = [Bytes.fromI32(1234567890)]
let ipfsHash = Bytes.fromI32(1234567890)
let newPredictionAddedEvent = createPredictionAddedEvent(
marketAddress,
estimatedProbabilityBps,
publisherAddress,
txHash,
txHashes,
ipfsHash
)
handlePredictionAdded(newPredictionAddedEvent)
Expand Down Expand Up @@ -68,8 +68,8 @@ describe("Describe entity assertions", () => {
assert.fieldEquals(
"PredictionAdded",
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1",
"txHash",
"1234567890"
"txHashes",
"[1234567890]"
)
assert.fieldEquals(
"PredictionAdded",
Expand Down
6 changes: 3 additions & 3 deletions graphs/omen-agentresultmapping/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==

"@types/node@*", "@types/node@>=13.7.0":
version "22.5.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44"
integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==
version "22.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc"
integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==
dependencies:
undici-types "~6.19.2"

Expand Down

0 comments on commit 6312ced

Please sign in to comment.