Skip to content

Commit 15a7bed

Browse files
authored
Fix/contract write error (#251)
* move to Record type for writeContract params input to prevent account and chain field overwriting * change set * keep old formatting * restore formatting
1 parent 7b22fdf commit 15a7bed

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

.changeset/dirty-kids-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sei-js/mcp-server": patch
3+
---
4+
5+
Move to Record type for writeContract params arg

packages/mcp-server/src/core/services/contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function readContract(params: ReadContractParameters, network = DEF
1919
* @returns Transaction hash
2020
* @throws Error if no private key is available
2121
*/
22-
export async function writeContract(params: WriteContractParameters, network = DEFAULT_NETWORK): Promise<Hash> {
22+
export async function writeContract(params: Record<string, any>, network = DEFAULT_NETWORK): Promise<Hash> {
2323
// Get private key from environment
2424
const key = getPrivateKeyAsHex();
2525

@@ -28,7 +28,7 @@ export async function writeContract(params: WriteContractParameters, network = D
2828
}
2929

3030
const client = getWalletClient(key, network);
31-
return await client.writeContract(params);
31+
return await client.writeContract(params as any);
3232
}
3333

3434
/**

packages/mcp-server/src/core/tools.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,11 @@ export function registerEVMTools(server: McpServer) {
797797
// Parse ABI if it's a string
798798
const parsedAbi = typeof abi === 'string' ? JSON.parse(abi) : abi;
799799

800-
const contractParams: WriteContractParameters = {
800+
const contractParams: Record<string, any> = {
801801
address: contractAddress as Address,
802802
abi: parsedAbi,
803803
functionName,
804-
args,
805-
chain: null, // This will use the default chain from the client
806-
account: null // This will use the default account from the client
804+
args
807805
};
808806

809807
const txHash = await services.writeContract(contractParams, network);

packages/mcp-server/src/tests/core/tools.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,9 +1968,7 @@ describe('EVM Tools', () => {
19681968
address: writeParams.contractAddress,
19691969
abi: writeParams.abi,
19701970
functionName: writeParams.functionName,
1971-
args: writeParams.args,
1972-
chain: null, // This is added by the implementation
1973-
account: null // This is added by the implementation
1971+
args: writeParams.args
19741972
},
19751973
'sei' // DEFAULT_NETWORK
19761974
);

0 commit comments

Comments
 (0)