-
Notifications
You must be signed in to change notification settings - Fork 28
/
search-your-latest-transactions.ts
48 lines (38 loc) · 1.24 KB
/
search-your-latest-transactions.ts
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
import { DFUSE_API_KEY, runMain, DFUSE_API_NETWORK } from "../../config"
import { createDfuseClient, SearchTransactionRow } from "@dfuse/client"
const account = "eoscanadacom"
async function main(): Promise<void> {
const client = createDfuseClient({ apiKey: DFUSE_API_KEY, network: DFUSE_API_NETWORK })
try {
const response = await client.searchTransactions(`auth:${account}`, {
limit: 10,
sort: "desc",
})
console.log()
console.log(`Your latest 10 transactions`)
if (!response.transactions || response.transactions.length <= 0) {
console.log("Oups nothing found")
return
}
const transactions = response.transactions || []
transactions.forEach((result: SearchTransactionRow) => {
console.log(
`- ${buildEosqLink(result.lifecycle.id)} (Block #${
result.lifecycle.execution_trace?.block_num
})`
)
})
console.log()
} catch (error) {
console.log("An error occurred", error)
}
client.release()
}
function buildEosqLink(transactionId: string): string {
let suffix = ""
if (["jungle", "kylin", "worbli"].includes(DFUSE_API_NETWORK)) {
suffix = `.${DFUSE_API_NETWORK}`
}
return `https://${suffix}eosq.app/tx/${transactionId}`
}
runMain(main)