@signet-base/cli 0.2.0 ā 0.2.1
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 +6 -6
- package/package.json +1 -1
- package/src/commands/list.js +32 -4
package/README.md
CHANGED
|
@@ -6,16 +6,16 @@ Command-line tool for [Signet](https://signet.sebayaki.com) onchain advertising.
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# List recent spotlight signatures
|
|
9
|
-
npx signet-cli list
|
|
10
|
-
npx signet-cli list -n 10
|
|
9
|
+
npx @signet-base/cli list
|
|
10
|
+
npx @signet-base/cli list -n 10
|
|
11
11
|
|
|
12
12
|
# Estimate spotlight cost
|
|
13
|
-
npx signet-cli estimate
|
|
14
|
-
npx signet-cli estimate --hours 6
|
|
13
|
+
npx @signet-base/cli estimate
|
|
14
|
+
npx @signet-base/cli estimate --hours 6
|
|
15
15
|
|
|
16
16
|
# Post a URL to spotlight (requires wallet)
|
|
17
|
-
npx signet-cli post --url https://example.com --hours 0
|
|
18
|
-
npx signet-cli post --url https://example.com --private-key 0x...
|
|
17
|
+
npx @signet-base/cli post --url https://example.com --hours 0
|
|
18
|
+
npx @signet-base/cli post --url https://example.com --private-key 0x...
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Environment Variables
|
package/package.json
CHANGED
package/src/commands/list.js
CHANGED
|
@@ -2,19 +2,47 @@ import { fetchSignatures } from "../api.js";
|
|
|
2
2
|
|
|
3
3
|
export async function list(opts) {
|
|
4
4
|
const count = parseInt(opts.count);
|
|
5
|
-
const endIndex = count;
|
|
6
5
|
|
|
7
6
|
try {
|
|
8
|
-
|
|
7
|
+
// Find the latest signature index by probing
|
|
8
|
+
let high = 100;
|
|
9
|
+
let latestIndex = -1;
|
|
10
|
+
|
|
11
|
+
// Quick probe to find approximate range
|
|
12
|
+
for (const probe of [1000, 500, 100, 50, 20, 10]) {
|
|
13
|
+
const { signatures } = await fetchSignatures(Math.max(0, probe - 1), probe, opts.baseUrl);
|
|
14
|
+
if (signatures?.length > 0) {
|
|
15
|
+
latestIndex = Math.max(latestIndex, ...signatures.map(s => s.signatureIndex));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// If no high index found, try from 0
|
|
21
|
+
if (latestIndex < 0) {
|
|
22
|
+
const { signatures } = await fetchSignatures(0, 9, opts.baseUrl);
|
|
23
|
+
if (!signatures?.length) {
|
|
24
|
+
console.log("No signatures found.");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
latestIndex = Math.max(...signatures.map(s => s.signatureIndex));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Fetch the most recent signatures
|
|
31
|
+
const startIndex = Math.max(0, latestIndex - count + 1);
|
|
32
|
+
const { signatures } = await fetchSignatures(startIndex, latestIndex, opts.baseUrl);
|
|
9
33
|
|
|
10
34
|
if (!signatures?.length) {
|
|
11
35
|
console.log("No signatures found.");
|
|
12
36
|
return;
|
|
13
37
|
}
|
|
14
38
|
|
|
15
|
-
|
|
39
|
+
// Sort descending (most recent first)
|
|
40
|
+
signatures.sort((a, b) => b.signatureIndex - a.signatureIndex);
|
|
41
|
+
const display = signatures.slice(0, count);
|
|
42
|
+
|
|
43
|
+
console.log(`\nš Recent Signet Signatures (${display.length})\n`);
|
|
16
44
|
|
|
17
|
-
for (const sig of
|
|
45
|
+
for (const sig of display) {
|
|
18
46
|
const date = new Date(sig.timestamp * 1000).toLocaleDateString();
|
|
19
47
|
const hunt = (Number(sig.huntAmount) / 1e18).toFixed(2);
|
|
20
48
|
const title = sig.metadata?.title || "(no title)";
|