mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
rippleapi - browser instructions; other cleanup to quickstart
This commit is contained in:
34
content/code_samples/rippleapi_quickstart/browser-demo.html
Normal file
34
content/code_samples/rippleapi_quickstart/browser-demo.html
Normal 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>
|
||||
69062
content/code_samples/rippleapi_quickstart/ripple-0.16.5.js
Normal file
69062
content/code_samples/rippleapi_quickstart/ripple-0.16.5.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user