Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Update fetch-and-compile readme with fetchAndCompileMultiple and getSupportedNetworks #4719

Merged
merged 5 commits into from
Feb 11, 2022

Conversation

haltman-at
Copy link
Contributor

Thanks to @lsqproduction for noticing we'd forgotten to update this. Hoping these usage examples are sufficient?

Copy link
Contributor

@lsqproduction lsqproduction left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for adding it.

Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new TS project to verify this snippet and ran into issues simply importing @Truffle/fetch-and-compile and trying to compile. Adding the snippet led to a lot more type errors.

$ tsc   
node_modules/@truffle/compile-common/dist/src/types.d.ts:1:47 - error TS2307: Cannot find module '@truffle/contract-schema/spec' or its corresponding type declarations.

1 import type { Abi, ImmutableReferences } from "@truffle/contract-schema/spec";
         
tsconfig.json
{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "esModuleInterop": true,
    "strict": true,
    "outDir": "dist",
    "sourceMap": true
  }
}
package.json
{
  "name": "fetch-and-compile",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@truffle/fetch-and-compile": "^0.4.0"
  }
}

@@ -65,5 +65,56 @@ async function decode(address: string) {
decode("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e");
```

If you want to fetch and compile multiple contracts from the same network, you can use `fetchAndCompileMultiple`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point we need to start introducing headings for each exposed interface, so that they remain visually separate. Would be nice also to have an upfront bulleted list at the top (with some preamble), linking to the individual headings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll go back and do that.

@haltman-at
Copy link
Contributor Author

OK, I added headers as @gnidan suggested, and added a note about skipLibCheck as @cds-amal suggested elsewhere. Note that the skipLibCheck thing really applies to a number of our packages! (Amal do you maybe want to put up an issue for that...?) Seeing as ultimately the problem comes from contract-schema, which a number of our packages depend on.

@@ -2,7 +2,11 @@

This is used to obtain external verified sourced and compile them.

### Usage
Note: If you import this into your TS project, you may need to set `skipLibCheck` in your tsconfig due to an indirect dependency on @truffle/contract-schema.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set is ambiguous here, perhaps enable, or explicitly "set skipLibCheck to true"

Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the help getting this tested

@haltman-at haltman-at merged commit 9c66156 into develop Feb 11, 2022
@haltman-at haltman-at deleted the sup-doc branch February 11, 2022 22:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants