mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-10 22:05:55 +00:00
fix(@cockpit/console): show contract names in the suggestions list
Update event name `"deploy:contract:deployed"` to `"deployment:contract:deployed"`. Also, listen one time for `"deployment:deployContracts:afterAll"` and then request the full contracts list so as to pickup contract names that were already deployed. This is necessary for subsequent `embark run` (without reset), otherwise the suggestions list will be missing contracts.
This commit is contained in:
parent
7b991bb58a
commit
4ee900480d
@ -1,4 +1,4 @@
|
|||||||
import { Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark";
|
import { Contract, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark";
|
||||||
import { fuzzySearch } from "embark-utils";
|
import { fuzzySearch } from "embark-utils";
|
||||||
import { suggestions as defaultSuggestions } from "../../suggestions.json";
|
import { suggestions as defaultSuggestions } from "../../suggestions.json";
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export default class Suggestions {
|
|||||||
|
|
||||||
this._suggestions = [...Suggestions.DEFAULT_SUGGESTIONS];
|
this._suggestions = [...Suggestions.DEFAULT_SUGGESTIONS];
|
||||||
|
|
||||||
Object.values(this.contracts).forEach((contract: any) => {
|
Object.values(this.contracts).forEach((contract: Contract) => {
|
||||||
this._suggestions.push({value: contract.className, command_type: "web3 object", description: "contract deployed at " + contract.deployedAddress});
|
this._suggestions.push({value: contract.className, command_type: "web3 object", description: "contract deployed at " + contract.deployedAddress});
|
||||||
this._suggestions.push({value: "profile " + contract.className, command_type: "embark command", description: "profile " + contract.className + " contract"});
|
this._suggestions.push({value: "profile " + contract.className, command_type: "embark command", description: "profile " + contract.className + " contract"});
|
||||||
});
|
});
|
||||||
@ -71,11 +71,17 @@ export default class Suggestions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private listenToEvents() {
|
private listenToEvents() {
|
||||||
this.events.on("deploy:contract:deployed", (contract: any) => {
|
this.embark.events.once("deployment:deployContracts:afterAll", () => {
|
||||||
this.contracts[contract.className] = contract;
|
this.events.on("deployment:contract:deployed", ({contract}: {contract: Contract}) => {
|
||||||
|
this.contracts[contract.className] = contract;
|
||||||
|
// reset backing variable so contracts suggestions can be re-built for next request
|
||||||
|
this._suggestions = [];
|
||||||
|
});
|
||||||
|
|
||||||
// reset backing variable so contracts suggestions can be re-built for next request
|
this.embark.events.request("contracts:list", (_: any, contracts: Contract[]) => {
|
||||||
this._suggestions = [];
|
contracts.forEach((contract) => { this.contracts[contract.className] = contract; });
|
||||||
|
this._suggestions = [];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user