Skip to content

Commit

Permalink
Merge pull request #231 from shariffdev/feat/api-key
Browse files Browse the repository at this point in the history
feat: api key and custom network
  • Loading branch information
fospring authored Mar 17, 2024
2 parents aed5339 + 542fa42 commit abb5d6f
Show file tree
Hide file tree
Showing 22 changed files with 271 additions and 26 deletions.
40 changes: 40 additions & 0 deletions __tests__/08.custom-network.ava.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import process from 'process';
import {Worker, getNetworkFromEnv} from 'near-workspaces';
import anyTest, {TestFn} from 'ava';

// To run this test, you need to set the NEAR_RPC_API_KEY environment variable tied the Pagoda testnet network.
// And the NEAR_WORKSPACES_NETWORK environment variable to 'custom'.
//
// Sample: NEAR_WORKSPACES_NETWORK=custom NEAR_RPC_API_KEY="xxx" yarn test...
if (getNetworkFromEnv() === 'custom' && process.env.NEAR_RPC_API_KEY !== '') {
const test = anyTest as TestFn<{
worker: Worker;
}>;

test.before(async t => {
const worker = await Worker.init({
network: 'custom',
rpcAddr: 'https://near-testnet.api.pagoda.co/rpc/v1/',
apiKey: process.env.NEAR_RPC_API_KEY!,
});
t.context.worker = worker;
});

test.after.always(async t => {
await t.context.worker.tearDown().catch(error => {
console.log('Failed to tear down the worker:', error);
});
});

test('Ping network', async t => {
try {
await t.context.worker.provider.block({finality: 'final'});
} catch (error: unknown) {
t.fail(`Failed to ping the network: ${error as string}`);
return;
}

t.pass('Network pinged successfully!');
});
}

8 changes: 8 additions & 0 deletions packages/js/dist/account/account-manager.d.ts

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/account/account-manager.d.ts.map

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

27 changes: 25 additions & 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 abb5d6f

Please sign in to comment.