Skip to content

Commit

Permalink
Merge branch 'main' into feat/sui-ledger-support
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy authored Dec 16, 2024
2 parents 6c85159 + 5cb30ff commit 1d5187c
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 453 deletions.
637 changes: 210 additions & 427 deletions axelar-chains-config/info/stagenet.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion evm/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async function processCommand(config, chain, options) {

const appContract = new Contract(options.destination, IAxelarExecutable.abi, wallet);

const tx = await appContract.execute(commandId, sourceChain, sourceAddress, payload);
const tx = await appContract.execute(commandId, sourceChain, sourceAddress, payload, gasOptions);
printInfo('Execute tx', tx.hash);
await tx.wait(chain.confirmations);

Expand Down
2 changes: 1 addition & 1 deletion evm/its.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ async function processCommand(config, chain, options) {
throw new Error(`${action} can only be performed by contract owner: ${owner}`);
}

const pauseStatus = options.pauseStatus;
const pauseStatus = options.pauseStatus === 'true';

const tx = await interchainTokenService.setPauseStatus(pauseStatus, gasOptions);

Expand Down
11 changes: 8 additions & 3 deletions stellar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ node stellar/deploy-contract.js deploy axelar_gas_service --chain-name <CHAIN_NA

### Interchain Token Service

Deploy Interchain Token wasm first.
```bash
node stellar/deploy-contract.js deploy interchain_token --chain-name <CHAIN_NAME> --wasm-path ../axelar-cgp-soroban/target/wasm32-unknown-unknown/release/interchain_token.optimized.wasm
```bash
node stellar/deploy-contract.js deploy interchain_token_service --chain-name <CHAIN_NAME> --wasm-path ../axelar-cgp-soroban/target/wasm32-unknown-unknown/release/interchain_token_service.optimized.wasm
```
Expand Down Expand Up @@ -173,16 +176,18 @@ node stellar/deploy-contract.js upgrade axelar_gateway --wasm-path ../axelar-cgp

### Interchain Token Service

#### Set Trusted Address
_Note_: Stellar ITS runs only in Hub mode. P2P connections are not supported. Therefore, rather than setting trusted ITS addresses, we set trusted chains (chains which are also registered with ITS Hub). The ITS Hub chain (axelar) itself is not a valid source/destination for direct ITS messages and so shouldn't be set as a trusted chain. All ITS messages must be sent to and received from the ITS Hub.
#### Set Trusted Chain
```bash
node stellar/its.js set-trusted-address [chain-name] [trusted-address]
node stellar/its.js set-trusted-chain [chain-name]
```
#### Remove Trusted Address
```bash
node stellar/its.js remove-trusted-address [chain-name]
node stellar/its.js remove-trusted-chain [chain-name]
```
## TTL extension and state archival recovery
Expand Down
3 changes: 2 additions & 1 deletion stellar/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async function getInitializeArgs(config, chain, contractName, wallet, options) {
case 'interchain_token_service': {
const gatewayAddress = nativeToScVal(Address.fromString(chain?.contracts?.axelar_gateway?.address), { type: 'address' });
const gasServiceAddress = nativeToScVal(Address.fromString(chain?.contracts?.axelar_gas_service?.address), { type: 'address' });
const itsHubAddress = nativeToScVal(config.axelar?.contracts?.InterchainTokenService?.address, { type: 'string' });
const chainName = nativeToScVal('stellar', { type: 'string' });

if (!chain?.contracts?.interchain_token?.wasmHash) {
Expand All @@ -60,7 +61,7 @@ async function getInitializeArgs(config, chain, contractName, wallet, options) {
type: 'bytes',
});

return { owner, gatewayAddress, gasServiceAddress, chainName, interchainTokenWasmHash };
return { owner, gatewayAddress, gasServiceAddress, itsHubAddress, chainName, interchainTokenWasmHash };
}

case 'axelar_operators':
Expand Down
29 changes: 14 additions & 15 deletions stellar/its.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ const { saveConfig, loadConfig, addOptionsToCommands, getChainConfig } = require
const { addBaseOptions, getWallet, broadcast } = require('./utils');
const { prompt } = require('../common/utils');

async function setTrustedAddress(wallet, _, chain, contractConfig, args, options) {
async function setTrustedChain(wallet, _, chain, contractConfig, arg, options) {
const contract = new Contract(contractConfig.address);
const [chainName, trustedAddress] = args;
const callArgs = [chainName, trustedAddress].map(nativeToScVal);
const callArg = nativeToScVal(arg, { type: 'string' });

const operation = contract.call('set_trusted_address', ...callArgs);
const operation = contract.call('set_trusted_chain', callArg);

await broadcast(operation, wallet, chain, 'Trusted Address Set', options);
await broadcast(operation, wallet, chain, 'Trusted Chain Set', options);
}

async function removeTrustedAddress(wallet, _, chain, contractConfig, arg, options) {
async function removeTrustedChain(wallet, _, chain, contractConfig, arg, options) {
const contract = new Contract(contractConfig.address);
const callArg = nativeToScVal(arg, { type: 'string' });

const operation = contract.call('remove_trusted_address', callArg);
const operation = contract.call('remove_trusted_chain', callArg);

await broadcast(operation, wallet, chain, 'Trusted Address Removed', options);
await broadcast(operation, wallet, chain, 'Trusted Chain Removed', options);
}

async function mainProcessor(processor, args, options) {
Expand Down Expand Up @@ -49,17 +48,17 @@ if (require.main === module) {
program.name('its').description('Interchain Token Service contract operations.');

program
.command('set-trusted-address <chainName> <trustedAddress>')
.description('set a trusted ITS address for a given chain')
.action((chainName, trustedAddress, options) => {
mainProcessor(setTrustedAddress, [chainName, trustedAddress], options);
.command('set-trusted-chain <chainName>')
.description('set a trusted ITS chain')
.action((chainName, options) => {
mainProcessor(setTrustedChain, chainName, options);
});

program
.command('remove-trusted-address <chainName>')
.description('remove a trusted ITS address for a given chain')
.command('remove-trusted-chain <chainName>')
.description('remove a trusted ITS chain')
.action((chainName, options) => {
mainProcessor(removeTrustedAddress, chainName, options);
mainProcessor(removeTrustedChain, chainName, options);
});

addOptionsToCommands(program, addBaseOptions);
Expand Down
22 changes: 17 additions & 5 deletions sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ const supportedPackages = PACKAGE_DIRS.map((dir) => ({
*/

async function postDeployRelayerDiscovery(published, keypair, client, config, chain, options) {
const [relayerDiscoveryObjectId, relayerDiscoveryObjectIdv0] = getObjectIdsByObjectTypes(published.publishTxn, [
const [relayerDiscoveryObjectId, relayerDiscoveryObjectIdv0, ownerCap] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::discovery::RelayerDiscovery`,
`${published.packageId}::relayer_discovery_v0::RelayerDiscovery_v0`,
`${published.packageId}::owner_cap::OwnerCap`,
]);

