Skip to content

Commit

Permalink
Merge branch 'develop' into hfi
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime authored Jan 8, 2025
2 parents a8e1b71 + e287157 commit df6c531
Show file tree
Hide file tree
Showing 31 changed files with 2,338 additions and 519 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ STORY_API_BASE_URL= # Story API base URL
STORY_API_KEY= # Story API key
PINATA_JWT= # Pinata JWT for uploading files to IPFS

# Cosmos
COSMOS_RECOVERY_PHRASE= # 12 words recovery phrase (need to be in quotes, because of spaces)
COSMOS_AVAILABLE_CHAINS= # mantrachaintestnet2,cosmos # Array of chains
# Cronos zkEVM
CRONOSZKEVM_ADDRESS=
CRONOSZKEVM_PRIVATE_KEY=
Expand Down
2 changes: 1 addition & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@elizaos/plugin-binance": "workspace:*",
"@elizaos/plugin-avail": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@ai16z/plugin-cosmos": "workspace:*",
"@elizaos/plugin-cosmos": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-coinprice": "workspace:*",
Expand Down
8 changes: 6 additions & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { confluxPlugin } from "@elizaos/plugin-conflux";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { evmPlugin } from "@elizaos/plugin-evm";
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
Expand Down Expand Up @@ -375,7 +376,7 @@ export function getTokenForProvider(
}
}

