mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-21 10:39:06 +00:00
Add log for handling muliple returned values (#359)
Co-authored-by: Dhruv Srivastava <dhruvdhs.ds@gmail.com>
This commit is contained in:
parent
7dada71fa3
commit
25df38ace2
@ -62,6 +62,8 @@ Steps:
|
||||
# NOTE: When passed an *URL* as contract path, it is assumed that it points to an already flattened contract file.
|
||||
```
|
||||
|
||||
* Ensure dependencies are installed in the contracts repository before generating the watcher
|
||||
|
||||
* Run the following command to generate a watcher from contract(s):
|
||||
|
||||
```bash
|
||||
|
@ -61,6 +61,8 @@
|
||||
"devDependencies": {
|
||||
"@ethersproject/abi": "^5.3.0",
|
||||
"@types/yargs": "^17.0.0",
|
||||
"@types/debug": "^4.1.5",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
||||
"@typescript-eslint/parser": "^5.47.1",
|
||||
"eslint": "^8.35.0",
|
||||
|
@ -60,32 +60,37 @@ export class Visitor {
|
||||
|
||||
let errorMessage = '';
|
||||
|
||||
const typeName = node.returnParameters[0].typeName;
|
||||
switch (typeName.type) {
|
||||
case 'ElementaryTypeName': {
|
||||
const returnType = typeName.name;
|
||||
if (node.returnParameters.length > 1) {
|
||||
errorMessage = `No support in codegen for multiple returned values from method ${node.name}`;
|
||||
} else {
|
||||
const typeName = node.returnParameters[0].typeName;
|
||||
switch (typeName.type) {
|
||||
case 'ElementaryTypeName': {
|
||||
const returnType = typeName.name;
|
||||
|
||||
this._schema.addQuery(name, params, returnType);
|
||||
this._resolvers.addQuery(name, params, returnType);
|
||||
this._entity.addQuery(name, params, returnType);
|
||||
this._database.addQuery(name, params, returnType);
|
||||
this._client.addQuery(name, params, returnType);
|
||||
this._schema.addQuery(name, params, returnType);
|
||||
this._resolvers.addQuery(name, params, returnType);
|
||||
this._entity.addQuery(name, params, returnType);
|
||||
this._database.addQuery(name, params, returnType);
|
||||
this._client.addQuery(name, params, returnType);
|
||||
|
||||
assert(this._contract);
|
||||
this._indexer.addQuery(this._contract.name, MODE_ETH_CALL, name, params, returnType);
|
||||
assert(this._contract);
|
||||
this._indexer.addQuery(this._contract.name, MODE_ETH_CALL, name, params, returnType);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'UserDefinedTypeName':
|
||||
errorMessage = `No support in codegen for user defined return type from method "${node.name}"`;
|
||||
break;
|
||||
|
||||
case 'ArrayTypeName':
|
||||
errorMessage = `No support in codegen for return type "${typeName.baseTypeName.name}[]" from method "${node.name}"`;
|
||||
break;
|
||||
|
||||
default:
|
||||
errorMessage = `No support in codegen for return type "${typeName.type}" from method "${node.name}"`;
|
||||
}
|
||||
case 'UserDefinedTypeName':
|
||||
errorMessage = `No support in codegen for user defined return type from method "${node.name}"`;
|
||||
break;
|
||||
|
||||
case 'ArrayTypeName':
|
||||
errorMessage = `No support in codegen for return type "${typeName.baseTypeName.name}[]" from method "${node.name}"`;
|
||||
break;
|
||||
|
||||
default:
|
||||
errorMessage = `No support in codegen for return type "${typeName.type}" from method "${node.name}"`;
|
||||
}
|
||||
|
||||
if (errorMessage !== '') {
|
||||
|
@ -3756,7 +3756,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138"
|
||||
integrity sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==
|
||||
|
||||
"@types/json-bigint@^1.0.0":
|
||||
"@types/json-bigint@^1.0.0", "@types/json-bigint@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/json-bigint/-/json-bigint-1.0.1.tgz#201062a6990119a8cc18023cfe1fed12fc2fc8a7"
|
||||
integrity sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==
|
||||
@ -6241,7 +6241,7 @@ commander@^2.15.1, commander@^2.20.3:
|
||||
|
||||
commander@^8.1.0:
|
||||
version "8.3.0"
|
||||
resolved "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
|
||||
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
|
||||
|
||||
compare-func@^2.0.0:
|
||||
@ -14685,7 +14685,7 @@ solc@0.7.3:
|
||||
|
||||
solc@0.8.13:
|
||||
version "0.8.13"
|
||||
resolved "https://registry.npmjs.org/solc/-/solc-0.8.13.tgz"
|
||||
resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.13.tgz#bafc7fcc11a627e2281e489076b80497123bb704"
|
||||
integrity sha512-C0yTN+rjEOGO6uVOXI8+EKa75SFMuZpQ2tryex4QxWIg0HRWZvCHKfVPuLZ5wx06Sb6GBp6uQA5yqQyXZnXOJw==
|
||||
dependencies:
|
||||
command-exists "^1.2.8"
|
||||
|
Loading…
Reference in New Issue
Block a user