Skip to content

feat: add solana #1

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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
794c56f
feat: add skeleton flow
frenzox Apr 29, 2025
c0ad70d
feat: add first gateway instructions
frenzox Apr 29, 2025
e276999
feat: add gas_service initialization
frenzox Apr 29, 2025
6d6c10e
refactor: move json keys to utils
frenzox Apr 30, 2025
2aa5c71
feat: add its initialization
frenzox Apr 30, 2025
f6246f4
feat: add its set-pause-status
frenzox Apr 30, 2025
94cf5ae
feat: its trusted chain add/remove
frenzox Apr 30, 2025
ae19a9f
feat: add gas service related keys to utils
frenzox Apr 30, 2025
02964f6
feat: add more its instructions
frenzox Apr 30, 2025
7e0046b
feat: add solana-devnet to chains
frenzox Apr 30, 2025
271551d
fix: add missing token manager types
frenzox Apr 30, 2025
6fe4bb4
feat: add more its instructions
frenzox Apr 30, 2025
19e0269
fix(solana): fix its pause/unpause
frenzox Apr 30, 2025
d8a54de
refactor(solana): move transaction result printing
frenzox Apr 30, 2025
f95177a
feat(solana): print token_id on deployments/registrations
frenzox Apr 30, 2025
f279ead
fix(solana): update how we deal with chains info file
frenzox May 1, 2025
a5f126a
fix(solana): be consistent with json manipulation
frenzox May 1, 2025
f4f0d40
feat(solana): add governance initialization
frenzox May 1, 2025
7be155e
feat(solana): governance proposal execution
frenzox May 2, 2025
c549ca6
feat(solana): gateway `approve` (local only)
frenzox May 7, 2025
ac2cc13
refactor(solana): make implementation closer existing ones
frenzox May 7, 2025
4c4243f
feat(solana): rotate signers
frenzox May 7, 2025
ac5101a
feat(solana): submit-proof
frenzox May 9, 2025
6e153f3
refactor(solana): major refactoring
frenzox May 9, 2025
ffa1f69
feat(solana): execute
frenzox May 9, 2025
d0f268a
refactor(solana): be consistent with error handling
frenzox May 9, 2025
012411d
fix(solana): use correct hash function
frenzox May 12, 2025
7311063
feat(solana): add misc helper commands
frenzox May 12, 2025
6a72411
fix(solana): remove changes to devnet-amplifier.json
frenzox May 12, 2025
bec3084
refactor(solana): move cli to solana root dir
frenzox May 12, 2025
32fcbe3
fix(solana): be consistent with help comments
frenzox May 12, 2025
0a8872c
feat(solana): readme
frenzox May 13, 2025
986051c
fix(solana): make output fila names consistent
frenzox May 13, 2025
647740d
chore(solana): format code
frenzox May 13, 2025
38009b8
fix(solana): create local multisig_prover module
frenzox May 13, 2025
7695748
fix(solana): remove spurious dbg! call
frenzox May 13, 2025
660ad5b
fix(solana): misc should be more general
frenzox May 14, 2025
04a9460
chore(solana): clean up dependencies
frenzox May 14, 2025
f4e9420
fix(solana): adjust code to latest solana-axelar
frenzox May 14, 2025
c9acc93
chore(solana): configure linter
frenzox May 14, 2025
b899b29
chore(solana): be consistent with import granularity
frenzox May 14, 2025
185ab69
fix(solana): fix all clippy errors
frenzox May 14, 2025
315134b
fix(solana): fix shellcheck issues
frenzox May 14, 2025
bf12f5c
fix(solana): add solana ITS address encoding
frenzox May 14, 2025
8918d96
chore(solana): be consistent with placeholders
frenzox May 14, 2025
ffe2629
refactor(solana): env and private key consistency
frenzox May 14, 2025
5678ba5
chore(solana): releases (WIP)
frenzox May 14, 2025
2681774
chore(solana): add skeleton release files
frenzox May 15, 2025
41f50a4
feat(solana): allow 'all' on ITS's set-trusted-chain
frenzox May 15, 2025
bf506bb
refactor(solana): make set-trusted-chain take positional arg
frenzox May 15, 2025
84c7a3f
fix(solana): fix number of signers check
frenzox May 15, 2025
30bd32e
fix(solana): some fixes to release docs
frenzox May 15, 2025
6ee630f
feat(solana): add Solana GMP release doc
frenzox May 16, 2025
216fc06
fix(solana): update solana cosmwasm GMP info
frenzox May 21, 2025
88ffd75
fix(solana): chain name and axelar env
frenzox May 21, 2025
f0f4536
fix(solana): fix send missing signers
frenzox May 21, 2025
9d76afd
feat(solana): add `query` subcommand
frenzox May 21, 2025
b499966
chore(solana): update release docs
frenzox May 21, 2025
aceaf0d
chore(solana): update readme
frenzox May 21, 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
30 changes: 30 additions & 0 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ const {
const { normalizeBech32 } = require('@cosmjs/encoding');
const fetch = require('node-fetch');
const StellarSdk = require('@stellar/stellar-sdk');
const bs58 = require('bs58');

const pascalToSnake = (str) => str.replace(/([A-Z])/g, (group) => `_${group.toLowerCase()}`).replace(/^_/, '');

const pascalToKebab = (str) => str.replace(/([A-Z])/g, (group) => `-${group.toLowerCase()}`).replace(/^-/, '');

const VERSION_REGEX = /^\d+\.\d+\.\d+$/;
const SHORT_COMMIT_HASH_REGEX = /^[a-f0-9]{7,}$/;
const SVM_BASE58_ADDRESS_REGEX = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;

function loadConfig(env) {
return require(`${__dirname}/../axelar-chains-config/info/${env}.json`);
Expand Down Expand Up @@ -305,6 +307,19 @@ function isValidStellarContract(address) {
return StellarSdk.StrKey.isValidContract(address);
}

/**
* Basic validatation to check if the provided string *might* be a valid SVM
* address. One needs to ensure that it's 32 bytes long after decoding.
*
* See https://solana.com/developers/guides/advanced/exchange#basic-verification.
*
* @param {string} address - The base58 encoded Solana address to validate
* @returns {boolean} - True if the address is valid, false otherwise
*/
function isValidSvmAddressFormat(address) {
return SVM_BASE58_ADDRESS_REGEX.test(address)
}

const validationFunctions = {
isNonEmptyString,
isNumber,
Expand All @@ -318,6 +333,7 @@ const validationFunctions = {
isValidStellarAddress,
isValidStellarAccount,
isValidStellarContract,
isValidSvmAddressFormat,
};

function validateParameters(parameters) {
Expand Down Expand Up @@ -588,10 +604,19 @@ function asciiToBytes(string) {
return hexlify(Buffer.from(string, 'ascii'));
}

function trySolanaAddressBytesFromBase58(string) {
const decoded = bs58.default.decode(string);
if (decoded.length !== 32) {
throw new Error(`Invalid Solana address: ${string}`);
}
return hexlify(decoded);
}

/**
* Encodes the destination address for Interchain Token Service (ITS) transfers.
* This function ensures proper encoding of the destination address based on the destination chain type.
* Note: - Stellar addresses are converted to ASCII byte arrays.
* - Solana (svm) addresses are decoded from base58 and hexlified.
* - EVM and Sui addresses are returned as-is (default behavior).
* - Additional encoding logic can be added for new chain types.
*/
Expand All @@ -607,6 +632,10 @@ function encodeITSDestination(config, destinationChain, destinationAddress) {
validateParameters({ isValidStellarAddress: { destinationAddress } });
return asciiToBytes(destinationAddress);

case 'svm':
validateParameters({ isValidSvmAddressFormat: { destinationAddress } });
return trySolanaAddressBytesFromBase58(destinationAddress);

case 'evm':
case 'sui':
default: // EVM, Sui, and other chains (return as-is)
Expand Down Expand Up @@ -665,6 +694,7 @@ module.exports = {
isValidStellarAddress,
isValidStellarAccount,
isValidStellarContract,
isValidSvmAddressFormat,
getCurrentVerifierSet,
asciiToBytes,
encodeITSDestination,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@mysten/sui": "^1.3.0",
"@stellar/stellar-sdk": "^13.0.0",
"axios": "^1.7.2",
"bs58": "^6.0.0",
"csv-parser": "^3.0.0",
"path": "^0.12.7",
"toml": "^3.0.0",
Expand Down
Loading
Loading