From 225dcea9a0e6e0dbe9d99e6fcb06664ec087295f Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 20 Jan 2022 11:50:25 +0000 Subject: [PATCH 1/2] fix: update ts examples Fix up tsconfig and also import CID from `ipfs-core` to remove the extra dependency. --- examples/types-use-ipfs-from-ts/package.json | 3 +-- examples/types-use-ipfs-from-ts/src/main.ts | 2 +- examples/types-use-ipfs-from-ts/tsconfig.json | 1 + examples/types-use-ipfs-from-typed-js/src/main.js | 3 ++- examples/types-use-ipfs-from-typed-js/tsconfig.json | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/types-use-ipfs-from-ts/package.json b/examples/types-use-ipfs-from-ts/package.json index f991a04a..629f23b0 100644 --- a/examples/types-use-ipfs-from-ts/package.json +++ b/examples/types-use-ipfs-from-ts/package.json @@ -8,8 +8,7 @@ "test": "tsc --noEmit" }, "dependencies": { - "ipfs-core": "^0.12.2", - "multiformats": "^9.4.1" + "ipfs-core": "^0.12.2" }, "devDependencies": { "typescript": "4.3.5" diff --git a/examples/types-use-ipfs-from-ts/src/main.ts b/examples/types-use-ipfs-from-ts/src/main.ts index ee7b88b1..262a114b 100644 --- a/examples/types-use-ipfs-from-ts/src/main.ts +++ b/examples/types-use-ipfs-from-ts/src/main.ts @@ -1,5 +1,5 @@ import { IPFS, create } from 'ipfs-core' -import { CID } from 'multiformats/cid' +import type { CID } from 'ipfs-core' export default async function main() { const node = await create() diff --git a/examples/types-use-ipfs-from-ts/tsconfig.json b/examples/types-use-ipfs-from-ts/tsconfig.json index df5cdf36..91dc5a65 100644 --- a/examples/types-use-ipfs-from-ts/tsconfig.json +++ b/examples/types-use-ipfs-from-ts/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "strict": true, "skipLibCheck": true, + "lib": ["ES2020", "ES2020.Promise", "ES2020.String", "ES2020.BigInt", "DOM", "DOM.Iterable"], "noImplicitAny": false, "esModuleInterop": true, "moduleResolution": "Node", diff --git a/examples/types-use-ipfs-from-typed-js/src/main.js b/examples/types-use-ipfs-from-typed-js/src/main.js index 0ea2af3a..8a7649e9 100644 --- a/examples/types-use-ipfs-from-typed-js/src/main.js +++ b/examples/types-use-ipfs-from-typed-js/src/main.js @@ -1,7 +1,8 @@ const { create } = require('ipfs-core') + /** * @typedef {import('ipfs-core-types').IPFS} IPFS - * @typedef {import('multiformats/cid').CID} CID + * @typedef {import('ipfs-core').CID} CID */ async function main () { diff --git a/examples/types-use-ipfs-from-typed-js/tsconfig.json b/examples/types-use-ipfs-from-typed-js/tsconfig.json index e3bbece7..023330ed 100644 --- a/examples/types-use-ipfs-from-typed-js/tsconfig.json +++ b/examples/types-use-ipfs-from-typed-js/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "allowJs": true, "checkJs": true, + "lib": ["ES2020", "ES2020.Promise", "ES2020.String", "ES2020.BigInt", "DOM", "DOM.Iterable"], "strict": true, "skipLibCheck": true, "noImplicitAny": false, From 3c9c38ee5a54452dcbdc99f02f003a6a907e0829 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 20 Jan 2022 20:41:40 +0000 Subject: [PATCH 2/2] fix: peerstore is becoming async --- examples/circuit-relaying/src/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/circuit-relaying/src/helpers.js b/examples/circuit-relaying/src/helpers.js index 1de13a8d..9139f136 100644 --- a/examples/circuit-relaying/src/helpers.js +++ b/examples/circuit-relaying/src/helpers.js @@ -86,7 +86,7 @@ module.exports = (ipfs, peersSet) => { for (let k = 0; k < 5; k++) { // protocols is undefined until the connection is negotiated so try a few times - const protocols = ipfs.libp2p.peerStore.protoBook.get(con.remotePeer) + const protocols = await ipfs.libp2p.peerStore.protoBook.get(con.remotePeer) if (!protocols) { await new Promise ((r) => {