-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxrplhelpers.js
More file actions
115 lines (104 loc) · 2.69 KB
/
xrplhelpers.js
File metadata and controls
115 lines (104 loc) · 2.69 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const xrpl = require("xrpl");
require("dotenv").config();
class XrplHelpers {
async getNextSequence() {
const client = new xrpl.Client(process.env.XRPL_RPC);
await client.connect();
const response = await client.request({
command: "account_info",
account: process.env.MULTI_SIG_WALLET_ADDRESS,
ledger_index: "validated",
});
await client.disconnect();
return response.result.account_data.Sequence;
}
async getAccountNFTs() {
const client = new xrpl.Client(process.env.XRPL_RPC);
await client.connect();
const response = await client.request({
command: "account_nfts",
account: process.env.MULTI_SIG_WALLET_ADDRESS,
ledger_index: "validated",
});
await client.disconnect();
return response.result;
}
async getAccountTransactions(client, marker) {
const request = this.TransactionRequestPayload();
if (marker != undefined) {
request.marker = marker;
}
const response = await client.request(request);
return response.result;
}
async getTransactionMetadata(txnHash) {
const client = new xrpl.Client(process.env.XRPL_RPC);
await client.connect();
const response = await client.request({
command: "tx",
transaction: txnHash,
});
await client.disconnect();
return response.result;
}
async getAccountSellOffers(tokenId)
{
const client = new xrpl.Client(process.env.XRPL_RPC);
await client.connect();
let nftSellOffers
try {
nftSellOffers = await client.request({
method: "nft_sell_offers",
tokenid: tokenId
})
} catch (err) {
console.log("No sell offers.")
}
await client.disconnect();
return nftSellOffers.result;
}
TransactionRequestPayload() {
return {
command: "account_tx",
account: process.env.MULTI_SIG_WALLET_ADDRESS,
};
}
CreateOfferPayload() {
return {
TransactionType: "NFTokenCreateOffer",
Account: process.env.MULTI_SIG_WALLET_ADDRESS,
NFTokenID: "",
Destination: "",
Amount: "0",
Flags: xrpl.NFTokenCreateOfferFlags.tfSellNFToken,
Sequence: 0,
Fee: "1000",
Memos: [
{
Memo: {
MemoData: "",
},
},
],
};
}
TokenMintPayload() {
return {
TransactionType: "NFTokenMint",
Account: process.env.MULTI_SIG_WALLET_ADDRESS,
Flags: xrpl.NFTokenMintFlags.tfTransferable,
URI: "",
NFTokenTaxon: 0,
Fee: "1000",
Sequence: 0,
Memos: [
{
Memo: {
MemoData: "",
},
},
],
};
}
}
module.exports = XrplHelpers;