Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sui): update its to interchainTokenService #517

Merged
merged 45 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
30b30b1
update naming, cgp-sui package version should be uptdated after release
Foivos Jan 27, 2025
1e7e97e
Merge remote-tracking branch 'origin/main' into feat/update-its-naming
Foivos Jan 28, 2025
c6a359f
prettier
Foivos Jan 28, 2025
d046a49
hopefully fix tests
Foivos Jan 28, 2025
375e068
fix sui test
Foivos Jan 28, 2025
030229a
rename ITS to InterchainTokenService in its-example as well
Foivos Jan 28, 2025
d8a6c2a
some more renaming
Foivos Jan 28, 2025
282d92d
some more renaming again
Foivos Jan 28, 2025
c511953
some renaming went wrong
Foivos Jan 28, 2025
e7c5ec5
prettier
Foivos Jan 28, 2025
89b8547
rename in its.js as well
Foivos Jan 28, 2025
a3e3a50
fix trusted addresses
Foivos Jan 28, 2025
757e6e8
prettier
Foivos Jan 28, 2025
434424b
fix its-example some
Foivos Jan 28, 2025
d074ca1
testing error fails
Foivos Jan 28, 2025
5146813
some more renaming
Foivos Jan 28, 2025
8015250
fixed some tests
Foivos Jan 28, 2025
43789a3
fix source address
Foivos Jan 28, 2025
8047bd0
try more fixes
Foivos Jan 28, 2025
fb26303
try to fix test.yaml again
Foivos Jan 28, 2025
11f69b0
more fixing
Foivos Jan 28, 2025
637fa98
Merge branch 'main' into feat/update-its-naming
milapsheth Jan 29, 2025
02cfc16
Merge remote-tracking branch 'origin/main' into feat/update-its-naming
Foivos Jan 29, 2025
38e807e
update test-sui
Foivos Jan 29, 2025
ec915aa
update its.js
Foivos Jan 29, 2025
cb76ff4
rename ITS to InterchainTokenSercvice everywhere
Foivos Jan 29, 2025
be6c9e7
prettier
Foivos Jan 29, 2025
2d1e7f6
fix deploy script
Foivos Jan 29, 2025
42255fd
revert evm changes
Foivos Jan 29, 2025
9c0d83b
fix local.json test
Foivos Jan 29, 2025
235384c
remove trusted address tracking on info
Foivos Jan 29, 2025
61cd930
Merge remote-tracking branch 'origin/main' into feat/update-its-naming
Foivos Jan 31, 2025
2c6f238
added checkTrustedAddresses again, to be filled in another PR.
Foivos Feb 4, 2025
ea94cae
Update sui/its.js
Foivos Feb 4, 2025
4e4866e
removed check so that all chains can be included
Foivos Feb 4, 2025
c20fd7f
Update sui/its.js
Foivos Feb 4, 2025
3334633
changed some command details
Foivos Feb 4, 2025
847f5ad
Merge branch 'feat/update-its-naming-temp' into feat/update-its-naming
Foivos Feb 4, 2025
6d6f1b4
some more comments
Foivos Feb 4, 2025
e732730
Update .github/workflows/test-sui.yaml
Foivos Feb 4, 2025
af3c158
Merge remote-tracking branch 'origin/main' into feat/update-its-naming
Foivos Feb 4, 2025
98e0ffd
prettier
Foivos Feb 5, 2025
a33a6f9
prettier and added options to broadcast
Foivos Feb 5, 2025
d0b7e32
update test slightly
Foivos Feb 5, 2025
25f75a7
Merge remote-tracking branch 'origin/main' into feat/update-its-naming
Foivos Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update its.js
Foivos committed Jan 29, 2025
commit ec915aaf5f39bedf90b09d832a781c4d86f19f6f
40 changes: 10 additions & 30 deletions sui/its.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ function parseTrustedChains(config, trustedChain) {
return trustedChain.split(',');
}

async function setupTrustedAddress(keypair, client, config, contracts, args, options) {
async function setupTrustedChain(keypair, client, config, contracts, args, options) {
const [trustedChain] = args;

const { InterchainTokenService: itsConfig } = contracts;
@@ -42,33 +42,17 @@ async function setupTrustedAddress(keypair, client, config, contracts, args, opt
} else {
await broadcastFromTxBuilder(txBuilder, keypair, 'Setup Trusted Address');
}

// Update InterchainTokenService config
for (const trustedChain of trustedChains) {
// Add trusted address to InterchainTokenService config
if (!contracts.InterchainTokenService.trustedAddresses) contracts.InterchainTokenService.trustedAddresses = [];

contracts.InterchainTokenService.trustedAddresses.push(trustedChain);
}
}

async function removeTrustedAddress(keypair, client, contracts, args, options) {
async function removeTrustedChain(keypair, client, contracts, args, options) {
const [trustedChain] = args;

const trustedAddressesObject = contracts.InterchainTokenService.trustedAddresses;

if (!trustedAddressesObject) throw new Error('No trusted addresses found');

const chainNames = trustedChain.split(',');

if (chainNames.length === 0) throw new Error('No chain names provided');

const txBuilder = new TxBuilder(client);

for (const chainName of chainNames) {
if (!trustedAddressesObject[chainName]) throw new Error(`No trusted addresses found for chain ${trustedChain}`);
}

await txBuilder.moveCall({
target: `${contracts.InterchainTokenService.address}::interchain_token_service::remove_trusted_chains`,
arguments: [
@@ -78,10 +62,6 @@ async function removeTrustedAddress(keypair, client, contracts, args, options) {
],
});

for (const chainName of chainNames) {
delete contracts.InterchainTokenService.trustedAddresses[chainName];
}

await broadcastFromTxBuilder(txBuilder, keypair, 'Remove Trusted Address');
}

@@ -106,26 +86,26 @@ if (require.main === module) {

// This command is used to setup the trusted address on the InterchainTokenService contract.
// The trusted address is used to verify the message from the source chain.
const setupTrustedAddressProgram = new Command()
.name('setup-trusted-address')
.command('setup-trusted-address <trusted-chain>')
const setupTrustedChainsProgram = new Command()
.name('add-trusted-chains')
.command('add-trusted-chains <trusted-chain>')
.description(
`Add trusted chain. The <trusted-chain> can be a list of chains separated by commas. It can also be a special tag to indicate a specific set of chains e.g. '${SPECIAL_CHAINS_TAGS.ALL_EVM}' to target all InterchainTokenService-deployed EVM chains`,
)
.action((trustedChain, options) => {
mainProcessor(setupTrustedAddress, options, [trustedChain], processCommand);
mainProcessor(setupTrustedChain, options, [trustedChain], processCommand);
});

const removeTrustedAddressProgram = new Command()
const removeTrustedChainsProgram = new Command()
.name('remove-trusted-address')
.description('Remove trusted address')
.command('remove-trusted-address <trusted-chain>')
.action((trustedChain, options) => {
mainProcessor(removeTrustedAddress, options, [trustedChain], processCommand);
mainProcessor(removeTrustedChain, options, [trustedChain], processCommand);
});

program.addCommand(setupTrustedAddressProgram);
program.addCommand(removeTrustedAddressProgram);
program.addCommand(setupTrustedChainsProgram);
program.addCommand(removeTrustedChainsProgram);

addOptionsToCommands(program, addBaseOptions, { offline: true });