@q-dev/q-ts-gdk-sdk
Version:
Typescript Library to interact with GDK Contracts
34 lines (26 loc) • 994 B
text/typescript
import Web3 from "web3";
import { InputOptions } from "@truffle/hdwallet-provider/dist/constructor/Constructor";
import HDWalletProvider from "@truffle/hdwallet-provider";
export class QSdkProvider extends HDWalletProvider {
constructor(public readonly hdWalletConfig: InputOptions) {
super(hdWalletConfig);
}
}
export class Web3Factory {
public static getVersion(): string {
return "test version";
}
public static createWeb3(hdWalletConfig: InputOptions): Web3 {
const provider = new QSdkProvider(hdWalletConfig);
const web3 = new Web3(provider);
web3.eth.handleRevert = true;
console.debug(`created web3 v${web3.version}`);
return web3;
}
public static createFromMnemonic(providerOrUrl: string, mnemonic: string): Web3 {
return this.createWeb3({ providerOrUrl, mnemonic });
}
public static createFromPrivateKeys(providerOrUrl: string, ...privateKeys: string[]): Web3 {
return this.createWeb3({ providerOrUrl, privateKeys });
}
}