Created
January 4, 2023 20:38
-
-
Save fhofman/45aaaae98b7a33104b342f7b3aa350b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THIS IS EXAMPLE CODE THAT USES HARDCODED VALUES FOR CLARITY. | |
# THIS IS EXAMPLE CODE THAT USES UN-AUDITED CODE. | |
# DO NOT USE THIS CODE IN PRODUCTION. | |
name = "Get > Uint256 - (TOML)" | |
schemaVersion = 1 | |
type = "directrequest" | |
# Optional External Job ID: Automatically generated if unspecified | |
# externalJobID = "b1d42cd5-4a3a-4200-b1f7-25a68e48aad8" | |
contractAddress = "YOUR_OPERATOR_CONTRACT_ADDRESS" | |
maxTaskDuration = "0s" | |
minIncomingConfirmations = 0 | |
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)"] | |
fetch [type="http" method=GET url="$(decode_cbor.get)" allowUnrestrictedNetworkAccess="true"] | |
parse [type="jsonparse" path="$(decode_cbor.path)" data="$(fetch)"] | |
multiply [type="multiply" input="$(parse)" times="$(decode_cbor.times)"] | |
encode_data [type="ethabiencode" abi="(bytes32 requestId, uint256 value)" data="{ \\"requestId\\": $(decode_log.requestId), \\"value\\": $(multiply) }"] | |
encode_tx [type="ethabiencode" | |
abi="fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes calldata 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_OPERATOR_CONTRACT_ADDRESS" data="$(encode_tx)"] | |
decode_log -> decode_cbor -> fetch -> parse -> multiply -> encode_data -> encode_tx -> submit_tx | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment