dsd-webclient-conn-lib
v0.0.2
Published
index.html file: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>HTTPS client</title> <script src="./node_modules/dsd-webclient-conn-lib/dsdweblib.js"> </script> </head> <body> <div id="log"></div>
Downloads
10
Readme
#Usage example
index.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTTPS client</title>
<script src="./node_modules/dsd-webclient-conn-lib/dsdweblib.js"> </script>
</head>
<body>
<div id="log"></div>
<script>
function log(title, msg) {
console.log(title, msg ? msg : "");
document.getElementById("log").innerHTML += '<div>'+title + (msg ? JSON.stringify(msg) : "")+'</div>';
}
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); }
);
</script>
</body>
</html>