Skip to content

Commit abb5d6f

Browse files
authored
Merge pull request #231 from shariffdev/feat/api-key
feat: api key and custom network
2 parents aed5339 + 542fa42 commit abb5d6f

22 files changed

+271
-26
lines changed

__tests__/08.custom-network.ava.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import process from 'process';
2+
import {Worker, getNetworkFromEnv} from 'near-workspaces';
3+
import anyTest, {TestFn} from 'ava';
4+
5+
// To run this test, you need to set the NEAR_RPC_API_KEY environment variable tied the Pagoda testnet network.
6+
// And the NEAR_WORKSPACES_NETWORK environment variable to 'custom'.
7+
//
8+
// Sample: NEAR_WORKSPACES_NETWORK=custom NEAR_RPC_API_KEY="xxx" yarn test...
9+
if (getNetworkFromEnv() === 'custom' && process.env.NEAR_RPC_API_KEY !== '') {
10+
const test = anyTest as TestFn<{
11+
worker: Worker;
12+
}>;
13+
14+
test.before(async t => {
15+
const worker = await Worker.init({
16+
network: 'custom',
17+
rpcAddr: 'https://near-testnet.api.pagoda.co/rpc/v1/',
18+
apiKey: process.env.NEAR_RPC_API_KEY!,
19+
});
20+
t.context.worker = worker;
21+
});
22+
23+
test.after.always(async t => {
24+
await t.context.worker.tearDown().catch(error => {
25+
console.log('Failed to tear down the worker:', error);
26+
});
27+
});
28+
29+
test('Ping network', async t => {
30+
try {
31+
await t.context.worker.provider.block({finality: 'final'});
32+
} catch (error: unknown) {
33+
t.fail(`Failed to ping the network: ${error as string}`);
34+
return;
35+
}
36+
37+
t.pass('Network pinged successfully!');
38+
});
39+
}
40+

packages/js/dist/account/account-manager.d.ts

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/js/dist/account/account-manager.d.ts.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/js/dist/account/account-manager.js

+25-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)