-
Notifications
You must be signed in to change notification settings - Fork 493
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
goal: Add asset optin command #3881
Conversation
Goal should now give a more helpful error message when the user needs to opt in to using an ASA (by sending a 0 unit txn to themselves).
When a user wants to opt an account into using an ASA, they can now use this goal utility command to construct a 0 unit transaction from and to a given account in order to activate that asset for use.
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.
it looks good.
cmd/goal/asset.go
Outdated
var optinAssetCmd = &cobra.Command{ | ||
Use: "optin", | ||
Short: "Optin to assets", | ||
Long: "Opt an acocunt in to asset use. An account will begin accepting an asset by issuing a zero-amount asset transfer to itself.", |
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: maybe change Opt an acocunt in to asset use
to Opt in to receive new assets
?
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 to Opt in to receive a new asset.
libgoal/transactions.go
Outdated
// | ||
// Call FillUnsignedTxTemplate afterwards to fill out common fields in | ||
// the resulting transaction template. | ||
func (c *Client) MakeUnsignedAssetOptinTx(index uint64, account string) (transactions.Transaction, error) { |
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: you could also call MakeUnsignedAssetSendTx with correct parameters for opt in to reduce repeated code.
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.
Yeah I've updated to do this. Originally I was having some issues using this because I wasn't providing the correct empty argument for clawback address which was causing failures.
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.
Looks great. Here are some other tests that would be good to update (some of these, like the ones with -c, aren't optins):
$ rg "asset send.*-a 0"
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB -c $ACCOUNT
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB -c $ACCOUNT
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB -c $ACCOUNT
create_destroy_optin_optout.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB
asset-misc.sh:${gcmd} asset send --assetid ${ASSET_ID} -f ${ACCOUNTB} -t ${ACCOUNTB} -a 0
asset-misc.sh:${gcmd} asset send --assetid ${ASSET_ID} -f ${ACCOUNTC} -t ${ACCOUNTC} -a 0
asset-misc.sh:${gcmd} asset send --assetid ${ASSET_ID} -f ${ACCOUNTD} -t ${ACCOUNTD} -a 0
limit-swap-test.sh:${gcmd} asset send -o ${TEMPDIR}/b-asset-init.tx -a 0 --assetid ${ASSET_ID} -t $ACCOUNT_ASSET_TRADER -f $ACCOUNT_ASSET_TRADER --validrounds $((${SETUP_ROUND} - ${ROUND} - 1))
limit-swap-test.sh:${gcmd} asset send --assetid ${ASSET_ID} -t ${ZERO_ADDRESS} -a 0 -c ${ACCOUNT} -f ${ACCOUNT_ASSET_TRADER} -o ${TEMPDIR}/bclose.tx
limit-swap-test.sh:${gcmd} asset send -o ${TEMPDIR}/b-asset-init.tx -a 0 --assetid ${ASSET_ID} -t $ACCOUNT_ASSET_TRADER -f $ACCOUNT_ASSET_TRADER --validrounds $((${SETUP_ROUND} - ${ROUND} - 1))
dex.sh:${gcmd} asset send -a 0 -f "${ACCT_ACTOR}" -t "${ACCT_ACTOR}" --creator "${ACCT_CREATOR}" --assetid "${ASSETID}"
e2e-app-real-assets-round.sh:${gcmd} asset send --assetid $ASSET_ID -a 0 -f $ACCOUNTB -t $ACCOUNTB
app-assets.sh: ${gcmd} asset send -a 0 "$@"
Co-authored-by: Will Winder <[email protected]>
Summary
Add
goal asset optin
subcommandAdds a subcommand to simplify the opt in process for ASA via goal.
A lot of the command code is duplicated from the send command, but it looks like there is plenty of duplication across other commands as well so I've kept with that trend instead of factoring things out separately.
Test Plan
Replicated optin error and updated error message to more accurately reflect the needed actions. Then tested out the new optin command via these txns:
[Optin txn created on testnet] (https://testnet.algoexplorer.io/tx/CYBP2PPFMWMZZV63PWFYOU3MY2WPD2DNJ2UPCYNJH4Z7ECQA34KQ) via
goal asset optin
Subsequent successful transfer of foobars