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

goal: Add asset optin command #3881

Merged
merged 8 commits into from
Apr 20, 2022
Merged

Conversation

Eric-Warehime
Copy link
Contributor

Summary

Add goal asset optin subcommand

Adds 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

Eric-Warehime and others added 3 commits April 12, 2022 15:39
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.
@CLAassistant
Copy link

CLAassistant commented Apr 13, 2022

CLA assistant check
All committers have signed the CLA.

@Eric-Warehime Eric-Warehime changed the title Goal asset optin goal: Add asset optin command Apr 13, 2022
Copy link
Contributor

@shiqizng shiqizng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good.

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.",
Copy link
Contributor

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?

Copy link
Contributor Author

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.

//
// Call FillUnsignedTxTemplate afterwards to fill out common fields in
// the resulting transaction template.
func (c *Client) MakeUnsignedAssetOptinTx(index uint64, account string) (transactions.Transaction, error) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@winder winder left a 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 "$@"

winder
winder previously approved these changes Apr 14, 2022
shiqizng
shiqizng previously approved these changes Apr 14, 2022
Co-authored-by: Will Winder <[email protected]>
@Eric-Warehime Eric-Warehime dismissed stale reviews from shiqizng and winder via bc0a25e April 20, 2022 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants