-
Notifications
You must be signed in to change notification settings - Fork 17
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(stellar): refactor operators script and add missing commands #540
base: main
Are you sure you want to change the base?
Conversation
stellar/operators.js
Outdated
|
||
if (returnValue.value()) { | ||
printInfo('Return value', returnValue.value()); | ||
if (!chain.contracts?.axelar_operators) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use validate parameters? Add a soroban- address validation method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added validateParameters
and isValidAddress
. also created a ticket to refactor other contract addresses: https://axelarnetwork.atlassian.net/browse/AXE-7492
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated ticket with details: refactor stellar scripts to add stellar address validation
if (!isValidAddress(contractAddress)) { | ||
throw new Error('Invalid operators contract'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This defeats the point of validateParameters
. Take a look at it's implementation. We want to add support for stellar address validation to it
validateParameters({
isValidStellarAddress: { contractAddress },
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could specialize into two functions as well
isStellarContract
and isStellarAccount
, since these addresses start with C
and G
respectively for stricter validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can work on this on a separate PR since this task may be out of scope and could impact other scripts. I've created a ticket to track it: https://axelarnetwork.atlassian.net/browse/AXE-7492
Co-authored-by: Milap Sheth <[email protected]>
@@ -340,6 +340,16 @@ function stellarAddressToBytes(address) { | |||
return hexlify(Buffer.from(address, 'ascii')); | |||
} | |||
|
|||
function isValidAddress(address) { | |||
try { | |||
// try conversion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: implied with try block
program.action((options) => { | ||
const config = loadConfig(options.env); | ||
processCommand(options, config, getChainConfig(config, options.chainName)); | ||
program.command('remove-operator <addrsess>').action((address, options) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
program.command('remove-operator <addrsess>').action((address, options) => { | |
program.command('remove-operator <address>').action((address, options) => { |
AXE-7488
is_operator
,add_operator
,remove_operator
functions has been tested.collect_fees
: https://stellar.expert/explorer/testnet/tx/4562552348495872refund
: https://stellar.expert/explorer/testnet/tx/4562612478029824