diff --git a/.env.sample b/.env.sample index 7652ab0..90cbfa1 100644 --- a/.env.sample +++ b/.env.sample @@ -10,9 +10,6 @@ APTOS_ORACLE_ADDRESS="" APTOS_INDEXER_CRON="*/5 * * * * *" APTOS_PRIVATE_KEY="" -X_API_KEY="" -X_API_SECRET="" - # Postgres config POSTGRES_USER=user POSTGRES_DB=xxxxxxxxx @@ -24,3 +21,9 @@ DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres_db:543 # Optionals SENTRY_DSN="" ECDSA_PRIVATE_KEY="" # for verity analysis. + +# Integrations +X_API_KEY="" +X_API_SECRET="" + +OPEN_AI_TOKEN="" \ No newline at end of file diff --git a/orchestrator/src/integrations/openAI.ts b/orchestrator/src/integrations/openAI.ts index 571d9e9..1fb1b5c 100644 --- a/orchestrator/src/integrations/openAI.ts +++ b/orchestrator/src/integrations/openAI.ts @@ -11,7 +11,7 @@ const chatSchema = Joi.object({ }).required(), ), }); -export default class TwitterIntegration extends BasicBearerAPIHandler { +export default class OpenAIIntegration extends BasicBearerAPIHandler { validatePayload(path: string, payload: string): boolean { try { if (this.supported_paths.includes(path)) { @@ -33,7 +33,7 @@ export default class TwitterIntegration extends BasicBearerAPIHandler { } } -export const instance = new TwitterIntegration( +export const instance = new OpenAIIntegration( env.integrations.xBearerToken, ["api.openai.com"], ["/v1/chat/completions"], diff --git a/rooch/Move.toml b/rooch/Move.toml index 9e16a19..6dfc23d 100644 --- a/rooch/Move.toml +++ b/rooch/Move.toml @@ -1,5 +1,5 @@ [package] -name = "verity-move-@orchestrators" +name = "verity-move-oracles" version = "0.0.1" [dependencies] diff --git a/rooch/sources/oracle_registry.move b/rooch/sources/oracle_registry.move index b1dec68..0136df4 100644 --- a/rooch/sources/oracle_registry.move +++ b/rooch/sources/oracle_registry.move @@ -77,6 +77,7 @@ module verity::registry { let supported_urls = &account::borrow_resource(@verity).supported_urls; let url = string_utils::to_lower_case(&url); + // Is the Orchestrator registered as an Oracle? if (simple_map::contains_key(supported_urls, &orchestrator)) { let orchestrator_urls = simple_map::borrow(supported_urls, &orchestrator); @@ -89,6 +90,7 @@ module verity::registry { if (orchestrator_url.minimum_payload_length > payload_length) { return option::none() }; + // The minimum_payload_length covers for metadata associated request payload. let chargeable_token: u256 = ((payload_length as u256) - (orchestrator_url.minimum_payload_length as u256)); return option::some( orchestrator_url.base_fee + diff --git a/rooch/sources/oracles.move b/rooch/sources/oracles.move index 760a603..4bd034a 100644 --- a/rooch/sources/oracles.move +++ b/rooch/sources/oracles.move @@ -54,6 +54,7 @@ module verity::oracles { oracle: address, response_status: u16, response: Option, + // This is an account to be paid back by the Contract in case of excess payment. account_to_credit: address, amount: u256 } @@ -62,6 +63,8 @@ module verity::oracles { struct GlobalParams has key { owner: address, treasury: Object>, + // Holds the address of each requesting Contract and their balance + // Either a calling Contract, or a User adjust the balance. balances: SimpleMap, } @@ -196,6 +199,7 @@ module verity::oracles { ): ObjectID { let sent_coin = coin::value(&payment); // 1024 could be changed to the max string length allowed on Move + // This 1024 is a default estaimate for the expected payload length, however, it's the user's responsibility to cover in case of requests that expect large payload responses. let option_min_amount = OracleSupport::estimated_cost(oracle, params.url, string::length(¶ms.body), 1024); assert!(option::is_some(&option_min_amount), OracleSupportError); let min_amount = option::destroy_some(option_min_amount);