-
Notifications
You must be signed in to change notification settings - Fork 9
An example of a dynamic oracle #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Code examples for Wrapped Keys guides
Fix Wrapped Keys solana send tx tests
Init SIWS example that uses `LitAction.checkConditions` for simple SIWS auth
Init SIWS Generate Session Sigs example
Init SIWS Authentication within a LA example code
Inits SIWS example to generate Session Sigs and decrypt a string
Init EIP-712 message signing using Wrapped Keys example
Add test for EIP-191 signing
Mint PKP through relayer using Google OAuth
const temperature = resp.properties.periods[0].temperature; | ||
|
||
// add any other data you want to include in the signature here | ||
// like the user's identity, or a nonce | ||
const messageToSign = { temperature, url }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have to define .properties.periods[0].temperature
then it's not truly dynamic is it?
Maybe we want to include this helper function in the Lit Action:
/**
* Extracts a nested value from an object using a dot-notation path string that can include array indices.
*
* @param {string} responseValue - The path string using dot notation (e.g. 'users[0].name' or 'meta.totalUsers')
* @param {any} data - The object to extract the value from
* @returns {any} The value at the specified path
*
* @example
* const data = {
* users: [
* { id: 1, name: 'Alice' },
* { id: 2, name: 'Bob' }
* ],
* meta: { totalUsers: 2 }
* };
*
* getValueFromResponse('users[0].name', data); // Returns 'Alice'
* getValueFromResponse('users[1].id', data); // Returns 2
* getValueFromResponse('meta.totalUsers', data); // Returns 2
*/
export function getValueFromResponse(responseValue: string, data: any): any {
return responseValue.split('.').reduce((acc: any, key: string) => {
const arrayMatch = key.match(/(\w+)\[(\d+)\]/);
if (arrayMatch) {
const [, arrayKey, index] = arrayMatch;
return acc?.[arrayKey]?.[parseInt(index)];
} else {
return acc?.[key];
}
}, data);
}
Then in jsParam
define the path you want to access
jsParams:{
responsePath: 'properties.periods[0].temperature'
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point! i'm working on a new implementation where the user just supplies the whole JS function, so that they can just parse whatever they want. will post it here when ready.
b9379a5
to
093b51d
Compare
Let the user pass in a URL, attach it to the signed data. Anyone can use this as a generic oracle.