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 all commits
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)
13 changes: 13 additions & 0 deletions packages/js/__tests__/jsonrpc.ava.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import process from 'process';

import test from 'ava';

import {JsonRpcProvider} from '..';

test('check url', t => {
const provider = JsonRpcProvider.fromNetwork('mainnet');
if (process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL) {
console.log('use rpc', process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL);
t.is(provider.connection.url, process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL.toString());
}
});
2 changes: 1 addition & 1 deletion packages/js/dist/jsonrpc.d.ts.map

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

8 changes: 6 additions & 2 deletions packages/js/dist/jsonrpc.js

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

2 changes: 1 addition & 1 deletion packages/js/dist/jsonrpc.js.map

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

2 changes: 1 addition & 1 deletion packages/js/dist/transaction.d.ts.map

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

4 changes: 3 additions & 1 deletion packages/js/dist/transaction.js

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

Loading
Loading