Skip to content

Instantly share code, notes, and snippets.

@vnavascues
Created October 29, 2021 17:38
Show Gist options
  • Save vnavascues/e783090b495239dce5efc7fe0e614388 to your computer and use it in GitHub Desktop.
Save vnavascues/e783090b495239dce5efc7fe0e614388 to your computer and use it in GitHub Desktop.
A TOML jobspec for the AccuWeather EA
type = "directrequest"
schemaVersion = 1
minContractPaymentLinkJuels = "1000000000000000000" # 0.1 LINK or 1 LINK
name = "AW AccuWeather Get Current Conditions by Location Coordinates 3"
contractAddress = "0x0000000000000000000000000000000000000000" # Replace with Operator.sol address (also in submit_tx task)
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)"]
accuweather [type=bridge
name="accuweather"
requestData="{\\"data\\": {\\"endpoint\\": \\"location-current-conditions\\",\\"lat\\": $(decode_cbor.lat),\\"lon\\": $(decode_cbor.lon),\\"units\\": $(decode_cbor.units)}}"
allowunrestrictednetworkaccess="true"]
locationFound_parse [type=jsonparse data="$(accuweather)" path="result,0"]
locationResult_parse [type=jsonparse data="$(accuweather)" path="result,1"]
currentConditionsResult_parse [type=jsonparse data="$(accuweather)" path="result,2"]
encode_data [type=ethabiencode
abi="(bytes32 _requestId, bool _locationFound, bytes memory _locationResult, bytes memory _currentConditionsResult)"
data="{\\"_requestId\\": $(decode_log.requestId),\\"_locationFound\\": $(locationFound_parse),\\"_locationResult\\": $(locationResult_parse),\\"_currentConditionsResult\\": $(currentConditionsResult_parse)}"]
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="0x0000000000000000000000000000000000000000" data="$(encode_tx)" minConfirmations="2"]
decode_log -> decode_cbor -> accuweather
accuweather -> locationFound_parse -> encode_data
accuweather -> locationResult_parse -> encode_data
accuweather -> currentConditionsResult_parse -> encode_data
encode_data -> encode_tx -> submit_tx
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment