Last active
November 5, 2022 01:35
-
-
Save shortthefomo/5d28929964e9a306ca809824824a949a to your computer and use it in GitHub Desktop.
XTPL NFT deriveSale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//pass tx as returned from ledger | |
ntfDeriveSale(tx) { | |
let hash = tx.hash || tx.transaction.hash | |
let trade = {} | |
let taker = tx.Account | |
for(let affected of (tx.meta || tx.metaData).AffectedNodes){ | |
let node = affected.DeletedNode | |
if(!node || node.LedgerEntryType !== 'NFTokenOffer') | |
continue | |
let destination = node.FinalFields.Destination || tx.Account | |
let maker = node.FinalFields.Owner | |
let paid = this.fromLedgerAmount(node.FinalFields.Amount) | |
let id = node.FinalFields.NFTokenID | |
trade = { | |
id, | |
hash, | |
taker, | |
maker, | |
destination, | |
paid | |
} | |
if (!node.FinalFields.Destination) { | |
taker = node.FinalFields.Owner | |
continue | |
} | |
} | |
console.log('NFT trade', trade) | |
return trade | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment