2

I am using the fulfillOracleRequest2 with bytes data

fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes data)

my API and external adapter parse is returning this:

parse jsonparse
["629343835796877311","629343835797458943","629343835797471231","629343835797479423","629343835797508095","629343835797516287","629343835796869119","629343835796881407","629343835796893695","629343835797344255","629343835797348351","629343835797467135","629343835797475327","629343835797483519","629343835797491711","629343835797499903","629343835797512191","629343835798421503","629343835796873215","629343835796885503","629343835796889599","629343835796910079","629343835796926463","629343835797327871","629343835797331967","629343835797352447","629343835797377023","629343835797495807","629343835797503999","629343835797528575","629343835797544959","629343835798409215","629343835798413311","629343835798417407","629343835798478847","629343835798487039","629343835796811775","629343835796828159","629343835796901887","629343835796914175","629343835796918271","629343835797008383","629343835797012479","629343835797336063","629343835797340159","629343835797360639","629343835797381119","629343835797385215","629343835797413887","629343835797524479","629343835797536767","629343835797540863","629343835797803007","629343835797811199","629343835798425599","629343835798429695","629343835798433791","629343835798474751","629343835798482943","629343835798495231","629343835796803583","629343835796815871","629343835796819967","629343835796905983","629343835796922367","629343835797000191","629343835797004287","629343835797024767","629343835797364735","629343835797368831","629343835797372927","629343835797393407","629343835797397503","629343835797409791","629343835797442559","629343835797446655","629343835797532671","629343835797549055","629343835797745663","629343835797786623","629343835797794815","629343835797807103","629343835798380543","629343835798388735","629343835798491135","629343835798499327","629343835798548479","629343835798552575","629343838201618431","629343838201634815"]

each of those uint64 actually is a string because javascript has issues dealing with big numbers.

I was trying to first encode those strings into uint64 and then in bytes with

parse        [type="jsonparse" path="data" data="$(fetch)"]
encode_data0  [type="ethabiencode" abi="(uint64[] value)" data="{\\"value\\": $(parse)}"]
encode_data  [type="ethabiencode" abi="(bytes32 requestId, bytes value)" data="{\\"requestId\\": $(decode_log.requestId), \\"value\\": $(encode_data0.value)}"]
encode_tx    [type="ethabiencode"
                  abi="fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes 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)}"
                 ]

the problem is that encode_data0 is producing a weird string of weird values:

OK
encode_data0 ethabiencode
"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000000000000000000000000008bbe0e25e412fff00000000000000000000000000000000000000000000000008bbe0e25e4a0fff00000000000000000000000000000000000000000..."
abi: (uint64[] value)
data: {"value": $(parse)}
FAIL
encode_data ethabiencode
data: value at key 'encode_data0' is a string, not a map or slice: keypath not found
abi: (bytes32 requestId, bytes value)
data: {"requestId": $(decode_log.requestId), "value": $(encode_data0.value)}

How do I go from this array of strings (returned by my API) into bytes that I can pass to fulfillOracleRequest2?

rolele
  • 781
  • 9
  • 24
  • You might have to wrap that API in an API yourself (external adapter) and convert the string to bytes32 off-chain if you're having issues there :/ – Patrick Collins Feb 11 '22 at 00:20

0 Answers0