chaingate
Version:
A complete TypeScript library for connecting to and making transactions on different blockchains
55 lines • 1.81 kB
JavaScript
import { HDWallet } from './Wallet/abstract/HDWallet/HDWallet';
import { PrivateKeyWallet } from './Wallet/implementations/PrivateKeyWallet/PrivateKeyWallet';
import { SeedWallet } from './Wallet/implementations/SeedWallet/SeedWallet';
import { PhraseWallet } from './Wallet/implementations/PhraseWallet/PhraseWallet';
export class InvalidWallet extends Error {
constructor() {
super('Wallet is invalid');
if (Error.captureStackTrace)
Error.captureStackTrace(this, InvalidWallet);
this.name = this.constructor.name;
}
}
// LocalWallet
export function isLocalWallet(wallet) {
return (wallet instanceof PhraseWallet ||
wallet instanceof SeedWallet ||
wallet instanceof PrivateKeyWallet);
}
export function requireLocalWallet(wallet) {
if (!isLocalWallet(wallet))
throw new InvalidWallet();
}
// HDWallet
export function isDerivationPathsWallet(wallet) {
return wallet instanceof HDWallet;
}
export function requireDerivationPathsSupport(wallet) {
if (!isDerivationPathsWallet(wallet))
throw new InvalidWallet();
}
// ImportedPrivateKey
export function isPrivateKeyWallet(wallet) {
return wallet instanceof PrivateKeyWallet;
}
export function requirePrivateKeyWallet(wallet) {
if (!isPrivateKeyWallet(wallet))
throw new InvalidWallet();
}
// Seed wallet
export function isSeedWallet(wallet) {
return wallet instanceof SeedWallet;
}
export function requireSeedWallet(wallet) {
if (!isSeedWallet(wallet))
throw new InvalidWallet();
}
// Phrase wallet
export function isPhraseWallet(wallet) {
return wallet instanceof PhraseWallet;
}
export function requirePhraseWallet(wallet) {
if (!isPhraseWallet(wallet))
throw new InvalidWallet();
}
//# sourceMappingURL=CastWallet.js.map