chain.contracts.RelayerDiscovery.objects = {
RelayerDiscovery: relayerDiscoveryObjectId,
RelayerDiscoveryv0: relayerDiscoveryObjectIdv0,
OwnerCap: ownerCap,
};
}

Expand Down Expand Up @@ -235,15 +237,22 @@ async function postDeployAxelarGateway(published, keypair, client, config, chain
async function postDeployIts(published, keypair, client, config, chain, options) {
const relayerDiscovery = chain.contracts.RelayerDiscovery?.objects?.RelayerDiscovery;

const [itsObjectId, itsv0ObjectId, ownerCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
const [itsObjectId, itsv0ObjectId, ownerCapObjectId, upgradeCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::its::ITS`,
`${published.packageId}::its_v0::ITS_v0`,
`${published.packageId}::owner_cap::OwnerCap`,
`${suiPackageAddress}::package::UpgradeCap`,
]);

const channelId = await getItsChannelId(client, itsv0ObjectId);

chain.contracts.ITS.objects = { ITS: itsObjectId, ITSv0: itsv0ObjectId, ChannelId: channelId, OwnerCap: ownerCapObjectId };
chain.contracts.ITS.objects = {
ITS: itsObjectId,
ITSv0: itsv0ObjectId,
ChannelId: channelId,
OwnerCap: ownerCapObjectId,
UpgradeCap: upgradeCapObjectId,
};

const tx = new Transaction();
tx.moveCall({
Expand All @@ -257,9 +266,12 @@ async function postDeployIts(published, keypair, client, config, chain, options)
async function postDeploySquid(published, keypair, client, config, chain, options) {
const relayerDiscovery = chain.contracts.RelayerDiscovery?.objects?.RelayerDiscovery;

const [squidObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [`${published.packageId}::squid::Squid`]);
const [squidObjectId, ownerCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::squid::Squid`,
`${published.packageId}::owner_cap::OwnerCap`,
]);
const channelId = await getSquidChannelId(client, squidObjectId);
chain.contracts.Squid.objects = { Squid: squidObjectId, ChannelId: channelId };
chain.contracts.Squid.objects = { Squid: squidObjectId, ChannelId: channelId, OwnerCap: ownerCapObjectId };

const tx = new Transaction();
tx.moveCall({
Expand Down

0 comments on commit 1d5187c

Please sign in to comment.