diff --git a/.env.example b/.env.example index b2aebf1b647..b1f05998b7d 100644 --- a/.env.example +++ b/.env.example @@ -58,7 +58,6 @@ TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email TWITTER_2FA_SECRET= -TWITTER_COOKIES= # Account cookies TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions TWITTER_SEARCH_ENABLE=FALSE # Enable timeline search, WARNING this greatly increases your chance of getting banned TWITTER_TARGET_USERS= # Comma separated list of Twitter user names to interact with diff --git a/README_CN.md b/README_CN.md index 6c9618447cc..146ce690cff 100644 --- a/README_CN.md +++ b/README_CN.md @@ -145,7 +145,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/README_ES.md b/README_ES.md index e009f73ffbd..17156e094c7 100644 --- a/README_ES.md +++ b/README_ES.md @@ -98,7 +98,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Nombre de usuario de la cuenta TWITTER_PASSWORD= # Contraseña de la cuenta TWITTER_EMAIL= # Correo electrónico de la cuenta -TWITTER_COOKIES= # Cookies de la cuenta X_SERVER_URL= XAI_API_KEY= diff --git a/README_JA.md b/README_JA.md index f17f9ba604c..dea9a32e272 100644 --- a/README_JA.md +++ b/README_JA.md @@ -96,7 +96,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # アカウントのユーザー名 TWITTER_PASSWORD= # アカウントのパスワード TWITTER_EMAIL= # アカウントのメール -TWITTER_COOKIES= # アカウントのクッキー X_SERVER_URL= XAI_API_KEY= diff --git a/README_PTBR.md b/README_PTBR.md index 8bdac6d84e0..e81258ff3a4 100644 --- a/README_PTBR.md +++ b/README_PTBR.md @@ -98,7 +98,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Nome de usuário da conta TWITTER_PASSWORD= # Senha da conta TWITTER_EMAIL= # Email da conta -TWITTER_COOKIES= # Cookies da conta X_SERVER_URL= XAI_API_KEY= diff --git a/README_RU.md b/README_RU.md index 0715359602c..a1f1b93b876 100644 --- a/README_RU.md +++ b/README_RU.md @@ -114,7 +114,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Имя пользователя аккаунта TWITTER_PASSWORD= # Пароль аккаунта TWITTER_EMAIL= # Email аккаунта -TWITTER_COOKIES= # Cookies аккаунта X_SERVER_URL= XAI_API_KEY= diff --git a/agent/src/index.ts b/agent/src/index.ts index 90acf72f9d5..3a8c1b502a2 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -214,9 +214,11 @@ export function getTokenForProvider( character: Character ): string { switch (provider) { - // no key needed for llama_local + // no key needed for llama_local or gaianet case ModelProviderName.LLAMALOCAL: return ""; + case ModelProviderName.GAIANET: + return ""; case ModelProviderName.OPENAI: return ( character.settings?.secrets?.OPENAI_API_KEY || @@ -311,6 +313,11 @@ export function getTokenForProvider( character.settings?.secrets?.AKASH_CHAT_API_KEY || settings.AKASH_CHAT_API_KEY ); + case ModelProviderName.GOOGLE: + return ( + character.settings?.secrets?.GOOGLE_GENERATIVE_AI_API_KEY || + settings.GOOGLE_GENERATIVE_AI_API_KEY + ); default: const errorMessage = `Failed to get token - unsupported model provider: ${provider}`; elizaLogger.error(errorMessage); @@ -645,7 +652,7 @@ async function startAgent( await db.init(); const cache = initializeCache( - process.env.CACHE_STORE, + process.env.CACHE_STORE ?? CacheStore.DATABASE, character, "", db diff --git a/docs/README.md b/docs/README.md index 0f186290034..27dc784eaf6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -102,7 +102,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/README_CN.md b/docs/README_CN.md index 64ed07eaf3a..61e5efe0a77 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -94,7 +94,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/README_FR.md b/docs/README_FR.md index a337222ff2a..db7f8bfacd3 100644 --- a/docs/README_FR.md +++ b/docs/README_FR.md @@ -102,7 +102,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/README_TH.md b/docs/README_TH.md index d50c69af0c0..d89c854cf0a 100644 --- a/docs/README_TH.md +++ b/docs/README_TH.md @@ -98,7 +98,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # ชื่อผู้ใช้บัญชี TWITTER_PASSWORD= # รหัสผ่าน TWITTER_EMAIL= # อีเมล -TWITTER_COOKIES= # คุกกี้ X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/api/_media/README_CN.md b/docs/docs/api/_media/README_CN.md index 9b1f922a6f2..3d101ddbffa 100644 --- a/docs/docs/api/_media/README_CN.md +++ b/docs/docs/api/_media/README_CN.md @@ -94,7 +94,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/api/_media/README_FR.md b/docs/docs/api/_media/README_FR.md index 456641cce41..41b92f055f2 100644 --- a/docs/docs/api/_media/README_FR.md +++ b/docs/docs/api/_media/README_FR.md @@ -94,7 +94,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/api/_media/README_JA.md b/docs/docs/api/_media/README_JA.md index 447be875a55..3bd9302ccbd 100644 --- a/docs/docs/api/_media/README_JA.md +++ b/docs/docs/api/_media/README_JA.md @@ -96,7 +96,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # アカウントのユーザー名 TWITTER_PASSWORD= # アカウントのパスワード TWITTER_EMAIL= # アカウントのメール -TWITTER_COOKIES= # アカウントのクッキー X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/api/_media/README_KOR.md b/docs/docs/api/_media/README_KOR.md index 1d541f87f9e..555d037d9f7 100644 --- a/docs/docs/api/_media/README_KOR.md +++ b/docs/docs/api/_media/README_KOR.md @@ -94,7 +94,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/api/index.md b/docs/docs/api/index.md index 0408a5cd353..4f3c232dcda 100644 --- a/docs/docs/api/index.md +++ b/docs/docs/api/index.md @@ -100,7 +100,6 @@ TWITTER_DRY_RUN=false TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies X_SERVER_URL= XAI_API_KEY= diff --git a/docs/docs/guides/configuration.md b/docs/docs/guides/configuration.md index bc51efda0bf..e5de0a0b96c 100644 --- a/docs/docs/guides/configuration.md +++ b/docs/docs/guides/configuration.md @@ -46,7 +46,6 @@ DISCORD_API_TOKEN= # Discord bot token TWITTER_USERNAME= # Bot Twitter username TWITTER_PASSWORD= # Bot Twitter password TWITTER_EMAIL= # Twitter account email -TWITTER_COOKIES= # Twitter auth cookies TWITTER_DRY_RUN=false # Test mode without posting ``` diff --git a/docs/docs/packages/clients.md b/docs/docs/packages/clients.md index d586112a9b0..b96d2b46b06 100644 --- a/docs/docs/packages/clients.md +++ b/docs/docs/packages/clients.md @@ -141,7 +141,6 @@ const client = await TwitterClientInterface.start(runtime); TWITTER_USERNAME = your_username; TWITTER_PASSWORD = your_password; TWITTER_EMAIL = your_email; -TWITTER_COOKIES = your_cookies; ``` ### Components diff --git a/docs/docs/quickstart.md b/docs/docs/quickstart.md index ba4143abf4e..7a12d76f55f 100644 --- a/docs/docs/quickstart.md +++ b/docs/docs/quickstart.md @@ -168,21 +168,10 @@ Add to your `.env`: TWITTER_USERNAME= # Account username TWITTER_PASSWORD= # Account password TWITTER_EMAIL= # Account email -TWITTER_COOKIES= # Account cookies (auth_token and CT0) ``` **Important:** Log in to the [Twitter Developer Portal](https://developer.twitter.com) and enable the "Automated" label for your account to avoid being flagged as inauthentic. -Example for TWITTER_COOKIES - -The TWITTER_COOKIES variable should be a JSON string containing the necessary cookies. You can find these cookies in your web browser's developer tools. Here is an example format: - -```bash -TWITTER_COOKIES='[{"key":"auth_token","value":"your token","domain":".twitter.com"}, - {"key":"ct0","value":"your ct0","domain":".twitter.com"}, - {"key":"guest_id","value":"your guest_id","domain":".twitter.com"}]' -``` - ### Telegram Bot 1. Create a bot diff --git a/packages/client-twitter/src/base.ts b/packages/client-twitter/src/base.ts index 861821170df..feedf94c4f1 100644 --- a/packages/client-twitter/src/base.ts +++ b/packages/client-twitter/src/base.ts @@ -153,7 +153,6 @@ export class ClientBase extends EventEmitter { } async init() { - //test const username = this.runtime.getSetting("TWITTER_USERNAME"); const password = this.runtime.getSetting("TWITTER_PASSWORD"); const email = this.runtime.getSetting("TWITTER_EMAIL"); @@ -163,36 +162,20 @@ export class ClientBase extends EventEmitter { ); const twitter2faSecret = this.runtime.getSetting("TWITTER_2FA_SECRET") || undefined; - const cookies = this.runtime.getSetting("TWITTER_COOKIES"); if (!username) { throw new Error("Twitter username not configured"); } - // Check for Twitter cookies - if (cookies) { - elizaLogger.debug("Using cookies from settings"); - const cookiesArray = JSON.parse(cookies); - await this.setCookiesFromArray(cookiesArray); - } else { - elizaLogger.debug("No cookies found in settings"); - elizaLogger.debug("Checking for cached cookies"); - const cachedCookies = await this.getCachedCookies(username); - if (cachedCookies) { - await this.setCookiesFromArray(cachedCookies); - } + const cachedCookies = await this.getCachedCookies(username); + + if (cachedCookies) { + elizaLogger.info("Using cached cookies"); + await this.setCookiesFromArray(cachedCookies); } elizaLogger.log("Waiting for Twitter login"); while (retries > 0) { - const cookies = await this.twitterClient.getCookies(); - if ((await this.twitterClient.isLoggedIn()) && !!cookies) { - elizaLogger.info("Already logged in."); - await this.cacheCookies(username, cookies); - elizaLogger.info("Successfully logged in and cookies cached."); - break; - } - try { await this.twitterClient.login( username, @@ -200,6 +183,17 @@ export class ClientBase extends EventEmitter { email, twitter2faSecret ); + if (await this.twitterClient.isLoggedIn()) { + elizaLogger.info("Successfully logged in."); + if (!cachedCookies) { + elizaLogger.info("Caching cookies"); + await this.cacheCookies( + username, + await this.twitterClient.getCookies() + ); + } + break; + } } catch (error) { elizaLogger.error(`Login attempt failed: ${error.message}`); } diff --git a/packages/client-twitter/src/environment.ts b/packages/client-twitter/src/environment.ts index 3340fc96740..8adabce3b80 100644 --- a/packages/client-twitter/src/environment.ts +++ b/packages/client-twitter/src/environment.ts @@ -10,7 +10,6 @@ export const twitterEnvSchema = z.object({ TWITTER_USERNAME: z.string().min(1, "Twitter username is required"), TWITTER_PASSWORD: z.string().min(1, "Twitter password is required"), TWITTER_EMAIL: z.string().email("Valid Twitter email is required"), - TWITTER_COOKIES: z.string().optional(), MAX_TWEET_LENGTH: z .string() .pipe(z.coerce.number().min(0).int()) @@ -37,9 +36,6 @@ export async function validateTwitterConfig( TWITTER_EMAIL: runtime.getSetting("TWITTER_EMAIL") || process.env.TWITTER_EMAIL, - TWITTER_COOKIES: - runtime.getSetting("TWITTER_COOKIES") || - process.env.TWITTER_COOKIES, MAX_TWEET_LENGTH: runtime.getSetting("MAX_TWEET_LENGTH") || process.env.MAX_TWEET_LENGTH || diff --git a/packages/plugin-evm/eslint.config.mjs b/packages/plugin-evm/eslint.config.mjs new file mode 100644 index 00000000000..92fe5bbebef --- /dev/null +++ b/packages/plugin-evm/eslint.config.mjs @@ -0,0 +1,3 @@ +import eslintGlobalConfig from "../../eslint.config.mjs"; + +export default [...eslintGlobalConfig]; diff --git a/packages/plugin-evm/package.json b/packages/plugin-evm/package.json index d784ddacf82..262a394193c 100644 --- a/packages/plugin-evm/package.json +++ b/packages/plugin-evm/package.json @@ -15,7 +15,8 @@ "scripts": { "build": "tsup --format esm --dts", "dev": "tsup --format esm --dts --watch", - "test": "vitest run" + "test": "vitest run", + "lint": "eslint --fix --cache ." }, "peerDependencies": { "whatwg-url": "7.1.0" diff --git a/packages/plugin-evm/src/actions/swap.ts b/packages/plugin-evm/src/actions/swap.ts index 1c66f43f14b..6501dbf8789 100644 --- a/packages/plugin-evm/src/actions/swap.ts +++ b/packages/plugin-evm/src/actions/swap.ts @@ -1,6 +1,5 @@ import type { IAgentRuntime, Memory, State } from "@ai16z/eliza"; import { - ChainId, createConfig, executeRoute, ExtendedChain, diff --git a/packages/plugin-evm/src/actions/transfer.ts b/packages/plugin-evm/src/actions/transfer.ts index 61b2bacbbe4..3060012e7f5 100644 --- a/packages/plugin-evm/src/actions/transfer.ts +++ b/packages/plugin-evm/src/actions/transfer.ts @@ -28,7 +28,7 @@ export class TransferAction { params.data = "0x"; } - await this.walletProvider.switchChain(params.fromChain); + this.walletProvider.switchChain(params.fromChain); const walletClient = this.walletProvider.getWalletClient( params.fromChain @@ -41,12 +41,12 @@ export class TransferAction { value: parseEther(params.amount), data: params.data as Hex, kzg: { - blobToKzgCommitment: function (blob: ByteArray): ByteArray { + blobToKzgCommitment: function (_: ByteArray): ByteArray { throw new Error("Function not implemented."); }, computeBlobKzgProof: function ( - blob: ByteArray, - commitment: ByteArray + _blob: ByteArray, + _commitment: ByteArray ): ByteArray { throw new Error("Function not implemented."); }, @@ -81,7 +81,7 @@ const buildTransferDetails = async ( const contextWithChains = context.replace( "SUPPORTED_CHAINS", - chains.toString() + chains.map((item) => `"${item}"`).join("|") ); const transferDetails = (await generateObjectDeprecated({ @@ -109,9 +109,9 @@ export const transferAction = { description: "Transfer tokens between addresses on the same chain", handler: async ( runtime: IAgentRuntime, - message: Memory, + _message: Memory, state: State, - options: any, + _options: any, callback?: HandlerCallback ) => { console.log("Transfer action handler called"); @@ -119,24 +119,11 @@ export const transferAction = { const action = new TransferAction(walletProvider); // Compose transfer context - const transferContext = composeContext({ + const paramOptions = await buildTransferDetails( state, - template: transferTemplate, - }); - - // Generate transfer content - const content = await generateObjectDeprecated({ runtime, - context: transferContext, - modelClass: ModelClass.LARGE, - }); - - const paramOptions: TransferParams = { - fromChain: content.fromChain, - toAddress: content.toAddress, - amount: content.amount, - data: content.data, - }; + walletProvider + ); try { const transferResp = await action.transfer(paramOptions); @@ -148,7 +135,7 @@ export const transferAction = { hash: transferResp.hash, amount: formatEther(transferResp.value), recipient: transferResp.to, - chain: content.fromChain, + chain: paramOptions.fromChain, }, }); } diff --git a/packages/plugin-evm/src/providers/wallet.ts b/packages/plugin-evm/src/providers/wallet.ts index 2b816c461bb..a72e2e9abfb 100644 --- a/packages/plugin-evm/src/providers/wallet.ts +++ b/packages/plugin-evm/src/providers/wallet.ts @@ -211,8 +211,8 @@ export const initWalletProvider = (runtime: IAgentRuntime) => { export const evmWalletProvider: Provider = { async get( runtime: IAgentRuntime, - message: Memory, - state?: State + _message: Memory, + _state?: State ): Promise { try { const walletProvider = initWalletProvider(runtime); diff --git a/packages/plugin-evm/src/tests/transfer.test.ts b/packages/plugin-evm/src/tests/transfer.test.ts index d637a6a3d9d..a6159db76d4 100644 --- a/packages/plugin-evm/src/tests/transfer.test.ts +++ b/packages/plugin-evm/src/tests/transfer.test.ts @@ -17,7 +17,7 @@ describe("Transfer Action", () => { it("should initialize with wallet provider", () => { const ta = new TransferAction(wp); - expect(ta).to.toBeDefined(); + expect(ta).toBeDefined(); }); }); describe("Transfer", () => { @@ -44,7 +44,7 @@ describe("Transfer Action", () => { }); const prepareChains = () => { - let customChains: Record = {}; + const customChains: Record = {}; const chainNames = ["iotexTestnet"]; chainNames.forEach( (chain) => diff --git a/packages/plugin-evm/src/tests/wallet.test.ts b/packages/plugin-evm/src/tests/wallet.test.ts index a8e5a3ee872..a6b227a4703 100644 --- a/packages/plugin-evm/src/tests/wallet.test.ts +++ b/packages/plugin-evm/src/tests/wallet.test.ts @@ -13,7 +13,7 @@ const customRpcUrls = { describe("Wallet provider", () => { let walletProvider: WalletProvider; let pk: `0x${string}`; - let customChains: Record = {}; + const customChains: Record = {}; beforeAll(() => { pk = generatePrivateKey(); @@ -32,24 +32,24 @@ describe("Wallet provider", () => { walletProvider = new WalletProvider(pk); - expect(walletProvider.getAddress()).to.be.eq(expectedAddress); + expect(walletProvider.getAddress()).toEqual(expectedAddress); }); it("sets default chain to ethereum mainnet", () => { walletProvider = new WalletProvider(pk); - expect(walletProvider.chains.mainnet.id).to.be.eq(mainnet.id); - expect(walletProvider.getCurrentChain().id).to.be.eq(mainnet.id); + expect(walletProvider.chains.mainnet.id).toEqual(mainnet.id); + expect(walletProvider.getCurrentChain().id).toEqual(mainnet.id); }); it("sets custom chains", () => { walletProvider = new WalletProvider(pk, customChains); - expect(walletProvider.chains.iotex.id).to.be.eq(iotex.id); - expect(walletProvider.chains.arbitrum.id).to.be.eq(arbitrum.id); + expect(walletProvider.chains.iotex.id).toEqual(iotex.id); + expect(walletProvider.chains.arbitrum.id).toEqual(arbitrum.id); }); it("sets the first provided custom chain as current chain", () => { walletProvider = new WalletProvider(pk, customChains); - expect(walletProvider.getCurrentChain().id).to.be.eq(iotex.id); + expect(walletProvider.getCurrentChain().id).toEqual(iotex.id); }); }); describe("Clients", () => { @@ -58,7 +58,7 @@ describe("Wallet provider", () => { }); it("generates public client", () => { const client = walletProvider.getPublicClient("mainnet"); - expect(client.chain.id).to.be.equal(mainnet.id); + expect(client.chain.id).toEqual(mainnet.id); expect(client.transport.url).toEqual( mainnet.rpcUrls.default.http[0] ); @@ -71,11 +71,11 @@ describe("Wallet provider", () => { const wp = new WalletProvider(pk, { ["mainnet"]: chain }); const client = wp.getPublicClient("mainnet"); - expect(client.chain.id).to.be.equal(mainnet.id); - expect(client.chain.rpcUrls.default.http[0]).to.eq( + expect(client.chain.id).toEqual(mainnet.id); + expect(client.chain.rpcUrls.default.http[0]).toEqual( mainnet.rpcUrls.default.http[0] ); - expect(client.chain.rpcUrls.custom.http[0]).to.eq( + expect(client.chain.rpcUrls.custom.http[0]).toEqual( customRpcUrls.mainnet ); expect(client.transport.url).toEqual(customRpcUrls.mainnet); @@ -86,7 +86,7 @@ describe("Wallet provider", () => { const client = walletProvider.getWalletClient("mainnet"); - expect(client.account.address).to.be.equal(expectedAddress); + expect(client.account.address).toEqual(expectedAddress); expect(client.transport.url).toEqual( mainnet.rpcUrls.default.http[0] ); @@ -102,12 +102,12 @@ describe("Wallet provider", () => { const client = wp.getWalletClient("mainnet"); - expect(client.account.address).to.be.equal(expectedAddress); - expect(client.chain.id).to.be.equal(mainnet.id); - expect(client.chain.rpcUrls.default.http[0]).to.eq( + expect(client.account.address).toEqual(expectedAddress); + expect(client.chain.id).toEqual(mainnet.id); + expect(client.chain.rpcUrls.default.http[0]).toEqual( mainnet.rpcUrls.default.http[0] ); - expect(client.chain.rpcUrls.custom.http[0]).to.eq( + expect(client.chain.rpcUrls.custom.http[0]).toEqual( customRpcUrls.mainnet ); expect(client.transport.url).toEqual(customRpcUrls.mainnet); @@ -120,16 +120,16 @@ describe("Wallet provider", () => { it("should fetch balance", async () => { const bal = await walletProvider.getWalletBalance(); - expect(bal).to.be.eq("0"); + expect(bal).toEqual("0"); }); it("should fetch balance for a specific added chain", async () => { const bal = await walletProvider.getWalletBalanceForChain("iotex"); - expect(bal).to.be.eq("0"); + expect(bal).toEqual("0"); }); it("should return null if chain is not added", async () => { const bal = await walletProvider.getWalletBalanceForChain("base"); - expect(bal).to.be.null; + expect(bal).toBeNull(); }); }); describe("Chain", () => { @@ -140,7 +140,7 @@ describe("Wallet provider", () => { const chainName = "iotex"; const chain: Chain = WalletProvider.genChainFromName(chainName); - expect(chain.rpcUrls.default.http[0]).to.eq( + expect(chain.rpcUrls.default.http[0]).toEqual( iotex.rpcUrls.default.http[0] ); }); @@ -152,59 +152,63 @@ describe("Wallet provider", () => { customRpcUrl ); - expect(chain.rpcUrls.default.http[0]).to.eq( + expect(chain.rpcUrls.default.http[0]).toEqual( iotex.rpcUrls.default.http[0] ); - expect(chain.rpcUrls.custom.http[0]).to.eq(customRpcUrl); + expect(chain.rpcUrls.custom.http[0]).toEqual(customRpcUrl); }); it("switches chain", () => { const initialChain = walletProvider.getCurrentChain().id; - expect(initialChain).to.be.eq(iotex.id); + expect(initialChain).toEqual(iotex.id); walletProvider.switchChain("mainnet"); const newChain = walletProvider.getCurrentChain().id; - expect(newChain).to.be.eq(mainnet.id); + expect(newChain).toEqual(mainnet.id); }); it("switches chain (by adding new chain)", () => { const initialChain = walletProvider.getCurrentChain().id; - expect(initialChain).to.be.eq(iotex.id); + expect(initialChain).toEqual(iotex.id); walletProvider.switchChain("arbitrum"); const newChain = walletProvider.getCurrentChain().id; - expect(newChain).to.be.eq(arbitrum.id); + expect(newChain).toEqual(arbitrum.id); }); it("adds chain", () => { const initialChains = walletProvider.chains; - expect(initialChains.base).to.be.undefined; + expect(initialChains.base).toBeUndefined(); const base = WalletProvider.genChainFromName("base"); walletProvider.addChain({ base }); const newChains = walletProvider.chains; - expect(newChains.arbitrum.id).to.be.eq(arbitrum.id); + expect(newChains.arbitrum.id).toEqual(arbitrum.id); }); it("gets chain configs", () => { const chain = walletProvider.getChainConfigs("iotex"); - expect(chain.id).to.eq(iotex.id); + expect(chain.id).toEqual(iotex.id); }); it("throws if tries to switch to an invalid chain", () => { const initialChain = walletProvider.getCurrentChain().id; - expect(initialChain).to.be.eq(iotex.id); + expect(initialChain).toEqual(iotex.id); + // intentionally set incorrect chain, ts will complain + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - expect(() => walletProvider.switchChain("eth")).to.throw(); + expect(() => walletProvider.switchChain("eth")).toThrow(); }); it("throws if unsupported chain name", () => { + // intentionally set incorrect chain, ts will complain + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - expect(() => - WalletProvider.genChainFromName("ethereum") - ).to.throw(); + expect(() => WalletProvider.genChainFromName("ethereum")).toThrow(); }); it("throws if invalid chain name", () => { + // intentionally set incorrect chain, ts will complain + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - expect(() => WalletProvider.genChainFromName("eth")).to.throw(); + expect(() => WalletProvider.genChainFromName("eth")).toThrow(); }); }); }); diff --git a/packages/plugin-evm/src/types/index.ts b/packages/plugin-evm/src/types/index.ts index 8fa8247dcdb..c2e7c29acd4 100644 --- a/packages/plugin-evm/src/types/index.ts +++ b/packages/plugin-evm/src/types/index.ts @@ -10,8 +10,8 @@ import type { } from "viem"; import * as viemChains from "viem/chains"; -const SupportedChainList = Object.keys(viemChains) as Array; -export type SupportedChain = (typeof SupportedChainList)[number]; +const _SupportedChainList = Object.keys(viemChains) as Array; +export type SupportedChain = (typeof _SupportedChainList)[number]; // Transaction types export interface Transaction { diff --git a/turbo.json b/turbo.json index f3fc60e2bac..ade86524007 100644 --- a/turbo.json +++ b/turbo.json @@ -19,6 +19,7 @@ "dependsOn": ["@ai16z/plugin-trustdb#build"] }, "@ai16z/plugin-nft-generation#build": { + "outputs": ["dist/**"], "dependsOn": ["@ai16z/plugin-node#build"] }, "eliza-docs#build": {