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

How do I get redspot to recognise Moonbeams types? #139

Closed forgetso closed 2 years ago

forgetso commented 2 years ago

Redspot Version 0.11.9-1

I have made some changes to redspot to add moonbeams types.

I then changed my config to use only moonbeam:

    networks: {
        // development: {
        //     endpoint: "ws://127.0.0.1:9944",
        //     gasLimit: "15000000",
        //     types: {},
        // },
        // jupiter: {
        //     endpoint: "wss://jupiter-poa.elara.patract.io",
        //     gasLimit: "400000000000",
        //     accounts: ["//Alice"],
        //     types: {},
        // },

        moonbeam: {
            endpoint: "ws://127.0.0.1:9944",
            gasLimit: "15000000",
            accounts: ["//Alice"],
            types: {},
        },
    },

When I run yarn test, I get a complaint about there not being a development network - which is correct. When I run yarn test --network moonbeam, it successfully connects to my node:

2021-09-09 13:35:15 Accepted a new tcp connection from 127.0.0.1:32792.
2021-09-09 13:35:15 Accepted a new tcp connection from 127.0.0.1:32794.

However, I still get a complaint about missing type data in node:

2021-09-09 14:35:17 METADATA: Unknown types found, no types for Collator, CollatorSnapshot, InflationInfo, Nominator, OrderedSet, RoundIndex, RoundInfo

Do I need to specify these types in the types section of my config as well as in this file?

atenjin commented 2 years ago

hey, will meanbeam support pallet-contracts in future? Our redspot-plugin https://docs.patract.io/en/redspot/plugin/redspot-known-types just pick the chain which contains pallet-contracts module. If you are planning to use the pallet-contracts in future, we can add your type in to this plugin

atenjin commented 2 years ago

oh it seems that I miss understand what your mean. you add your config to know-types package, and try to test?

forgetso commented 2 years ago

will meanbeam support pallet-contracts in future?

I don't know, I just wanted to get my existing redspot project working with a moonbeam development node. Is pallet-contracts required for the chain to work with redspot?

you add your config to know-types package, and try to test?

Yes, I've added the config to known types package in my fork. For example, in moonbeam.ts I have:

    Collator: {
        id: "AccountId",
        bond: "Balance",
        nominators: "Vec<Bond>",
        total: "Balance",
        state: "CollatorStatus",
    },

However, it seems these type definitions are not passed through when using yarn test like in the following example:

import {artifacts, network, patract} from "redspot";
import {expect} from "chai";

const {getContractFactory, getRandomSigner} = patract;
const {blake2AsHex, blake2AsU8a} = require('@polkadot/util-crypto');
const {stringToU8a} = require('@polkadot/util');
const {api, getAddresses, getSigners, createSigner, keyring} = network;
import "@redspot/known-types";

describe("PROSOPO", () => {
    after(() => {
        return api.disconnect();
    });

    // setup function called by all tests
    async function setup() {
        await api.isReady
        const registry = api.registry;
        const collatorDef = api.registry.getDefinition('Collator');
        console.log(collatorDef); // prints undefined
        process.exit();

  //....tests
atenjin commented 2 years ago

emm, redspot all api just support pallet-contracts interface, we have not design the support for pallet-evm. I think if you connect to moonbeam, maybe using ethereum tools is enough.

forgetso commented 2 years ago

Yeah, I should probably use hardhat for this. Thanks for the advice.