Skip to content

Commit

Permalink
chore: add denom to default config
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Oct 23, 2023
1 parent 7f74790 commit 8a6c43d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
13 changes: 11 additions & 2 deletions packages/axelar-local-dev-cosmos/src/__tests__/docker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/axelar-local-dev-cosmos/src/lib/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,6 +31,7 @@ const defaultStartOptions = {
name: cosmosAppName,
port: defaultLcdPort,
rpcPort: defaultRpcPort,
denom: defaultDenom,
},
};

Expand All @@ -42,7 +44,7 @@ export async function start(options?: StartOptions): Promise<CosmosChainInfo> {

// 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
Expand Down Expand Up @@ -86,7 +88,7 @@ export async function start(options?: StartOptions): Promise<CosmosChainInfo> {
mnemonic,
address,
},
denom: "stake",
denom: chain.denom,
lcdUrl: `http://localhost:${chain.port}`,
rpcUrl: `http://localhost:${chain.rpcPort}`,
};
Expand Down
1 change: 1 addition & 0 deletions packages/axelar-local-dev-cosmos/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface CosmosChainOptions {
name: string;
port: number;
rpcPort: number;
denom: string;
}

0 comments on commit 8a6c43d

Please sign in to comment.