Skip to content

Commit

Permalink
Merge pull request #217 from fospring/feat-issue-123/use-proxy-address
Browse files Browse the repository at this point in the history
feat-issue-123: add rpc url env to replace default rpc url
  • Loading branch information
ailisp authored Sep 11, 2023
2 parents 5509fac + a9e510d commit dada180
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 14 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)
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

0 comments on commit dada180

Please sign in to comment.