Misc Playground/Docs fixes
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilationOptions": {
|
||||
"followSymlinks": true
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"filePath": "./src/index.ts",
|
||||
"outFile": "./dist/types-bundled.d.ts",
|
||||
"libraries": {
|
||||
"inlinedLibraries": ["@xocash/primitives"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@bitauth/libauth": "^3.0.0",
|
||||
"@electrum-cash/network": "^4.1.1",
|
||||
"@electrum-cash/protocol": "2.1.0-development.8075178089",
|
||||
"@generalprotocols/oracle-client": "^0.0.1",
|
||||
@@ -45,7 +46,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.12",
|
||||
"dts-bundle-generator": "^9.5.1",
|
||||
"rollup": "^4.45.0",
|
||||
"rollup-plugin-dts": "^6.2.1"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// NOTE: This file is used to build type bundles for use with the XO Stack playground.
|
||||
// The XO Stack Playground uses Monaco Editor - which requires that types are all bundled in a single file.
|
||||
// (Technically, we can load many individual files, but resolution is incredibly slow and complex)
|
||||
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import { defineConfig } from 'rollup';
|
||||
import pkg from './package.json' with { type: 'json' };
|
||||
|
||||
export default defineConfig({
|
||||
input: 'dist/index.d.ts',
|
||||
@@ -7,5 +12,13 @@ export default defineConfig({
|
||||
file: 'dist/types-bundled.d.ts',
|
||||
format: 'es',
|
||||
},
|
||||
// Omit all dependencies and peer dependencies from the final type bundle.
|
||||
// TODO: We may actually want to include these, but are unable to get it to work currently.
|
||||
// The advantage would be that we can produce bundles that also contain dependent types.
|
||||
// For example: LibAuth, Electrum-Network, etc.
|
||||
external: [
|
||||
...Object.keys(pkg.dependencies || {}),
|
||||
...Object.keys(pkg.peerDependencies || {}),
|
||||
],
|
||||
plugins: [dts()],
|
||||
});
|
||||
|
||||
@@ -48,13 +48,9 @@ export type BlockchainElectrumEvents = {
|
||||
};
|
||||
|
||||
export type BlockchainElectrumOpts = {
|
||||
servers: Array<string>;
|
||||
application: string;
|
||||
};
|
||||
|
||||
export type BlockchainElectrumParams = {
|
||||
store?: BaseStore;
|
||||
opts?: Partial<BlockchainElectrumOpts>;
|
||||
servers?: Array<string>;
|
||||
application?: string;
|
||||
};
|
||||
|
||||
export class BlockchainElectrum extends BaseBlockchain<
|
||||
@@ -82,24 +78,20 @@ export class BlockchainElectrum extends BaseBlockchain<
|
||||
|
||||
// Options
|
||||
store: BaseStore;
|
||||
opts: BlockchainElectrumOpts;
|
||||
servers: Array<string>;
|
||||
application: string;
|
||||
|
||||
constructor(public readonly params: BlockchainElectrumParams = {}) {
|
||||
constructor(public readonly opts: BlockchainElectrumOpts = {}) {
|
||||
super();
|
||||
|
||||
// Set the store, or use the memory store by default.
|
||||
this.store = params.store ?? new StoreInMemory();
|
||||
|
||||
// Combine provided options with default options.
|
||||
this.opts = {
|
||||
servers: [
|
||||
'bch.imaginary.cash',
|
||||
'cashnode.bch.ninja',
|
||||
'electrum.imaginary.cash',
|
||||
],
|
||||
application: 'XOApp',
|
||||
...params.opts,
|
||||
};
|
||||
this.store = opts.store ?? new StoreInMemory();
|
||||
this.servers = opts.servers ?? [
|
||||
'bch.imaginary.cash',
|
||||
'cashnode.bch.ninja',
|
||||
'electrum.imaginary.cash',
|
||||
];
|
||||
this.application = opts.application ?? 'XOApp';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,9 +101,9 @@ export class BlockchainElectrum extends BaseBlockchain<
|
||||
*/
|
||||
static async from<T extends typeof BlockchainElectrum>(
|
||||
this: T,
|
||||
params: BlockchainElectrumParams = {},
|
||||
opts: BlockchainElectrumOpts = {},
|
||||
) {
|
||||
const blockchain = new this(params);
|
||||
const blockchain = new this(opts);
|
||||
|
||||
await blockchain.start();
|
||||
|
||||
@@ -125,10 +117,10 @@ export class BlockchainElectrum extends BaseBlockchain<
|
||||
// Iterate over each server in our list of servers.
|
||||
// NOTE: We are still using an Electrum Client due to the above bug.
|
||||
// But, if we cannot connect to the first server, we will try the second (and third if given, etc) as a fallback.
|
||||
for (const electrumServer of this.opts.servers) {
|
||||
for (const electrumServer of this.servers) {
|
||||
// Initialize an Electrum client using the given server.
|
||||
const electrum = await initializeElectrumClient(
|
||||
this.opts.application,
|
||||
this.application,
|
||||
electrumServer,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user