From bf22e788473b12ce053d4cb22ff61d915b738e3a Mon Sep 17 00:00:00 2001 From: Jorge Silva Date: Fri, 23 Dec 2022 15:28:49 +0000 Subject: [PATCH] remove allowance check in wasp-cli --- tools/cluster/tests/wasp-cli_test.go | 29 ++++++++++++++++++++++------ tools/wasp-cli/chain/accounts.go | 6 ------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/cluster/tests/wasp-cli_test.go b/tools/cluster/tests/wasp-cli_test.go index 2c65635f37..97eebc8824 100644 --- a/tools/cluster/tests/wasp-cli_test.go +++ b/tools/cluster/tests/wasp-cli_test.go @@ -153,14 +153,14 @@ func TestWaspCLIDeposit(t *testing.T) { ) require.Regexp(t, `.*Error: \(empty\).*`, strings.Join(out, "")) - // mint 1 native token + // mint 2 native tokens // TODO we know its the first foundry to be created by the chain, so SN must be 1, // but there is NO WAY to obtain the SN, this is a design flaw that must be fixed. foundrySN := "1" out = w.PostRequestGetReceipt( "accounts", accounts.FuncFoundryModifySupply.Name, "string", accounts.ParamFoundrySN, "uint32", foundrySN, - "string", accounts.ParamSupplyDeltaAbs, "bigint", "1", + "string", accounts.ParamSupplyDeltaAbs, "bigint", "2", "string", accounts.ParamDestroyTokens, "bool", "false", "-l", "base:1000000", "--off-ledger", @@ -169,23 +169,40 @@ func TestWaspCLIDeposit(t *testing.T) { // withdraw this token to the wasp-cli L1 address out = w.Run("chain", "balance") - tokenID := strings.Split(out[4], " ")[0] + tokenID := "" + for _, line := range out { + if strings.Contains(line, "0x") { + tokenID = strings.Split(line, " ")[0] + } + } out = w.PostRequestGetReceipt( "accounts", accounts.FuncWithdraw.Name, - "-l", fmt.Sprintf("base:1000000, %s:1", tokenID), + "-l", fmt.Sprintf("base:1000000, %s:2", tokenID), "--off-ledger", ) require.Regexp(t, `.*Error: \(empty\).*`, strings.Join(out, "")) - // deposit the native token to the chain + // deposit the native token to the chain (to an ethereum account) w.Run( "chain", "deposit", eth.String(), - fmt.Sprintf("base:100000, %s:1", tokenID), + fmt.Sprintf("%s:1", tokenID), "--adjust-storage-deposit", ) out = w.Run("chain", "balance", eth.String()) require.Contains(t, strings.Join(out, ""), tokenID) + + // deposit the native token to the chain (to the cli account) + w.Run( + "chain", "deposit", + fmt.Sprintf("%s:1", tokenID), + "--adjust-storage-deposit", + ) + out = w.Run("chain", "balance") + require.Contains(t, strings.Join(out, ""), tokenID) + // no token balance on L1 + out = w.Run("balance") + require.NotContains(t, strings.Join(out, ""), tokenID) }) } diff --git a/tools/wasp-cli/chain/accounts.go b/tools/wasp-cli/chain/accounts.go index 39c55864d6..ab14ba362a 100644 --- a/tools/wasp-cli/chain/accounts.go +++ b/tools/wasp-cli/chain/accounts.go @@ -127,13 +127,7 @@ func depositCmd() *cobra.Command { log.Check(err) tokensStr := strings.Split(strings.Join(args[1:], ""), ",") tokens := util.ParseFungibleTokens(tokensStr) - - // calculate the correct allowance (funds to send - gas fee) allowance := isc.NewAllowanceFungibleTokens(tokens.Clone()) - ok := allowance.SpendFromBudget(getTokensForRequestFee()) - if !ok { - panic("not enough tokens for allowance + fee") - } util.WithSCTransaction(GetCurrentChainID(), func() (*iotago.Transaction, error) { return SCClient(accounts.Contract.Hname()).PostRequest(