Skip to content

Commit

Permalink
fix: fix /test/config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
gtsonevv committed Apr 19, 2024
1 parent d75ce67 commit 8480fa6
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions packages/near-api-js/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,50 @@ const fs = require('fs');
let worker;
module.exports = async function getConfig(env) {
switch (env) {
case 'production':
case 'mainnet':
return {
networkId: 'mainnet',
nodeUrl: 'https://rpc.mainnet.near.org',
walletUrl: 'https://wallet.near.org',
helperUrl: 'https://helper.mainnet.near.org',
};
case 'development':
case 'testnet':
return {
networkId: 'default',
nodeUrl: 'https://rpc.testnet.near.org',
walletUrl: 'https://wallet.testnet.near.org',
helperUrl: 'https://helper.testnet.near.org',
masterAccount: 'test.near',
};
case 'betanet':
return {
networkId: 'betanet',
nodeUrl: 'https://rpc.betanet.near.org',
walletUrl: 'https://wallet.betanet.near.org',
helperUrl: 'https://helper.betanet.near.org',
};
case 'local':
return {
networkId: 'local',
nodeUrl: 'http://localhost:3030',
keyPath: `${process.env.HOME}/.near/validator_key.json`,
walletUrl: 'http://localhost:4000/wallet',
};
case 'test':
case 'ci':
if (!worker) worker = await Worker.init();
const keyFile = fs.readFileSync(`${worker.rootAccount.manager.config.homeDir}/validator_key.json`);
const keyPair = JSON.parse(keyFile.toString());
return {
networkId: worker.config.network,
nodeUrl: worker.manager.config.rpcAddr,
masterAccount: worker.rootAccount._accountId,
secretKey: keyPair.secret_key || keyPair.private_key
};
default:
throw Error(`Unconfigured environment '${env}'. Can be configured in src/config.js.`);
case 'production':
case 'mainnet':
return {
networkId: 'mainnet',
nodeUrl: 'https://rpc.mainnet.near.org',
walletUrl: 'https://wallet.near.org',
helperUrl: 'https://helper.mainnet.near.org',
};
case 'development':
case 'testnet':
return {
networkId: 'default',
nodeUrl: 'https://rpc.testnet.near.org',
walletUrl: 'https://wallet.testnet.near.org',
helperUrl: 'https://helper.testnet.near.org',
masterAccount: 'test.near',
};
case 'betanet':
return {
networkId: 'betanet',
nodeUrl: 'https://rpc.betanet.near.org',
walletUrl: 'https://wallet.betanet.near.org',
helperUrl: 'https://helper.betanet.near.org',
};
case 'local':
return {
networkId: 'local',
nodeUrl: 'http://localhost:3030',
keyPath: `${process.env.HOME}/.near/validator_key.json`,
walletUrl: 'http://localhost:4000/wallet',
};
case 'test':
case 'ci': {
if (!worker) worker = await Worker.init();
const keyFile = fs.readFileSync(`${worker.rootAccount.manager.config.homeDir}/validator_key.json`);
const keyPair = JSON.parse(keyFile.toString());
return {
networkId: worker.config.network,
nodeUrl: worker.manager.config.rpcAddr,
masterAccount: worker.rootAccount._accountId,
secretKey: keyPair.secret_key || keyPair.private_key
};
}
default:
throw Error(`Unconfigured environment '${env}'. Can be configured in src/config.js.`);
}
};

0 comments on commit 8480fa6

Please sign in to comment.