Class Platform
Introduction
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
React Hooks
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)
Class Platform
new platform(platformStatus, workerLoading)
setPlatformStatus: React.Dispatch<React.SetStateAction<type_platformStatus>>
type_platformStatus: 'LOCKED'|'UNLOCKED'|'NONE'
setWorkerLoading: React.Dispatch<React.SetStateAction<number>>: from0~100
Returns: Instance of class platform.
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.
Security credentials required functions
platform.createAccount(passcode)
Returns: Promise<string>
Return resolve: 12 words Secret Recovery Phrase (SRP) split by space, zero length string (create account was fail)
Return reject: Never.
passcode <string> (length > 5)
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.
passcode <string> (length > 5)
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.
oldPasscode <string> (length > 5)
newPasscode <string> (length > 5)
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.
SRP <string> 12 words Secret Recovery Phrase (SRP) split by space.
passcode <string> (length > 5) The new passcode for securus account.
platform.showSRP(passcode)
passcode<string> (length > 5)
Returns: Promise<string>
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)
authorizationKey<string> The access authorization which return from success testPasscode.
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)
authorizationKey<string> The access authorization which return from success testPasscode.
privateKey<string> The private key.
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)
authorizationKey<string> The access authorization which return from success testPasscode.
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)
authorizationKey<string> The access authorization which return from success testPasscode.
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.
No security credentials required functions
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.
gasPrice: Number of GWAI unit
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[]>
wallet_public_key <string> profile.keyID
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.
Last updated