Skip to content

Incorrect description and confusing operation of the createSubAccount function #1445

@AlexKushnir1

Description

@AlexKushnir1

Description

The documented parameters for function createSubAccount are not appropriate namely contract

* Create a new sub-account under an existing account
* (e.g. create `sub.new.near` by signing with `new.near`)
* @param account name of the existing account under which the new account is created
* @param contract root contract for the target network (e.g. `testnet`)
* @param newAccount name of the created account
* @param newPublicKey public key for the created account's initial full access key
* @param initialBalance initial account balance in yN
* @param blockReference block ID/finality
* @param deps sign-and-send dependencies
*/
export async function createSubAccount({ account, newAccount, newPublicKey, initialBalance, blockReference, deps }: CreateAccountParams) {
return SignedTransactionComposer.init({ sender: account, receiver: newAccount, deps })
.createAccount()
.transfer(initialBalance)
.addFullAccessKey(newPublicKey)
.signAndSend(blockReference);
}

Also it"s weird for me that we must to pass the name of existing account and then new name with parent"s suffix. Like:

{
  account: 'true-pull.testnet',
  newAccount: 'alex.true-pull.testnet',
...

It"s need to be described, I"m not sure that we can change due to the design

Optional: User Story

As a user, I realy like the near-api-rs way to creating accounts and its checking is_sub_account_of()

I would like to work on it. Grateful for every feedback!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Shipped 🚀

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions