Skip to content

Commit

Permalink
feat-issue-123: add rpc url env to replace default rpc url
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringChiu authored and fospring committed Sep 7, 2023
1 parent fcb029b commit 9498a1f
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 16 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,18 @@ Pro Tips
* specify which port to run on

* and more!

Env variables
========
```text
NEAR_CLI_MAINNET_RPC_SERVER_URL
NEAR_CLI_TESTNET_RPC_SERVER_URL
```
Clear them in case you want to get back to the default RPC server.

Example:

```shell
export NEAR_CLI_MAINNET_RPC_SERVER_URL=<put_your_rpc_server_url_here>
```
here is a testcase: [jsonrpc.ava.js](./packages/js/__tests__/jsonrpc.ava.js)
10 changes: 10 additions & 0 deletions packages/js/__tests__/jsonrpc.ava.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import test from "ava";

Check failure on line 1 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote.
import {JsonRpcProvider} from "..";

Check failure on line 2 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote.

test("check url", async (t) => {

Check failure on line 4 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote.

Check failure on line 4 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Function was declared as `async` but doesn't use `await`.

Check failure on line 4 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected parentheses around single function argument.
const provider = JsonRpcProvider.fromNetwork("mainnet");

Check failure on line 5 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote.
if (process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL) {

Check failure on line 6 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected use of the global variable 'process'. Use 'require("process")' instead.
console.log("use rpc", process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL);

Check failure on line 7 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote.

Check failure on line 7 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Multiple spaces found before 'process'.

Check failure on line 7 in packages/js/__tests__/jsonrpc.ava.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected use of the global variable 'process'. Use 'require("process")' instead.
t.is(provider.connection.url, process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL.toString());
}
});
2 changes: 1 addition & 1 deletion packages/js/dist/account/account-manager.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/js/dist/account/account-manager.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9498a1f

Please sign in to comment.