Description
Describe the bug
As per my understanding, for opting out of a transaction in Algo-builder, we need to send a AssetTransfer
transaction with amount 0, receiver as ourselves and closeRemainderTo
set to the creator address.
const optOutTxn = {
type: types.TransactionType.TransferAsset,
sign: types.SignType.SecretKey,
fromAccount: customer.account,
toAccountAddr: customer.account.addr,
assetID: nft_id,
amount: 0,
payFlags: { totalFee: 1000, closeRemainderTo: seller.account.addr },
};
An example on your repo can be found here:
algo-builder/examples/permissioned-token/scripts/user/opt-out.js
Lines 20 to 30 in 326d6d3
Although the opt out works fine, I am getting warning printed that the is already opted in to the asset
Expected Behavior
No warnings
Current Behavior
Warning printed
<account address> is already opted in to the asset <asset id>
Possible Solution
In the following function, a console.warn()
is added in Line 390 if asset holding is defined but does not handle the case when the transaction is for opting out.
You can add another if condition to check if closeRemainderTo
field is set to the creator of the Asset which confirms that this transaction is a Opt Out transaction and not opt in.
algo-builder/packages/runtime/src/account.ts
Lines 387 to 402 in 326d6d3
Steps to Reproduce
- Create an NFT
- Create Opt Out transaction
Environment
- OS: Windows 11
- Node.js version: v16.15.0
- algob version: NA
Activity