fix: add testnetChannelEndpoint()

This commit is contained in:
Michael Vines
2018-12-19 19:28:28 -08:00
parent b5d058e88f
commit 62c1efc955
8 changed files with 69 additions and 14 deletions

View File

@@ -13,3 +13,4 @@ export {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
export {
sendAndConfirmRawTransaction,
} from './util/send-and-confirm-raw-transaction';
export {testnetChannelEndpoint} from './util/testnet';

View File

@@ -168,11 +168,13 @@ export class Transaction {
programIds.push(programId);
}
instruction.keys.map(key => key.toString()).forEach(key => {
if (!keys.includes(key)) {
keys.push(key);
}
});
instruction.keys
.map(key => key.toString())
.forEach(key => {
if (!keys.includes(key)) {
keys.push(key);
}
});
});
const instructions = this.instructions.map(instruction => {

View File

@@ -0,0 +1,27 @@
//@flow
import {testnetDefaultChannel} from '../../package.json';
/**
* @private
*/
const endpoint = {
edge: 'https://api.edge.testnet.solana.com',
beta: 'https://api.beta.testnet.solana.com',
stable: 'https://api.testnet.solana.com',
};
/**
* Retrieves the RPC endpoint URL for the specified testnet release
* channel
*/
export function testnetChannelEndpoint(channel?: string): string {
if (!channel) {
return endpoint[testnetDefaultChannel];
}
if (endpoint[channel]) {
return endpoint[channel];
}
throw new Error(`Unknown channel: ${channel}`);
}