rippleapi - browser instructions; other cleanup to quickstart

This commit is contained in:
mDuo13
2016-01-29 15:11:18 -08:00
parent 257d473063
commit 84e93f47e1
5 changed files with 69244 additions and 12 deletions

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<script src="ripple-0.16.5.js"></script>
<script>
console.log(ripple);
var api = new ripple.RippleAPI({server:'wss://s1.ripple.com/'});
api.connect().then(()=>{
return api.getServerInfo();
}).then(server_info=>{
document.body.innerHTML += `<p>Connected to rippled server!</p>
<table>
<tr><th>Version</th>
<td>${ server_info.buildVersion }</td></tr>
<tr><th>Ledgers available</th>
<td>${ server_info.completeLedgers }</td></tr>
<tr><th>hostID</th>
<td>${ server_info.hostID }</td></tr>
<tr><th>Most Recent Validated Ledger Seq.</th>
<td>${ server_info.validatedLedger.ledgerVersion }</td></tr>
<tr><th>Most Recent Validated Ledger Hash</th>
<td>${ server_info.validatedLedger.hash }</td></tr>
<tr><th>Seconds since last ledger validated</th>
<td>${ server_info.validatedLedger.age }</td></tr>
</table>`;
});
</script>
<style type="text/css">
td, th { border: 1px solid black; padding: 5px; }
table { border-collapse: collapse; }
</style>
</head>
<body></body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
const {RippleAPI} = require('ripple-lib');
const assert = require('assert');
/* Credentials of the account placing the offer */
/* Credentials of the account placing the order */
const my_addr = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
const my_secret = 's████████████████████████████';
@@ -34,7 +34,7 @@ const my_instructions = {maxLedgerVersionOffset: ledgerOffset};
function verifyTransaction(hash, options) {
console.log('Verifing Transaction');
return api.getTransaction(hash, options).then(data => {
console.log('Result: ', data.outcome.result);
console.log('Final Result: ', data.outcome.result);
console.log('Validated in Ledger: ', data.outcome.ledgerVersion);
console.log('Sequence: ', data.sequence);
return data.outcome.result === 'tesSUCCESS';
@@ -57,8 +57,8 @@ Still requires vlaidation */
function submitTransaction(lastClosedLedgerVersion, prepared, secret) {
const signedData = api.sign(prepared.txJSON, secret);
return api.submit(signedData.signedTransaction).then(data => {
console.log('Result: ', data.resultCode);
console.log('Message: ', data.resultMessage);
console.log('Tentative Result: ', data.resultCode);
console.log('Tentative Message: ', data.resultMessage);
/* if transaction was not successfully submitted throw error */
assert.strictEqual(data.resultCode, 'tesSUCCESS');
/* if successfully submitted fire off validation workflow */