Description
Provides convenient way to call PDS server API of edzLabs.com's PDS service.
Full api reference look at app.dase.io
Examples
var CONN = require("dsd-client-conn-lib");
var dsdConn = CONN.connClient2;
var dsdCst = CONN.Consts;
dsdConn.setDaseServer({ host: "partner.dase.io", port: 5110 });
function log(title, msg) {
console.log(title, msg ? msg : "");
}
log("sendSilver should success");
dsdConn.getCoreClient().sendSilver({
senderId: "0x003e8c791cb39b4cad756b9c25431d6eb3fed85c",
senderPassword: "12345678",
silverAmount: 100,
toUserId: "0xb35ef3e31f2944d252eda42801caf5d890d1d7f9"
}).then(
ok => { log("sendSilver ok: ", ok); },
err => { log("sendSilver err: ", err); }
);
log("sendSilver2 should error");
dsdConn.getDaseClient().sendSilver({
senderId: "0x003e8c791cb39b4cad756b9c25431d6eb3fed85c",
senderPassword: "12345678",
toUserId: "0xb35ef3e31f2944d252eda42801caf5d890d1d7f9"
}).then(
ok => { log("sendSilver2 ok: ", ok); },
err => {
log("sendSilver2 err: ", err);
//specify error handlers if necessary
if(err.code === dsdCst.errorCodes.WrongParametersCount.id) {
log("I have wrong parameters count..."+dsdCst.errorCodes.WrongParametersCount.name);
//do something
}
else if(err.code === dsdCst.errorCodes.ServerSideError.id) {
log("I have server error..."+ dsdCst.errorCodes.ServerSideError.name);
//do something
}
}
);
console.log("addDab should success");
dsdConn.getPdsClient().addDab({
ownerId: "0x003e8c791cb39b4cad756b9c25431d6eb3fed85c",
assetUrl: "http://localhost",
ownerPassword: "12345678",
publicDescription: "new client lib asset",
// custodians: [],
// linkedDabId: 0,
// publicityType: dsdCst.publicityTypes.PublicityPublic.id,
// dataHash: 0
}).then(
ok => { log("addDab ok: ", ok); },
err => { log("addDab err: ", err); }
);
###########################
Core API methods
/////
// Description:
// Method newUser
//
// @param password {String}
// @returns {Keys} Look at Type description in Docs.
///
/////
// Description:
// Method newUser_Public
//
// @param password {String}
// @returns {Keys} Look at Type description in Docs.
///
/////
// Description:
// Method getKeys
//
// @param userId {Address}
// @param password {String}
// @returns {Keys} Look at Type description in Docs.
///
/////
// Description:
// Method getKeys_Public
//
// @param userId {Address}
// @param password {String}
// @returns {Keys} Look at Type description in Docs.
///
/////
// Description:
// Method sendWeis
//
// @param sender {Address}
// @param senderPassword {String}
// @param receiver {Address}
// @param weiAmount {Integer}
// @param undefined {Unknown}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method getSilverBalance
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method getGoldBalance_Public
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method transferOut
//
// @param srcUserId {Address}
// @param password {String}
// @param destUserId {Address}
// @param amount {Integer}
// @returnsunspecified
///
/////
// Description:
// Method transferOut_Public
//
// @param srcUserId {Address}
// @param password {String}
// @param destUserId {Address}
// @param amount {Integer}
// @returnsunspecified
///
/////
// Description:
// Method getBalanceWeis_Public
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method buyGoldForWeis_Public
//
// @param userId {Address}
// @param password {String}
// @param goldAmount {Integer}
// @param weisAmount {Integer}
// @returns {Integer}
///
/////
// Description:
// Method weisAmountForGold_Public
//
// @param userId {Address}
// @param goldAmount {Integer}
// @returns {Integer}
///
/////
// Description:
// Method getEvents
//
// @param userId {Address}
// @param pos {Integer}
// @param size {Integer}
// @param filterName {String}
// @param relation {Object} Look at Constants description in Docs.
// @returnsunspecified
///
/////
// Description:
// Method getEvents_Public
//
// @param userId {Address}
// @param pos {Integer}
// @param size {Integer}
// @param filterName {String}
// @param relation {Object} Look at Constants description in Docs.
// @returnsunspecified
///
/////
// Description:
// Method getLastBlock
//
// @returns {Integer}
///
/////
// Description:
// Method getLastBlock_Public
//
// @returns {Integer}
///
/////
// Description:
// Method silverCostInGold
//
// @param userId {Address}
// @param silverAmount {Integer}
// @returns {Integer}
///
/////
// Description:
// Method goldCostInSilver_Public
//
// @param userId {Address}
// @param goldAmount {Integer}
// @returns {Integer}
///
/////
// Description:
// Method approveUserToSpendMySilver
//
// @param fromUserId {Address}
// @param password {String}
// @param silverAmount {Integer}
// @param toUserId {Address}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method approveTreasuryToSpendMySilver
//
// @param fromUserId {Address}
// @param password {String}
// @param silverAmount {Integer}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method sendSilver
//
// @param senderId {Address}
// @param senderPassword {String}
// @param silverAmount {Integer}
// @param toUserId {Address}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method spendAlienSilver
//
// @param spenderId {Address}
// @param password {String}
// @param fromUserId {Address}
// @param silverAmount {Integer}
// @param toUserId {Address}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method isValidUser
//
// @param account {Address}
// @param password {String}
// @returns {Boolean}
///
/////
// Description:
// Method getEligibilityValue
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method wantVote
//
// @param userId {Address}
// @param userPassword {String}
// @param iWish {Boolean}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method getVoteRewardInSilver
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method getVoteCostInSilver
//
// @param userId {Address}
// @returns {Integer}
///
/////
// Description:
// Method getContractVoters
//
// @param userId {Address}
// @returns - Array of {Address}
///
/////
// Description:
// Method getQuorumVoters
//
// @returns - Array of {Address}
///
/////
// Description:
// Method getCandidatesPool
//
// @param userId {Address}
// @returns - Array of {Address}
///
/////
// Description:
// Method isInCandidatesPool
//
// @param userId {Address}
// @returns {Boolean}
///
/////
// Description:
// Method hasPledge
//
// @param userId {Address}
// @returns {Boolean}
///
/////
// Description:
// Method isLicensedForVoting
//
// @param userId {Address}
// @returns {Boolean}
///
/////
// Description:
// Method getMyCoinbase
//
// @returns {Address}
///
/////
// Description:
// Method withdrawPledge
//
// @param userId {Address}
// @param userPassword {String}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method sendMessageSecured
//
// @returnsunspecified
///
/////
// Description:
// Method getMessageSecured
//
// @returnsunspecified
///
/////
// Description:
// Method getMessagesSecuredCount
//
// @returnsunspecified
///
/////
// Description:
// Method getLastReadMessageIndex
//
// @returns
///
/////
// Description:
// Method setAttributeSecured
//
// @returns
///
/////
// Description:
// Method getAttributeSecured
//
// @returns
///
###########################
CDASE API methods
/////
// Description:
// Method addDab
//
// @param ownerId {Address}
// @param ownerPassword {String}
// @param assetUrl {String}
// @param publicDescription {String}
// @param linkedDabId (optional. default: 0) {Integer}
// @param custodians (optional. default: []) - Array of {Address}
// @param publicityType (optional. default: 0) {Integer} Look at Constants description in Docs.
// @param dataHash (optional. default: 0) {Integer}
// @returns {Integer}
///
/////
// Description:
// Method addDabList
//
// @param ownerId {Address}
// @param ownerPassword {String}
// @param dataArr - Array of {Object}
// @returns {Transaction} Look at Type description in Docs.
///
/////
// Description:
// Method addTag
//
// @param ownerId {Address}
// @param ownerPassword {String}
// @param undefined {Unknown}
// @param signature {String}
// @param linkedDabId {Integer}
// @returns {Integer}
///
/////
// Description:
// Method getTagsIdsForDab
//
// @param dabId {Integer}
// @param requestor {Address}
// @returns
///
/////
// Description:
// Method getOwnedDabsIds
//
// @param userId {Address}
// @returns - Array of {Integer}
///
/////
// Description:
// Method getSharedDabsIds
//
// @param userId {Address}
// @returns - Array of {Integer}
///
/////
// Description:
// Method getCustodiedDabsIds
//
// @param userId {Address}
// @returns - Array of {Integer}
///
/////
// Description:
// Method getDabs
//
// @param userId {Address}
// @param dabId - Array of {Integer}
// @returns - Array of {Dab} Look at Type description in Docs.
///
/////
// Description:
// Method getDabsPage
//
// @param userId {Address}
// @param startDabId (optional. default: 0) {Integer}
// @param pageSize (optional. default: 10) {Integer}
// @returns - Array of {Dab} Look at Type description in Docs.
///
/////
// Description:
// Method getDabsForTag
//
// @param userId {Address}
// @param tagTitle (optional. default: "") {String}
// @param tagId (optional. default: undefined) {Integer}
// @returns - Array of {Dab} Look at Type description in Docs.
///
/////
// Description:
// Method offerSellAccess
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyerId {Address}
// @param dabId {Integer}
// @param minPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method offerBuyAccess
//
// @param buyer {Address}
// @param buyerPassword {String}
// @param dabId {Integer}
// @param maxPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method offerSellOwnership
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @param minPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method offerBuyOwnership
//
// @param buyer {Address}
// @param buyerPassword {String}
// @param dabId {Integer}
// @param maxPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method offerBuyCustody
//
// @param buyer {Address}
// @param buyerPassword {String}
// @param dabId {Integer}
// @param maxPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method offerSellCustody
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @param minPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method approveOwnershipDeal
//
// @param custodian {Address}
// @param custodianPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method approveAccessDeal
//
// @param custodian {Address}
// @param custodianPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method approveCustodyDeal
//
// @param custodian {Address}
// @param custodianPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method getTotalLicenseFee
//
// @param licenseType {Integer} Look at Constants description in Docs.
// @returns {Integer}
///
/////
// Description:
// Method repairIntegrity
//
// @param owner {Address}
// @param ownerPassword {String}
// @param dabId {Integer}
// @returns
///
/////
// Description:
// Method trustToBuyAccess
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @param minPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method trustToBuyOwnership
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @param minPrice {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method untrustToBuyAccess
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method untrustToBuyOwnership
//
// @param seller {Address}
// @param sellerPassword {String}
// @param buyer {Address}
// @param dabId {Integer}
// @returns {Boolean}
///
/////
// Description:
// Method getDealsForDab
//
// @param userId {Address}
// @param dabId {Integer}
// @returns - Array of {Deal} Look at Type description in Docs.
///
/////
// Description:
// Method checkUserPrvPayment
//
// @returns
///
/////
// Description:
// Method addDataSecured
//
// @returns
///
/////
// Description:
// Method getSecuredDabsInfoPage
//
// @returns
///
/////
// Description:
// Method listSecuredOwnedDabs
//
// @returns
///
/////
// Description:
// Method listSecuredSharedDabs
//
// @returns
///
/////
// Description:
// Method listSecuredCustodiedDabs
//
// @returns
///
/////
// Description:
// Method getSecuredDabsInfo
//
// @returns
///
/////
// Description:
// Method payBill
//
// @returns
///
###########################
PDS API methods
/////
// Description:
// Method listVaults
//
// @param ownerId {Address}
// @returns - Array of {Vault} Look at Type description in Docs.
///
/////
// Description:
// Method getUploadTicket
//
// @param userId {Address}
// @param password {String}
// @param vaultUserId {Integer}
// @param vaultPassword {String}
// @returns {Ticket} Look at Type description in Docs.
///
/////
// Description:
// Method getAccessTicket
//
// @param dabId {Integer}
// @param buyer {Address}
// @param seller {Address}
// @param argsBuyerSignature {String}
// @param publicKey {String}
// @param vaultUserId {Integer}
// @param vaultPassword {String}
// @returns {Ticket} Look at Type description in Docs.
///
/////
// Description:
// Method getAccessTicketSecured
//
// @returns
///