ontology-ts-sdk
Version:
Comprehensive TypeScript library for the Ontology blockchain.
494 lines (493 loc) • 17.2 kB
TypeScript
import { Address, PublicKey } from '../../crypto';
import { DDOAttribute } from '../../transaction/ddo';
import { Transaction } from '../../transaction/transaction';
import Group from './ontid/group';
import { Signer } from './ontid/signer';
/**
* Address of ONT ID contract
*/
export declare const ONTID_CONTRACT = "0000000000000000000000000000000000000003";
/**
* Registers Identity.
*
* Register ontid with public key
*
* @param ontid User's ONT ID
* @param publicKey Public key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRegIDWithPublicKeyTx(ontid: string, publicKey: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Registers Identity.
*
* Register ontid with public key
*
* @param ontid User's ONT ID
* @param publicKey Public key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRegisterOntidTx(ontid: string, publicKey: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Register with multi controller
*
* The tx needs the signatures of: signer of the ontid, the controller, payer
*
* @param ontid User's ONT ID
* @param controllers Multi controllers
* @param signers Signer of controllers
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRegIdWithMultiControllerTx(ontid: string, controllers: Group, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Revoke ONT ID
*
*
* @param ontid User's ONT ID
* @param index Index of pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildMakeRevokeIdTx(ontid: string, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Revoke ONT ID by multi controller
* This tx needs the signature of the multi controlers
*
* @param ontid User's ONT ID
* @param signers Signer of controllers
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRevokeIdByMultiController(ontid: string, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Remove controller
* This tx needs the signature of pk with the given index
*
* @param ontid User's ONT ID
* @param index Index of controller's pk
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRemoveControllerTx(ontid: string, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Registers Identity with initial attributes.
*
* @param ontid User's ONT ID
* @param attributes Array of DDOAttributes
* @param publicKey User's public key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRegIdWithAttributesTx(ontid: string, attributes: DDOAttribute[], publicKey: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Adds attributes to ONT ID.
*
* @param ontid User's ONT ID
* @param attributes Array of DDOAttributes
* @param publicKey User's public key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddAttributeTx(ontid: string, attributes: DDOAttribute[], publicKey: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Removes attribute from ONT ID.
*
* @param ontid User's ONT ID
* @param key Key of attribute to remove
* @param publicKey User's public key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*
*/
export declare function buildRemoveAttributeTx(ontid: string, key: string, publicKey: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Queries attributes attached to ONT ID.
*
* @param ontid User's ONT ID
*/
export declare function buildGetAttributesTx(ontid: string): Transaction;
/**
* Adds attribute to ONT ID by multi controllers.
*
* @param ontid User's ONT ID
* @param attributes Attributes to add
* @param signers Signers
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddAttributesByMultiControllerTx(ontid: string, attributes: DDOAttribute[], signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Adds attribute to ONT ID by pk
*
* @param ontid User's ONT ID
* @param attributes Attributes to add
* @param index Index of pk
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddAttributesByIndexTx(ontid: string, attributes: DDOAttribute[], index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove attribute to ONT ID by multi controllers.
*
* @param ontid User's ONT ID
* @param key Key of attribute to remove
* @param signers Signers of multi controllers
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemoveAttributeByMultiControllerTx(ontid: string, key: string, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove attribute to ONT ID by pk
*
* @param ontid User's ONT ID
* @param key Key of attribute to remove
* @param index Index of the pk
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemoveAttributeByIndexTx(ontid: string, key: string, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Queries Description Object of ONT ID(DDO).
*
* @param ontid User's ONT ID
*/
export declare function buildGetDDOTx(ontid: string): Transaction;
/**
* Adds a new public key to ONT ID.
*
* @param ontid User's ONT ID
* @param newPk New public key to be added
* @param userKey User's public key
* @param controller Controller of new pk
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddPubKeyTx(ontid: string, newPk: PublicKey, userKey: PublicKey, controller: string, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Adds a new public key and its controller to ONT ID by multi controllers.
*
* @param ontid User's ONT ID
* @param newPk New public key to be added
* @param signers Singers of controllers
* @param controller ONT ID of the new pk. Optional
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddKeyByMultiControllerTx(ontid: string, newPk: PublicKey, signers: Signer[], controller: string, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Adds a new public key to ONT ID by auth key.
*
* @param ontid User's ONT ID
* @param newPk New public key to be added
* @param index Index of auth key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddKeyByIndexTx(ontid: string, newPk: PublicKey, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove public key of ONT ID by auth key.
*
* @param ontid User's ONT ID
* @param newPk Pubkey to remove
* @param index Index of auth key
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemoveKeyByIndexTx(ontid: string, newPk: PublicKey, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Set recovery to ONT ID
*
*
* @param ontid User's ONT ID
* @param newRecovery newRecovery
* @param index Index of new recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildSetRecoveryTx(ontid: string, newRecovery: Group, index: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Update recovery to ONT ID
*
*
* @param ontid User's ONT ID
* @param recovery recovery New recovery to add
* @param signers Signers of old recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildUpdateRecoveryTx(ontid: string, recovery: Group, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Adds a new public key to ONT ID by recovery
*
* @param ontid User's ONT ID
* @param newPk New public key to be added
* @param signers Signers of recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildAddKeyByRecoveryTx(ontid: string, newPk: PublicKey, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove a new public key to ONT ID by recovery
*
* @param ontid User's ONT ID
* @param pubkeyIndex Index of pk to remove
* @param signers Signers of recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemoveKeyByRecoveryTx(ontid: string, pubkeyIndex: number, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove public key of ONT ID by multi controllers.
*
* @param ontid User's ONT ID
* @param pubkeyIndex Index of pubkey to be removed
* @param signers Controllers' signers
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemoveKeyByMultiControllerTx(ontid: string, pubkeyIndex: number, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Revokes a public key from ONT ID.
*
* @param ontid User's ONT ID
* @param pk2Remove Public key to be removed
* @param Pk(auth key) of ONT ID.
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer
*/
export declare function buildRemovePubKeyTx(ontid: string, pk2Remove: PublicKey, pk: PublicKey, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Queries public keys attached to ONT ID.
*
* @param ontid User's ONT ID
*/
export declare function buildGetPublicKeysTx(ontid: string): Transaction;
/**
* Queries the state of the public key associated with ONT ID.
*
* @param ontid user's ONT ID
* @param pkId User's public key Id
*/
export declare function buildGetPublicKeyStateTx(ontid: string, pkId: number): Transaction;
/**
* Add auth key to ONT ID
*
*
* @param ontid User's ONT ID
* @param pubkey If isNewPublicKey set false, this is the new public key to set as auth key
* @param controller ONT ID of the new auth key
* @param signIndex Index of signer's pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildAddNewAuthKeyTx(ontid: string, pubkey: PublicKey, controller: string, signIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Remove auth key of ONT ID
*
*
* @param ontid User's ONT ID
* @param index Index of the auth key to remove
* @param signIndex Index of signer's pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRemoveAuthKeyTx(ontid: string, index: number, signIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Add new auth key to ONT ID by recovery
*
*
* @param ontid User's ONT ID
* @param pubkey Pk to add as new auth key
* @param controller ONT ID of the new auth key
* @param signers Signers of recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildAddNewAuthKeyByRecoveryTx(ontid: string, pubkey: PublicKey, controller: string, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove auth key of ONT ID by recovery
*
*
* @param ontid User's ONT ID
* @param index Index of auth key to remove
* @param signers Signers of recovery
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRemoveAuthKeyByRecoveryTx(ontid: string, index: number, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Add new auth key to ONT ID by controller
*
*
* @param ontid User's ONT ID
* @param pubkey Pk to add as new auth key
* @param controller ONT ID of the new auth key
* @param signers Signers of controller
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildAddNewAuthKeyByControllerTx(ontid: string, pubkey: PublicKey, controller: string, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* remove auth key of ONT ID by controller
*
*
* @param ontid User's ONT ID
* @param index Index of auth key to remove
* @param signers Signers of controller
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRemoveAuthKeyByControllerTx(ontid: string, index: number, signers: Signer[], gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Add service to ONT ID
*
*
* @param ontid User's ONT ID
* @param serviceId Identifier of service
* @param type Type of service
* @param serviceEndpoint Endpoint of service
* @param index Index of signer's pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildAddServiceTx(ontid: string, serviceId: string, type: string, serviceEndpoint: string, pkIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Update service to ONT ID
*
*
* @param ontid User's ONT ID
* @param serviceId Identifier of service
* @param type Type of service
* @param serviceEndpoint Endpoint of service
* @param pkIndex Index of signer's pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildUpdateServiceTx(ontid: string, serviceId: string, type: string, serviceEndpoint: string, pkIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Remove service to ONT ID
*
*
* @param ontid User's ONT ID
* @param serviceId Identifier of service
* @param pkIndex Index of signer's pubkey
* @param gasLimit Gas limit
* @param gasPrice Gas price
* @param payer Payer. Optional.
*/
export declare function buildRemoveServiceTx(ontid: string, serviceId: string, pkIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Add context to ONT ID
*
*
* @param ontid User's ONT ID
* @param context Context to add
* @param pkIndex Index of pk
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildAddContextTx(ontid: string, context: string[], pkIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Remove context of ONT ID
*
*
* @param ontid User's ONT ID
* @param context Context to remove
* @param pkIndex Index of signer's pubkey
* @param gasPrice Gas price
* @param gasLimit Gas limit
* @param payer Payer. Optional.
*/
export declare function buildRemoveContextTx(ontid: string, context: string[], pkIndex: number, gasPrice: string, gasLimit: string, payer?: Address): Transaction;
/**
* Verify signature
* Tx needs contain the signature to verify
*
* @param ontid User's ONT ID
* @param keyIndex Index of pubkey
*/
export declare function buildVerifySignatureTx(ontid: string, keyIndex: number): Transaction;
/**
* Verify multi controller
*
*
* @param ontid User's ONT ID
* @param signers Signers of multi controllers
*/
export declare function buildVerifyMultiControllerTx(ontid: string, signers: Signer[]): Transaction;
/**
* Get service
* Pre-exec this tx
*
* @param ontid User's ONT ID
* @param signers Signers of multi controllers
*/
export declare function buildGetServiceTx(ontid: string, serviceId: string): Transaction;
/**
* Get controller
* Pre-exec this tx
*
* @param ontid User's ONT ID
*/
export declare function buildGetControllerTx(ontid: string): Transaction;
/**
* Get document
* Pre-exec this tx
*
* @param ontid User's ONT ID
*/
export declare function buildGetDocumentTx(ontid: string): Transaction;
export interface DocumentPubKey {
id: string;
type: string;
controller: string;
publicKeyHex: string;
}
export interface Document {
'@context': [string];
id: string;
publicKey: [DocumentPubKey];
authentication: [string];
controller: string | null;
recovery: string | null;
service: [any];
attribute: [DDOAttribute] | null;
created: number;
updated: number;
proof: string;
}
export declare function getDocumentJson(ontid: string, restNode: string): Promise<Document>;