async function initializeDatabase(dataDir: string) {
function initializeDatabase(dataDir: string) {
if (process.env.POSTGRES_URL) {
elizaLogger.info("Initializing PostgreSQL connection...");
const db = new PostgresDatabaseAdapter({
Expand Down Expand Up @@ -587,6 +588,9 @@ export async function createAgent(
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? evmPlugin
: null,
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
createCosmosPlugin(),
(getSecret(character, "SOLANA_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith(
Expand Down Expand Up @@ -769,7 +773,7 @@ async function startAgent(
fs.mkdirSync(dataDir, { recursive: true });
}

db = (await initializeDatabase(dataDir)) as IDatabaseAdapter &
db = initializeDatabase(dataDir) as IDatabaseAdapter &
IDatabaseCacheAdapter;

const cache = initializeCache(
Expand Down
36 changes: 10 additions & 26 deletions characters/cosmosHelper.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
"clients": [],
"modelProvider": "groq",
"settings": {
"secrets": {},
"voice": {
"model": "en_US-male-medium"
},
"chains": {
"cosmos": ["axelar", "carbon", "mantrachaintestnet2"]
}
},
"plugins": ["@ai16z/plugin-cosmos","@ai16z/plugin-bootstrap"],
"plugins": [],
"bio": [
"Expert in Cosmos ecosystem.",
"Knowledgeable in CosmWasm and Stargate.",
Expand All @@ -24,37 +23,22 @@
"Supports projects and interactions within the Cosmos ecosystem."
],
"knowledge": [
"knows EXACT cost to families under Kamala ($29,000)",
"understands REAL border numbers (worse than reported)",
"saw what really happened in Minneapolis 2020",
"remembers who begged for help (and when)",
"knows why Iran's president targeting us",
"understands Secret Service allocation (and why they do it)",
"knows REAL rally numbers (they hide them)",
"saw the TRUTH about China Virus response",
"understands states' rights better than anyone",
"knows why they're letting in illegal guns",
"remembers when America was AFFORDABLE",
"understands the REAL election interference",
"knows why they're scared of WorldLibertyFi",
"saw what they did to women's sports",
"understands the REAL Middle East situation",
"knows why missiles flying everywhere now",
"remembers perfect peace under Trump presidency",
"understands Democrat election strategy (letting in MILLIONS)",
"knows Kamala's REAL tax plans (coming for everything)",
"saw what they did to Minneapolis (and other cities)"
"Knows how Cosmos blockchain works",
"Knows what actions should he call for token transfer, swapping or bridging",
"Knows that users might want to do specific actions multiple times and should help them by doing it again.",
"Should always ask for confirmation before calling an COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP actions.",
"Should call actions COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP only after previous confirmation."
],
"messageExamples": [
[
{
"user": "{{user1}}",
"content": { "text": "Can you explain the Cosmos Hub?" }
"content": { "text": "Show my balances of my wallet on {{mantrachaintestnet2}}" }
},
{
"user": "CosmosHelper",
"content": {
"text": "The Cosmos Hub is the central blockchain in the Cosmos ecosystem, facilitating interoperability between connected blockchains."
"text": "Your balances on chain {{mantrachaintestnet2}} are: \n - 13456.124 OM\n - 1222 ONDO\n 0.122122 USDY"
}
}
],
Expand Down Expand Up @@ -97,12 +81,12 @@
[
{
"user": "{{user1}}",
"content": { "text": "What are validators?" }
"content": { "text": "Make transfer 0.0001 OM to mantra13248w8dtnn07sxc3gq4l3ts4rvfyat6fks0ecj on mantrachaintestnet2" }
},
{
"user": "CosmosHelper",
"content": {
"text": "Validators are responsible for securing the network by validating transactions and producing new blocks. They earn rewards through staking."
"text": "Sure, your transfer i being processed."
}
}
]
Expand Down
19 changes: 11 additions & 8 deletions packages/plugin-cosmos/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `@ai16z/plugin-cosmos`
# `@elizaos/plugin-cosmos`

This plugin provides actions and utilities for interacting with Cosmos-compatible blockchains.

Expand All @@ -7,15 +7,17 @@ This plugin provides actions and utilities for interacting with Cosmos-compatibl
## Development

Prepare Eliza according to [README](../../README.md)
Add variables required for `@ai16z/plugin-cosmos` :
```
Add variables required for `@elizaos/plugin-cosmos` :

```
COSMOS_RECOVERY_PHRASE=your recovery phrase words
COSMOS_AVAILABLE_CHAINS=chain1,chain2,chain3
```
```

Ensure the appropriate environment variables are added for the plugin. If they are correctly configured, the project will run with `@ai16z/plugin-cosmos`
Ensure the appropriate environment variables are added for the plugin. If they are correctly configured, the project will run with `@elizaos/plugin-cosmos`

Run Eliza

Run Eliza
```
pnpm run dev
```
Expand All @@ -26,13 +28,12 @@ pnpm run dev

To start using the plugin, you need to provide your **Cosmos account recovery phrases** and the list of **available chains**. Add the following to your `.env` file:


```env
COSMOS_RECOVERY_PHRASE=your recovery phrase words
COSMOS_AVAILABLE_CHAINS=chain1,chain2,chain3
```
Ensure that the chain names in `COSMOS_AVAILABLE_CHAINS` match the identifiers from the [chain-registry](https://github.com/cosmos/chain-registry) library for compatibility.

Ensure that the chain names in `COSMOS_AVAILABLE_CHAINS` match the identifiers from the [chain-registry](https://github.com/cosmos/chain-registry) library for compatibility.

### Using the Cosmos Helper Character

Expand All @@ -51,9 +52,11 @@ To use the character, pass it with the `--characters` flag:
---

### Custom chain configuration

Plugin allows you to pass you custom chain config to `createCosmosPlugin` function invoked in `../agent/src/index`.

Your custom configuration fulfills the interfaces from `chain-registry`

```
import type { assets, chains } from "chain-registry";
Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ai16z/plugin-cosmos",
"name": "@elizaos/plugin-cosmos",
"version": "1.0.0",
"main": "dist/index.js",
"type": "module",
Expand All @@ -13,12 +13,16 @@
"bignumber.js": "9.1.2",
"chain-registry": "^1.69.68",
"tsup": "8.3.5",
"zod": "3.23.8"
"zod": "3.23.8",
"interchain": "^1.10.4"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache .",
"test": "vitest run"
},
"devDependencies": {
"@chain-registry/types": "^0.50.44"
}
}
Loading

0 comments on commit df6c531

Please sign in to comment.