-
Notifications
You must be signed in to change notification settings - Fork 94
Addresses subdomains in create_account, dev-deploy #324
Conversation
…nd throws if needed
# Conflicts: # commands/create-account.js
I think it should be fixed by this 7e31bfb, try rebasing/merging with |
Update: I think I am not understanding what a TLA is according to @bowenwang1996 who had a comment here:
|
@@ -32,6 +38,26 @@ module.exports = { | |||
|
|||
async function createAccount(options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a check that the suffix matches the network that the user is talking to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than that, looks good.
commands/create-account.js
Outdated
const exitOnError = require('../utils/exit-on-error'); | ||
const connect = require('../utils/connect'); | ||
const { KeyPair } = require('near-api-js'); | ||
const NEAR_ENV_SUFFIXES = [ | ||
'near', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go to config. Maybe even just reuse masterAccount
for this, but use helperUrl
for account creation when available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helperUrl
? I thought that is only used in the dev-deploy. As far as I know, the create_account
command will always need a masterAccount
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is generally used when you create accounts using near.createAccount
https://github.com/near/near-api-js/blob/f1dcf73ff3549fe7bc7caf35c7c6e43fbc4a2703/src/near.ts#L59
https://github.com/near/near-api-js/blob/f1dcf73ff3549fe7bc7caf35c7c6e43fbc4a2703/src/near.ts#L37
Though really the only hard statement here is that name suffix should be configurable, I'm not sure it should be universally be the same as masterAccount
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, interesting. Currently if you try passing just the helperUrl
yargs is set to fail because masterAccount
is required.
./bin/near create_account mike.asdf.test --accountHelper https://helper.testnet.nearprotocol.com
gives
Missing required argument: masterAccount
I feel like that'd be a good enhancement for another issue. Is it cool if we do this in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like the idea of using config for those, by the way, and I'll be pushing up a change that checks config's networkId
against it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I'll be pushing up a change that checks config's networkId against it.
not sure what do you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like that'd be a good enhancement for another issue. Is it cool if we do this in another PR?
sure, my main point here is just so that we avoid hardcoding suffixes in shell. If they are in config – they can easily be altered for a given project, etc. Probably should also be passable as argument (again so that it's easy to override when needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I just pushed up a commit that essentially suggests to the user that most of the time if they're on betanet, the account will end in .beta. But it's not blocking. We can't make it a hard requirement because of the custom TLAs, too. Good point
commands/create-account.js
Outdated
console.log(`Top-level accounts (not ending in .near, .test, etc) must be greater than ${TLA_MIN_LENGTH} characters`); | ||
return; | ||
} | ||
} else if (splitAccount.length === 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length isn't limited to 3, can be easily foo.bar.baz.alice.near
if you have bar.baz.alice.near
as masterAccount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, this is helpful feedback
commands/dev-deploy.js
Outdated
@@ -67,7 +67,7 @@ async function createDevAccountIfNeeded({ near, keyStore, networkId, init }) { | |||
} | |||
} | |||
|
|||
const accountId = `dev-${Date.now()}`; | |||
const accountId = `dev-${Date.now()}.test.near`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should take masterAccount
from config, suffix here not necessarily test.near
.
@vgrichina when you get a sec, this is ready for re-review. I just moved it out of Draft, so want to ping as I don't know if Github alerts reviewers upon that action. |
# Conflicts: # commands/create-account.js
Addresses #307.
Note that there is still an underlying issue when the test tries to deploy a contract:
Edit: resolved, see Vlad's comment below.
Edit2:
This ended up being a bit of a compromise, knowing that long-term, we'll be allowing TLA's that are based on other chains' account addresses. Yet at the same time, we want to make clear to the end user that most of the time they'll want to approach account creation as subaccounts.
Here's a list of commands run and the results to demonstrate:
./bin/near create_account hihihi --masterAccount asdf.test
results in:
./bin/near create_account hihihiveryveryverylongnamethisisunusual --masterAccount asdf.test
passes
NODE_ENV=betanet ./bin/near create_account mike.asdf.test --masterAccount asdf.test
passes but throws the message:
./bin/near create_account mike.asdf.test --masterAccount asdf.test
succeeds
./bin/near create_account hi.mike.asdf.test --masterAccount mike.asdf.test
succeeds
./bin/near create_account hi.mike.asdf.test --masterAccount mike.asdf.purvis
results in:
./bin/near create_account hi.mike.asdf.purvis --masterAccount mike.asdf.test
results in: