Skip to content

Instantly share code, notes, and snippets.

@danstarns
Last active January 9, 2022 09:23
Show Gist options
  • Select an option

  • Save danstarns/0614db8cb7858f130573c2c2938caede to your computer and use it in GitHub Desktop.

Select an option

Save danstarns/0614db8cb7858f130573c2c2938caede to your computer and use it in GitHub Desktop.
example.toml
type = "directrequest"
schemaVersion = 1
name = "select"
contractAddress = "YOUR_ORACLE_ADDRESS"
maxTaskDuration = "0s"
observationSource = """
decode_log [type="ethabidecodelog"
abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"]
decode_cbor [type="cborparse" data="$(decode_log.data)"]
adapter [type="bridge" name="neo4j" requestData="{\\"id\\": $(jobSpec.externalJobID), \\"data\\":{\\"query\\": $(decode_cbor.query)}}"]
jsondecode [type="jsonparse" data="$(adapter)" path="data,result,result"]
encode_data [type="ethabiencode" abi="(bytes32 value)" data="{ \\"value\\": $(jsondecode) }"]
encode_tx [type="ethabiencode"
abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_data)}"
]
submit_tx [type="ethtx" to="YOUR_ORACLE_ADDRESS" data="$(encode_tx)"]
decode_log -> decode_cbor -> adapter -> jsondecode -> encode_data -> encode_tx -> submit_tx
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment