Does anyone have an example Chainlink Large response Toml job specs for Chainlink node operators? - chainlink

Does anyone have an example of Chainlink Large response Toml job specs for Chainlink node operators?
The only example I could find was json:
{
"name": "large-word",
"initiators": [
{
"id": 9,
"jobSpecId": "7a97ff84-93ec-406d-9062-1b2531f9251a",
"type": "runlog",
"params": {
"address": "0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8"
}
}
],
"tasks": [
{
"jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
"type": "httpget"
},
{
"jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
"type": "jsonparse"
},
{
"jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
"type": "resultcollect"
},
{
"jobSpecId": "7a97ff8493ec406d90621b2531f9251a",
"type": "ethtx",
"confirmations": 1,
"params": {
"abiEncoding": [
"bytes32",
"bytes"
]
}
}
]
}
Do we just change the Abi encoding?
any help would be much appreciated. thanks

You can achieve this with a simple V2 direct request job, you just need to ensure your ABI and parameter encoding is correct, and matches what the contract expects, no resultCollect is needed for V2. In addition to this, you need to use the v0.7 onwards Operator.sol as your oracle contract as opposed to the older Oracle.sol, as this is the one that has the fulfillOracleRequest2 function that takes a bytes parameter for the data, as opposed to a bytes32 parameter (which limits the size of your response)
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.cborPayload)"]
// Then, we use the decoded request parameters to make an HTTP fetch
fetch [type="http" method=GET url="$(decode_cbor.fetchURL)"]
parse [type="jsonparse" path="$(decode_cbor.jsonPath)" data="$(fetch)"]
// Finally, we send a response on-chain.
// Note that single-word responses automatically populate
// the requestId.
encode_response [type="ethabiencode"
abi="(bytes data)"
data="{\\"data\\": $(parse) }"]
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_response)}"
]
submit_tx [type="ethtx" to="0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8" data="$(encode_tx)"]
decode_log -> decode_cbor -> fetch -> parse -> encode_response -> encode_tx -> submit_tx

Related

Adaptivecards Send POST call to external API in MS Teams

I am building a script that pushes adaptive card messages to an MS Teams channel connector via a webhook requesting the approval of a supervisor.
I want to put two buttons on the bottom of the message, one to decline and another to approve the request. For this, I need to push a boolean value to an API endpoint. My initial idea was to create an API endpoint accepting a JSON body and looking into the JSON body for approval over a POST request but apparently, this is no longer supported in MS Teams and then I was thinking to use Action.OpenUrl to push this as a query parameter in the URL, but unfortunately this opens a new tab with the query parameter.
Is there any other way to achieve this? This is a sample JSON for the MS Teams webhook:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"msTeams": {
"width": "full"
},
"actions": [
{
"type": "Action.OpenUrl",
"title": "Approve",
"url": "https://<api_endpoint_url>?approved=true"
},
{
"type": "Action.OpenUrl",
"title": "Decline",
"url": "https://<api_endpoint_url>?approved=false"
}
]
}
}
]
}
This sample shows a feature where user can send task request to his manager and manager can approve/reject the request in group chat.You can try like below code:-
case "approved":
string[] approvedCard = { ".", "Cards", "ApprovedCard.json" };
var approvedAttachment = GetResponseAttachment(approvedCard, data, out cardJson);
Activity approvedActivity = new Activity();
approvedActivity.Type = "message";
approvedActivity.Id = turnContext.Activity.ReplyToId;
approvedActivity.Attachments = new List<Attachment> { approvedAttachment };
await turnContext.UpdateActivityAsync(approvedActivity);
response = JObject.Parse(cardJson);
adaptiveCardResponse = new AdaptiveCardInvokeResponse()
{
StatusCode = 200,
Type = "application/vnd.microsoft.card.adaptive",
Value = response
};
return CreateInvokeResponse(adaptiveCardResponse);
Ref Sample-https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-request-approval/csharp

How to get the current earnings of the farms via Elrond REST API

How I could obtain the current earnings of a farm from Maiar Exchange via Elrond REST API?
For example, for the LKMEX farm I want to determine the current earnings (My Earned MEX) in MEX and/or USDT since the latest harverst or 'reinvest'. Thanks!
Based on what I was looking in maiar.exchange. You can determine there is a graphql request for this.
You can do graphql request to https://graph.maiar.exchange/graphql. I did not search if there is any OpenAPI spec to know if there is any security bound to this route. However, to help you out, here is the graphql (with redacted content), that is used to get current amount in farm with current harvestable amount:
{
"variables": {
"getRewardsForPositionArgs": {
"farmsPositions": [
{
"attributes": "XXXX",
"identifier": "MEXFARM-XXXXX-XXXXX",
"farmAddress": "erd1XXXX",
"liquidity": "19700000000000000000000000"
},
{
"attributes": "XXX",
"identifier": "LKFARM-XXXXXXX-XXXXXX",
"farmAddress": "erd1XXXXX",
"liquidity": "19700000000000000000000000"
},
]
}
},
"query": "query ($getRewardsForPositionArgs: BatchFarmRewardsComputeArgs!) {\n getRewardsForPosition(farmsPositions: $getRewardsForPositionArgs) {\n rewards\n remainingFarmingEpochs\n decodedAttributes {\n aprMultiplier\n compoundedReward\n initialFarmingAmount\n currentFarmAmount\n lockedRewards\n identifier\n __typename\n }\n __typename\n }\n}\n"
}
Liquidity is from where you want to get the data. There might be a need to do another graphql request before doing this to know where you are for liquidity.

Microsoft graph API - unable to use $filter operation in "toRecipients" array

Hello guys hope ur doing good,
I want to filter out the graph api response based on the "toRecipient" which is a array, hence I used lambda expression, but it gives error.
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"date": "2021-09-22T06:04:17",
"request-id": "c6077cd4-dbec-4671-9c11-10e547917d29",
"client-request-id": "66dfbc92-2482-11f3-86f9-22652a4e4e00"
}
}
My actual response is
"toRecipients": [
{
"emailAddress": {
"name": "abc",
"address": "abc#abc.com"
}
}
],
I had used this operation to filter out
https://graph.microsoft.com/v1.0/me/mailFolders/sentItems/messages?&$top=1000&$search="abc#abc.com"
Graph API calls underlaying Office 365 API.
According to the documentation, property ToRecipients is not filterable.

How to mention array of object in hasura graphql action type?

How to define the Action type in Hasura graphql(console) for below given API response?
{
"data": [
{
"name": "Jordan Smith",
"id": 101,
"location": "Florida",
"speciality_id": 214
},
{
"name": "Cathy Morphy",
"id": 104,
"location": "london",
"speciality_id": 214
}
],
"count": 2 }
If you have control over what's in your API response, and can change it to just return an array of objects (what's inside data), then something like this should work:
type Query {
doctors(specialty_id: Int, search: String, limit: Int, offset: Int): [Doctor]
}
type Doctor {
name: String
id: Int
location: String
specialty_id: Int
}
If you don't have control over the API response, you'll need another layer (e.g. a serverless function or another server endpoint to request the data and transform the response into the format Hasura Actions can handle).
See also:
https://github.com/hasura/graphql-engine/issues/4806
https://hasura.io/docs/latest/graphql/core/actions/types/index.html#custom-graphql-types

Why am I getting constant time-out errors with Teams Shifts API? (Microsoft Graph)

When querying a schedule in Teams Shifts which has sizeable amounts of shifts (say, 100+ shifts over a month - which is like a 30 person team working every day) we are constantly getting 504 errors (gateway timeouts)
We've tried using TOP and limiting the amount of days we're returning to reduce the request size, but the GRAPH API for Shifts is VERY limited in terms of search and filtering capacity
REQUEST EXAMPLE (FROM MS FLOW, via custom connector).
{
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['shared_medicus365-5fconnector-5f455cfd1c6d1a89ed-5fce5269b428f1d481']['connectionId']"
}
},
"method": "get",
"path": "/beta/teams/#{encodeURIComponent(items('fe_team')?['TeamID'])}/schedule/shifts",
"queries": {
"$filter": "sharedShift/startDateTime ge #{outputs('composeStartOfDay')} and sharedShift/endDateTime le #{body('6monthsAhead')}",
"$top": "1000"
},
"authentication": "#parameters('$authentication')"
},
"metadata": {
"flowSystemMetadata": {
"swaggerOperationId": "ListTeamsShifts"
}
}
}
We're using the EXACT defined methods as described in the microsoft documentation.
We're getting a 504 response from GRAPH - gateway timeouts (again) any time the message size is anything beyond more than a few weeks worth of Shifts.
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "437ad3be-be70-4bbe-b972-f9e24b588b5c",
"date": "2019-09-03T19:01:57"
}
}
}

Resources