Skip to content

Commit

Permalink
Merge pull request elizaOS#589 from ai16z/shaw/fix-zerog
Browse files Browse the repository at this point in the history
fix: Shaw/fix zerog
  • Loading branch information
lalalune authored Nov 25, 2024
2 parents c6a3bf9 + 8442d09 commit a4bf4c7
Show file tree
Hide file tree
Showing 29 changed files with 12,284 additions and 23 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,20 @@ COINBASE_PRIVATE_KEY= # from coinbase developer portal
# if not configured it will be generated and written to runtime.character.settings.secrets.COINBASE_GENERATED_WALLET_ID and runtime.character.settings.secrets.COINBASE_GENERATED_WALLET_HEX_SEED
COINBASE_GENERATED_WALLET_ID= # not your address but the wallet id from generating a wallet through the plugin
COINBASE_GENERATED_WALLET_HEX_SEED= # not your address but the wallet hex seed from generating a wallet through the plugin and calling export

# Conflux Configuration
CONFLUX_CORE_PRIVATE_KEY=
CONFLUX_CORE_SPACE_RPC_URL=
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=

2 changes: 2 additions & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"@ai16z/client-twitter": "workspace:*",
"@ai16z/eliza": "workspace:*",
"@ai16z/plugin-bootstrap": "workspace:*",
"@ai16z/plugin-conflux": "workspace:*",
"@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
21 changes: 14 additions & 7 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import {
validateCharacterConfig,
} from "@ai16z/eliza";
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 @@ -233,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 @@ -252,16 +258,17 @@ export function createAgent(
character,
plugins: [
bootstrapPlugin,
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 a4bf4c7

Please sign in to comment.