fix: add testnetChannelEndpoint()
This commit is contained in:
@@ -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';
|
||||
|
@@ -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 => {
|
||||
|
27
web3.js/src/util/testnet.js
Normal file
27
web3.js/src/util/testnet.js
Normal 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}`);
|
||||
}
|
Reference in New Issue
Block a user