Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HarmonyExtension

Hierarchy

  • HarmonyExtension

Index

Constructors

constructor

  • new HarmonyExtension(wallet: ExtensionInterface, config?: HarmonyConfig): HarmonyExtension
  • Create an blockchain instance support wallet injection

    example
    // Using Mathwallet instance
    export const initEx = async() => {
      hmyEx = new HarmonyExtension(window.harmony);
    }
    // Using OneWallet instance
    export const initEx = async() => {
      hmyEx = new HarmonyExtension(window.onewallet);
    }

    Parameters

    • wallet: ExtensionInterface

      could be MathWallet or OneWallet instance

    • Default value config: HarmonyConfig = {chainId: utils.defaultConfig.Default.Chain_ID,chainType: utils.defaultConfig.Default.Chain_Type,}

      (optional), using default Chain_Id and Chain_Type

    Returns HarmonyExtension

Methods

isExtension

  • isExtension(wallet: ExtensionInterface): void
  • Parameters

    • wallet: ExtensionInterface

    Returns void

login

  • login(): Promise<ExtensionAccount>
  • Get the wallet account

    example
    const account = hmyEx.login();
    console.log(account);

    Returns Promise<ExtensionAccount>

logout

  • logout(): Promise<void>
  • Log out the wallet account

    example
    hmyEx.logout();

    Returns Promise<void>

setProvider

  • Will change the provider for its module.

    example
    const tmp = hmyEx.setProvider('http://localhost:9500');

    Parameters

    • provider: string | HttpProvider | WSProvider

      a valid provider, you can replace it with your own working node

    Returns void

setShardID

  • setShardID(shardID: number): void
  • Change the Shard ID

    example
    hmyEx.setShardID(2);

    Parameters

    • shardID: number

    Returns void

shardingStructures

  • shardingStructures(shardingStructures: ShardingItem[]): void
  • Set the sharding Structure

    example
    hmyEx.shardingStructures([
      {"current":true,"http":"http://127.0.0.1:9500",
       "shardID":0,"ws":"ws://127.0.0.1:9800"},
      {"current":false,"http":"http://127.0.0.1:9501",
       "shardID":1,"ws":"ws://127.0.0.1:9801"}
    ]);

    Parameters

    • shardingStructures: ShardingItem[]

      The array of information of sharding structures

    Returns void

Generated using TypeDoc