@helium/sus 0.6.24-next.9 → 0.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -18
- package/lib/cjs/index.js +441 -345
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/src/index.js +347 -244
- package/lib/esm/src/index.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/index.d.ts +12 -9
- package/lib/types/src/index.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Features:
|
|
|
14
14
|
* Explorer link to simulated transaction
|
|
15
15
|
* Parse out base and priority fees
|
|
16
16
|
* Flag writable accounts that did not change in simulation
|
|
17
|
+
* Batch as many fetches as possible into getMultipleAccounts to reduce load on RPC
|
|
17
18
|
|
|
18
19
|
## Usage
|
|
19
20
|
|
|
@@ -23,10 +24,10 @@ import { sus } from "@helium/sus"
|
|
|
23
24
|
const result = await sus({
|
|
24
25
|
connection,
|
|
25
26
|
wallet,
|
|
26
|
-
|
|
27
|
+
serializedTransactions: [transaction.serialize({
|
|
27
28
|
verifySignatures: false,
|
|
28
29
|
requireAllSignatures: false,
|
|
29
|
-
}),
|
|
30
|
+
})],
|
|
30
31
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
31
32
|
checkCNfts: true,
|
|
32
33
|
// Necessary for explorer link
|
|
@@ -47,16 +48,16 @@ This feature also allows us to show a detailed diff on fields that change on anc
|
|
|
47
48
|
const result = await sus({
|
|
48
49
|
connection,
|
|
49
50
|
wallet,
|
|
50
|
-
|
|
51
|
+
serializedTransactions: [transaction.serialize({
|
|
51
52
|
verifySignatures: false,
|
|
52
53
|
requireAllSignatures: false,
|
|
53
|
-
}),
|
|
54
|
+
})],
|
|
54
55
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
55
56
|
checkCNfts: true,
|
|
56
57
|
// Necessary for explorer link
|
|
57
58
|
cluster: "devnet"
|
|
58
59
|
})
|
|
59
|
-
console.log(result.writableAccounts)
|
|
60
|
+
console.log(result[0].writableAccounts)
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
Consider a transaction that mints helium data credits by burning HNT. This will return something like this. Note the owner field is best-effort but allows a UI to display which accounts may be owned by the user.:
|
|
@@ -197,16 +198,16 @@ Sus attempts to parse the instructions of any program with an anchor-compliant I
|
|
|
197
198
|
const result = await sus({
|
|
198
199
|
connection,
|
|
199
200
|
wallet,
|
|
200
|
-
serializedTransaction: transaction.serialize({
|
|
201
|
+
serializedTransaction: [transaction.serialize({
|
|
201
202
|
verifySignatures: false,
|
|
202
203
|
requireAllSignatures: false,
|
|
203
|
-
}),
|
|
204
|
+
})],
|
|
204
205
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
205
206
|
checkCNfts: true,
|
|
206
207
|
// Necessary for explorer link
|
|
207
208
|
cluster: "devnet"
|
|
208
209
|
})
|
|
209
|
-
console.log(result.instructions)
|
|
210
|
+
console.log(result[0].instructions)
|
|
210
211
|
```
|
|
211
212
|
|
|
212
213
|
Parsing results in the following data:
|
|
@@ -327,21 +328,25 @@ Sus attempts to warn for various suspicious transactions. One example is a trans
|
|
|
327
328
|
const result = await sus({
|
|
328
329
|
connection,
|
|
329
330
|
wallet,
|
|
330
|
-
serializedTransaction: transaction.serialize({
|
|
331
|
+
serializedTransaction: [transaction.serialize({
|
|
331
332
|
verifySignatures: false,
|
|
332
333
|
requireAllSignatures: false,
|
|
333
|
-
}),
|
|
334
|
+
})],
|
|
334
335
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
335
336
|
checkCNfts: true,
|
|
336
337
|
// Necessary for explorer link
|
|
337
338
|
cluster: "devnet"
|
|
338
339
|
})
|
|
339
|
-
console.log(result.warnings)
|
|
340
|
+
console.log(result[0].warnings)
|
|
340
341
|
```
|
|
341
342
|
|
|
342
343
|
```javascript
|
|
343
344
|
[
|
|
344
|
-
|
|
345
|
+
{
|
|
346
|
+
severity: 'warning',
|
|
347
|
+
message: "More than 2 accounts with negative balance change. Is this emptying your wallet?",
|
|
348
|
+
shortMessage: '2+ Writable'
|
|
349
|
+
}
|
|
345
350
|
]
|
|
346
351
|
```
|
|
347
352
|
|
|
@@ -355,16 +360,16 @@ import { sus } from "@helium/sus"
|
|
|
355
360
|
const result = await sus({
|
|
356
361
|
connection,
|
|
357
362
|
wallet,
|
|
358
|
-
serializedTransaction: transaction.serialize({
|
|
363
|
+
serializedTransaction: [transaction.serialize({
|
|
359
364
|
verifySignatures: false,
|
|
360
365
|
requireAllSignatures: false,
|
|
361
|
-
}),
|
|
366
|
+
})],
|
|
362
367
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
363
368
|
checkCNfts: true,
|
|
364
369
|
// Necessary for explorer link
|
|
365
370
|
cluster: "devnet"
|
|
366
371
|
})
|
|
367
|
-
console.log(result.balanceChanges)
|
|
372
|
+
console.log(result[0].balanceChanges)
|
|
368
373
|
```
|
|
369
374
|
|
|
370
375
|
```javascript
|
|
@@ -431,16 +436,16 @@ import { sus } from "@helium/sus"
|
|
|
431
436
|
const result = await sus({
|
|
432
437
|
connection,
|
|
433
438
|
wallet,
|
|
434
|
-
serializedTransaction: transaction.serialize({
|
|
439
|
+
serializedTransaction: [transaction.serialize({
|
|
435
440
|
verifySignatures: false,
|
|
436
441
|
requireAllSignatures: false,
|
|
437
|
-
}),
|
|
442
|
+
})],
|
|
438
443
|
// Check for cNFT changes, this only works if you have an RPC with DAS support
|
|
439
444
|
checkCNfts: true,
|
|
440
445
|
// Necessary for explorer link
|
|
441
446
|
cluster: "devnet"
|
|
442
447
|
})
|
|
443
|
-
console.log(result.possibleCNftChanges)
|
|
448
|
+
console.log(result[0].possibleCNftChanges)
|
|
444
449
|
```
|
|
445
450
|
|
|
446
451
|
Unfortunately, this method is limited by how much data can be fetched from DAS. If a user has more than 200 hotspots, for example, Sus will not be able to check all hotspots past that limit for matches to a mutable tree in the transaction.
|