@xyz17711/token-verdict 0.0.0-stage → 0.1.0
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 +86 -2
- package/dist/index.d.ts +113 -0
- package/dist/index.js +11 -0
- package/dist/langchain.d.ts +22 -0
- package/dist/langchain.js +19 -0
- package/package.json +40 -4
- package/src/index.ts +126 -0
- package/src/langchain.ts +28 -0
- package/test/index.test.mjs +24 -0
- package/test/langchain.test.mjs +16 -0
- package/tsconfig.json +16 -0
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xyz17711/token-verdict
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/17711-services/clients/actions/workflows/publish-node.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@xyz17711/token-verdict)
|
|
5
|
+
[](https://github.com/17711-services/clients/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
Typed TypeScript client for **🪙 token-verdict-service**, part of the
|
|
8
|
+
[17711.xyz](https://api.17711.xyz) microservice fleet -- pay-per-call APIs settled in USDC via
|
|
9
|
+
[x402](https://x402.org), listed on [x402scan](https://www.x402scan.com/server/f1c7b972-3405-4b75-8b4f-d1bfbd6305ff).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @xyz17711/token-verdict
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Methods
|
|
18
|
+
|
|
19
|
+
| Method | Description |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `getVerdict` | Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402) |
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Client } from "@xyz17711/token-verdict";
|
|
27
|
+
|
|
28
|
+
const client = new Client("https://api.17711.xyz/registry/🪙 token-verdict-service");
|
|
29
|
+
// see the Methods table above for every available call and its request/response type
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Paying past the free quota
|
|
33
|
+
|
|
34
|
+
Every gated tool allows a small number of free calls per day; beyond that it returns a 402
|
|
35
|
+
challenge. Without a wallet configured, this client throws `PaymentRequiredError` with the price,
|
|
36
|
+
network, and payee address attached:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Client, PaymentRequiredError } from "@xyz17711/token-verdict";
|
|
40
|
+
|
|
41
|
+
const client = new Client("https://api.17711.xyz/registry/🪙 token-verdict-service");
|
|
42
|
+
try {
|
|
43
|
+
await client.getVerdict(/* ... */);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
if (e instanceof PaymentRequiredError) {
|
|
46
|
+
console.log(`needs ${e.priceUsdc} USDC on ${e.network}, payable to ${e.payTo}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To pay automatically, configure a wallet on the client -- the private key should come from your
|
|
52
|
+
own environment/secrets manager, never a literal string in source code:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Client } from "@xyz17711/token-verdict";
|
|
56
|
+
|
|
57
|
+
const client = new Client("https://api.17711.xyz/registry/🪙 token-verdict-service", {
|
|
58
|
+
x402PrivateKey: process.env.X402_PRIVATE_KEY,
|
|
59
|
+
x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
|
|
60
|
+
x402MaxPaymentUsdc: 0.01, // refuse any single call above this
|
|
61
|
+
x402MaxTotalSpendUsdc: 1.0, // refuse once this WALLET's lifetime spend would exceed it
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Never commit a private key.** Both spend caps are required together with the key -- a wallet
|
|
66
|
+
with real funds and no explicit caps refuses to construct at all (`WalletConfigError`), on
|
|
67
|
+
purpose. The cumulative cap is tracked per wallet address, shared by every `Client` you construct
|
|
68
|
+
with that same key in this process.
|
|
69
|
+
|
|
70
|
+
## LangChain.js
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { Client } from "@xyz17711/token-verdict";
|
|
74
|
+
import { TokenVerdictToolkit } from "@xyz17711/token-verdict/langchain";
|
|
75
|
+
|
|
76
|
+
const client = new Client("https://api.17711.xyz/registry/🪙 token-verdict-service", { /* ...wallet options... */ });
|
|
77
|
+
const tools = new TokenVerdictToolkit(client).getTools();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Requires the optional `@langchain/core`+`zod` peer dependencies (`npm install @langchain/core
|
|
81
|
+
zod`) -- importing the base package above never requires them; only `@xyz17711/token-verdict/langchain`
|
|
82
|
+
does.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT -- see [`LICENSE`](../../LICENSE), shared by every language's client library in the
|
|
87
|
+
`clients` repo this package lives in.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed HTTP client and request/response interfaces for 🪙 token-verdict-service.
|
|
3
|
+
*/
|
|
4
|
+
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
5
|
+
export interface ContractInfo {
|
|
6
|
+
/** Whether the contract can block addresses. */
|
|
7
|
+
blacklist?: boolean | null;
|
|
8
|
+
/** Whether the real owner is hidden. */
|
|
9
|
+
hidden_owner?: boolean | null;
|
|
10
|
+
/** Whether new tokens can be minted. */
|
|
11
|
+
mintable?: boolean | null;
|
|
12
|
+
/** Owner address, absent when ownership is renounced. */
|
|
13
|
+
owner?: string | null;
|
|
14
|
+
/** Whether a previous owner can take ownership back. */
|
|
15
|
+
owner_can_reclaim?: boolean | null;
|
|
16
|
+
ownership_renounced: boolean;
|
|
17
|
+
/** Whether transfers can be paused. */
|
|
18
|
+
pausable?: boolean | null;
|
|
19
|
+
/** Whether it is an upgradeable proxy (the logic can be replaced). */
|
|
20
|
+
proxy?: boolean | null;
|
|
21
|
+
/** Whether the contract can self-destruct. */
|
|
22
|
+
self_destruct?: boolean | null;
|
|
23
|
+
/** Whether the source code is published and verified. */
|
|
24
|
+
source_verified?: boolean | null;
|
|
25
|
+
/** Whether the owner can change the taxes after launch. */
|
|
26
|
+
taxes_modifiable?: boolean | null;
|
|
27
|
+
}
|
|
28
|
+
export interface Finding {
|
|
29
|
+
/** Stable code, e.g. `trading.honeypot`, `liquidity.low`, `contract.mintable`. */
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
/** `critical`, `high`, `medium`, `low` or `info`. */
|
|
33
|
+
severity: string;
|
|
34
|
+
}
|
|
35
|
+
export interface HoldersInfo {
|
|
36
|
+
count?: number | null;
|
|
37
|
+
/** Share of the supply held by the creator, in percent. */
|
|
38
|
+
creator_percent?: number | null;
|
|
39
|
+
/** Share of the supply held by the owner, in percent. */
|
|
40
|
+
owner_percent?: number | null;
|
|
41
|
+
/** Share held by the ten largest wallets that are not contracts, in percent. */
|
|
42
|
+
top10_wallets_percent?: number | null;
|
|
43
|
+
}
|
|
44
|
+
export interface LiquidityInfo {
|
|
45
|
+
/** Share of the liquidity-token supply that is locked, in percent. */
|
|
46
|
+
locked_percent?: number | null;
|
|
47
|
+
/** Age in days of the oldest trading pool. */
|
|
48
|
+
pool_age_days?: number | null;
|
|
49
|
+
pools: number;
|
|
50
|
+
/** Largest pool: exchange name. */
|
|
51
|
+
top_pool?: string | null;
|
|
52
|
+
/** Liquidity in USD summed over the trading pools. */
|
|
53
|
+
total_usd: number;
|
|
54
|
+
}
|
|
55
|
+
export interface MarketInfo {
|
|
56
|
+
buys_24h: number;
|
|
57
|
+
fully_diluted_value_usd?: number | null;
|
|
58
|
+
price_change_24h_percent?: number | null;
|
|
59
|
+
price_usd?: number | null;
|
|
60
|
+
sells_24h: number;
|
|
61
|
+
volume_24h_usd: number;
|
|
62
|
+
}
|
|
63
|
+
export interface TradingInfo {
|
|
64
|
+
/** Buy tax in percent. */
|
|
65
|
+
buy_tax_percent?: number | null;
|
|
66
|
+
/** Whether a holder cannot sell their whole balance. */
|
|
67
|
+
cannot_sell_all?: boolean | null;
|
|
68
|
+
/** Whether the token cannot be sold after being bought. */
|
|
69
|
+
honeypot?: boolean | null;
|
|
70
|
+
/** Sell tax in percent. */
|
|
71
|
+
sell_tax_percent?: number | null;
|
|
72
|
+
}
|
|
73
|
+
export interface GetVerdictResponse {
|
|
74
|
+
address: string;
|
|
75
|
+
/** How old this verdict is, in seconds (0 for a fresh check). */
|
|
76
|
+
age_seconds: number;
|
|
77
|
+
chain: string;
|
|
78
|
+
contract: ContractInfo;
|
|
79
|
+
/** Always states that this is an automated risk screen, not advice. */
|
|
80
|
+
disclaimer: string;
|
|
81
|
+
/** Everything that drove the verdict, most severe first. */
|
|
82
|
+
findings: Finding[];
|
|
83
|
+
/** `true` when served from a stored result. */
|
|
84
|
+
from_cache: boolean;
|
|
85
|
+
holders: HoldersInfo;
|
|
86
|
+
liquidity: LiquidityInfo;
|
|
87
|
+
market: MarketInfo;
|
|
88
|
+
name?: string | null;
|
|
89
|
+
/** When the data was read (UTC). */
|
|
90
|
+
retrieved_at: string;
|
|
91
|
+
/** 0 to 100, higher is safer; derived from the findings. */
|
|
92
|
+
safety_score: number;
|
|
93
|
+
/** The data sources consulted. */
|
|
94
|
+
sources: string[];
|
|
95
|
+
symbol?: string | null;
|
|
96
|
+
trading: TradingInfo;
|
|
97
|
+
/** `safe`, `caution`, `danger` or `unknown` (the security source did not answer: not a green light). */
|
|
98
|
+
verdict: string;
|
|
99
|
+
}
|
|
100
|
+
export interface GetVerdictRequest {
|
|
101
|
+
/** The token contract address (`0x` followed by 40 hex characters). */
|
|
102
|
+
address: string;
|
|
103
|
+
/** The chain: `base` (default), `ethereum`, `bsc`, `polygon`, `arbitrum`, `optimism` or `avalanche`. */
|
|
104
|
+
chain?: string | null;
|
|
105
|
+
/** The oldest verdict you accept, in seconds. Omit it for the default (verdicts up to 5 minutes old); `0` forces a fresh check. The response always says how old it is. */
|
|
106
|
+
max_age_seconds?: number | null;
|
|
107
|
+
}
|
|
108
|
+
/** Typed client for 🪙 token-verdict-service, e.g. `client.getVerdict(...)`. */
|
|
109
|
+
export declare class Client extends BaseClient {
|
|
110
|
+
/** Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402) */
|
|
111
|
+
getVerdict(request: GetVerdictRequest): Promise<GetVerdictResponse>;
|
|
112
|
+
}
|
|
113
|
+
export { ClientOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed HTTP client and request/response interfaces for 🪙 token-verdict-service.
|
|
3
|
+
*/
|
|
4
|
+
import { Client as BaseClient } from "@xyz17711/core";
|
|
5
|
+
/** Typed client for 🪙 token-verdict-service, e.g. `client.getVerdict(...)`. */
|
|
6
|
+
export class Client extends BaseClient {
|
|
7
|
+
/** Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402) */
|
|
8
|
+
async getVerdict(request) {
|
|
9
|
+
return this.post("/v1/token-verdict/get_verdict", request);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain.js tools for 🪙 token-verdict-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `token-verdict/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { Client } from "./index.js";
|
|
6
|
+
export declare class TokenVerdictToolkit {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: Client);
|
|
9
|
+
getTools(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
10
|
+
address: z.ZodString;
|
|
11
|
+
chain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
max_age_seconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
13
|
+
}, z.core.$strip>, {
|
|
14
|
+
address: string;
|
|
15
|
+
chain?: string | null | undefined;
|
|
16
|
+
max_age_seconds?: number | null | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
address: string;
|
|
19
|
+
chain?: string | null | undefined;
|
|
20
|
+
max_age_seconds?: number | null | undefined;
|
|
21
|
+
}, import("./index.js").GetVerdictResponse, unknown, "getVerdict">[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain.js tools for 🪙 token-verdict-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `token-verdict/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
|
+
*/
|
|
4
|
+
import { tool } from "@langchain/core/tools";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
export class TokenVerdictToolkit {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
getTools() {
|
|
11
|
+
return [
|
|
12
|
+
tool(async (input) => this.client.getVerdict(input), {
|
|
13
|
+
name: "getVerdict",
|
|
14
|
+
description: "Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402)",
|
|
15
|
+
schema: z.object({ address: z.string(), chain: z.string().nullable().optional(), max_age_seconds: z.number().nullable().optional() }),
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyz17711/token-verdict",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Generated typed client for the 🪙 token-verdict-service 17711.xyz microservice.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./langchain": {
|
|
14
|
+
"types": "./dist/langchain.d.ts",
|
|
15
|
+
"default": "./dist/langchain.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p .",
|
|
20
|
+
"test": "npm run build && node --test test/*.test.mjs"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@xyz17711/core": "^0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@langchain/core": ">=0.3",
|
|
27
|
+
"zod": "^3 || ^4"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@langchain/core": {
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"zod": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5",
|
|
39
|
+
"@langchain/core": "^1.2",
|
|
40
|
+
"zod": "^4"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed HTTP client and request/response interfaces for 🪙 token-verdict-service.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
6
|
+
|
|
7
|
+
export interface ContractInfo {
|
|
8
|
+
/** Whether the contract can block addresses. */
|
|
9
|
+
blacklist?: boolean | null;
|
|
10
|
+
/** Whether the real owner is hidden. */
|
|
11
|
+
hidden_owner?: boolean | null;
|
|
12
|
+
/** Whether new tokens can be minted. */
|
|
13
|
+
mintable?: boolean | null;
|
|
14
|
+
/** Owner address, absent when ownership is renounced. */
|
|
15
|
+
owner?: string | null;
|
|
16
|
+
/** Whether a previous owner can take ownership back. */
|
|
17
|
+
owner_can_reclaim?: boolean | null;
|
|
18
|
+
ownership_renounced: boolean;
|
|
19
|
+
/** Whether transfers can be paused. */
|
|
20
|
+
pausable?: boolean | null;
|
|
21
|
+
/** Whether it is an upgradeable proxy (the logic can be replaced). */
|
|
22
|
+
proxy?: boolean | null;
|
|
23
|
+
/** Whether the contract can self-destruct. */
|
|
24
|
+
self_destruct?: boolean | null;
|
|
25
|
+
/** Whether the source code is published and verified. */
|
|
26
|
+
source_verified?: boolean | null;
|
|
27
|
+
/** Whether the owner can change the taxes after launch. */
|
|
28
|
+
taxes_modifiable?: boolean | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Finding {
|
|
32
|
+
/** Stable code, e.g. `trading.honeypot`, `liquidity.low`, `contract.mintable`. */
|
|
33
|
+
code: string;
|
|
34
|
+
message: string;
|
|
35
|
+
/** `critical`, `high`, `medium`, `low` or `info`. */
|
|
36
|
+
severity: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface HoldersInfo {
|
|
40
|
+
count?: number | null;
|
|
41
|
+
/** Share of the supply held by the creator, in percent. */
|
|
42
|
+
creator_percent?: number | null;
|
|
43
|
+
/** Share of the supply held by the owner, in percent. */
|
|
44
|
+
owner_percent?: number | null;
|
|
45
|
+
/** Share held by the ten largest wallets that are not contracts, in percent. */
|
|
46
|
+
top10_wallets_percent?: number | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface LiquidityInfo {
|
|
50
|
+
/** Share of the liquidity-token supply that is locked, in percent. */
|
|
51
|
+
locked_percent?: number | null;
|
|
52
|
+
/** Age in days of the oldest trading pool. */
|
|
53
|
+
pool_age_days?: number | null;
|
|
54
|
+
pools: number;
|
|
55
|
+
/** Largest pool: exchange name. */
|
|
56
|
+
top_pool?: string | null;
|
|
57
|
+
/** Liquidity in USD summed over the trading pools. */
|
|
58
|
+
total_usd: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface MarketInfo {
|
|
62
|
+
buys_24h: number;
|
|
63
|
+
fully_diluted_value_usd?: number | null;
|
|
64
|
+
price_change_24h_percent?: number | null;
|
|
65
|
+
price_usd?: number | null;
|
|
66
|
+
sells_24h: number;
|
|
67
|
+
volume_24h_usd: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TradingInfo {
|
|
71
|
+
/** Buy tax in percent. */
|
|
72
|
+
buy_tax_percent?: number | null;
|
|
73
|
+
/** Whether a holder cannot sell their whole balance. */
|
|
74
|
+
cannot_sell_all?: boolean | null;
|
|
75
|
+
/** Whether the token cannot be sold after being bought. */
|
|
76
|
+
honeypot?: boolean | null;
|
|
77
|
+
/** Sell tax in percent. */
|
|
78
|
+
sell_tax_percent?: number | null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface GetVerdictResponse {
|
|
82
|
+
address: string;
|
|
83
|
+
/** How old this verdict is, in seconds (0 for a fresh check). */
|
|
84
|
+
age_seconds: number;
|
|
85
|
+
chain: string;
|
|
86
|
+
contract: ContractInfo;
|
|
87
|
+
/** Always states that this is an automated risk screen, not advice. */
|
|
88
|
+
disclaimer: string;
|
|
89
|
+
/** Everything that drove the verdict, most severe first. */
|
|
90
|
+
findings: Finding[];
|
|
91
|
+
/** `true` when served from a stored result. */
|
|
92
|
+
from_cache: boolean;
|
|
93
|
+
holders: HoldersInfo;
|
|
94
|
+
liquidity: LiquidityInfo;
|
|
95
|
+
market: MarketInfo;
|
|
96
|
+
name?: string | null;
|
|
97
|
+
/** When the data was read (UTC). */
|
|
98
|
+
retrieved_at: string;
|
|
99
|
+
/** 0 to 100, higher is safer; derived from the findings. */
|
|
100
|
+
safety_score: number;
|
|
101
|
+
/** The data sources consulted. */
|
|
102
|
+
sources: string[];
|
|
103
|
+
symbol?: string | null;
|
|
104
|
+
trading: TradingInfo;
|
|
105
|
+
/** `safe`, `caution`, `danger` or `unknown` (the security source did not answer: not a green light). */
|
|
106
|
+
verdict: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface GetVerdictRequest {
|
|
110
|
+
/** The token contract address (`0x` followed by 40 hex characters). */
|
|
111
|
+
address: string;
|
|
112
|
+
/** The chain: `base` (default), `ethereum`, `bsc`, `polygon`, `arbitrum`, `optimism` or `avalanche`. */
|
|
113
|
+
chain?: string | null;
|
|
114
|
+
/** The oldest verdict you accept, in seconds. Omit it for the default (verdicts up to 5 minutes old); `0` forces a fresh check. The response always says how old it is. */
|
|
115
|
+
max_age_seconds?: number | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Typed client for 🪙 token-verdict-service, e.g. `client.getVerdict(...)`. */
|
|
119
|
+
export class Client extends BaseClient {
|
|
120
|
+
/** Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402) */
|
|
121
|
+
async getVerdict(request: GetVerdictRequest): Promise<GetVerdictResponse> {
|
|
122
|
+
return this.post<GetVerdictResponse>("/v1/token-verdict/get_verdict", request);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { ClientOptions };
|
package/src/langchain.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain.js tools for 🪙 token-verdict-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `token-verdict/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { tool } from "@langchain/core/tools";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Client } from "./index.js";
|
|
8
|
+
|
|
9
|
+
export class TokenVerdictToolkit {
|
|
10
|
+
private client: Client;
|
|
11
|
+
|
|
12
|
+
constructor(client: Client) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getTools() {
|
|
17
|
+
return [
|
|
18
|
+
tool(
|
|
19
|
+
async (input) => this.client.getVerdict(input),
|
|
20
|
+
{
|
|
21
|
+
name: "getVerdict",
|
|
22
|
+
description: "Token verdict and security check: is this token safe? Honeypot, rug pull and scam detection with taxes, liquidity and admin powers ($0.01, x402)",
|
|
23
|
+
schema: z.object({ address: z.string(), chain: z.string().nullable().optional(), max_age_seconds: z.number().nullable().optional() }),
|
|
24
|
+
},
|
|
25
|
+
),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies every token-verdict client method sends a request to the expected path/HTTP verb and parses a well-formed response -- one test per operation, real fetch mocked via a plain reassignment of `globalThis.fetch` (no extra test/mocking dependency). Runs against the COMPILED package (`../dist/index.js`) -- build before testing.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { Client } from "../dist/index.js";
|
|
8
|
+
|
|
9
|
+
test("getVerdict calls the expected path", async () => {
|
|
10
|
+
const originalFetch = globalThis.fetch;
|
|
11
|
+
globalThis.fetch = async (url, init = {}) => {
|
|
12
|
+
const parsed = new URL(url);
|
|
13
|
+
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
14
|
+
assert.equal(parsed.pathname, "/v1/token-verdict/get_verdict");
|
|
15
|
+
return new Response(JSON.stringify({ address: "test", age_seconds: 0, chain: "test", contract: { blacklist: null, hidden_owner: null, mintable: null, owner: null, owner_can_reclaim: null, ownership_renounced: false, pausable: null, proxy: null, self_destruct: null, source_verified: null, taxes_modifiable: null }, disclaimer: "test", findings: [], from_cache: false, holders: { count: null, creator_percent: null, owner_percent: null, top10_wallets_percent: null }, liquidity: { locked_percent: null, pool_age_days: null, pools: 0, top_pool: null, total_usd: 0 }, market: { buys_24h: 0, fully_diluted_value_usd: null, price_change_24h_percent: null, price_usd: null, sells_24h: 0, volume_24h_usd: 0 }, name: null, retrieved_at: "test", safety_score: 0, sources: [], symbol: null, trading: { buy_tax_percent: null, cannot_sell_all: null, honeypot: null, sell_tax_percent: null }, verdict: "test" }), { status: 200 });
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
const client = new Client("https://example.test");
|
|
19
|
+
const result = await client.getVerdict({ address: "test", chain: null, max_age_seconds: null });
|
|
20
|
+
assert.ok(result !== undefined);
|
|
21
|
+
} finally {
|
|
22
|
+
globalThis.fetch = originalFetch;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies every token-verdict LangChain tool through the real StructuredTool (`.invoke()`), not just the underlying client method -- catches schema-shape bugs a plain client-method test would miss. Requires the `langchain`/`zod` dev dependencies.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { Client } from "../dist/index.js";
|
|
8
|
+
import { TokenVerdictToolkit } from "../dist/langchain.js";
|
|
9
|
+
|
|
10
|
+
test("getVerdict tool invoke", async () => {
|
|
11
|
+
globalThis.fetch = async () => new Response(JSON.stringify({ address: "test", age_seconds: 0, chain: "test", contract: { blacklist: null, hidden_owner: null, mintable: null, owner: null, owner_can_reclaim: null, ownership_renounced: false, pausable: null, proxy: null, self_destruct: null, source_verified: null, taxes_modifiable: null }, disclaimer: "test", findings: [], from_cache: false, holders: { count: null, creator_percent: null, owner_percent: null, top10_wallets_percent: null }, liquidity: { locked_percent: null, pool_age_days: null, pools: 0, top_pool: null, total_usd: 0 }, market: { buys_24h: 0, fully_diluted_value_usd: null, price_change_24h_percent: null, price_usd: null, sells_24h: 0, volume_24h_usd: 0 }, name: null, retrieved_at: "test", safety_score: 0, sources: [], symbol: null, trading: { buy_tax_percent: null, cannot_sell_all: null, honeypot: null, sell_tax_percent: null }, verdict: "test" }), { status: 200 });
|
|
12
|
+
const toolkit = new TokenVerdictToolkit(new Client("https://example.test"));
|
|
13
|
+
const t = toolkit.getTools().find((x) => x.name === "getVerdict");
|
|
14
|
+
const result = await t.invoke({ address: "test", chain: "test", max_age_seconds: 0 });
|
|
15
|
+
assert.ok(result !== undefined);
|
|
16
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src"
|
|
15
|
+
]
|
|
16
|
+
}
|