@antseed/cli 0.1.185 → 0.1.186
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/dist/cli/commands/buyer/start.d.ts.map +1 -1
- package/dist/cli/commands/buyer/start.js +7 -2
- package/dist/cli/commands/buyer/start.js.map +1 -1
- package/dist/gateway/console-api/handlers/wallet-deposits.test.d.ts +2 -0
- package/dist/gateway/console-api/handlers/wallet-deposits.test.d.ts.map +1 -0
- package/dist/gateway/console-api/handlers/wallet-deposits.test.js +94 -0
- package/dist/gateway/console-api/handlers/wallet-deposits.test.js.map +1 -0
- package/dist/gateway/console-api/handlers/wallet.d.ts +3 -0
- package/dist/gateway/console-api/handlers/wallet.d.ts.map +1 -1
- package/dist/gateway/console-api/handlers/wallet.js +86 -2
- package/dist/gateway/console-api/handlers/wallet.js.map +1 -1
- package/dist/gateway/console-api/types.d.ts +29 -0
- package/dist/gateway/console-api/types.d.ts.map +1 -1
- package/dist/gateway/console-api/types.js.map +1 -1
- package/dist/gateway/pinned-model.d.ts +7 -0
- package/dist/gateway/pinned-model.d.ts.map +1 -0
- package/dist/gateway/pinned-model.js +25 -0
- package/dist/gateway/pinned-model.js.map +1 -0
- package/dist/gateway/pinned-model.test.d.ts +2 -0
- package/dist/gateway/pinned-model.test.d.ts.map +1 -0
- package/dist/gateway/pinned-model.test.js +47 -0
- package/dist/gateway/pinned-model.test.js.map +1 -0
- package/dist/gateway/services/deposits.d.ts +57 -0
- package/dist/gateway/services/deposits.d.ts.map +1 -0
- package/dist/gateway/services/deposits.js +119 -0
- package/dist/gateway/services/deposits.js.map +1 -0
- package/dist/gateway/services/deposits.test.d.ts +2 -0
- package/dist/gateway/services/deposits.test.d.ts.map +1 -0
- package/dist/gateway/services/deposits.test.js +67 -0
- package/dist/gateway/services/deposits.test.js.map +1 -0
- package/dist/gateway/store-data.test.js +1 -1
- package/dist/gateway/store-data.test.js.map +1 -1
- package/dist/gateway/store-migrations.d.ts +0 -4
- package/dist/gateway/store-migrations.d.ts.map +1 -1
- package/dist/gateway/store-migrations.js +23 -0
- package/dist/gateway/store-migrations.js.map +1 -1
- package/dist/gateway/store.d.ts +36 -0
- package/dist/gateway/store.d.ts.map +1 -1
- package/dist/gateway/store.js +52 -4
- package/dist/gateway/store.js.map +1 -1
- package/dist/proxy/buyer-proxy.d.ts +4 -0
- package/dist/proxy/buyer-proxy.d.ts.map +1 -1
- package/dist/proxy/buyer-proxy.js +20 -0
- package/dist/proxy/buyer-proxy.js.map +1 -1
- package/dist/proxy/deposit-log.d.ts +20 -0
- package/dist/proxy/deposit-log.d.ts.map +1 -0
- package/dist/proxy/deposit-log.js +64 -0
- package/dist/proxy/deposit-log.js.map +1 -0
- package/dist/proxy/deposit-log.test.d.ts +2 -0
- package/dist/proxy/deposit-log.test.d.ts.map +1 -0
- package/dist/proxy/deposit-log.test.js +26 -0
- package/dist/proxy/deposit-log.test.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface DepositLogEntry {
|
|
2
|
+
/** The transaction that credited the deposits balance (the relay's sweep, or a direct deposit). */
|
|
3
|
+
txHash: string;
|
|
4
|
+
/** USDC base units credited, after the relay fee. */
|
|
5
|
+
creditedBaseUnits: string;
|
|
6
|
+
/** When the watcher saw it credited (epoch ms). */
|
|
7
|
+
at: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class DepositLog {
|
|
10
|
+
private readonly dir;
|
|
11
|
+
/** Appends run one at a time, so two events for the same deposit cannot both pass the duplicate check. */
|
|
12
|
+
private queue;
|
|
13
|
+
constructor(stateDir: string);
|
|
14
|
+
private file;
|
|
15
|
+
/** Records a credited deposit once (the watcher can report the same one again when it backfills the hash). */
|
|
16
|
+
record(address: string, entry: DepositLogEntry): Promise<void>;
|
|
17
|
+
/** The wallet's credited deposits, oldest first; unreadable lines are skipped. */
|
|
18
|
+
list(address: string): Promise<DepositLogEntry[]>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=deposit-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit-log.d.ts","sourceRoot":"","sources":["../../src/proxy/deposit-log.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,eAAe;IAC9B,mGAAmG;IACnG,MAAM,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAA;IACzB,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAA;CACX;AAID,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,0GAA0G;IAC1G,OAAO,CAAC,KAAK,CAAsC;gBAEvC,QAAQ,EAAE,MAAM;IAI5B,OAAO,CAAC,IAAI;IAIZ,8GAA8G;IAC9G,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9D,kFAAkF;IAC5E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAqBxD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deposits credited to each buyer wallet, kept so the gateway can issue a
|
|
3
|
+
* confirmation for every one of them. The deposit watcher only reports its
|
|
4
|
+
* latest event, and public RPC endpoints cannot search a wallet's history
|
|
5
|
+
* (they cap log queries at a few thousand blocks), so the buyer writes each
|
|
6
|
+
* credited deposit down as it happens: one JSON line per deposit, one file per
|
|
7
|
+
* wallet, under the data directory. The chain stays the source of truth; the
|
|
8
|
+
* gateway verifies every entry against the transaction receipt.
|
|
9
|
+
*/
|
|
10
|
+
import { appendFile, mkdir, readFile } from 'node:fs/promises';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
const TX_HASH_RE = /^0x[0-9a-f]{64}$/;
|
|
13
|
+
export class DepositLog {
|
|
14
|
+
dir;
|
|
15
|
+
/** Appends run one at a time, so two events for the same deposit cannot both pass the duplicate check. */
|
|
16
|
+
queue = Promise.resolve();
|
|
17
|
+
constructor(stateDir) {
|
|
18
|
+
this.dir = join(stateDir, 'deposits');
|
|
19
|
+
}
|
|
20
|
+
file(address) {
|
|
21
|
+
return join(this.dir, `${address.toLowerCase()}.jsonl`);
|
|
22
|
+
}
|
|
23
|
+
/** Records a credited deposit once (the watcher can report the same one again when it backfills the hash). */
|
|
24
|
+
record(address, entry) {
|
|
25
|
+
const txHash = entry.txHash.toLowerCase();
|
|
26
|
+
if (!TX_HASH_RE.test(txHash))
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
const run = this.queue.then(async () => {
|
|
29
|
+
const existing = await this.list(address);
|
|
30
|
+
if (existing.some((row) => row.txHash === txHash))
|
|
31
|
+
return;
|
|
32
|
+
await mkdir(this.dir, { recursive: true });
|
|
33
|
+
await appendFile(this.file(address), `${JSON.stringify({ ...entry, txHash })}\n`, 'utf8');
|
|
34
|
+
});
|
|
35
|
+
this.queue = run.catch(() => undefined);
|
|
36
|
+
return run;
|
|
37
|
+
}
|
|
38
|
+
/** The wallet's credited deposits, oldest first; unreadable lines are skipped. */
|
|
39
|
+
async list(address) {
|
|
40
|
+
let text;
|
|
41
|
+
try {
|
|
42
|
+
text = await readFile(this.file(address), 'utf8');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const rows = [];
|
|
48
|
+
for (const line of text.split('\n')) {
|
|
49
|
+
if (!line.trim())
|
|
50
|
+
continue;
|
|
51
|
+
try {
|
|
52
|
+
const row = JSON.parse(line);
|
|
53
|
+
if (typeof row.txHash === 'string' && TX_HASH_RE.test(row.txHash) && typeof row.creditedBaseUnits === 'string' && typeof row.at === 'number') {
|
|
54
|
+
rows.push({ txHash: row.txHash, creditedBaseUnits: row.creditedBaseUnits, at: row.at });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// A torn last line (crash mid-write) is ignored; the deposit can still be added by its transaction hash.
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return rows;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=deposit-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit-log.js","sourceRoot":"","sources":["../../src/proxy/deposit-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAWhC,MAAM,UAAU,GAAG,kBAAkB,CAAA;AAErC,MAAM,OAAO,UAAU;IACJ,GAAG,CAAQ;IAC5B,0GAA0G;IAClG,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAA;IAEnD,YAAY,QAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACvC,CAAC;IAEO,IAAI,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IACzD,CAAC;IAED,8GAA8G;IAC9G,MAAM,CAAC,OAAe,EAAE,KAAsB;QAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACzC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAA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AG,CAAC,iBAAiB,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAA;gBACzF,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,yGAAyG;YAC3G,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit-log.test.d.ts","sourceRoot":"","sources":["../../src/proxy/deposit-log.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { appendFileSync, mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { test } from 'node:test';
|
|
6
|
+
import { DepositLog } from './deposit-log.js';
|
|
7
|
+
const WALLET = `0x${'AB'.repeat(20)}`;
|
|
8
|
+
const TX = `0x${'a1'.repeat(32)}`;
|
|
9
|
+
test('records each credited deposit once, per wallet, and skips torn lines', async () => {
|
|
10
|
+
const dir = mkdtempSync(join(tmpdir(), 'antseed-deposit-log-'));
|
|
11
|
+
try {
|
|
12
|
+
const log = new DepositLog(dir);
|
|
13
|
+
await Promise.all([
|
|
14
|
+
log.record(WALLET, { txHash: TX, creditedBaseUnits: '1000000', at: 1 }),
|
|
15
|
+
log.record(WALLET, { txHash: TX.toUpperCase().replace('0X', '0x'), creditedBaseUnits: '1000000', at: 2 }),
|
|
16
|
+
]);
|
|
17
|
+
await log.record(WALLET, { txHash: 'not-a-hash', creditedBaseUnits: '1', at: 3 });
|
|
18
|
+
appendFileSync(join(dir, 'deposits', `${WALLET.toLowerCase()}.jsonl`), '{"txHash":"0x');
|
|
19
|
+
assert.deepEqual(await log.list(WALLET.toLowerCase()), [{ txHash: TX, creditedBaseUnits: '1000000', at: 1 }]);
|
|
20
|
+
assert.deepEqual(await log.list(`0x${'cd'.repeat(20)}`), []);
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
rmSync(dir, { recursive: true, force: true });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=deposit-log.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit-log.test.js","sourceRoot":"","sources":["../../src/proxy/deposit-log.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;AACrC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;AAEjC,IAAI,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;IACtF,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAAA;IAC/D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;YACvE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;SAC1G,CAAC,CAAA;QACF,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;QACjF,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAA;QACvF,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QAC7G,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9D,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antseed/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.186",
|
|
4
4
|
"description": "Antseed Network CLI and Web Dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"reflect-metadata": "^0.2.2",
|
|
34
34
|
"zod": "^4",
|
|
35
35
|
"@antseed/ant-agent": "0.1.35",
|
|
36
|
-
"@antseed/api-adapter": "0.1.50",
|
|
37
36
|
"@antseed/ants": "0.1.23",
|
|
38
37
|
"@antseed/connected-apps": "0.1.0",
|
|
39
|
-
"@antseed/
|
|
40
|
-
"@antseed/
|
|
38
|
+
"@antseed/api-adapter": "0.1.50",
|
|
39
|
+
"@antseed/payments": "0.1.67",
|
|
41
40
|
"@antseed/provider-core": "0.2.57",
|
|
42
|
-
"@antseed/
|
|
41
|
+
"@antseed/gateway-console": "0.1.6",
|
|
42
|
+
"@antseed/node": "0.2.140"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/better-sqlite3": "^7.6.13",
|