Skip to content

Commit

Permalink
Add 0g
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Nov 25, 2024
2 parents edecd95 + 4a1a9cc commit 8442d09
Show file tree
Hide file tree
Showing 14 changed files with 9,514 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ CONFLUX_ESPACE_PRIVATE_KEY=
CONFLUX_ESPACE_RPC_URL=
CONFLUX_MEME_CONTRACT_ADDRESS=

#ZeroG
ZEROG_INDEXER_RPC=
ZEROG_EVM_RPC=
ZEROG_PRIVATE_KEY=
ZEROG_FLOW_ADDRESS=

# Coinbase Commerce
COINBASE_COMMERCE_KEY=

1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@ai16z/plugin-image-generation": "workspace:*",
"@ai16z/plugin-node": "workspace:*",
"@ai16z/plugin-solana": "workspace:*",
"@ai16z/plugin-0g": "workspace:*",
"@ai16z/plugin-starknet": "workspace:*",
"@ai16z/plugin-coinbase": "workspace:*",
"readline": "1.3.0",
Expand Down
19 changes: 11 additions & 8 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import { confluxPlugin } from "@ai16z/plugin-conflux";
import { solanaPlugin } from "@ai16z/plugin-solana";
import { zgPlugin } from "@ai16z/plugin-0g";
import { nodePlugin } from "@ai16z/plugin-node";
import {
coinbaseCommercePlugin,
Expand Down Expand Up @@ -234,6 +235,10 @@ export async function initializeClients(
return clients;
}

function getSecret(character: Character, secret: string) {
return character.settings.secrets?.[secret] || process.env[secret];
}

export function createAgent(
character: Character,
db: IDatabaseAdapter,
Expand All @@ -253,19 +258,17 @@ export function createAgent(
character,
plugins: [
bootstrapPlugin,
character.settings.secrets?.CONFLUX_CORE_PRIVATE_KEY
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
? confluxPlugin
: null,
nodePlugin,
character.settings.secrets?.WALLET_PUBLIC_KEY ? solanaPlugin : null,
character.settings.secrets?.COINBASE_COMMERCE_KEY ||
process.env.COINBASE_COMMERCE_KEY
getSecret(character, "WALLET_PUBLIC_KEY") ? solanaPlugin : null,
getSecret(character, "ZEROG_PRIVATE_KEY") ? zgPlugin : null,
getSecret(character, "COINBASE_COMMERCE_KEY")
? coinbaseCommercePlugin
: null,
(character.settings.secrets?.COINBASE_API_KEY ||
process.env.COINBASE_API_KEY) &&
(character.settings.secrets?.COINBASE_PRIVATE_KEY ||
process.env.COINBASE_PRIVATE_KEY)
getSecret(character, "COINBASE_API_KEY") &&
getSecret(character, "COINBASE_PRIVATE_KEY")
? coinbaseMassPaymentsPlugin
: null,
].filter(Boolean),
Expand Down
Loading

0 comments on commit 8442d09

Please sign in to comment.