andromedaprotocol / andromeda-core

Operating System and ADO Smart Contracts
https://andromedaprotocol.io/
38 stars 27 forks source link

When trying to transfer cw20 tokens to a wallet, an error occurs. #540

Closed vasylNaumenko closed 1 month ago

vasylNaumenko commented 2 months ago

Describe the bug When trying to transfer cw20 tokens to a wallet, an error occurs.

Error Code message index: 0: InvalidAddress

To Reproduce

Steps to reproduce the behavior:

Go to 'ado execute' Select a message type: [Option 1] 'Transfer' Input Amount: 2000000 Input Recipient: wasm1c4w4jxdkvj3ygdycdkjy98jve6w0d7257eqfx9 See error ⠂ Simulating Tx...

Error: Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: InvalidAddress: execute wasm contract failed [!cosm!wasm/wasmd@v0.50.0/x/wasm/keeper/keeper.go:404] with gas used: '101355': unknown request

Expected behavior transfer cw20 tokens to the wallet

Screenshots

image

image

Environment (please complete the following information):

Additional context During the initialization of the cw20, it is specified that the contract owner must have 10000000000 LND. image

vasylNaumenko commented 2 months ago

Checking the balance of the connected wallet works correctly. Sending native tokens to another wallet also functions properly.

image image
leifasorensen commented 2 months ago

Unable to Replicate: Description & Recommended Next Steps

It is believed that the issue is that the wallet address you have provided as a recipient is considered as unrecognized. Unless this is a typographical error it is believed to potentially be an issue with an unrecognized chain address or potentially a conflict in the contract schemas.

I have tested what I believe to be the same configuration using CW20@1.0.0 on Andromeda' testnet and was unable to replicate the conflict. (Details provided below)

We would recommend that you retry the ado execute command but this time with the --print flag. This may provide you with more details on the error you are encountering.

For reference: The bank send process you performed is to assure that the recipient address is a registered address on the chain (as some chains have seemed to not recognize untransacted wallet addresses in the past). You have confirmed the wallet by adding funds, but you did not show if you then retried the original cw20>transfer() message and if it resolved the invalid address issue being reported. This process was one that we had previously found may have resolved unrecognized addresses.

Successful Testing of CW20@1.0.0 Transfer() from one address to another

CW20 Transfer Test
crnbarr93 commented 2 months ago

@vasylNaumenko Would you mind providing your instantiation message for the contract?

It also looks like the economics contract might be missing from your OS deployment from the description you've provided.

vasylNaumenko commented 2 months ago

@vasylNaumenko Would you mind providing your instantiation message for the contract?

Here's the code I used to instantiate the cw20 contract:

msgInstCw20Bytes, err := json.Marshal(map[string]interface{}{
        "name":     "CW20 Token",
        "symbol":   "LND", // only letters A-z, "-", 3-20 characters
        "decimals": 6,
        "initial_balances": []map[string]interface{}{
            {
                "address": acc1.Address,
                "amount":  "10000000000",
            },
        },
        "mint": map[string]interface{}{
            "minter": acc1.Address,
            "cap":    "1000000000000000000",
        },
        "owner":          acc1.Address,
        "kernel_address": rawKernelContractAddress,
    })
    if err != nil {
        log.Fatal("error marshaling instantiate message", zap.Error(err))
        return
    }
    _, cw20Addr, err := uploadAndInstantiate(
        chainService,
        client,
        log,
        acc1,
        msgInstCw20Bytes,
        "./artifacts/andromeda_cw20.wasm",
        5000000,
    )
    if err != nil {
        log.Fatal("error uploading andromeda_cw20.wasm", zap.Error(err))
        return
    }

This instantiation was successful, and I was able to obtain the contract address. As mentioned earlier, I can successfully perform the following operations:

Check balances and transfer native tokens between wallets. Save and retrieve values for keys in the kernel.

It also looks like the economics contract might be missing from your OS deployment from the description you've provided.

Thank you for pointing that out. I'll make sure to deploy the economics contract as part of the OS setup. Are there any other smart contracts that should be included in the deployment for a complete and functional Andromeda OS setup? I want to ensure I haven't missed any essential components. If you could provide a list of all the necessary contracts for a full Andromeda OS deployment, it would be extremely helpful. This will allow me to verify my current setup and add any missing pieces.

crnbarr93 commented 2 months ago

@vasylNaumenko Would you mind providing your instantiation message for the contract?

Here's the code I used to instantiate the cw20 contract:

msgInstCw20Bytes, err := json.Marshal(map[string]interface{}{
      "name":     "CW20 Token",
      "symbol":   "LND", // only letters A-z, "-", 3-20 characters
      "decimals": 6,
      "initial_balances": []map[string]interface{}{
          {
              "address": acc1.Address,
              "amount":  "10000000000",
          },
      },
      "mint": map[string]interface{}{
          "minter": acc1.Address,
          "cap":    "1000000000000000000",
      },
      "owner":          acc1.Address,
      "kernel_address": rawKernelContractAddress,
  })
  if err != nil {
      log.Fatal("error marshaling instantiate message", zap.Error(err))
      return
  }
  _, cw20Addr, err := uploadAndInstantiate(
      chainService,
      client,
      log,
      acc1,
      msgInstCw20Bytes,
      "./artifacts/andromeda_cw20.wasm",
      5000000,
  )
  if err != nil {
      log.Fatal("error uploading andromeda_cw20.wasm", zap.Error(err))
      return
  }

This instantiation was successful, and I was able to obtain the contract address. As mentioned earlier, I can successfully perform the following operations:

Check balances and transfer native tokens between wallets. Save and retrieve values for keys in the kernel.

It also looks like the economics contract might be missing from your OS deployment from the description you've provided.

Thank you for pointing that out. I'll make sure to deploy the economics contract as part of the OS setup. Are there any other smart contracts that should be included in the deployment for a complete and functional Andromeda OS setup? I want to ensure I haven't missed any essential components. If you could provide a list of all the necessary contracts for a full Andromeda OS deployment, it would be extremely helpful. This will allow me to verify my current setup and add any missing pieces.

Apologies for the slow reply, the following contracts are required to be instantiated and the ones marked with * must be recorded in the Kernel contract with UpsertKeyAddress, I'll provide the key in brackets:

vasylNaumenko commented 2 months ago

@crnbarr93 Thank you for the clarification! The cw20 token transfer is now working, but the problem with querying the cw20 contract and other contracts remains. For any query using "ado query ", I receive a "Schema not found" error.

Could you please advise, is it possible that I've missed something and some additional actions are required to make the contract queries work?

crnbarr93 commented 2 months ago

These commands use our GQL server to fetch the related JSON schema based on the ADO type/version. Seems like it's not picking up the correct version/schema for the commands. You should still be able to use the standard wasm query/execute commands and provide the relevant JSON data.