diff --git a/packages/axelar-local-dev-cosmos/src/__tests__/CosmosClient.spec.ts b/packages/axelar-local-dev-cosmos/src/__tests__/CosmosClient.spec.ts index ea175e2e..63e5c600 100644 --- a/packages/axelar-local-dev-cosmos/src/__tests__/CosmosClient.spec.ts +++ b/packages/axelar-local-dev-cosmos/src/__tests__/CosmosClient.spec.ts @@ -11,16 +11,57 @@ describe("CosmosClient", () => { }); it("should query the balance", async () => { - const balance = await cosmosClient.getOwnerBalance(); + const balance = await cosmosClient.getOwnerAccount(); expect(parseInt(balance || "0")).toBeGreaterThan(0); }); - it.only("should be able to upload wasm contract", async () => { + it("should be able to upload wasm contract", async () => { const _path = path.resolve(__dirname, "../..", "wasm/multi_send.wasm"); - console.log("contract path:", _path); const response = await cosmosClient.uploadWasm(_path); - console.log(response); expect(response).toBeDefined(); }); + + it.only("should be able to execute the wasm contract", async () => { + const _path = path.resolve(__dirname, "../..", "wasm/multi_send.wasm"); + const response = await cosmosClient.uploadWasm(_path); + + const { client } = cosmosClient; + const ownerAddress = await cosmosClient.getOwnerAccount(); + + const { contractAddress } = await client.instantiate( + ownerAddress, + response.codeId, + { + channel: "channel-0", + }, + "amazing random contract", + "auto" + ); + + const denom = cosmosClient.chainInfo.denom; + + console.log( + "Current Balance:", + await cosmosClient.getBalance(ownerAddress), + denom + ); + + const response2 = await client.execute( + ownerAddress, + contractAddress, + { + multi_send_to_evm: { + destination_chain: "ethereum", + destination_address: "0x49324C7f83568861AB1b66E547BB1B66431f1070", + recipients: ["0x49324C7f83568861AB1b66E547BB1B66431f1070"], + }, + }, + "auto", + "test", + [{ amount: "1000000", denom }] + ); + + console.log("Response", response2); + }); }); diff --git a/packages/axelar-local-dev-cosmos/src/__tests__/docker.spec.ts b/packages/axelar-local-dev-cosmos/src/__tests__/docker.spec.ts index f2aa0320..e7986395 100644 --- a/packages/axelar-local-dev-cosmos/src/__tests__/docker.spec.ts +++ b/packages/axelar-local-dev-cosmos/src/__tests__/docker.spec.ts @@ -4,14 +4,23 @@ import fetch from "node-fetch"; setLogger(() => undefined); -describe.skip("docker", () => { +describe("docker", () => { it("should start Cosmos container successfully", async () => { - const { owner, rpcUrl, lcdUrl } = await start(); + const customDenom = "testdenom"; + const { owner, rpcUrl, lcdUrl, denom } = await start({ + chain: { + denom: customDenom, + name: "testchain", + port: 1317, + rpcPort: 26657, + }, + }); expect(owner.mnemonic).toBeDefined(); expect(owner.address).toBeDefined(); expect(rpcUrl).toBeDefined(); expect(lcdUrl).toBeDefined(); + expect(denom).toBe(customDenom); }); it("should stop Cosmos container gracefully", async () => { diff --git a/packages/axelar-local-dev-cosmos/src/lib/docker.ts b/packages/axelar-local-dev-cosmos/src/lib/docker.ts index d614048b..125ad744 100644 --- a/packages/axelar-local-dev-cosmos/src/lib/docker.ts +++ b/packages/axelar-local-dev-cosmos/src/lib/docker.ts @@ -8,6 +8,7 @@ import fs from "fs"; // A default app name export const cosmosAppName = "demo-chain"; +export const defaultDenom = "udemo"; // A default port export const defaultLcdPort = 1317; @@ -30,6 +31,7 @@ const defaultStartOptions = { name: cosmosAppName, port: defaultLcdPort, rpcPort: defaultRpcPort, + denom: defaultDenom, }, }; @@ -42,7 +44,7 @@ export async function start(options?: StartOptions): Promise { // Write given env vars to .env file const envPath = path.join(dockerPath, ".env"); - const env = `CHAIN_NAME=${chain.name}\nCHAIN_PORT=${chain.port}\nCHAIN_RPC_PORT=${chain.rpcPort}`; + const env = `CHAIN_ID=${chain.name}\nCHAIN_PORT=${chain.port}\nCHAIN_RPC_PORT=${chain.rpcPort}\nDENOM=${chain.denom}\nMONIKER=${chain.name}`; fs.writeFileSync(envPath, env); // Check if docker is running @@ -86,7 +88,7 @@ export async function start(options?: StartOptions): Promise { mnemonic, address, }, - denom: "stake", + denom: chain.denom, lcdUrl: `http://localhost:${chain.port}`, rpcUrl: `http://localhost:${chain.rpcPort}`, }; diff --git a/packages/axelar-local-dev-cosmos/src/types.ts b/packages/axelar-local-dev-cosmos/src/types.ts index df8468bf..0dce7e7b 100644 --- a/packages/axelar-local-dev-cosmos/src/types.ts +++ b/packages/axelar-local-dev-cosmos/src/types.ts @@ -20,4 +20,5 @@ export interface CosmosChainOptions { name: string; port: number; rpcPort: number; + denom: string; }