From 5503d2e5410a48bc0a9cf768154907fa9a8786f0 Mon Sep 17 00:00:00 2001 From: jonghwan lee Date: Mon, 6 Jan 2025 16:34:42 +0900 Subject: [PATCH] [BLCKCHN-217] Add Cronos ID #38 Add resolveCronosId functionality - Introduced new parameters for resolving a CronosId to its corresponding wallet address in `chain-ai.helpers.ts`. - Updated `agent.constants.ts` to include the new function in the tools list. - Modified `agent.interfaces.ts` to define the new `ResolveCronosId` function and its associated data structure. This enhancement allows users to resolve CronosIds, improving the functionality of the agent service. --- .../src/helpers/chain-ai.helpers.ts | 11 +++++++++ .../src/services/agent/agent.constants.ts | 23 +++++++++++++++++++ .../src/services/agent/agent.interfaces.ts | 7 ++++++ 3 files changed, 41 insertions(+) diff --git a/ai/cryptocom-ai-agent-service/src/helpers/chain-ai.helpers.ts b/ai/cryptocom-ai-agent-service/src/helpers/chain-ai.helpers.ts index 80290bb..236f4d6 100644 --- a/ai/cryptocom-ai-agent-service/src/helpers/chain-ai.helpers.ts +++ b/ai/cryptocom-ai-agent-service/src/helpers/chain-ai.helpers.ts @@ -154,3 +154,14 @@ export const getErc20BalanceParameters = { }, required: ['address', 'contractAddress'], }; + +export const resolveCronosIdParameters = { + type: 'object', + properties: { + cronosId: { + type: 'string', + description: 'The CronosId to resolve (must end with .cro)', + }, + }, + required: ['cronosId'], +}; diff --git a/ai/cryptocom-ai-agent-service/src/services/agent/agent.constants.ts b/ai/cryptocom-ai-agent-service/src/services/agent/agent.constants.ts index 3fb5677..d8ab73f 100644 --- a/ai/cryptocom-ai-agent-service/src/services/agent/agent.constants.ts +++ b/ai/cryptocom-ai-agent-service/src/services/agent/agent.constants.ts @@ -13,6 +13,7 @@ import { wrapTokenParameters, getCurrentTimeParameters, getErc20BalanceParameters, + resolveCronosIdParameters, } from '../../helpers/chain-ai.helpers.js'; import { BlockchainFunction } from './agent.interfaces.js'; @@ -124,6 +125,14 @@ export const TOOLS: OpenAI.Chat.ChatCompletionTool[] = [ parameters: getErc20BalanceParameters, }, }, + { + type: 'function', + function: { + name: BlockchainFunction.ResolveCronosId, + description: 'Resolve a CronosId (.cro) to its corresponding wallet address', + parameters: resolveCronosIdParameters, + }, + }, ]; export const GEMINI_TOOLS = { @@ -306,5 +315,19 @@ export const GEMINI_TOOLS = { required: ['address', 'contractAddress'], }, }, + { + name: BlockchainFunction.ResolveCronosId, + description: 'Resolve a CronosId (.cro) to its corresponding wallet address', + parameters: { + type: 'OBJECT', + properties: { + cronosId: { + type: 'STRING', + description: 'The CronosId to resolve (must end with .cro)', + }, + }, + required: ['cronosId'], + }, + }, ], }; diff --git a/ai/cryptocom-ai-agent-service/src/services/agent/agent.interfaces.ts b/ai/cryptocom-ai-agent-service/src/services/agent/agent.interfaces.ts index f9c2d51..b94e7f0 100644 --- a/ai/cryptocom-ai-agent-service/src/services/agent/agent.interfaces.ts +++ b/ai/cryptocom-ai-agent-service/src/services/agent/agent.interfaces.ts @@ -50,6 +50,7 @@ export interface FunctionArgs { fromContractAddress: string; toContractAddress: string; name: string; + cronosId: string; } export enum Symbol { @@ -91,6 +92,7 @@ export enum BlockchainFunction { GetCurrentTime = 'getCurrentTime', FunctionNotFound = 'functionNotFound', GetErc20Balance = 'getErc20Balance', + ResolveCronosId = 'resolveCronosId', } export interface BlockchainFunctionResponse { @@ -246,3 +248,8 @@ export interface GeminiOptions { apiKey: string; model?: string; } + +export interface ResolveCronosIdData { + cronosId: string; + resolvedAddress: string; +}