@kasarlabs/starknet-rpc-mcp 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/LICENSE +21 -0
- package/README.md +38 -0
- package/bin/starknet-rpc-mcp.js +14 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +169 -0
- package/build/index.js.map +1 -0
- package/build/lib/types/index.d.ts +85 -0
- package/build/lib/types/index.js +51 -0
- package/build/lib/types/index.js.map +1 -0
- package/build/schemas/index.d.ts +88 -0
- package/build/schemas/index.js +78 -0
- package/build/schemas/index.js.map +1 -0
- package/build/tools/getBlockLatestAccepted.d.ts +10 -0
- package/build/tools/getBlockLatestAccepted.js +16 -0
- package/build/tools/getBlockLatestAccepted.js.map +1 -0
- package/build/tools/getBlockNumber.d.ts +10 -0
- package/build/tools/getBlockNumber.js +16 -0
- package/build/tools/getBlockNumber.js.map +1 -0
- package/build/tools/getBlockStateUpdate.d.ts +12 -0
- package/build/tools/getBlockStateUpdate.js +16 -0
- package/build/tools/getBlockStateUpdate.js.map +1 -0
- package/build/tools/getBlockTransactionCount.d.ts +12 -0
- package/build/tools/getBlockTransactionCount.js +16 -0
- package/build/tools/getBlockTransactionCount.js.map +1 -0
- package/build/tools/getBlockTransactionsTraces.d.ts +12 -0
- package/build/tools/getBlockTransactionsTraces.js +16 -0
- package/build/tools/getBlockTransactionsTraces.js.map +1 -0
- package/build/tools/getBlockWithReceipts.d.ts +12 -0
- package/build/tools/getBlockWithReceipts.js +16 -0
- package/build/tools/getBlockWithReceipts.js.map +1 -0
- package/build/tools/getBlockWithTxHashes.d.ts +12 -0
- package/build/tools/getBlockWithTxHashes.js +16 -0
- package/build/tools/getBlockWithTxHashes.js.map +1 -0
- package/build/tools/getBlockWithTxs.d.ts +12 -0
- package/build/tools/getBlockWithTxs.js +16 -0
- package/build/tools/getBlockWithTxs.js.map +1 -0
- package/build/tools/getChainId.d.ts +10 -0
- package/build/tools/getChainId.js +16 -0
- package/build/tools/getChainId.js.map +1 -0
- package/build/tools/getClass.d.ts +13 -0
- package/build/tools/getClass.js +16 -0
- package/build/tools/getClass.js.map +1 -0
- package/build/tools/getClassAt.d.ts +13 -0
- package/build/tools/getClassAt.js +16 -0
- package/build/tools/getClassAt.js.map +1 -0
- package/build/tools/getClassHash.d.ts +13 -0
- package/build/tools/getClassHash.js +16 -0
- package/build/tools/getClassHash.js.map +1 -0
- package/build/tools/getClassHashAt.d.ts +13 -0
- package/build/tools/getClassHashAt.js +16 -0
- package/build/tools/getClassHashAt.js.map +1 -0
- package/build/tools/getNonceForAddress.d.ts +13 -0
- package/build/tools/getNonceForAddress.js +16 -0
- package/build/tools/getNonceForAddress.js.map +1 -0
- package/build/tools/getSpecVersion.d.ts +10 -0
- package/build/tools/getSpecVersion.js +16 -0
- package/build/tools/getSpecVersion.js.map +1 -0
- package/build/tools/getStorageAt.d.ts +14 -0
- package/build/tools/getStorageAt.js +16 -0
- package/build/tools/getStorageAt.js.map +1 -0
- package/build/tools/getSyncingStats.d.ts +10 -0
- package/build/tools/getSyncingStats.js +16 -0
- package/build/tools/getSyncingStats.js.map +1 -0
- package/build/tools/getTransactionByBlockIdAndIndex.d.ts +13 -0
- package/build/tools/getTransactionByBlockIdAndIndex.js +16 -0
- package/build/tools/getTransactionByBlockIdAndIndex.js.map +1 -0
- package/build/tools/getTransactionByHash.d.ts +12 -0
- package/build/tools/getTransactionByHash.js +16 -0
- package/build/tools/getTransactionByHash.js.map +1 -0
- package/build/tools/getTransactionReceipt.d.ts +12 -0
- package/build/tools/getTransactionReceipt.js +16 -0
- package/build/tools/getTransactionReceipt.js.map +1 -0
- package/build/tools/getTransactionStatus.d.ts +12 -0
- package/build/tools/getTransactionStatus.js +16 -0
- package/build/tools/getTransactionStatus.js.map +1 -0
- package/build/tools/getTransactionTrace.d.ts +12 -0
- package/build/tools/getTransactionTrace.js +16 -0
- package/build/tools/getTransactionTrace.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kasar Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Snak - RPC Plugin
|
|
2
|
+
|
|
3
|
+
The RPC Plugin provides tools for interacting directly with the Starknet blockchain via RPC (Remote Procedure Call) methods, enabling access to blockchain data and state.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
This plugin adds the following RPC tools:
|
|
8
|
+
|
|
9
|
+
- **get_chain_id**: Retrieve the unique identifier (chain ID) of the Starknet network.
|
|
10
|
+
- **get_syncing_status**: Retrieve the syncing status of the Starknet node.
|
|
11
|
+
- **get_class_hash**: Retrieve the unique class hash for a contract at a specific address.
|
|
12
|
+
- **get_spec_version**: Get the current spec version from the Starknet RPC provider.
|
|
13
|
+
- **get_block_with_tx_hashes**: Retrieve block details including transaction hashes.
|
|
14
|
+
- **get_block_with_receipts**: Fetch block details with transaction receipts.
|
|
15
|
+
- **get_transaction_status**: Fetch transaction status by hash.
|
|
16
|
+
- **get_block_number**: Get the current block number from the Starknet network.
|
|
17
|
+
- **get_block_transaction_count**: Get the number of transactions in a specific block.
|
|
18
|
+
- **get_storage_at**: Get the storage value at a specific slot for a contract.
|
|
19
|
+
- **get_class**: Retrieve the complete class definition of a contract.
|
|
20
|
+
- **get_class_at**: Fetch the class definition of a contract at a specific address.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
The RPC Plugin is used internally by the Starknet Agent and doesn't need to be called directly. When the agent is initialized, it automatically registers these tools, making them available for use.
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
When asking the agent to perform RPC-related tasks, it will use the appropriate tool from this plugin:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
"What's the current block number?" // Uses get_block_number
|
|
32
|
+
"Show me the status of transaction 0x1234..." // Uses get_transaction_status
|
|
33
|
+
"What's the chain ID of the current network?" // Uses get_chain_id
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
To extend this plugin, add new tools in the `src/tools` directory and register them in the `registerTools` function in `src/tools/index.ts`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const buildPath = join(__dirname, '..', 'build', 'index.js');
|
|
8
|
+
|
|
9
|
+
if (!existsSync(buildPath)) {
|
|
10
|
+
console.error('Build not found. Run: npm run build');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
await import(buildPath);
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { registerToolsWithServer, getOnchainRead, } from '@kasarlabs/ask-starknet-core';
|
|
5
|
+
import dotenv from 'dotenv';
|
|
6
|
+
import { getSpecVersion } from './tools/getSpecVersion.js';
|
|
7
|
+
import { getBlockWithTxHashes } from './tools/getBlockWithTxHashes.js';
|
|
8
|
+
import { getBlockWithReceipts } from './tools/getBlockWithReceipts.js';
|
|
9
|
+
import { getTransactionStatus } from './tools/getTransactionStatus.js';
|
|
10
|
+
import { getClass } from './tools/getClass.js';
|
|
11
|
+
import { getChainId } from './tools/getChainId.js';
|
|
12
|
+
import { getSyncingStats } from './tools/getSyncingStats.js';
|
|
13
|
+
import { getBlockNumber } from './tools/getBlockNumber.js';
|
|
14
|
+
import { getBlockTransactionCount } from './tools/getBlockTransactionCount.js';
|
|
15
|
+
import { getStorageAt } from './tools/getStorageAt.js';
|
|
16
|
+
import { getClassAt } from './tools/getClassAt.js';
|
|
17
|
+
import { getClassHashAt } from './tools/getClassHashAt.js';
|
|
18
|
+
import { getStorageAtSchema, blockIdSchema, blockIdAndContractAddressSchema, getClassAtSchema, getClassHashAtSchema, transactionHashSchema, } from './schemas/index.js';
|
|
19
|
+
dotenv.config();
|
|
20
|
+
const server = new McpServer({
|
|
21
|
+
name: 'starknet-rpc',
|
|
22
|
+
version: '0.0.1',
|
|
23
|
+
});
|
|
24
|
+
const registerTools = (RpcToolRegistry) => {
|
|
25
|
+
RpcToolRegistry.push({
|
|
26
|
+
name: 'get_chain_id',
|
|
27
|
+
description: 'Retrieve the unique identifier (chain ID) of the Starknet network',
|
|
28
|
+
execute: async (params) => {
|
|
29
|
+
const onchainRead = getOnchainRead();
|
|
30
|
+
const provider = onchainRead.provider;
|
|
31
|
+
return await getChainId(provider);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
RpcToolRegistry.push({
|
|
35
|
+
name: 'get_syncing_status',
|
|
36
|
+
description: 'Retrieve the syncing status of the Starknet node',
|
|
37
|
+
execute: async (params) => {
|
|
38
|
+
const onchainRead = getOnchainRead();
|
|
39
|
+
const provider = onchainRead.provider;
|
|
40
|
+
return await getSyncingStats(provider);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
RpcToolRegistry.push({
|
|
44
|
+
name: 'get_class_hash',
|
|
45
|
+
description: 'Retrieve the unique class hash for a contract at a specific address',
|
|
46
|
+
schema: getClassHashAtSchema,
|
|
47
|
+
execute: async (params) => {
|
|
48
|
+
const onchainRead = getOnchainRead();
|
|
49
|
+
const provider = onchainRead.provider;
|
|
50
|
+
return await getClassHashAt(provider, params);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
RpcToolRegistry.push({
|
|
54
|
+
name: 'get_spec_version',
|
|
55
|
+
description: 'Get the current spec version from the Starknet RPC provider',
|
|
56
|
+
execute: async (params) => {
|
|
57
|
+
const onchainRead = getOnchainRead();
|
|
58
|
+
const provider = onchainRead.provider;
|
|
59
|
+
return await getSpecVersion(provider);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
RpcToolRegistry.push({
|
|
63
|
+
name: 'get_block_with_tx_hashes',
|
|
64
|
+
description: 'Retrieve the details of a block, including transaction hashes',
|
|
65
|
+
schema: blockIdSchema,
|
|
66
|
+
execute: async (params) => {
|
|
67
|
+
const onchainRead = getOnchainRead();
|
|
68
|
+
const provider = onchainRead.provider;
|
|
69
|
+
return await getBlockWithTxHashes(provider, params);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
RpcToolRegistry.push({
|
|
73
|
+
name: 'get_block_with_receipts',
|
|
74
|
+
description: 'Fetch block details with transaction receipts',
|
|
75
|
+
schema: blockIdSchema,
|
|
76
|
+
execute: async (params) => {
|
|
77
|
+
const onchainRead = getOnchainRead();
|
|
78
|
+
const provider = onchainRead.provider;
|
|
79
|
+
return await getBlockWithReceipts(provider, params);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
RpcToolRegistry.push({
|
|
83
|
+
name: 'get_transaction_status',
|
|
84
|
+
description: 'Fetch transaction status by hash',
|
|
85
|
+
schema: transactionHashSchema,
|
|
86
|
+
execute: async (params) => {
|
|
87
|
+
const onchainRead = getOnchainRead();
|
|
88
|
+
const provider = onchainRead.provider;
|
|
89
|
+
return await getTransactionStatus(provider, params);
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
RpcToolRegistry.push({
|
|
93
|
+
name: 'get_block_number',
|
|
94
|
+
description: 'Get the current block number from the Starknet network',
|
|
95
|
+
execute: async (params) => {
|
|
96
|
+
const onchainRead = getOnchainRead();
|
|
97
|
+
const provider = onchainRead.provider;
|
|
98
|
+
return await getBlockNumber(provider);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
RpcToolRegistry.push({
|
|
102
|
+
name: 'get_block_transaction_count',
|
|
103
|
+
description: 'Get the number of transactions in a specific block',
|
|
104
|
+
schema: blockIdSchema,
|
|
105
|
+
execute: async (params) => {
|
|
106
|
+
const onchainRead = getOnchainRead();
|
|
107
|
+
const provider = onchainRead.provider;
|
|
108
|
+
return await getBlockTransactionCount(provider, params);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
RpcToolRegistry.push({
|
|
112
|
+
name: 'get_storage_at',
|
|
113
|
+
description: 'Get the storage value at a specific slot for a contract',
|
|
114
|
+
schema: getStorageAtSchema,
|
|
115
|
+
execute: async (params) => {
|
|
116
|
+
const onchainRead = getOnchainRead();
|
|
117
|
+
const provider = onchainRead.provider;
|
|
118
|
+
return await getStorageAt(provider, params);
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
RpcToolRegistry.push({
|
|
122
|
+
name: 'get_class',
|
|
123
|
+
description: 'Retrieve the complete class definition of a contract at a specified address and block',
|
|
124
|
+
schema: blockIdAndContractAddressSchema,
|
|
125
|
+
execute: async (params) => {
|
|
126
|
+
const onchainRead = getOnchainRead();
|
|
127
|
+
const provider = onchainRead.provider;
|
|
128
|
+
return await getClass(provider, params);
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
RpcToolRegistry.push({
|
|
132
|
+
name: 'get_class_at',
|
|
133
|
+
description: 'Fetch the class definition of a contract at a specific address in the latest state',
|
|
134
|
+
schema: getClassAtSchema,
|
|
135
|
+
execute: async (params) => {
|
|
136
|
+
const onchainRead = getOnchainRead();
|
|
137
|
+
const provider = onchainRead.provider;
|
|
138
|
+
return await getClassAt(provider, params);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
export const RegisterToolInServer = async () => {
|
|
143
|
+
const tools = [];
|
|
144
|
+
registerTools(tools);
|
|
145
|
+
await registerToolsWithServer(server, tools);
|
|
146
|
+
};
|
|
147
|
+
const checkEnv = () => {
|
|
148
|
+
const rpcUrl = process.env.STARKNET_RPC_URL;
|
|
149
|
+
if (!rpcUrl) {
|
|
150
|
+
console.error('Missing required environment variable: STARKNET_RPC_URL');
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
};
|
|
155
|
+
async function main() {
|
|
156
|
+
const transport = new StdioServerTransport();
|
|
157
|
+
if (!checkEnv()) {
|
|
158
|
+
console.error('Failed to initialize RPC Provider');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
await RegisterToolInServer();
|
|
162
|
+
await server.connect(transport);
|
|
163
|
+
console.error('Starknet RPC MCP Server running on stdio');
|
|
164
|
+
}
|
|
165
|
+
main().catch((error) => {
|
|
166
|
+
console.error('Fatal error in main():', error);
|
|
167
|
+
process.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AK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RpcProvider } from 'starknet';
|
|
2
|
+
import { SystemMessage } from '@langchain/core/messages';
|
|
3
|
+
import { z as Zod } from 'zod';
|
|
4
|
+
export interface StarknetTool<P = unknown> {
|
|
5
|
+
name: string;
|
|
6
|
+
plugins: string;
|
|
7
|
+
description: string;
|
|
8
|
+
schema?: Zod.AnyZodObject;
|
|
9
|
+
responseFormat?: string;
|
|
10
|
+
execute: (agent: SnakAgentInterface, params: P, plugins_manager?: any) => Promise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface SignatureTool<P = any> {
|
|
13
|
+
name: string;
|
|
14
|
+
categorie?: string;
|
|
15
|
+
description: string;
|
|
16
|
+
schema?: object;
|
|
17
|
+
execute: (params: P) => Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
export declare enum AgentMode {
|
|
20
|
+
INTERACTIVE = "interactive",
|
|
21
|
+
AUTONOMOUS = "autonomous",
|
|
22
|
+
HYBRID = "hybrid"
|
|
23
|
+
}
|
|
24
|
+
export interface RawAgentConfig {
|
|
25
|
+
name: string;
|
|
26
|
+
group: string;
|
|
27
|
+
description: string;
|
|
28
|
+
lore: string[];
|
|
29
|
+
objectives: string[];
|
|
30
|
+
knowledge: string[];
|
|
31
|
+
interval: number;
|
|
32
|
+
plugins: string[];
|
|
33
|
+
memory: MemoryConfig;
|
|
34
|
+
rag?: RagConfig;
|
|
35
|
+
mcpServers?: Record<string, any>;
|
|
36
|
+
mode: AgentMode;
|
|
37
|
+
}
|
|
38
|
+
export interface MemoryConfig {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
shortTermMemorySize?: number;
|
|
41
|
+
memorySize?: number;
|
|
42
|
+
maxIterations?: number;
|
|
43
|
+
embeddingModel?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface RagConfig {
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
topK?: number;
|
|
48
|
+
embeddingModel?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface AgentConfig {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
group: string;
|
|
54
|
+
description: string;
|
|
55
|
+
interval: number;
|
|
56
|
+
chatId: string;
|
|
57
|
+
plugins: string[];
|
|
58
|
+
memory: MemoryConfig;
|
|
59
|
+
rag?: RagConfig;
|
|
60
|
+
mcpServers?: Record<string, any>;
|
|
61
|
+
mode: AgentMode;
|
|
62
|
+
maxIterations: number;
|
|
63
|
+
prompt: SystemMessage;
|
|
64
|
+
}
|
|
65
|
+
export interface DatabaseCredentials {
|
|
66
|
+
host: string;
|
|
67
|
+
port: number;
|
|
68
|
+
user: string;
|
|
69
|
+
password: string;
|
|
70
|
+
database: string;
|
|
71
|
+
}
|
|
72
|
+
export interface SnakAgentInterface {
|
|
73
|
+
getAccountCredentials: () => {
|
|
74
|
+
accountPublicKey: string;
|
|
75
|
+
accountPrivateKey: string;
|
|
76
|
+
};
|
|
77
|
+
getDatabaseCredentials: () => DatabaseCredentials;
|
|
78
|
+
getSignature: () => {
|
|
79
|
+
signature: string;
|
|
80
|
+
};
|
|
81
|
+
getProvider: () => RpcProvider;
|
|
82
|
+
getAgentConfig: () => AgentConfig;
|
|
83
|
+
}
|
|
84
|
+
import winston from 'winston';
|
|
85
|
+
export declare const logger: winston.Logger;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export var AgentMode;
|
|
2
|
+
(function (AgentMode) {
|
|
3
|
+
AgentMode["INTERACTIVE"] = "interactive";
|
|
4
|
+
AgentMode["AUTONOMOUS"] = "autonomous";
|
|
5
|
+
AgentMode["HYBRID"] = "hybrid";
|
|
6
|
+
})(AgentMode || (AgentMode = {}));
|
|
7
|
+
import winston from 'winston';
|
|
8
|
+
const levels = {
|
|
9
|
+
error: 0,
|
|
10
|
+
warn: 1,
|
|
11
|
+
info: 2,
|
|
12
|
+
http: 3,
|
|
13
|
+
debug: 4,
|
|
14
|
+
};
|
|
15
|
+
const colors = {
|
|
16
|
+
error: 'red',
|
|
17
|
+
warn: 'yellow',
|
|
18
|
+
info: 'green',
|
|
19
|
+
http: 'magenta',
|
|
20
|
+
debug: 'blue',
|
|
21
|
+
};
|
|
22
|
+
winston.addColors(colors);
|
|
23
|
+
const level = () => {
|
|
24
|
+
if (process.env.LOG_LEVEL) {
|
|
25
|
+
return process.env.LOG_LEVEL.toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
const env = process.env.NODE_ENV || 'production';
|
|
28
|
+
return env === 'development' ? 'debug' : 'info';
|
|
29
|
+
};
|
|
30
|
+
const format = winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.colorize({ all: true }), winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`));
|
|
31
|
+
let transports;
|
|
32
|
+
try {
|
|
33
|
+
transports = [
|
|
34
|
+
new winston.transports.Console(),
|
|
35
|
+
new winston.transports.File({
|
|
36
|
+
filename: 'logs/error.log',
|
|
37
|
+
level: 'error',
|
|
38
|
+
}),
|
|
39
|
+
new winston.transports.File({ filename: 'logs/combined.log' }),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
transports = [new winston.transports.Console()];
|
|
44
|
+
}
|
|
45
|
+
export const logger = winston.createLogger({
|
|
46
|
+
level: level(),
|
|
47
|
+
levels,
|
|
48
|
+
format,
|
|
49
|
+
transports,
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":"AAqCA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IA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AAI,CAAC;IACH,UAAU,GAAG;QACX,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE;QAEhC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,QAAQ,EAAE,gBAAgB;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;QAEF,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,KAAK,EAAE;IACd,MAAM;IACN,MAAM;IACN,UAAU;CACX,CAAC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const contractAddressSchema: z.ZodObject<{
|
|
3
|
+
contractAddress: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
contractAddress: string;
|
|
6
|
+
}, {
|
|
7
|
+
contractAddress: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const blockIdSchema: z.ZodObject<{
|
|
10
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
blockId: string | number;
|
|
13
|
+
}, {
|
|
14
|
+
blockId: string | number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const blockIdAndContractAddressSchema: z.ZodObject<{
|
|
17
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
18
|
+
classHash: z.ZodString;
|
|
19
|
+
}, "strict", z.ZodTypeAny, {
|
|
20
|
+
classHash: string;
|
|
21
|
+
blockId: string | number;
|
|
22
|
+
}, {
|
|
23
|
+
classHash: string;
|
|
24
|
+
blockId: string | number;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const getStorageAtSchema: z.ZodObject<{
|
|
27
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
28
|
+
contractAddress: z.ZodString;
|
|
29
|
+
key: z.ZodString;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
key: string;
|
|
32
|
+
blockId: string | number;
|
|
33
|
+
contractAddress: string;
|
|
34
|
+
}, {
|
|
35
|
+
key: string;
|
|
36
|
+
blockId: string | number;
|
|
37
|
+
contractAddress: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const getClassAtSchema: z.ZodObject<{
|
|
40
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
41
|
+
contractAddress: z.ZodString;
|
|
42
|
+
key: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
key: string;
|
|
45
|
+
blockId: string | number;
|
|
46
|
+
contractAddress: string;
|
|
47
|
+
}, {
|
|
48
|
+
key: string;
|
|
49
|
+
blockId: string | number;
|
|
50
|
+
contractAddress: string;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const getClassHashAtSchema: z.ZodObject<{
|
|
53
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
54
|
+
contractAddress: z.ZodString;
|
|
55
|
+
key: z.ZodString;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
key: string;
|
|
58
|
+
blockId: string | number;
|
|
59
|
+
contractAddress: string;
|
|
60
|
+
}, {
|
|
61
|
+
key: string;
|
|
62
|
+
blockId: string | number;
|
|
63
|
+
contractAddress: string;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const getTransactionByBlockIdAndIndexSchema: z.ZodObject<{
|
|
66
|
+
blockId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
67
|
+
transactionIndex: z.ZodNumber;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
blockId: string | number;
|
|
70
|
+
transactionIndex: number;
|
|
71
|
+
}, {
|
|
72
|
+
blockId: string | number;
|
|
73
|
+
transactionIndex: number;
|
|
74
|
+
}>;
|
|
75
|
+
export declare const transactionHashSchema: z.ZodObject<{
|
|
76
|
+
transactionHash: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
transactionHash: string;
|
|
79
|
+
}, {
|
|
80
|
+
transactionHash: string;
|
|
81
|
+
}>;
|
|
82
|
+
export type GetStorageParams = z.infer<typeof getStorageAtSchema>;
|
|
83
|
+
export type GetClassAtParams = z.infer<typeof getClassAtSchema>;
|
|
84
|
+
export type BlockIdParams = z.infer<typeof blockIdSchema>;
|
|
85
|
+
export type BlockIdAndContractAddressParams = z.infer<typeof blockIdAndContractAddressSchema>;
|
|
86
|
+
export type GetTransactionByBlockIdAndIndexParams = z.infer<typeof getTransactionByBlockIdAndIndexSchema>;
|
|
87
|
+
export type ContractAddressParams = z.infer<typeof contractAddressSchema>;
|
|
88
|
+
export type TransactionHashParams = z.infer<typeof transactionHashSchema>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export const contractAddressSchema = z.object({
|
|
3
|
+
contractAddress: z.string().describe('The address of the contract'),
|
|
4
|
+
});
|
|
5
|
+
export const blockIdSchema = z.object({
|
|
6
|
+
blockId: z.union([
|
|
7
|
+
z
|
|
8
|
+
.string()
|
|
9
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
10
|
+
z.number().describe('A block number.'),
|
|
11
|
+
]),
|
|
12
|
+
});
|
|
13
|
+
export const blockIdAndContractAddressSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
blockId: z.union([
|
|
16
|
+
z
|
|
17
|
+
.string()
|
|
18
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
19
|
+
z.number().describe('A block number.'),
|
|
20
|
+
]),
|
|
21
|
+
classHash: z.string().describe('The class hash of the contract'),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const getStorageAtSchema = z.object({
|
|
25
|
+
blockId: z.union([
|
|
26
|
+
z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
29
|
+
z.number().describe('A block number.'),
|
|
30
|
+
]),
|
|
31
|
+
contractAddress: z.string().describe('The address of the contract'),
|
|
32
|
+
key: z
|
|
33
|
+
.string()
|
|
34
|
+
.describe('The key to the storage value for the given contract'),
|
|
35
|
+
});
|
|
36
|
+
export const getClassAtSchema = z.object({
|
|
37
|
+
blockId: z.union([
|
|
38
|
+
z
|
|
39
|
+
.string()
|
|
40
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
41
|
+
z.number().describe('A block number.'),
|
|
42
|
+
]),
|
|
43
|
+
contractAddress: z.string().describe('The address of the contract'),
|
|
44
|
+
key: z
|
|
45
|
+
.string()
|
|
46
|
+
.describe('The class for the given contract at the given block'),
|
|
47
|
+
});
|
|
48
|
+
export const getClassHashAtSchema = z.object({
|
|
49
|
+
blockId: z.union([
|
|
50
|
+
z
|
|
51
|
+
.string()
|
|
52
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
53
|
+
z.number().describe('A block number.'),
|
|
54
|
+
]),
|
|
55
|
+
contractAddress: z.string().describe('The address of the contract'),
|
|
56
|
+
key: z
|
|
57
|
+
.string()
|
|
58
|
+
.describe('The class hash for the given contract at the given block need to be a real class hash'),
|
|
59
|
+
});
|
|
60
|
+
export const getTransactionByBlockIdAndIndexSchema = z.object({
|
|
61
|
+
blockId: z.union([
|
|
62
|
+
z
|
|
63
|
+
.string()
|
|
64
|
+
.describe("The block identifier. Can be 'latest', 'pending', or a block hash."),
|
|
65
|
+
z.number().describe('A block number.'),
|
|
66
|
+
]),
|
|
67
|
+
transactionIndex: z
|
|
68
|
+
.number()
|
|
69
|
+
.int()
|
|
70
|
+
.nonnegative()
|
|
71
|
+
.describe('The index of the transaction within the block.'),
|
|
72
|
+
});
|
|
73
|
+
export const transactionHashSchema = z.object({
|
|
74
|
+
transactionHash: z
|
|
75
|
+
.string()
|
|
76
|
+
.describe('The hash of the requested transaction.'),
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC;QACf,CAAC;aACE,MAAM,EAAE;aACR,QAAQ,CACP,oEAAoE,CACrE;QACH,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;KACvC,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC;KAC7C,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC;QACf,CAAC;aACE,MAAM,EAAE;aACR,QAAQ,CACP,oEAAoE,CACrE;QACH,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;KACvC,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;CACjE,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC;QACf,CAAC;aACE,M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AQ,CACP,oEAAoE,CACrE;QACH,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;KACvC,CAAC;IACF,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,WAAW,EAAE;SACb,QAAQ,CAAC,gDAAgD,CAAC;CAC9D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,QAAQ,CAAC,wCAAwC,CAAC;CACtD,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RpcProvider } from 'starknet';
|
|
2
|
+
export declare const getBlockLatestAccepted: (provider: RpcProvider) => Promise<{
|
|
3
|
+
status: string;
|
|
4
|
+
blockHashAndNumber: any;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
status: string;
|
|
8
|
+
error: string;
|
|
9
|
+
blockHashAndNumber?: undefined;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const getBlockLatestAccepted = async (provider) => {
|
|
2
|
+
try {
|
|
3
|
+
const blockHashAndNumber = await provider.getBlockLatestAccepted();
|
|
4
|
+
return {
|
|
5
|
+
status: 'success',
|
|
6
|
+
blockHashAndNumber: blockHashAndNumber,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
return {
|
|
11
|
+
status: 'failure',
|
|
12
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=getBlockLatestAccepted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBlockLatestAccepted.js","sourceRoot":"","sources":["../../src/tools/getBlockLatestAccepted.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,QAAqB,EAAE,EAAE;IACpE,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,MAAM,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QAEnE,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,kBAAkB,EAAE,kBAAyB;SAC9C,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const getBlockNumber = async (provider) => {
|
|
2
|
+
try {
|
|
3
|
+
const blockNumber = await provider.getBlockNumber();
|
|
4
|
+
return {
|
|
5
|
+
status: 'success',
|
|
6
|
+
blockNumber,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
return {
|
|
11
|
+
status: 'failure',
|
|
12
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=getBlockNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBlockNumber.js","sourceRoot":"","sources":["../../src/tools/getBlockNumber.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,QAAqB,EAAE,EAAE;IAC5D,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAC;QAEpD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,WAAW;SACZ,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RpcProvider } from 'starknet';
|
|
2
|
+
export declare const getBlockStateUpdate: (provider: RpcProvider, params: {
|
|
3
|
+
blockId: string;
|
|
4
|
+
}) => Promise<{
|
|
5
|
+
status: string;
|
|
6
|
+
blockStateUpdate: import("starknet").StateUpdateResponse;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
status: string;
|
|
10
|
+
error: string;
|
|
11
|
+
blockStateUpdate?: undefined;
|
|
12
|
+
}>;
|