-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
889 additions
and
166 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/axelar-local-dev-cosmos/docker/ibcrelayer/docker-compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.8" | ||
services: | ||
ibc-relayer: | ||
container_name: ibc-relayer | ||
image: node:18-alpine | ||
working_dir: /app | ||
volumes: | ||
- ./ibc-setup:/app/.ibc-setup | ||
# command: | ||
# - npm i -g @confio/[email protected] | ||
entrypoint: | ||
- sh | ||
- -c | ||
- | | ||
npm i -g @confio/[email protected] && | ||
ibc-setup init && | ||
ibc-setup ics20 -v && | ||
/bin/sh | ||
# depends_on: [axelar, wasm] |
21 changes: 21 additions & 0 deletions
21
packages/axelar-local-dev-cosmos/docker/ibcrelayer/ibc-setup/registry.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: 1 | ||
|
||
chains: | ||
wasm: | ||
chain_id: wasm | ||
prefix: wasm | ||
gas_price: 0.025uwasm | ||
hd_path: m/44'/1234'/0'/2' | ||
estimated_block_time: 400 | ||
estimated_indexer_time: 60 | ||
rpc: | ||
- http://localhost/wasm-rpc | ||
axelar: | ||
chain_id: axelar | ||
prefix: axelar | ||
gas_price: 0.025uaxl | ||
hd_path: m/44'/1234'/0'/2' | ||
estimated_block_time: 400 | ||
estimated_indexer_time: 60 | ||
rpc: | ||
- http://localhost/axelar-rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/axelar-local-dev-cosmos/docker/wasm/docker-compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
packages/axelar-local-dev-cosmos/jest/jest.global-setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { stopAll, startAll } from "../src/docker"; | ||
import { stopAll, startAll, waitForRpc } from "../src/docker"; | ||
|
||
export default async () => { | ||
// await startAll(); | ||
try { | ||
await waitForRpc("axelar", 5000); | ||
await waitForRpc("wasm", 5000); | ||
} catch (e) { | ||
console.error( | ||
"\nPlease make sure you have started the docker containers by running `npm start` before running tests" | ||
); | ||
throw e; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
"!dist/artifacts" | ||
], | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --testMatch='**/*.spec.ts' --runInBand", | ||
"test:e2e": "jest --testMatch='**/*.e2e.ts' --runInBand", | ||
"clean": "rm -rf src/types dist artifacts", | ||
"prettier": "prettier --write 'src/**/*.ts'", | ||
"build": "npm run clean && npm run build-ts", | ||
|
@@ -18,8 +19,11 @@ | |
}, | ||
"dependencies": { | ||
"@axelar-network/axelar-local-dev": "2.1.1", | ||
"@confio/relayer": "^0.10.0", | ||
"@cosmjs/cosmwasm-stargate": "^0.31.1", | ||
"@cosmjs/stargate": "^0.31.1" | ||
"@cosmjs/stargate": "^0.31.1", | ||
"@types/sinon": "^10.0.20", | ||
"sinon": "^17.0.0" | ||
}, | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
|
75 changes: 0 additions & 75 deletions
75
packages/axelar-local-dev-cosmos/src/__tests__/CosmosClient.spec.ts
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
packages/axelar-local-dev-cosmos/src/__tests__/cosmos-client.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import path from "path"; | ||
import { CosmosClient } from ".."; | ||
|
||
describe("CosmosClient", () => { | ||
let wasmClient: CosmosClient; | ||
let axelarClient: CosmosClient; | ||
|
||
beforeAll(async () => { | ||
wasmClient = await CosmosClient.create("wasm"); | ||
axelarClient = await CosmosClient.create("axelar"); | ||
}); | ||
|
||
it("should be able to upload wasm contract", async () => { | ||
const _path = path.resolve(__dirname, "../..", "wasm/multi_send.wasm"); | ||
const response = await wasmClient.uploadWasm(_path); | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("should be able to send tokens to given address on wasm", async () => { | ||
const recipient = "wasm1puut77ku823785u3c7aalwqdrawe3lnjgwt89v"; | ||
const amount = "1000000"; | ||
const initialBalance = await wasmClient.getBalance(recipient); | ||
await wasmClient.fundWallet(recipient, amount); | ||
const balance = await wasmClient.getBalance(recipient); | ||
expect(parseInt(balance)).toBe(parseInt(initialBalance) + parseInt(amount)); | ||
}); | ||
|
||
it("should be able to send tokens to given address on axelar", async () => { | ||
const recipient = "axelar1puut77ku823785u3c7aalwqdrawe3lnjxuv68x"; | ||
const amount = "1000000"; | ||
const initialBalance = await axelarClient.getBalance(recipient); | ||
await axelarClient.fundWallet(recipient, amount); | ||
const balance = await axelarClient.getBalance(recipient); | ||
expect(parseInt(balance)).toBe(parseInt(initialBalance) + parseInt(amount)); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/axelar-local-dev-cosmos/src/__tests__/ibc-relayer-client.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IBCRelayerClient } from "../clients/IBCRelayerClient"; | ||
|
||
describe("IBCRelayerClient", () => { | ||
it.skip("should be able to create a connection and channel", async () => { | ||
const relayerClient = await IBCRelayerClient.create(); | ||
|
||
const response = await relayerClient.initConnection(); | ||
|
||
expect(response.axelar).toBeDefined(); | ||
expect(response.wasm).toBeDefined(); | ||
|
||
const response2 = await relayerClient.createChannel("B"); | ||
|
||
expect(response2).toBeDefined(); | ||
expect(response2!.src).toBeDefined(); | ||
expect(response2!.dest).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import path from "path"; | ||
import { CosmosClient, IBCRelayerClient } from ".."; | ||
import { ChannelInfo } from "@confio/relayer/build/lib/ibcclient"; | ||
|
||
describe("E2E - IBC", () => { | ||
let wasmClient: CosmosClient; | ||
let axelarClient: CosmosClient; | ||
let relayerClient: IBCRelayerClient; | ||
let srcChannelId: string; | ||
let destChannelId: string; | ||
|
||
beforeAll(async () => { | ||
wasmClient = await CosmosClient.create("wasm"); | ||
axelarClient = await CosmosClient.create("axelar"); | ||
|
||
// Initialize the connection and channel | ||
relayerClient = await IBCRelayerClient.create(); | ||
await relayerClient.initConnection(); | ||
const { dest, src } = await relayerClient.createChannel("B"); | ||
srcChannelId = src.channelId; | ||
destChannelId = dest.channelId; | ||
console.log("Created IBC Channel:", src, dest); | ||
}); | ||
|
||
it("ibc transfer", async () => { | ||
const ownerAddress = await wasmClient.getOwnerAccount(); | ||
const recipient = "axelar1puut77ku823785u3c7aalwqdrawe3lnjxuv68x"; | ||
|
||
// Send tokens to the recipient | ||
await wasmClient.ibcTransfer( | ||
ownerAddress, | ||
recipient, | ||
srcChannelId, | ||
"10000" | ||
); | ||
|
||
// Get the ibc denom | ||
const ibcDenom = axelarClient.getIBCDenom(destChannelId, "uwasm"); | ||
|
||
// Relay the packet | ||
await relayerClient.relayPackets(); | ||
|
||
// Check the balance on axelar chain | ||
const ibcAmount = await axelarClient.getBalance(recipient, ibcDenom); | ||
expect(parseInt(ibcAmount)).toBeGreaterThan(0); | ||
}); | ||
|
||
// Usually takes 2-3 minutes to run | ||
it("should be able to execute the wasm contract from wasm to axelar chain", async () => { | ||
// Upload the wasm contract | ||
const _path = path.resolve(__dirname, "../..", "wasm/multi_send.wasm"); | ||
const response = await wasmClient.uploadWasm(_path); | ||
|
||
// Instantiate the contract | ||
const { client } = wasmClient; | ||
const ownerAddress = await wasmClient.getOwnerAccount(); | ||
const { contractAddress } = await client.instantiate( | ||
ownerAddress, | ||
response.codeId, | ||
{ | ||
channel: srcChannelId, | ||
}, | ||
"amazing random contract", | ||
"auto" | ||
); | ||
|
||
const denom = wasmClient.chainInfo.denom; | ||
|
||
const execution = await client.execute( | ||
ownerAddress, | ||
contractAddress, | ||
{ | ||
multi_send_to_evm: { | ||
destination_chain: "ethereum", | ||
destination_address: "0x49324C7f83568861AB1b66E547BB1B66431f1070", | ||
recipients: ["0x49324C7f83568861AB1b66E547BB1B66431f1070"], | ||
}, | ||
}, | ||
"auto", | ||
"test", | ||
[{ amount: "1000000", denom }] | ||
); | ||
|
||
await relayerClient.relayPackets(); | ||
|
||
expect(execution).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.