web3-unity-sdk
web3-unity-sdk copied to clipboard
Parameter in RunContractFunction does not match to self-hosted server
Hi Moralis team,
together with @YosephKS we found a minor mismatch between the Unity SDK and the EVM API code generated for the self-hosted server cloud code.
In NativeApi.cs#L451 and CloudApi/NativeApi.cs#L448 the parameter function_name
is in snake case while in the server code runContractFunctionOperation.ts#L42 it's in camel case functionName
. This leads to the following error:
Error: HTTP/1.1 400 Bad Request
{"code":141,"error":"[C0005] Request contains unknown parameter: function_name. This operation supports the following parameters: address, chain, functionName, providerUrl, subdomain, abi, params"}
As a workaround, either the parameter mentioned above can be changed to camel case or the parsing can be patched in the server code with:
formattedParams = {};
function camelToUnderscore(key) {
return key.replace( /([A-Z])/g, "_$1" ).toLowerCase();
}
for(let key in params) {
const camelCaseKeys = key.toLowerCase().replace(/([-_][a-z])/g, group =>
group
.toUpperCase()
.replace('_', '')
);
const formattedParams[camelCaseKeys] = params[key];
}
function_name
findings in this repository that need to be fixed 😉 Please consider if other parameters must also be specified in the camel case!
Best regards