Permalink
Browse files

Rename the Buidler Runtime Environment's provider to `ethereum` (#174)

* Remove unneeded tslint directive

* Rename the Buidler Runtime Environment's provider to ethereum
  • Loading branch information...
alcuadrado committed Feb 7, 2019
1 parent 771ecde commit f3b4f245ad1ac0f9961f2331a33318ee9535e998
@@ -1,7 +1,7 @@
task("accounts", "Prints a list of the available accounts", async taskArgs => {
const accounts = await env.provider.send("eth_accounts");
task("accounts", "Prints a list of the available accounts", async () => {
const accounts = await ethereum.send("eth_accounts");

console.log("Accounts:", accounts);
});
console.log("Accounts:", accounts);
});

module.exports = {};
@@ -1,9 +1,10 @@
// We require the Buidler Runtime Environment explicitly here. This is optional.
const env = require("@nomiclabs/buidler");

async function main() {
await env.run("compile");

const accounts = await env.provider.send("eth_accounts");
const accounts = await env.ethereum.send("eth_accounts");

console.log("Accounts:", accounts);
}
@@ -2,7 +2,7 @@ const assert = require("assert");

describe("Ethereum provider", function() {
it("Should return the accounts", async function() {
const accounts = await provider.send("eth_accounts");
const accounts = await ethereum.send("eth_accounts");
assert(accounts.length !== 0, "No account was returned");
});
});
@@ -22,15 +22,15 @@ export class Environment implements BuidlerRuntimeEnvironment {
"runTaskDefinition"
];

public provider: IEthereumProvider;
public ethereum: IEthereumProvider;

constructor(
public readonly config: ResolvedBuidlerConfig,
public readonly buidlerArguments: BuidlerArguments,
public readonly tasks: TasksMap,
private readonly extenders: EnvironmentExtender[] = []
) {
this.provider = lazyObject(() =>
this.ethereum = lazyObject(() =>
createProvider(buidlerArguments.network, config.networks)
);

@@ -1,4 +1,3 @@
// tslint:disable-next-line no-implicit-dependencies
import { DeepPartial, Omit } from "ts-essentials";
import { EthereumProvider } from "web3x/providers";

@@ -227,7 +226,7 @@ export type ActionType<ArgsT extends TaskArguments> = (
export type IEthereumProvider = EthereumProvider;

export interface BuidlerRuntimeEnvironment {
readonly provider: IEthereumProvider;
readonly ethereum: IEthereumProvider;
readonly config: ResolvedBuidlerConfig;
readonly buidlerArguments: BuidlerArguments;
readonly tasks: TasksMap;
@@ -65,7 +65,7 @@ describe("Environment", () => {
it("should create an environment", () => {
assert.deepEqual(env.config, config);
assert.isDefined(env.tasks);
assert.isDefined(env.provider);
assert.isDefined(env.ethereum);
});

it("should run a task correctly", async () => {

0 comments on commit f3b4f24

Please sign in to comment.