Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter in RunContractFunction does not match to self-hosted server #68

Open
dFohlen opened this issue Jan 11, 2023 · 0 comments
Open

Comments

@dFohlen
Copy link

dFohlen commented Jan 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant