Chain Link Job decode_log.data not found - chainlink

I am trying to use an external adapter to take in parameters for off-chain computation. The job seems to fail before it even gets to the external adapter because it is unable to find a data key that seems to exist. (below)
requestData: key decode_cbor / keypath decode_cbor.userId: keypath not found
data: key decode_log / keypath **decode_log.data**: keypath not found
decode_log ethabidecodelog
{"callbackAddr":"0xf0e477c7a664631df4544cc8d3fe6cd34443d78d","callbackFunctionId":[146,205,170,243],"cancelExpiration":1637816760,"data":"amFtb3VudFBhaWRhMWZ1c2VySWRkV2lsbGpjb250cmFjdElkZ2F3ZXJhc2Q=","dataVersion":1,"payment":1000000000000000000,"requestId":[90,93,214,7,123,29,189,59,8,213,171,109,197,119,238,114,0,2,247,196,90,23,232,53,255,135,143,200,168,211,46,156],"requester":"0xf0e477c7a664631df4544cc8d3fe6cd34443d78d","specId":[56,54,57,52,99,56,54,54,50,56,102,48,52,98,49,53,56,98,101,101,97,48,98,49,50,56,53,54,98,50,52,54]}
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 cborparse
data: key decode_log / keypath decode_log.data: keypath not found
data: $(decode_log.data)
The data comes into the contract via req.add calls and i was wondering if it might be a problem with my abi
function requestData(address _oracle, string memory _jobId,string memory _amount, string memory _userId, string memory _contractId)
public
onlyOwner
{
Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fulfillEthereumPrice.selector);
req.add("amountPaid", _amount);
req.add("userId", _userId);
req.add("contractId", _contractId);
sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
}
'''
_______
```type = "directrequest"
schemaVersion = 1
name = "TgetherisPaid"
contractAddress = "0x7CbeF9F1C57b13d412D7651D8a1cFb898600952C"
maxTaskDuration = "1s"
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)"]
my_bridge_task [type="bridge"
name="tgether_ispaid_el_ea"
requestData="{\\"data\\":{\\"userid\\": $(decode_cbor.userId), \\"contractId\\": $(decode_cbor.contractId), \\"amountPaid\\": $(decode_cbor.amountPaid)}}"
]
"""

I was having the same issue here and happens that i was missing the decode_cbor task on the lasts line of the job definition in your case that would be:
decode_log -> decode_cbor -> my_bridge_task

Related

GraphQL Input set Boolean value

I am working on a GraphQL Input Scheme which is based on a Union. The goal is to have either only a delivery address with hasInvoice: false or have a delivery address and invoice address with hasInvoice: true. I got it everything working except the boolean part.
input BaseAddress {
street: String!
number: Int!
}
input OnlyDeliveryAddress {
address: BaseAddress!
withInvoiceAddress: false!
}
input WithInvoiceAddress {
address: BaseAddress!
withInvoiceAddress: true!
invoiceAddress: BaseAddress!
}
union Address = OnlyDeliveryAddress | WithInvoiceAddress
Having booleans as Scalars is not working. Is there a way to only allow the specified boolean to be accepted?

how to update state when state is object that contains array of objects in React 17

I have a form that collects demographic information for one adult and also for each child (minor) that will accompany the adult. Example of data for one minor: {firstName: "Jimmy", lastName: "Smith"}).
I can use setMinors((prevArray) => [...prevArray, data]) to update the minors state as the user adds, edits and possibly deletes minors.
On form submit, I want to setWaiver() with the collection of objects from the minors state at that time, but I cannot determine the correct way to do this.
const[minors, setMinors] = useState([]);
const[waiver, setWaiver] = useState({ firstName : "", lastName : "", email : "", minors: [] });
If you have insight into how to accomplish updating the waiver state to include the objects from the minors state, I appreciate your help.
If you want to update minors in waiver that code will help you
const[minors, setMinors] = useState([]);
const[waiver, setWaiver] = useState({ firstName : "", lastName : "", email : "", minors: [] });
const updateMinors=(newMinors)=>{
setWaiver((prevWaiver)=>({...prevWaiver, minors : newMinors}));
}

Get a string from any API using Chainlink Large Response Example

I just need to get a string from this json, for example: https://filesamples.com/samples/code/json/sample1.json
I took the Chainlink example and just change the URL and path. The example works fine, but if you use a different json o jobid it do not work.
Link to chainlink example: https://docs.chain.link/docs/large-responses/
Is there any way to solve this?
Code used:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "#chainlink/contracts/src/v0.8/ChainlinkClient.sol";
/**
* #notice DO NOT USE THIS CODE IN PRODUCTION. This is an example contract.
*/
contract GenericLargeResponse is ChainlinkClient {
using Chainlink for Chainlink.Request;
// variable bytes returned in a signle oracle response
bytes public data;
string public dataS;
/**
* #notice Initialize the link token and target oracle
* #dev The oracle address must be an Operator contract for multiword response
*
*
* Kovan Testnet details:
* Link Token: 0xa36085F69e2889c224210F603D836748e7dC0088
* Oracle: 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8 (Chainlink DevRel)
*
*/
constructor(
) {
setChainlinkToken(0xa36085F69e2889c224210F603D836748e7dC0088);
setChainlinkOracle(0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8);
}
/**
* #notice Request variable bytes from the oracle
*/
function requestBytes(
)
public
{
bytes32 specId = "7a97ff8493ec406d90621b2531f9251a";
uint256 payment = 100000000000000000;
Chainlink.Request memory req = buildChainlinkRequest(specId, address(this), this.fulfillBytes.selector);
req.add("get","https://filesamples.com/samples/code/json/sample1.json");
req.add("path", "fruit");
requestOracleData(req, payment);
}
event RequestFulfilled(
bytes32 indexed requestId,
bytes indexed data
);
/**
* #notice Fulfillment function for variable bytes
* #dev This is called by the oracle. recordChainlinkFulfillment must be used.
*/
function fulfillBytes(
bytes32 requestId,
bytes memory bytesData
)
public
recordChainlinkFulfillment(requestId)
{
emit RequestFulfilled(requestId, bytesData);
data = bytesData;
dataS = string(data);
}
}
The response of that API is:
{
"fruit": "Apple",
"size": "Large",
"color": "Red"
}
The fruit has a value of Apple. You'll need to have the API return the bytes edition of Apple instead.
You'll notice the example returns JSON that looks like:
{
"image": "0x68747470733a2f2f697066732e696f2f697066732f516d5358416257356b716e3259777435444c336857354d736a654b4a4839724c654c6b51733362527579547871313f66696c656e616d653d73756e2d636861696e6c696e6b2e676966"
}
Which is the hex edition of the URL of the image.

why create a new row when gorm update associations

I followed the document code same struct and migrate
here's my model
type User struct {
gorm.Model
AddressID uint ``
Address UserAddress `gorm:"references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
}
type UserAddress struct {
gorm.Model
Address string `gorm:"type:varchar(50);notNull"`
}
document works fine when migrate and create data
db.AutoMigrate(&UserAddress{})
db.AutoMigrate(&User{})
but when I try update data use associations
user := &User{
ID: 1,
AddressID: 1,
Address: UserAddress{
Address: "new address",
},
}
db.Session(&gorm.Session{FullSaveAssociations: true}).Updates(&user)
document says:
If you want to update associations’s data, you should use the FullSaveAssociations mode:
then it still create a new data of address and update user.address_id
INSERT INTO `user_address` (`address`,`created_at`,`updated_at`,`deleted_at`) VALUES ('changed','2021-08-13 14:07:39.149','2021-08-13 14:07:39.149',NULL) ON DUPLICATE KEY UPDATE `address`=VALUES(`address`),`created_at`=VALUES(`created_at`),`updated_at`=VALUES(`updated_at`),`deleted_at`=VALUES(`deleted_at`)
where am I missing here or it just doesn't work at all?
You didn't give a unique id for Address. So it create new address record with autoincrement ID. And update the ID value associated with it.
user := &User{
ID: 1,
AddressID: 1,
Address: UserAddress{
ID: 1,
Address: "new address",
},
}

I am trying to make a call to accounts.notifylogin (Gigya API) from Postman but getting 403003 error

The API request I am calling from Postman is
https://accounts.eu1.gigya.com/accounts.notifyLogin?UIDSig=[dummy_UIDSig]&UIDTimestamp=1608199002&UID=2e607bf09ce12874a909c5c1513fa437&apiKey=[API_of_the_site]&siteUID=[site_uid]
for me, the issue seems to be in UIDSig (not sure how to create it),
and getting bellow response
{
"callId": "c1f16c61f09d4be5962c2ab046396cbf",
"errorCode": 403003,
"errorDetails": "invalid request signature",
"errorMessage": "Invalid request signature",
"apiVersion": 2,
"statusCode": 403,
"statusReason": "Forbidden",
"time": "2020-12-17T10:21:00.966Z"
}
Many Thanks.
You only pass UID Signature when on a mobile device, otherwise you pass providerSessions - which is the data you received from the social network. For generating a signature, it would require something similar to this (and should only EVER be done on the server, as it requires using your secret key):
string constructSignature(string timestamp, string UID, string secretKey) {
baseString = timestamp + "_" + UID; // Construct a "base string" for signing
binaryBaseString = ConvertUTF8ToBytes(baseString); // Convert the base string into a binary array
binaryKey = ConvertFromBase64ToBytes(secretKey); // Convert secretKey from BASE64 to a binary array
binarySignature = hmacsha1(binaryKey, binaryBaseString); // Use the HMAC-SHA1 algorithm to calculate the signature
signature = ConvertToBase64(binarySignature); // Convert the signature to a BASE64
return signature;
}

Resources