nujan-io / nujan-ide

Web IDE, powered by Nujan, is your ultimate browser-based IDE designed to simplify the journey of writing, testing, compiling, deploying, and interacting with smart contracts on TON. Write smart contracts from anywhere, No setups, no downloads, just pure convenience and versatility.
https://ide.nujan.io
Other
112 stars 12 forks source link

Nujan ide website cannot reference a contract in another file in one file #4

Closed ichewm closed 6 months ago

ichewm commented 10 months ago

a.tact file

import "@stdlib/deploy";
import "./b.tact";

message HiFromParent {
    greeting: String;
}

// we have one instance of the parent
contract TodoParent with Deployable {

    init() {}

    receive("greet 3") {
        let i: Int = 0;
        repeat (3) {
            i = i + 1;
            let init: StateInit = initOf TodoChild(i);
            send(SendParameters{
                to: contractAddress(init),
                body: HiFromParent{greeting: "darling"}.toCell(),
                value: ton("0.1"),              // pay for message and potential deployment
                mode: SendIgnoreErrors,
                code: init.code,                // if child is not deployed, also deploy it
                data: init.data
            });
        }
    }

    receive(msg: HiFromChild) {
        dump("😑 handling hi from child");
        dump(msg.fromSeqno);
    }
}

b.tact file

message HiFromChild {
    fromSeqno: Int as uint64;
    greeting: String;
}

message HiFromParent {
    greeting: String;
}

// we have multiple instances of the children
contract TodoChild {

    seqno: Int as uint64;

    // when deploying an instance, we must specify its index (sequence number)
    init(seqno: Int) {
        self.seqno = seqno;
    }

    receive(msg: HiFromParent) {
        dump(self.seqno);
        dump("😃 handling hi from parent");
        self.reply(HiFromChild{fromSeqno: self.seqno, greeting: "sup"}.toCell());
    }
}

The build error is displayed as Could not resolve import ./b.tact in a.tact

This kind of introduction method can be implemented in vscode import "./b";

image

rahulyadav-57 commented 6 months ago

This has been resolved.