Skip to content

Commit

Permalink
"wip: fixed rpc initialization"
Browse files Browse the repository at this point in the history
  • Loading branch information
enigmarikki committed Jan 14, 2025
1 parent 3062891 commit 99b29a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ SOLANA_ADMIN_PRIVATE_KEY= # This wallet is used to verify NFTs
SOLANA_ADMIN_PUBLIC_KEY= # This wallet is used to verify NFTs
SOLANA_VERIFY_TOKEN= # Authentication token for calling the verification API

# Injective
INJECTIVE_PRIVATE_KEY= #
INJECTIVE_PUBLIC_KEY= #

# Fallback Wallet Configuration (deprecated)
WALLET_PRIVATE_KEY=
WALLET_PUBLIC_KEY=
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const defaultCharacter: Character = {
username: "eliza",
plugins: [],
clients: [],
modelProvider: ModelProviderName.LLAMALOCAL,
modelProvider: ModelProviderName.OPENAI,
settings: {
secrets: {},
voice: {
Expand Down
27 changes: 17 additions & 10 deletions packages/plugin-injective/src/action/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Memory,
ModelClass,
State,
elizaLogger,
composeContext,
type Action,
generateObjectDeprecated,
Expand Down Expand Up @@ -48,7 +49,6 @@ export function createGenericAction({
description, // e.g. "Place a bid using the InjectiveGrpcClient"
examples, // your example user/assistant conversation
similes, // (optional) synonyms or alternate names if you like

// (Optional) global validation for the entire Action
validate: async (_runtime, _message) => {
return true;
Expand All @@ -61,8 +61,8 @@ export function createGenericAction({
_options: { [key: string]: unknown },
callback?: HandlerCallback
): Promise<boolean> => {
console.log(`Starting ${name} handler...`);

elizaLogger.log(`Starting ${name} handler...`);
elizaLogger.debug(`create action: ${name}`);
// 1. Compose or update the state
if (!state) {
state = (await runtime.composeState(message)) as State;
Expand All @@ -85,7 +85,7 @@ export function createGenericAction({

// 4. TODO: Validate the LLM context
// if (!validateContent(runtime, content)) {
// console.error(`Invalid content for ${name} action.`);
// elizaLogger.error(`Invalid content for ${name} action.`);
// if (callback) {
// callback({
// text: `Invalid content for ${name}`,
Expand All @@ -98,9 +98,11 @@ export function createGenericAction({
// 5. Initialize the Injective client
try {
const rawNetwork = runtime.getSetting("INJECTIVE_NETWORK");
const privateKey = runtime.getSetting("INJECTIVE_PRIVATE_KEY");
const evmPublicKey = runtime.getSetting("EVM_PUBLIC_KEY");
const injectivePublicKey = runtime.getSetting("INJECTIVE_PUBLIC_KEY");
const injectivePrivateKey = runtime.getSetting(
"INJECTIVE_PRIVATE_KEY"
);
const ethPublicKey = runtime.getSetting("EVM_PUBLIC_KEY");
const injPublicKey = runtime.getSetting("INJECTIVE_PUBLIC_KEY");
const network = rawNetwork as
| "MainnetK8s"
| "MainnetLB"
Expand All @@ -117,14 +119,19 @@ export function createGenericAction({
| "Devnet2"
| "Devnet"
| "Local";
if (!privateKey || !evmPublicKey || !network) {
if (
!injectivePrivateKey ||
(!ethPublicKey && !injPublicKey) ||
!network
) {
throw new Error("Incorrect configuration");
}

const client = new InjectiveGrpcClient(
network,
publicKey,
privateKey
injectivePrivateKey,
ethPublicKey,
injPublicKey
);

// 6. Dynamically call the specified functionName on the Injective client
Expand Down

0 comments on commit 99b29a0

Please sign in to comment.