patractlabs / redspot

Redspot is an Substrate pallet-contracts (ink!) development environment. Compile your contracts and run them on a different networks. Redspot's core forks from Hardhat but changed a lot to suit substrate.
https://redspot.patract.io/
Other
67 stars 22 forks source link

correct ss58Format according to connected blockchain #76

Closed RoyTimes closed 3 years ago

RoyTimes commented 3 years ago

I have been using https://github.com/patractlabs/patract to run a local blockchain node. While Patract is using ss58 prefix 26, I seems to get a ss58 prefix 42 address from signer.address

To reproduce: seed phrase: collect fiscal multiply word slice milk ahead donkey often filter cliff ancient signer.address: 5CLkFCxF1FcQ3oT9KmhpSx8YmZu3eJydG3d7CogxmcnxDvkF which seems to be a ss58Format 42

From packages/redspot-core/src/provider/construction.ts

  const keyring = new Keyring({
    type: 'sr25519',
    //ss58Format: 26
  });

while the ss58Format is not set and I assume Polkadot.js set it to 42 by default. To query const system.ss58Prefix: u8 which will yield the correct prefix.

I'm not sure if I'm understanding it right or just being an idiot. Please let me know. I can draft up a PR if this is indeed an issue.

ii-ii-ii commented 3 years ago

Yes, this is a bug. api.registry.chainSS58 will be set correctly after api.isReady. But the keyring's ss58 doesn't seem to be set. I'm not sure if I should override the api.isReady method and add keyring.setSS58Format(...) to api.isReady. I would like api.registry.chainSS58 and keyring.ss58 to be consistent. Feel free to submit pr.

RoyTimes commented 3 years ago

I'm also getting TypeError: Cannot read property 'blockWeights' of undefined from node_modules/@redspot/patract/contract.js:28:59) on populateTransaction. When I went into the source of it and tried to print out contract.api.const at https://github.com/patractlabs/redspot/blob/8379e0ed8f1012f0f6acc58e34e4cb153f04c45d/packages/redspot-patract/src/contract.ts#L65 ... it's printing out {}

These are unknown territories of mine but I would guess these two issues are linked.

ii-ii-ii commented 3 years ago

I'm afraid they may not be linked to each other. I wasn't able to reproduce the problem, and I think it's possible that it was caused by some modification you made.

RoyTimes commented 3 years ago

The TypeError: Cannot read property 'blockWeights' of undefined was triggered when I tried to run a script w/npx redspot run script/script.ts. npx redspot test works fine.

I'll look into it this week and try to figure out what's happening. Will update here if I can give instructions to reproduce or figure out how I caused the error myself.

ii-ii-ii commented 3 years ago

ok, Note that to use the api, await api.isReady first;

ii-ii-ii commented 3 years ago

Fixed in version 0.10.2-6 https://github.com/patractlabs/redspot/commit/ab1cba018055a7815046aba3d1de8172d0a2cc57