-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.js
39 lines (36 loc) · 1.03 KB
/
sample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const {XrplClient} = require('xrpl-client')
const connection = new XrplClient('wss://testnet.xrpl-labs.com')
const main = async () => {
const offers = (await Promise.all((await connection.send({
command: 'account_objects',
account: 'rLyYk3V8siKuUSyHrBfHXnEx7YxhatgmyC',
type: 'offer',
limit: 100
})).account_objects.map(async openOffer => {
Object.assign(openOffer, {
originalTx: await connection.send({
command: 'tx',
transaction: openOffer.PreviousTxnID
})
})
return openOffer
}))).map(offer => {
return {
offerHash: offer.BookDirectory,
createHash: offer.originalTx.hash,
now: {
gets: offer.TakerGets,
pays: offer.TakerPays
},
original: {
gets: offer.originalTx.TakerGets,
pays: offer.originalTx.TakerPays
},
openPercentage: Number(offer.TakerGets?.value || offer.TakerGets)
/ Number(offer.originalTx.TakerGets?.value || offer.originalTx.TakerGets)
* 100
}
})
console.log(offers)
}
main()