near / near-cli

General purpose command line tools for interacting with NEAR Protocol
https://docs.near.org
MIT License
193 stars 92 forks source link

Cannot create account #1106

Closed wackazong closed 4 months ago

wackazong commented 4 months ago

Describe the bug I cannot create a new account on testnet with near-cli 4.0.8

To Reproduce

near create-account pleaseletmedothis.testnet --useFaucet --verbose 

Using options: {
  useFaucet: true,
  verbose: true,
  v: true,
  initialBalance: '1',
  signWithLedger: false,
  useLedgerKey: false,
  ledgerPath: "44'/397'/0'/0'/1'",
  useLedgerPK: false,
  newLedgerKey: false,
  PkLedgerPath: "44'/397'/0'/0'/1'",
  networkId: 'testnet',
  newAccountId: 'pleaseletmedothis.testnet'
}
near create-account <new-account-id>

Create a new account

Options:
      --help                                      Show help  [boolean]
      --version                                   Show version number  [boolean]
  -v, --verbose                                   Prints out verbose output  [boolean] [default: false]
      --new-account-id                            Account to be created (e.g. bob.testnet, bob.near, sub.bob.testnet, sub.bob.near)
      --useFaucet                                 Pre-fund the account through a faucet service (testnet only)  [boolean] [default: false]
      --useAccount, --accountId, --masterAccount  Account that will request and fund creating the new account  [string]
      --initialBalance                            Number of tokens to transfer to the new account  [string] [default: "1"]
      --publicKey                                 Public key to initialize the account with  [string]
      --seedPhrase                                seedPhrase from which to derive the account's publicKey  [string]
      --signWithLedger, --useLedgerKey            Use Ledger for signing  [boolean] [default: false]
      --ledgerPath                                Path to the Ledger key  [string] [default: "44'/397'/0'/0'/1'"]
      --useLedgerPK, --newLedgerKey               Initialize the account using the public key from the Ledger  [boolean] [default: false]
      --PkLedgerPath                              Path to the Ledger key that will be added to the account  [string] [default: "44'/397'/0'/0'/1'"]
      --networkId                                 Which network to use. Supports: mainnet, testnet, custom  [string] [default: "testnet"]

TypedError: Can't complete the action because account pleaseletmedothis.testnet doesn't exist
    at JsonRpcProvider.<anonymous> (/Users/alexander/.nvm/versions/node/v20.9.0/lib/node_modules/near-cli/node_modules/@near-js/providers/lib/json-rpc-provider.js:377:39)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/alexander/.nvm/versions/node/v20.9.0/lib/node_modules/near-cli/node_modules/@near-js/providers/lib/json-rpc-provider.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'AccountDoesNotExist',
  context: undefined
}

Expected behavior An account should be created as no account with this name exists

wackazong commented 4 months ago

This seems to be caused by the assertAccountDoesNotExist method throwing an error because the near-api-js fails if you call state() on a non-existing account. If I remove that check the account is created.

zavodil commented 4 months ago

I can confirm this bug

gagdiez commented 4 months ago

ok, this is weird, because all tests are passing, which include this option. Let me dig into what is happening with the release.

gagdiez commented 4 months ago

just released a fix, version 4.0.9, please test and let me know @zavodil @wackazong

wackazong commented 4 months ago

Confirmed working. Thanks.