Skip to content

Commit

Permalink
feat: support for axelar-cgp-sui, deployment and relaying (#91)
Browse files Browse the repository at this point in the history
* added a dummy its to showcase how it works.

* made some headway but still lots to do.

* Added relayer functionality

* prettier and update packages

* update package.lock

* Fixed relaying and tests, but there are errors when running in parralel

* update sui binary

* update sui binary

* update sui binary
  • Loading branch information
Foivos authored Oct 31, 2023
1 parent df7d366 commit 9290139
Show file tree
Hide file tree
Showing 21 changed files with 535 additions and 194 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

- name: Download and Install Sui Binary
run: |
wget https://github.com/MystenLabs/sui/releases/download/devnet-v1.7.0/sui-devnet-v1.7.0-ubuntu-x86_64.tgz
tar -xvf sui-devnet-v1.7.0-ubuntu-x86_64.tgz
wget https://github.com/MystenLabs/sui/releases/download/mainnet-v1.11.2/sui-mainnet-v1.11.2-ubuntu-x86_64.tgz
tar -xvf sui-mainnet-v1.11.2-ubuntu-x86_64.tgz
sudo mv ./target/release/sui-test-validator-ubuntu-x86_64 /usr/local/bin/sui-test-validator
sudo mv ./target/release/sui-ubuntu-x86_64 /usr/local/bin/sui
Expand Down
156 changes: 139 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions packages/axelar-local-dev-sui/__tests__/deploy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SuiNetwork } from '../src/SuiNetwork';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import { toHEX } from '@mysten/bcs';
import path from 'path';

describe('Sui Network', () => {
Expand All @@ -13,36 +12,38 @@ describe('Sui Network', () => {

it('should deploy a sample module', async () => {
const response = await client.deploy(path.join(__dirname, '../move/sample'));
expect(response.packages.length).toBe(client.gatewayObjects.length);
expect(response.packages[0].packageId).toBe(client.gatewayObjects[0].packageId);

expect(response.packages.length).toBe(1);
});

it('should deploy and execute a function', async () => {
const response = await client.deploy(path.join(__dirname, '../move/sample'));

const packageId = response.packages[0].packageId;
const singleton: any = response.publishTxn.objectChanges?.find((change) => (change as any).objectType === `${packageId}::test::Singleton` )

const tx = new TransactionBlock();
const msg = 'hello from test';
const msgBytes = new Uint8Array(Buffer.from(msg, 'utf8'));

tx.moveCall({
target: `${response.packages[0].packageId}::hello_world::execute`,
arguments: [tx.pure('0x0'), tx.pure('Avalanche'), tx.pure('0x0'), tx.pure(toHEX(msgBytes))],
target: `${response.packages[0].packageId}::test::send_call`,
arguments: [tx.object(singleton.objectId), tx.pure('Avalanche'), tx.pure('0x0'), tx.pure(msg)],
});
await client.execute(tx);

const { data } = await client.queryEvents({
query: {
MoveModule: {
module: `hello_world`,
package: response.packages[0].packageId,
module: `test`,
package: packageId,
},
},
limit: 1,
});

const updatedMessage = (data[0].parsedJson as any).updated_message;
const event = (data[0].parsedJson as any);

// query the value
expect(updatedMessage).toEqual(msg);
expect(event.destination_chain).toEqual('Avalanche');
expect(event.destination_address).toEqual('0x0');
expect(String.fromCharCode(...event.payload)).toEqual(msg);
});
});
Loading

0 comments on commit 9290139

Please sign in to comment.