0

I am upgrading the DAO to use version 4 of the near sdk. During the migration I needed to change the way the AccountId struct was used, from being a string to being a struct that holds a string.

The original test has a token id of an empty string, "" assigned to a const which cannot be converted to a struct instance because instantiating a struct isn't constant. An empty string "" now raises a panic because it isn't a proper account id (it must have lowercase letters and numbers with a period, among other things).

I changed it to base.token and added constructors where there were strings before.

Here is my code: https://github.com/roshkins/sputnik-dao-contract

I'm getting this error:

---- test_multi_council stdout ----
thread 'test_multi_council' panicked at 'Outcome ExecutionOutcome {     
    logs: [],
    receipt_ids: [
        `6MxMk3XY6o2VnL4DucLADm86gUJPJHDfecQQ9hUDA72X`,
        `7k1jV711STFLKdbznRCvXr27UxJ2WwgZfnoGiZiFrEKm`,
    ],
    burnt_gas: 2428070807578,
    tokens_burnt: 242807080757800000000,
    status: Failure(Action #0: Can't complete the action because account "base.token" doesn't exist),

If I add an account called "base.token" it throws an error because it's a sub account. I tried changing the accountid of the contract to base.token that also throws that error. Any help?

Edit: I was able to add the following code to change the root account name to base.token: let mut gen_cfg = GenesisConfig::default(); gen_cfg.init_root_signer(base_token().as_str());

I get a slightly different error now:

thread 'test_multi_council' panicked at 'Outcome ExecutionOutcome {
    logs: [],
    receipt_ids: [
        `6MxMk3XY6o2VnL4DucLADm86gUJPJHDfecQQ9hUDA72X`,
        `7k1jV711STFLKdbznRCvXr27UxJ2WwgZfnoGiZiFrEKm`,
    ],
    burnt_gas: 2428070807578,
    tokens_burnt: 242807080757800000000,
    status: Failure(Action #0: cannot find contract code for account base.token),
} was a failure',
Rashi Abramson
  • 1,127
  • 8
  • 16
  • 1
    I didn't downvote it, but do you have any more context about what you have done with the DAO before getting to this error? Are you following along with any guide? Thanks! – starpause Sep 01 '21 at 05:55
  • I added a link to my code and some context. – Rashi Abramson Sep 01 '21 at 19:10
  • 1
    Thanks! I think the problem is that base.token doesn't exist. Have you created the token yet? Here is some very WIP documentation which includes token creation and adopting the token for voting: https://hackmd.io/lMmmRVXASuGf9Xrx75Pmlw – starpause Sep 01 '21 at 20:15

1 Answers1

1

For sub-accounts, you can only create an account if you have keys to the root account. So if you owned token TLA (top-level account) you could create base.token. So you could have token.near as an accountId and then you would be able to create base.token.near. Does that make sense?

Here is some more info on the account model: https://docs.near.org/docs/concepts/account#subaccounts

Josh Ford
  • 316
  • 1
  • 3
  • Makes sense. I ended up going in a different direction which resolved this test. It turns out that the code relied on strings not being converted to the AccountId struct, and that fixed the errors. – Rashi Abramson Sep 03 '21 at 15:31