@conquest-eth/tools 0.0.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 +259 -0
- package/dist/cli-tool-generator.d.ts +22 -0
- package/dist/cli-tool-generator.d.ts.map +1 -0
- package/dist/cli-tool-generator.js +217 -0
- package/dist/cli-tool-generator.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +76 -0
- package/dist/cli.js.map +1 -0
- package/dist/contracts/space-info.d.ts +7 -0
- package/dist/contracts/space-info.d.ts.map +1 -0
- package/dist/contracts/space-info.js +34 -0
- package/dist/contracts/space-info.js.map +1 -0
- package/dist/fleet/index.d.ts +4 -0
- package/dist/fleet/index.d.ts.map +1 -0
- package/dist/fleet/index.js +7 -0
- package/dist/fleet/index.js.map +1 -0
- package/dist/fleet/manager.d.ts +70 -0
- package/dist/fleet/manager.d.ts.map +1 -0
- package/dist/fleet/manager.js +92 -0
- package/dist/fleet/manager.js.map +1 -0
- package/dist/fleet/resolve.d.ts +51 -0
- package/dist/fleet/resolve.d.ts.map +1 -0
- package/dist/fleet/resolve.js +140 -0
- package/dist/fleet/resolve.js.map +1 -0
- package/dist/fleet/send.d.ts +29 -0
- package/dist/fleet/send.d.ts.map +1 -0
- package/dist/fleet/send.js +81 -0
- package/dist/fleet/send.js.map +1 -0
- package/dist/helpers/index.d.ts +14 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +28 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/dist/planet/acquire.d.ts +16 -0
- package/dist/planet/acquire.d.ts.map +1 -0
- package/dist/planet/acquire.js +27 -0
- package/dist/planet/acquire.js.map +1 -0
- package/dist/planet/exit.d.ts +17 -0
- package/dist/planet/exit.d.ts.map +1 -0
- package/dist/planet/exit.js +56 -0
- package/dist/planet/exit.js.map +1 -0
- package/dist/planet/index.d.ts +4 -0
- package/dist/planet/index.d.ts.map +1 -0
- package/dist/planet/index.js +6 -0
- package/dist/planet/index.js.map +1 -0
- package/dist/planet/manager.d.ts +106 -0
- package/dist/planet/manager.d.ts.map +1 -0
- package/dist/planet/manager.js +253 -0
- package/dist/planet/manager.js.map +1 -0
- package/dist/storage/interface.d.ts +93 -0
- package/dist/storage/interface.d.ts.map +1 -0
- package/dist/storage/interface.js +2 -0
- package/dist/storage/interface.js.map +1 -0
- package/dist/storage/json-storage.d.ts +28 -0
- package/dist/storage/json-storage.d.ts.map +1 -0
- package/dist/storage/json-storage.js +148 -0
- package/dist/storage/json-storage.js.map +1 -0
- package/dist/tools/acquire_planets.d.ts +7 -0
- package/dist/tools/acquire_planets.d.ts.map +1 -0
- package/dist/tools/acquire_planets.js +63 -0
- package/dist/tools/acquire_planets.js.map +1 -0
- package/dist/tools/exit_planets.d.ts +5 -0
- package/dist/tools/exit_planets.d.ts.map +1 -0
- package/dist/tools/exit_planets.js +31 -0
- package/dist/tools/exit_planets.js.map +1 -0
- package/dist/tools/get_my_planets.d.ts +5 -0
- package/dist/tools/get_my_planets.d.ts.map +1 -0
- package/dist/tools/get_my_planets.js +30 -0
- package/dist/tools/get_my_planets.js.map +1 -0
- package/dist/tools/get_pending_exits.d.ts +3 -0
- package/dist/tools/get_pending_exits.d.ts.map +1 -0
- package/dist/tools/get_pending_exits.js +37 -0
- package/dist/tools/get_pending_exits.js.map +1 -0
- package/dist/tools/get_pending_fleets.d.ts +3 -0
- package/dist/tools/get_pending_fleets.d.ts.map +1 -0
- package/dist/tools/get_pending_fleets.js +41 -0
- package/dist/tools/get_pending_fleets.js.map +1 -0
- package/dist/tools/get_planets_around.d.ts +7 -0
- package/dist/tools/get_planets_around.d.ts.map +1 -0
- package/dist/tools/get_planets_around.js +41 -0
- package/dist/tools/get_planets_around.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/resolve_fleet.d.ts +5 -0
- package/dist/tools/resolve_fleet.d.ts.map +1 -0
- package/dist/tools/resolve_fleet.js +37 -0
- package/dist/tools/resolve_fleet.js.map +1 -0
- package/dist/tools/send_fleet.d.ts +16 -0
- package/dist/tools/send_fleet.d.ts.map +1 -0
- package/dist/tools/send_fleet.js +62 -0
- package/dist/tools/send_fleet.js.map +1 -0
- package/dist/tools/verify_exit_status.d.ts +5 -0
- package/dist/tools/verify_exit_status.d.ts.map +1 -0
- package/dist/tools/verify_exit_status.js +39 -0
- package/dist/tools/verify_exit_status.js.map +1 -0
- package/dist/types.d.ts +126 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -0
- package/dist/util/hashing.d.ts +33 -0
- package/dist/util/hashing.d.ts.map +1 -0
- package/dist/util/hashing.js +38 -0
- package/dist/util/hashing.js.map +1 -0
- package/dist/util/time.d.ts +43 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.js +55 -0
- package/dist/util/time.js.map +1 -0
- package/package.json +78 -0
- package/src/cli-tool-generator.ts +287 -0
- package/src/cli.ts +109 -0
- package/src/contracts/space-info.ts +41 -0
- package/src/fleet/index.ts +8 -0
- package/src/fleet/manager.ts +140 -0
- package/src/fleet/resolve.ts +187 -0
- package/src/fleet/send.ts +112 -0
- package/src/helpers/index.ts +59 -0
- package/src/index.ts +181 -0
- package/src/planet/acquire.ts +41 -0
- package/src/planet/exit.ts +71 -0
- package/src/planet/index.ts +6 -0
- package/src/planet/manager.ts +335 -0
- package/src/storage/interface.ts +111 -0
- package/src/storage/json-storage.ts +184 -0
- package/src/tools/acquire_planets.ts +81 -0
- package/src/tools/exit_planets.ts +35 -0
- package/src/tools/get_my_planets.ts +30 -0
- package/src/tools/get_pending_exits.ts +37 -0
- package/src/tools/get_pending_fleets.ts +41 -0
- package/src/tools/get_planets_around.ts +44 -0
- package/src/tools/index.ts +10 -0
- package/src/tools/resolve_fleet.ts +37 -0
- package/src/tools/send_fleet.ts +68 -0
- package/src/tools/verify_exit_status.ts +43 -0
- package/src/types.ts +178 -0
- package/src/util/hashing.ts +60 -0
- package/src/util/time.ts +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { Implementation } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { Chain } from 'viem';
|
|
4
|
+
import { ServerOptions } from '@modelcontextprotocol/sdk/server';
|
|
5
|
+
/**
|
|
6
|
+
* Create and configure an MCP server for Conquest.eth game interactions
|
|
7
|
+
*
|
|
8
|
+
* @param params - Configuration parameters for the server
|
|
9
|
+
* @param params.chain - The blockchain chain to connect to
|
|
10
|
+
* @param params.privateKey - Optional private key for signing transactions (wallet operations)
|
|
11
|
+
* @param params.gameContract - The game contract address
|
|
12
|
+
* @param options - Optional server configuration
|
|
13
|
+
* @param options.ethereum - Whether to include Ethereum MCP tools (default: false)
|
|
14
|
+
* @param options.rpcURL - Optional custom RPC URL
|
|
15
|
+
* @param options.serverOptions - Optional MCP server options
|
|
16
|
+
* @param options.serverInfo - Optional server metadata to override defaults
|
|
17
|
+
* @param options.storageConfig - Storage configuration for fleets and exits
|
|
18
|
+
* @param options.storageConfig.type - Storage type ('json' or 'sqlite')
|
|
19
|
+
* @param options.storageConfig.dataDir - Optional data directory path
|
|
20
|
+
* @returns Configured MCP server instance with Conquest game tools registered
|
|
21
|
+
*/
|
|
22
|
+
export declare function createServer(params: {
|
|
23
|
+
chain: Chain;
|
|
24
|
+
privateKey?: `0x${string}`;
|
|
25
|
+
gameContract: `0x${string}`;
|
|
26
|
+
}, options?: {
|
|
27
|
+
ethereum?: boolean;
|
|
28
|
+
rpcURL?: string;
|
|
29
|
+
serverOptions?: ServerOptions;
|
|
30
|
+
serverInfo?: Implementation;
|
|
31
|
+
storageConfig?: {
|
|
32
|
+
type: 'json' | 'sqlite';
|
|
33
|
+
dataDir?: string;
|
|
34
|
+
};
|
|
35
|
+
}): McpServer;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAElE,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAe/D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,KAAK,MAAM,EAAE,CAAA;CAAC,EAC/E,OAAO,CAAC,EAAE;IACT,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,aAAa,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CAC5D,aAwID"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
3
|
+
import { createServer as createMCPEthereumServer } from 'tools-ethereum';
|
|
4
|
+
import { getClients } from 'tools-ethereum/helpers';
|
|
5
|
+
import { createSpaceInfo } from './contracts/space-info.js';
|
|
6
|
+
import { JsonFleetStorage } from './storage/json-storage.js';
|
|
7
|
+
import { FleetManager } from './fleet/manager.js';
|
|
8
|
+
import { PlanetManager } from './planet/manager.js';
|
|
9
|
+
// Import refactored tools
|
|
10
|
+
import * as tools from './tools/index.js';
|
|
11
|
+
import { stringifyWithBigInt } from './helpers/index.js';
|
|
12
|
+
import { Abi_IOuterSpace } from 'conquest-eth-v0-contracts/abis/IOuterSpace.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create and configure an MCP server for Conquest.eth game interactions
|
|
15
|
+
*
|
|
16
|
+
* @param params - Configuration parameters for the server
|
|
17
|
+
* @param params.chain - The blockchain chain to connect to
|
|
18
|
+
* @param params.privateKey - Optional private key for signing transactions (wallet operations)
|
|
19
|
+
* @param params.gameContract - The game contract address
|
|
20
|
+
* @param options - Optional server configuration
|
|
21
|
+
* @param options.ethereum - Whether to include Ethereum MCP tools (default: false)
|
|
22
|
+
* @param options.rpcURL - Optional custom RPC URL
|
|
23
|
+
* @param options.serverOptions - Optional MCP server options
|
|
24
|
+
* @param options.serverInfo - Optional server metadata to override defaults
|
|
25
|
+
* @param options.storageConfig - Storage configuration for fleets and exits
|
|
26
|
+
* @param options.storageConfig.type - Storage type ('json' or 'sqlite')
|
|
27
|
+
* @param options.storageConfig.dataDir - Optional data directory path
|
|
28
|
+
* @returns Configured MCP server instance with Conquest game tools registered
|
|
29
|
+
*/
|
|
30
|
+
export function createServer(params, options) {
|
|
31
|
+
const { gameContract: gameContractAddress, ...mcpEthereumParams } = params;
|
|
32
|
+
const clients = getClients(params, options);
|
|
33
|
+
const gameContract = {
|
|
34
|
+
address: gameContractAddress,
|
|
35
|
+
abi: Abi_IOuterSpace,
|
|
36
|
+
};
|
|
37
|
+
const name = `mcp-conquest-eth-v0`;
|
|
38
|
+
const server = options?.ethereum
|
|
39
|
+
? createMCPEthereumServer(mcpEthereumParams, {
|
|
40
|
+
...options,
|
|
41
|
+
serverInfo: { name, version: pkg.version, ...options?.serverInfo },
|
|
42
|
+
})
|
|
43
|
+
: new McpServer(options?.serverInfo || {
|
|
44
|
+
name,
|
|
45
|
+
version: pkg.version,
|
|
46
|
+
}, options?.serverOptions || { capabilities: { logging: {} } });
|
|
47
|
+
// Initialize SpaceInfo and contractConfig
|
|
48
|
+
let spaceInfo = null;
|
|
49
|
+
let contractConfig = null;
|
|
50
|
+
const initSpaceInfo = async () => {
|
|
51
|
+
if (!spaceInfo || !contractConfig) {
|
|
52
|
+
const result = await createSpaceInfo(clients, gameContract);
|
|
53
|
+
spaceInfo = result.spaceInfo;
|
|
54
|
+
contractConfig = result.contractConfig;
|
|
55
|
+
}
|
|
56
|
+
return { spaceInfo, contractConfig };
|
|
57
|
+
};
|
|
58
|
+
// Initialize storage
|
|
59
|
+
const storageConfig = options?.storageConfig || { type: 'json', dataDir: './data' };
|
|
60
|
+
const storage = new JsonFleetStorage(storageConfig.dataDir || './data');
|
|
61
|
+
// Initialize managers (will be initialized after spaceInfo is ready)
|
|
62
|
+
let fleetManager = null;
|
|
63
|
+
let planetManager = null;
|
|
64
|
+
// Helper to ensure managers are initialized
|
|
65
|
+
const ensureManagersInitialized = async () => {
|
|
66
|
+
const { spaceInfo: si, contractConfig: cc } = await initSpaceInfo();
|
|
67
|
+
// Initialize fleetManager even without walletClient for read-only operations
|
|
68
|
+
if (!fleetManager && si && cc) {
|
|
69
|
+
fleetManager = new FleetManager(clients, gameContract, si, cc, storage);
|
|
70
|
+
}
|
|
71
|
+
// Initialize planetManager even without walletClient for read-only operations
|
|
72
|
+
if (!planetManager && si && cc) {
|
|
73
|
+
planetManager = new PlanetManager(clients, gameContract, si, cc, storage);
|
|
74
|
+
}
|
|
75
|
+
if (!fleetManager) {
|
|
76
|
+
throw new Error('Fleet manager not initialized');
|
|
77
|
+
}
|
|
78
|
+
if (!planetManager) {
|
|
79
|
+
throw new Error('Planet manager not initialized');
|
|
80
|
+
}
|
|
81
|
+
return { fleetManager, planetManager };
|
|
82
|
+
};
|
|
83
|
+
// Auto-register all tools
|
|
84
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
85
|
+
// Skip the file that's not a tool
|
|
86
|
+
if (name === 'default')
|
|
87
|
+
continue;
|
|
88
|
+
server.registerTool(name, {
|
|
89
|
+
description: tool.description,
|
|
90
|
+
inputSchema: tool.schema,
|
|
91
|
+
}, async (args) => {
|
|
92
|
+
try {
|
|
93
|
+
const { fleetManager, planetManager } = await ensureManagersInitialized();
|
|
94
|
+
const env = {
|
|
95
|
+
sendStatus: async (_message) => {
|
|
96
|
+
// TODO: Implement progress notifications when sessionId is available
|
|
97
|
+
},
|
|
98
|
+
fleetManager,
|
|
99
|
+
planetManager,
|
|
100
|
+
};
|
|
101
|
+
const result = await tool.execute(env, args);
|
|
102
|
+
// Convert ToolResult to CallToolResult
|
|
103
|
+
if (result.success === false) {
|
|
104
|
+
return {
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: 'text',
|
|
108
|
+
text: stringifyWithBigInt({
|
|
109
|
+
error: result.error,
|
|
110
|
+
...(result.stack ? { stack: result.stack } : {}),
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
isError: true,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
content: [
|
|
119
|
+
{
|
|
120
|
+
type: 'text',
|
|
121
|
+
text: stringifyWithBigInt(result.result, 2),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: 'text',
|
|
131
|
+
text: stringifyWithBigInt({
|
|
132
|
+
error: error instanceof Error ? error.message : String(error),
|
|
133
|
+
}),
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
isError: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return server;
|
|
142
|
+
}
|
|
143
|
+
//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BAEpD,uCAAuC;gBACvC,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;oBAC9B,OAAO;wBACN,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,MAAe;gCACrB,IAAI,EAAE,mBAAmB,CAAC;oCACzB,KAAK,EAAE,MAAM,CAAC,KAAK;oCACnB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iCAC9C,CAAC;6BACF;yBACD;wBACD,OAAO,EAAE,IAAI;qBACb,CAAC;gBACH,CAAC;gBAED,OAAO;oBACN,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;yBAC3C;qBACD;iBACD,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO;oBACN,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,mBAAmB,CAAC;gCACzB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;6BAC7D,CAAC;yBACF;qBACD;oBACD,OAAO,EAAE,IAAI;iBACb,CAAC;YACH,CAAC;QACF,CAAC,CACD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Clients, GameContract } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Acquire (stake) multiple planets
|
|
4
|
+
*
|
|
5
|
+
* @param clients - Viem clients (publicClient and walletClient)
|
|
6
|
+
* @param gameContract - The game contract instance with address and ABI
|
|
7
|
+
* @param planetIds - Array of planet location IDs to acquire
|
|
8
|
+
* @param amountToMint - Amount of native token to spend
|
|
9
|
+
* @param tokenAmount - Amount of staking token to spend
|
|
10
|
+
* @returns Transaction hash and list of planets acquired
|
|
11
|
+
*/
|
|
12
|
+
export declare function acquirePlanets(clients: Clients, gameContract: GameContract, planetIds: bigint[], amountToMint: bigint, tokenAmount: bigint): Promise<{
|
|
13
|
+
hash: `0x${string}`;
|
|
14
|
+
planetsAcquired: bigint[];
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=acquire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquire.d.ts","sourceRoot":"","sources":["../../src/planet/acquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EAAE,EACnB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC;IAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAsB3D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Acquire (stake) multiple planets
|
|
3
|
+
*
|
|
4
|
+
* @param clients - Viem clients (publicClient and walletClient)
|
|
5
|
+
* @param gameContract - The game contract instance with address and ABI
|
|
6
|
+
* @param planetIds - Array of planet location IDs to acquire
|
|
7
|
+
* @param amountToMint - Amount of native token to spend
|
|
8
|
+
* @param tokenAmount - Amount of staking token to spend
|
|
9
|
+
* @returns Transaction hash and list of planets acquired
|
|
10
|
+
*/
|
|
11
|
+
export async function acquirePlanets(clients, gameContract, planetIds, amountToMint, tokenAmount) {
|
|
12
|
+
const sender = clients.walletClient.account.address;
|
|
13
|
+
const nativeTokenAmount = (amountToMint * 1000000000000000000n) / 1000000000000000000000n; // TODO BigInt((PlayToken.linkedData as any).numTokensPerNativeTokenAt18Decimals);
|
|
14
|
+
console.log(`Acquiring ${planetIds.length} planets with ${amountToMint} native tokens and ${tokenAmount} staking tokens using ${nativeTokenAmount} native tokens`);
|
|
15
|
+
// Get the contract acquireMultipleViaNativeTokenAndStakingToken function signature
|
|
16
|
+
const simulation = await clients.publicClient.simulateContract({
|
|
17
|
+
...gameContract,
|
|
18
|
+
functionName: 'acquireMultipleViaNativeTokenAndStakingToken',
|
|
19
|
+
args: [planetIds, amountToMint, tokenAmount],
|
|
20
|
+
account: sender,
|
|
21
|
+
value: nativeTokenAmount,
|
|
22
|
+
});
|
|
23
|
+
// Send the transaction
|
|
24
|
+
const hash = await clients.walletClient.writeContract(simulation.request);
|
|
25
|
+
return { hash, planetsAcquired: planetIds };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=acquire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquire.js","sourceRoot":"","sources":["../../src/planet/acquire.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,OAAgB,EAChB,YAA0B,EAC1B,SAAmB,EACnB,YAAoB,EACpB,WAAmB;IAEnB,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAQ,CAAC,OAAO,CAAC;IAErD,MAAM,iBAAiB,GAAG,CAAC,YAAY,GAAG,oBAAoB,CAAC,GAAG,uBAAuB,CAAC,CAAC,kFAAkF;IAE7K,OAAO,CAAC,GAAG,CACV,aAAa,SAAS,CAAC,MAAM,iBAAiB,YAAY,sBAAsB,WAAW,yBAAyB,iBAAiB,gBAAgB,CACrJ,CAAC;IAEF,mFAAmF;IACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC;QAC9D,GAAG,YAAY;QACf,YAAY,EAAE,8CAA8C;QAC5D,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC;QAC5C,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,iBAAiB;KACxB,CAAC,CAAC;IAEH,uBAAuB;IACvB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAE1E,OAAO,EAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FleetStorage } from '../storage/interface.js';
|
|
2
|
+
import { Clients, GameContract } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Exit (unstake) multiple planets to retrieve staked tokens
|
|
5
|
+
*
|
|
6
|
+
* @param clients - Viem clients (publicClient and walletClient)
|
|
7
|
+
* @param gameContract - The game contract instance with address and ABI
|
|
8
|
+
* @param planetIds - Array of planet location IDs to exit
|
|
9
|
+
* @param exitDuration - Duration of the exit process in seconds (from contract config)
|
|
10
|
+
* @param storage - Storage instance for tracking pending exits
|
|
11
|
+
* @returns Transaction hash and list of planet IDs for which exits were initiated
|
|
12
|
+
*/
|
|
13
|
+
export declare function exitPlanets(clients: Clients, gameContract: GameContract, planetIds: bigint[], exitDuration: bigint, storage: FleetStorage): Promise<{
|
|
14
|
+
hash: `0x${string}`;
|
|
15
|
+
exitsInitiated: bigint[];
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=exit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/planet/exit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAE/D;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EAAE,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC;IAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAkD1D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getCurrentTimestamp } from '../util/time.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exit (unstake) multiple planets to retrieve staked tokens
|
|
4
|
+
*
|
|
5
|
+
* @param clients - Viem clients (publicClient and walletClient)
|
|
6
|
+
* @param gameContract - The game contract instance with address and ABI
|
|
7
|
+
* @param planetIds - Array of planet location IDs to exit
|
|
8
|
+
* @param exitDuration - Duration of the exit process in seconds (from contract config)
|
|
9
|
+
* @param storage - Storage instance for tracking pending exits
|
|
10
|
+
* @returns Transaction hash and list of planet IDs for which exits were initiated
|
|
11
|
+
*/
|
|
12
|
+
export async function exitPlanets(clients, gameContract, planetIds, exitDuration, storage) {
|
|
13
|
+
const sender = clients.walletClient.account.address;
|
|
14
|
+
const currentTime = getCurrentTimestamp();
|
|
15
|
+
// Get planet states to verify ownership
|
|
16
|
+
const result = await clients.publicClient.readContract({
|
|
17
|
+
...gameContract,
|
|
18
|
+
functionName: 'getPlanetStates',
|
|
19
|
+
args: [planetIds],
|
|
20
|
+
});
|
|
21
|
+
const states = result[0];
|
|
22
|
+
// Create pending exit records for each planet
|
|
23
|
+
const exitsInitiated = [];
|
|
24
|
+
for (let i = 0; i < planetIds.length; i++) {
|
|
25
|
+
const planetId = planetIds[i];
|
|
26
|
+
const state = states[i];
|
|
27
|
+
// Only create exit record for planets owned by the sender
|
|
28
|
+
if (state.owner && state.owner.toLowerCase() === sender.toLowerCase()) {
|
|
29
|
+
const exit = {
|
|
30
|
+
planetId,
|
|
31
|
+
player: sender,
|
|
32
|
+
exitStartTime: currentTime,
|
|
33
|
+
exitDuration: Number(exitDuration),
|
|
34
|
+
exitCompleteTime: currentTime + Number(exitDuration),
|
|
35
|
+
numSpaceships: state.numSpaceships,
|
|
36
|
+
owner: state.owner,
|
|
37
|
+
completed: false,
|
|
38
|
+
interrupted: false,
|
|
39
|
+
lastCheckedAt: currentTime,
|
|
40
|
+
};
|
|
41
|
+
await storage.savePendingExit(exit);
|
|
42
|
+
exitsInitiated.push(planetId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Get the contract exitMultipleFor function signature
|
|
46
|
+
const simulation = await clients.publicClient.simulateContract({
|
|
47
|
+
...gameContract,
|
|
48
|
+
functionName: 'exitMultipleFor',
|
|
49
|
+
args: [sender, planetIds],
|
|
50
|
+
account: sender,
|
|
51
|
+
});
|
|
52
|
+
// Send the transaction
|
|
53
|
+
const hash = await clients.walletClient.writeContract(simulation.request);
|
|
54
|
+
return { hash, exitsInitiated };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=exit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../../src/planet/exit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAIpD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,OAAgB,EAChB,YAA0B,EAC1B,SAAmB,EACnB,YAAoB,EACpB,OAAqB;IAErB,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAQ,CAAC,OAAO,CAAC;IACrD,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAE1C,wCAAwC;IACxC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC;QACtD,GAAG,YAAY;QACf,YAAY,EAAE,iBAAiB;QAC/B,IAAI,EAAE,CAAC,SAAS,CAAC;KACjB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,8CAA8C;IAC9C,MAAM,cAAc,GAAa,EAAE,CAAC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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/planet/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/planet/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,oBAAoB;AACpB,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { SpaceInfo } from 'conquest-eth-v0-contracts';
|
|
3
|
+
import type { PlanetInfo, PlanetState } from 'conquest-eth-v0-contracts';
|
|
4
|
+
import type { FleetStorage } from '../storage/interface.js';
|
|
5
|
+
import type { ClientsWithOptionalWallet, ContractConfig, ExternalPlanet, GameContract, PendingExit } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* PlanetManager manages planet-related operations in the Conquest game
|
|
8
|
+
* including acquiring new planets and initiating exit processes
|
|
9
|
+
*/
|
|
10
|
+
export declare class PlanetManager {
|
|
11
|
+
private readonly clients;
|
|
12
|
+
private readonly gameContract;
|
|
13
|
+
private readonly spaceInfo;
|
|
14
|
+
private readonly contractConfig;
|
|
15
|
+
private readonly storage;
|
|
16
|
+
constructor(clients: ClientsWithOptionalWallet, gameContract: GameContract, spaceInfo: SpaceInfo, contractConfig: ContractConfig, storage: FleetStorage);
|
|
17
|
+
/**
|
|
18
|
+
* Ensure walletClient is available for operations that require it
|
|
19
|
+
*/
|
|
20
|
+
private requireWalletClient;
|
|
21
|
+
/**
|
|
22
|
+
* Acquire (stake) multiple planets
|
|
23
|
+
*/
|
|
24
|
+
acquire(planetIds: bigint[], amountToMint: bigint, tokenAmount: bigint): Promise<{
|
|
25
|
+
hash: `0x${string}`;
|
|
26
|
+
planetsAcquired: bigint[];
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Acquire (stake) multiple planets with automatic cost calculation
|
|
30
|
+
*/
|
|
31
|
+
acquireWithAutoCalc(planetIds: bigint[]): Promise<{
|
|
32
|
+
hash: `0x${string}`;
|
|
33
|
+
planetsAcquired: bigint[];
|
|
34
|
+
costs: {
|
|
35
|
+
amountToMint: bigint;
|
|
36
|
+
tokenAmount: bigint;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate acquisition costs for planets based on their stats
|
|
41
|
+
*
|
|
42
|
+
* @param planetIds - Array of planet location IDs
|
|
43
|
+
* @returns Object with total amountToMint and tokenAmount
|
|
44
|
+
*/
|
|
45
|
+
calculateAcquisitionCosts(planetIds: bigint[]): {
|
|
46
|
+
amountToMint: bigint;
|
|
47
|
+
tokenAmount: bigint;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Exit (unstake) multiple planets
|
|
51
|
+
*/
|
|
52
|
+
exit(planetIds: bigint[]): Promise<{
|
|
53
|
+
hash: `0x${string}`;
|
|
54
|
+
exitsInitiated: bigint[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Get planet info by location ID
|
|
58
|
+
*/
|
|
59
|
+
getPlanetInfo(planetId: bigint): PlanetInfo | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Get planet ID by x,y coordinates
|
|
62
|
+
* @param x - X coordinate
|
|
63
|
+
* @param y - Y coordinate
|
|
64
|
+
* @returns Planet location ID as bigint, or undefined if no planet exists at coordinates
|
|
65
|
+
*/
|
|
66
|
+
getPlanetIdByCoordinates(x: number, y: number): bigint | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Get multiple planet infos
|
|
69
|
+
*/
|
|
70
|
+
getPlanetInfos(planetIds: bigint[]): (PlanetInfo | undefined)[];
|
|
71
|
+
/**
|
|
72
|
+
* Get planets around a center point within a radius
|
|
73
|
+
*/
|
|
74
|
+
getPlanetsAround(centerX: number, centerY: number, radius: number): Promise<{
|
|
75
|
+
info: PlanetInfo;
|
|
76
|
+
state: PlanetState;
|
|
77
|
+
}[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get my planets (owned by the current wallet)
|
|
80
|
+
*/
|
|
81
|
+
getMyPlanets(radius?: number): Promise<Array<{
|
|
82
|
+
info: PlanetInfo;
|
|
83
|
+
state: ExternalPlanet;
|
|
84
|
+
}>>;
|
|
85
|
+
/**
|
|
86
|
+
* Get pending exits for the current player
|
|
87
|
+
*/
|
|
88
|
+
getMyPendingExits(): Promise<PendingExit[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Verify exit status for a planet
|
|
91
|
+
*/
|
|
92
|
+
verifyExitStatus(planetId: bigint): Promise<{
|
|
93
|
+
exit: PendingExit;
|
|
94
|
+
interrupted: boolean;
|
|
95
|
+
newOwner?: Address;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Clean up old completed exits
|
|
99
|
+
*/
|
|
100
|
+
cleanupOldCompletedExits(olderThanDays?: number): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Calculate distance between two planets
|
|
103
|
+
*/
|
|
104
|
+
calculateDistance(fromPlanetId: bigint, toPlanetId: bigint): number | undefined;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/planet/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,OAAO,EAAC,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAC,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