mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-12 03:54:13 +00:00
c0cd668c64
* Layed out components for custom nodes. * Outline of custom nodes. Still missing various features and error handling. * Persist custom nodes to local storage. * Make custom nodes removable. * Add latest block functions, call it when switching nodes. * Initialize correct node, move node utils into utils file. * Fix names * Send headers along with rpc requests. * Remove custom network options for now. * PR feedback. * One last log. * Fix tests. * Headers in batch too. * Switch to node when you add it. * Reduce hackery. * Clean up linter and tsc. * Fix latest block hex conversion. * Unit tests. * Fix missing property. * Fix Modal title typing.
19 lines
548 B
TypeScript
19 lines
548 B
TypeScript
import RPCNode from '../rpc';
|
|
import RPCClient from '../rpc/client';
|
|
import { CustomNodeConfig } from 'config/data';
|
|
|
|
export default class CustomNode extends RPCNode {
|
|
constructor(config: CustomNodeConfig) {
|
|
const endpoint = `${config.url}:${config.port}`;
|
|
super(endpoint);
|
|
|
|
const headers: { [key: string]: string } = {};
|
|
if (config.auth) {
|
|
const { username, password } = config.auth;
|
|
headers.Authorization = `Basic ${btoa(`${username}:${password}`)}`;
|
|
}
|
|
|
|
this.client = new RPCClient(endpoint, headers);
|
|
}
|
|
}
|