Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
feat(ipfs): change ipfs-core to ipfs
Browse files Browse the repository at this point in the history
wip #19
  • Loading branch information
0x77dev committed Feb 1, 2022
1 parent b835de4 commit 892a67c
Show file tree
Hide file tree
Showing 4 changed files with 1,862 additions and 88 deletions.
2 changes: 2 additions & 0 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"dependencies": {
"@chainsafe/libp2p-noise": "^5.0.2",
"ipfs": "^0.62.0",
"ipfs-core": "^0.13.0",
"libp2p-webrtc-star": "^0.25.0",
"libp2p-websockets": "^0.16.2",
"tslib": "^2.3.1"
},
"license": "GPL-3.0",
Expand Down
6 changes: 1 addition & 5 deletions packages/ipfs/src/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export const listen = [
'/dns4/dstack-relay.herokuapp.com/tcp/443/wss/p2p-webrtc-star/',
'/dns4/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star/',
'/dns6/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star',
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star/',
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star/'
'/dns4/dstack-relay.herokuapp.com/tcp/443/wss/p2p-webrtc-star/'
]
36 changes: 19 additions & 17 deletions packages/ipfs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import * as IPFS from "ipfs-core"
import { listen } from "./addresses"

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import IPFS from 'ipfs'
import type { Options as IPFSOptions } from 'ipfs-core'
// @ts-expect-error: no-types
import WebRTCStar from 'libp2p-webrtc-star'
// @ts-expect-error: no-types
import WS from 'libp2p-websockets'
import { NOISE } from '@chainsafe/libp2p-noise'
import { listen } from './addresses'

export type Options = Omit<IPFS.Options, "libp2p">
export type Options = Omit<IPFSOptions, 'libp2p'>

export const create = (options?: Options, wrtc?: any): Promise<IPFS.IPFS> => {
return IPFS.create({
config: {
Discovery: {
webRTCStar: { Enabled: true },
webRTCStar: { Enabled: true }
},
Addresses: {
Swarm: listen,
Swarm: listen
},
Bootstrap: [
'/dns4/dstack-relay.herokuapp.com/tcp/443/wss/p2p-webrtc-star/p2p/QmV2uXBKbii29iJKHKVy8sx5m49qdDTBYNybVoa5uLJtrf',
'/dns4/ipfs.thedisco.zone/tcp/4430/wss/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt',
'/dns6/ipfs.thedisco.zone/tcp/4430/wss/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt'
'/dns4/dstack-relay.herokuapp.com/tcp/443/wss/p2p-webrtc-star/p2p/QmV2uXBKbii29iJKHKVy8sx5m49qdDTBYNybVoa5uLJtrf'
],
...options?.config
},
...options,
relay: {
enabled: true,
hop: {
enabled: true
}
},
libp2p: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
modules: {
transport: [WebRTCStar],
// @ts-expect-error: incompatible type
transport: [WS, WebRTCStar],
connEncryption: [NOISE]
},
config: {
Expand All @@ -48,7 +50,7 @@ export const create = (options?: Options, wrtc?: any): Promise<IPFS.IPFS> => {
dht: {
enabled: true,
kBucketSize: 20
},
},
}
}
})
}
Loading

0 comments on commit 892a67c

Please sign in to comment.