Last updated
Last updated
This class provides platform-level operations, and typically requires presenting system security credentials when invoked. These security credentials are issued to the UI after the client account is unlocked with a passcode. The UI needs to retain these security credentials throughout its entire lifecycle, and they must be presented when invoking this class.
Class platform
Type profile
listeningVersionHook (profileVerHook: React.Dispatch<React.SetStateAction<number>>)
Number will be changed when profile was updated.
listeningAssetsHook (profileVerHook: React.Dispatch<React.SetStateAction<number>>)
Number will be changed when assets balance was updated.
listeningMiningHook(miningHook: React.Dispatch<React.SetStateAction<mining>>)
listeningGuardianPurchaseHook (profileVerHook: React.Dispatch<React.SetStateAction<number>>)
Number will be changed when status changed.
1 => Transferring asset to CONET Guardian.
2 => Waiting for transfer to be confirmed.
3 => Waiting for purchase to be confirmed by CONET.
4 => Purchase completed.
-1 => Token transfer failed.
-2, TX => Purchase declined by CONET (please connect CONET team with this TX)
new platform(platformStatus, workerLoading)
type_platformStatus: 'LOCKED'|'UNLOCKED'|'NONE'
setWorkerLoading: React.Dispatch<React.SetStateAction<number>>: from0~100
Creates a new instance of platform. Monitor the percentage of backend processes being loaded by setWorkerLoading, Show client status when loading is complete by setPlatformStatus.
platform.createAccount(passcode)
Return resolve: 12 words Secret Recovery Phrase (SRP) split by space, zero length string (create account was fail)
Return reject: Never.
This function only available when platformStatus is "NONE"
platform.testPasscode(passcode, profileVerHook)
Returns: Promise<[passcodeStatus: boolean, authorizationKey: string]>
Return resolve: Unlock wallet success when passcodeStatus is true, return authorizationKey. Unlock wallet fail when passcodeStatus was false.
Return reject: Never.
profileVerHook: React.Dispatch<React.SetStateAction<number>> The number of remote new version updates compare the current local version.
platformStatus will be update to UNLOCKED when passcode success.
Class platform will get authorization key from backend which can access user private data after passcode is success.
platform.resetPasscode(oldPasscode, newPasscode)
Returns: Promise<[passcodeStatus: boolean, authorizationKey: string]>
Return resolve: Unlock wallet success when reset passcode was down, return authorizationKey. Unlock wallet fail when passcodeStatus was false.
Return reject: Never.
platform.recoverAccount(SRP, passcode)
Returns: Promise<authorizationKey: string>
Return resolve: Return authorizationKey when recover Account from SRP, or null when recover fail.
Return reject: Never.
platform.showSRP(passcode)
Return resolve: 12 words Secret Recovery Phrase (SRP) split by space or zero length string (unavailable)
return reject: Never.
Require: Class platform has complete authorization.
platform.getAllProfiles(authorizationKey)
Returns: Promise<profile[]>
Return resolve: All profiles or null array (unavailable)
return reject: Never.
Require: Class platform has complete authorization.
platform.importWallet(authorizationKey, privateKey, data)
data <any> UI custom data. example want put a "import" TAG.
Returns: Promise<profile[]>
Return resolve: All profiles or null array (when private key or authorizationKey is illegal.)
Return reject: Never.
Require: Class platform has complete authorization.
platform.updateProfile(authorizationKey, profile)
profile<profile> Include UI custom data.
Returns: Promise<profile[]>
Return resolve: All profiles or null array (when profile or authorizationKey is illegal.)
Return reject: Never.
Require: Class platform has complete authorization.
platform.addProfile(authorizationKey, data)
data <any> UI custom data. example want put a "import" TAG.
Returns: Promise<profile[]>
Return resolve: All profiles or null array (when authorizationKey is illegal.)
Return reject: Never.
Require: Class platform has complete authorization.
platform.startMining(authorizationKey, profile: profile)
Returns: Promise<status: number>
platform.stopMining()
Returns: Promise<profile[]>
Return resolve: null
Return reject: Never.
platform.CONETFaucet(walletPublicAddress)
Returns: Promise<boolean> True: success, False: fail. (each 24 hours can request once only.)
platform.prePurchase(nodes: number, amount: number, purchaseProfile: profile, payAssetName: string)
Returns: Promise<[gasPrice: string, estimateFee string, nodeAvailable: boolean, availableNodes: number]>
All is null: Insufficient wallet assets cannot complete transfer.
estimateFee: Number of ETH unit
nodeAvailable: True = Purchase can be finish , False = no available nodes can be purchase.
availableNodes: The balance of available nodes which can be purchase.
Error: Network unavailable.
platform.claimToken(profile: profile, assetName: string)
Returns: Promise<[boolean]>
All is null: Insufficient wallet assets cannot complete transfer.
Error: no balance.
platform.guardianPurchase(nodes: number, amount: number, purchaseProfile: profile, payAssetName: string)
Returns: Promise<[]>
All is null: Insufficient wallet assets cannot complete transfer.
Error: Network unavailable.
process status please see the HOOK : listeningGuardianPurchaseHook
platform.getTransferGas(amount: string, profile: profile, payAssetName: string)
Returns: Promise<[fixed Amount, gasPrice: string, estimateFee string]> null return for sufficient assets.
Error: Network unavailable.
platform.transferAsset(amount: string, profile: profile, payAssetName: string)
Returns: Promise<[boolean]>true for transfer success.
Error: Network unavailable.
platform.getRefereesList(wallet_public_key)
Returns: Promise<refereesTree[]>
Return referees tree array.
platform.getAssetsPrice()
Returns: Promise<price[]>
Return reject: Never.
platform.fx168PrePurchase(nodes: number)
Returns: Promise<orders: fx168Order[]> The hash will return when success.
Error: INVALID_DATA. When nodes <1
platform.deleteAccount()
Returns: Promise<boolean>
Return resolve: true: success. false: fail
Return reject: Never.
setPlatformStatus: <React.SetStateAction<type_platformStatus>>
Returns: Instance of platform.
Returns: Promise<>
passcode <> (length > 5)
passcode <> (length > 5)
oldPasscode <> (length > 5)
newPasscode <> (length > 5)
SRP <> 12 words Secret Recovery Phrase (SRP) split by space.
passcode <> (length > 5) The new passcode for securus account.
passcode<> (length > 5)
Returns: Promise<>
authorizationKey<> The access authorization which return from success testPasscode.
authorizationKey<> The access authorization which return from success testPasscode.
privateKey<> The private key.
authorizationKey<> The access authorization which return from success testPasscode.
authorizationKey<> The access authorization which return from success testPasscode.
gasPrice: Number of
wallet_public_key <> profile.keyID