Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat-issue-123: add rpc url env to replace default rpc url #217

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading