2.0.2-beta.0 • Published 10 months ago

@oraichain/share-transfer v2.0.2-beta.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

oKey Share Transfer Module

npm version minzip

The Share Transfer Module helps you add or remove the and password as a share for oKey. This module is the part of the oKey SDK.

Installation

npm install --save @oraichain/share-transfer

Initialization

Import the ShareTransferModule class from @oraichain/share-transfer

import ShareTransferModule from "@oraichain/share-transfer";

Assign the ShareTransferModule class to a variable

const shareTransferModule = new ShareTransferModule();

Returns

The ShareTransferModule class returns an object with the following properties:

declare class ShareTransferModule implements IModule {
  moduleName: string;
  tbSDK: ITKeyApi;
  currentEncKey: BN;
  requestStatusCheckId: number;
  requestStatusCheckInterval: number;
  constructor();
  static refreshShareTransferMiddleware(
    generalStore: unknown,
    oldShareStores: ShareStoreMap,
    newShareStores: ShareStoreMap
  ): ShareTransferStorePointer;
  setModuleReferences(tbSDK: ITKeyApi): void;
  setRequestStatusCheckInterval(interval: number): void;
  initialize(): Promise<void>;
  requestNewShare(
    userAgent: string,
    availableShareIndexes: Array<string>,
    callback?: (err?: ITkeyError, shareStore?: ShareStore) => void
  ): Promise<string>;
  addCustomInfoToShareRequest(encPubKeyX: string, customInfo: string): Promise<void>;
  lookForRequests(): Promise<Array<string>>;
  approveRequest(encPubKeyX: string, shareStore?: ShareStore): Promise<void>;
  approveRequestWithShareIndex(encPubKeyX: string, shareIndex: string): Promise<void>;
  getShareTransferStore(): Promise<ShareTransferStore>;
  setShareTransferStore(shareTransferStore: ShareTransferStore): Promise<void>;
  startRequestStatusCheck(encPubKeyX: string, deleteRequestAfterCompletion: boolean): Promise<ShareStore>;
  cancelRequestStatusCheck(): Promise<void>;
  deleteShareTransferStore(encPubKey: string): Promise<void>;
  resetShareTransferStore(): Promise<void>;
  private _cleanUpCurrentRequest;
}

Usage

With the ShareTransferModule, you've access to the following functions:

Request a new share

requestNewShare(userAgent: string, availableShareIndexes: Array<string>, callback?: (err?: ITkeyError, shareStore?: ShareStore) => void)

  • userAgent: The user agent of the client that is requesting a new share.
  • availableShareIndexes: An array of share indexes that are available for the client.
  • callback: A callback function that is called when the request is complete.

Return

  • Promise<string>: Share index of the new share.

Add custom info to share request

addCustomInfoToShareRequest(encPubKeyX: string, customInfo: string)

  • encPubKeyX: The public key of the share that is being requested.
  • customInfo: The custom info that is being added to the share request.

Look for requests

lookForRequests()

Return

  • Promise<Array<string>>: An array of indexes of pending requests

Approve request

approveRequest(encPubKeyX: string, shareStore?: ShareStore)

  • encPubKeyX: The public key of the share that is being approved.
  • shareStore: The share store that is being approved.

Approve request with share index

approveRequestWithShareIndex(encPubKeyX: string, shareIndex: string)

  • encPubKeyX: The public key of the share that is being approved.
  • shareIndex: The share index that is being approved.

Get share transfer store

getShareTransferStore()

Return

  • Promise<ShareTransferStore>: The share transfer store.

Set share transfer store

setShareTransferStore(shareTransferStore: ShareTransferStore)

  • shareTransferStore: The share transfer store.

Start request status check

startRequestStatusCheck(encPubKeyX: string, deleteRequestAfterCompletion: boolean)

  • encPubKeyX: The public key of the share that is being checked.
  • deleteRequestAfterCompletion: Whether or not to delete the request after it is completed.

Return

  • Promise<ShareStore>: The share store.

Cancel request status check

cancelRequestStatusCheck()

Delete share transfer store

deleteShareTransferStore(encPubKey: string)

  • encPubKey: The public key of the share that is being deleted.

Reset share transfer store

resetShareTransferStore()

2.2.1

10 months ago

2.2.0

10 months ago

2.1.4

10 months ago

2.1.3

10 months ago

2.1.6

10 months ago

2.1.5

10 months ago

2.1.2

11 months ago

2.1.1

11 months ago

2.1.0

11 months ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.2-beta.0

2 years ago

2.0.1

2 years ago

2.0.1-beta.2

2 years ago

2.0.0

2 years ago

1.3.1-beta.0

2 years ago

1.3.0

2 years ago

1.2.19-beta.0

2 years ago

1.2.18

2 years ago

1.2.18-beta.2

2 years ago

1.2.18-beta.1

2 years ago

1.2.18-beta.0

2 years ago

1.2.17

2 years ago

1.2.17-beta.4

2 years ago

1.2.17-beta.3

2 years ago

1.2.17-beta.0

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago