Skip to content

Commit

Permalink
remove "http://" from provider Url (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkent600 authored Sep 14, 2018
1 parent 7a398fe commit 6dc6b6a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"live": 20
},
"providerPort": 8545,
"providerUrl": "http://127.0.0.1",
"providerUrl": "127.0.0.1",
"globalGenTokenAddresses": {
"default": "0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf",
"ganache": "0xdcf22b53f327b4f7f3ac42d957834bd962637555"
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Name of the blockchain network used during Arc contract migration. Other inform
The port to use when connecting to the blockchain network at runtime. Default is 8545.

**providerUrl**
The url to use when connecting to the blockchain network at runtime. Default is http://127.0.0.1.
The url to use when connecting to the blockchain network at runtime. Default is "127.0.0.1".

<a name="txDepthRequiredForConfirmation"></a>
**txDepthRequiredForConfirmation**
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function InitializeArcJs(options?: InitializeArcOptions): Promise<W
}

ConfigService.set("providerPort", networkDefaults.port);
ConfigService.set("providerUrl", `http://${networkDefaults.host}`);
ConfigService.set("providerUrl", `${networkDefaults.host}`);
}

const web3 = await Utils.getWeb3();
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export class Utils {
// then avoid time-consuming and futile retry
throw new Error("Utils.getWeb3: already tried and failed");
} else {
let url = ConfigService.get("providerUrl");
let url = `http://${ConfigService.get("providerUrl")}`;
const port = ConfigService.get("providerPort");
if (port) {
url = `${url}:${port}`;
}
/* tslint:disable-next-line:max-line-length */
LoggingService.debug(`Utils.getWeb3: instantiating web3 with configured provider at ${url}`);
// No web3 is injected, look for a provider at providerUrl:providerPort (which defaults to http://127.0.0.1)
// No web3 is injected, look for a provider at providerUrl:providerPort (which defaults to 127.0.0.1)
// This happens when running tests, or in a browser that is not running MetaMask
preWeb3 = new webConstructor(new Web3Providers.HttpProvider(url));
}
Expand Down
10 changes: 5 additions & 5 deletions test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import "./helpers";

describe("ConfigService", () => {
it("can get and set configuration values", () => {
assert.equal(ConfigService.get("providerUrl"), "http://127.0.0.1");
ConfigService.set("providerUrl", "http://localhost");
assert.equal(ConfigService.get("providerUrl"), "http://localhost");
assert.equal(ConfigService.get("providerUrl"), "127.0.0.1");
ConfigService.set("providerUrl", "localhost");
assert.equal(ConfigService.get("providerUrl"), "localhost");
});

it("doesn't reload default values when imported again", () => {
const newConfigService = require("../lib/configService").ConfigService;
assert.equal(newConfigService.get("providerUrl"), "http://localhost");
ConfigService.set("providerUrl", "http://127.0.0.1");
assert.equal(newConfigService.get("providerUrl"), "localhost");
ConfigService.set("providerUrl", "127.0.0.1");
});

it("can specify gasPrice", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("InitializeArcJs", () => {

it("initializes default network params", async () => {
await InitializeArcJs({ useNetworkDefaultsFor: "kovan" });
assert.equal(ConfigService.get("providerUrl"), "http://127.0.0.1");
assert.equal(ConfigService.get("providerUrl"), "127.0.0.1");
assert.equal(ConfigService.get("providerPort"), 8547);
});
});
Expand Down

0 comments on commit 6dc6b6a

Please sign in to comment.