From 8cf3a0b76ed9c9b9a33df88ed5e8af34d32a47c1 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Wed, 17 Feb 2021 12:18:12 -0500 Subject: [PATCH] Feat(cli): Clean up pinning CLI flags (#1012) --- .../cli/src/__tests__/ceramic-daemon.test.ts | 4 ++-- packages/cli/src/bin/ceramic.ts | 12 ++++++------ packages/cli/src/ceramic-cli-utils.ts | 12 ++++++------ packages/cli/src/ceramic-daemon.ts | 12 ++++++------ .../core/src/__tests__/ceramic-anchor.test.ts | 2 +- .../core/src/__tests__/ceramic-pinning.test.ts | 4 ++-- .../ceramic-recover-documents.test.ts | 10 +++++----- packages/core/src/__tests__/ceramic.test.ts | 18 +++++++++--------- packages/core/src/ceramic.ts | 8 ++++---- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/cli/src/__tests__/ceramic-daemon.test.ts b/packages/cli/src/__tests__/ceramic-daemon.test.ts index de444a470b..5f3c5822e1 100644 --- a/packages/cli/src/__tests__/ceramic-daemon.test.ts +++ b/packages/cli/src/__tests__/ceramic-daemon.test.ts @@ -81,8 +81,8 @@ describe('Ceramic interop: core <> http-client', () => { // performed yet by the time the test checks. To eliminate this race condition we should set // anchorOnRequest to false in the config for the InMemoryAnchorService and anchor manually // throughout the tests. - const pinsetDirectory = tmpFolder.path - core = await Ceramic.create(ipfs, {pubsubTopic: topic, pinsetDirectory}) + const stateStoreDirectory = tmpFolder.path + core = await Ceramic.create(ipfs, {pubsubTopic: topic, stateStoreDirectory}) const doctypeHandler = new TileDoctypeHandler() doctypeHandler.verifyJWS = (): Promise => { return } diff --git a/packages/cli/src/bin/ceramic.ts b/packages/cli/src/bin/ceramic.ts index 324424dcc8..0363e57bd5 100644 --- a/packages/cli/src/bin/ceramic.ts +++ b/packages/cli/src/bin/ceramic.ts @@ -8,8 +8,8 @@ program .option('--ethereum-rpc ', 'The Ethereum RPC URL used for communicating with Ethereum blockchain') .option('--anchor-service-api ', 'The anchor service URL to use') .option('--validate-docs', 'Validate documents according to their schemas. It is enabled by default') - .option('--pinning-endpoint ', 'Pinning endpoints') - .option('--pinset-directory ', `The directory path used for pinning service. Defaults to HOME_DIR/.ceramic/pinset`) + .option('--ipfs-pinning-endpoint ', 'Ipfs pinning endpoints') + .option('--state-store-directory ', `The directory path used for storing pinned document state. Defaults to HOME_DIR/.ceramic/pinset`) .option('--gateway', 'Makes read only endpoints available. It is disabled by default') .option('--port ', 'Port daemon is available. Default is 7007') .option('--debug', 'Enable debug logging level. Default is false') @@ -26,8 +26,8 @@ program ethereumRpc, anchorServiceApi, validateDocs, - pinningEndpoint, - pinsetDirectory, + ipfsPinningEndpoint, + stateStoreDirectory, gateway, port, debug, @@ -44,8 +44,8 @@ program ethereumRpc, anchorServiceApi, validateDocs, - pinningEndpoint, - pinsetDirectory, + ipfsPinningEndpoint, + stateStoreDirectory, gateway, port, debug, diff --git a/packages/cli/src/ceramic-cli-utils.ts b/packages/cli/src/ceramic-cli-utils.ts index e24499cb05..d1bd34172c 100644 --- a/packages/cli/src/ceramic-cli-utils.ts +++ b/packages/cli/src/ceramic-cli-utils.ts @@ -39,8 +39,8 @@ export class CeramicCliUtils { * @param ethereumRpc - Ethereum RPC URL * @param anchorServiceApi - Anchor service API URL * @param validateDocs - Validate docs according to schemas or not - * @param pinningEndpoints - Pinning endpoints - * @param pinsetDirectory - Path to the directory that will be used for storing pinned document state + * @param ipfsPinningEndpoints - Ipfs pinning endpoints + * @param stateStoreDirectory - Path to the directory that will be used for storing pinned document state * @param gateway - read only endpoints available. It is disabled by default * @param port - port daemon is availabe. Default is 7007 * @param debug - Enable debug logging level @@ -57,8 +57,8 @@ export class CeramicCliUtils { ethereumRpc: string, anchorServiceApi: string, validateDocs: boolean, - pinningEndpoints: string[], - pinsetDirectory: string, + ipfsPinningEndpoints: string[], + stateStoreDirectory: string, gateway: boolean, port: number, debug: boolean, @@ -78,9 +78,9 @@ export class CeramicCliUtils { const config: CreateOpts = { ethereumRpcUrl: ethereumRpc, anchorServiceUrl: anchorServiceApi, - pinsetDirectory, + stateStoreDirectory, validateDocs, - pinningEndpoints, + ipfsPinningEndpoints, gateway, port, debug, diff --git a/packages/cli/src/ceramic-daemon.ts b/packages/cli/src/ceramic-daemon.ts index e4a1a94617..8cd99216b3 100644 --- a/packages/cli/src/ceramic-daemon.ts +++ b/packages/cli/src/ceramic-daemon.ts @@ -33,10 +33,10 @@ export interface CreateOpts { ethereumRpcUrl?: string; anchorServiceUrl?: string; - pinsetDirectory?: string; + stateStoreDirectory?: string; validateDocs?: boolean; - pinningEndpoints?: string[]; + ipfsPinningEndpoints?: string[]; gateway?: boolean; debug: boolean; logToFiles?: boolean; @@ -93,12 +93,12 @@ const makeCeramicConfig = function (opts: CreateOpts): CeramicConfig { ceramicConfig.pubsubTopic = opts.pubsubTopic } - if (opts.pinsetDirectory) { - ceramicConfig.pinsetDirectory = opts.pinsetDirectory + if (opts.stateStoreDirectory) { + ceramicConfig.stateStoreDirectory = opts.stateStoreDirectory } - if (opts.pinningEndpoints) { - ceramicConfig.pinningEndpoints = opts.pinningEndpoints + if (opts.ipfsPinningEndpoints) { + ceramicConfig.ipfsPinningEndpoints = opts.ipfsPinningEndpoints } if (opts.logToFiles) { diff --git a/packages/core/src/__tests__/ceramic-anchor.test.ts b/packages/core/src/__tests__/ceramic-anchor.test.ts index 58f9c53a08..da37111fa7 100644 --- a/packages/core/src/__tests__/ceramic-anchor.test.ts +++ b/packages/core/src/__tests__/ceramic-anchor.test.ts @@ -11,7 +11,7 @@ const seed = u8a.fromString('6e34b2e1a9624113d81ece8a8a22e6e97f0e145c25c1d4d2d0e const createCeramic = async (ipfs: IpfsApi, anchorManual: boolean): Promise => { const ceramic = await Ceramic.create(ipfs, { - pinsetDirectory: await tmp.tmpName(), + stateStoreDirectory: await tmp.tmpName(), anchorOnRequest: !anchorManual, restoreDocuments: false, pubsubTopic: "/ceramic/inmemory/test" // necessary so Ceramic instances can talk to each other diff --git a/packages/core/src/__tests__/ceramic-pinning.test.ts b/packages/core/src/__tests__/ceramic-pinning.test.ts index 23569f783d..94201ed522 100644 --- a/packages/core/src/__tests__/ceramic-pinning.test.ts +++ b/packages/core/src/__tests__/ceramic-pinning.test.ts @@ -7,9 +7,9 @@ import { createIPFS } from './ipfs-util'; const seed = u8a.fromString('6e34b2e1a9624113d81ece8a8a22e6e97f0e145c25c1d4d2d0e62753b4060c83', 'base16') -const createCeramic = async (ipfs: IpfsApi, pinsetDirectory, anchorOnRequest = false): Promise => { +const createCeramic = async (ipfs: IpfsApi, stateStoreDirectory, anchorOnRequest = false): Promise => { const ceramic = await Ceramic.create(ipfs, { - pinsetDirectory, + stateStoreDirectory, anchorOnRequest, pubsubTopic: "/ceramic/inmemory/test" // necessary so Ceramic instances can talk to each other }) diff --git a/packages/core/src/__tests__/ceramic-recover-documents.test.ts b/packages/core/src/__tests__/ceramic-recover-documents.test.ts index 77c3529209..0e37bd6f04 100644 --- a/packages/core/src/__tests__/ceramic-recover-documents.test.ts +++ b/packages/core/src/__tests__/ceramic-recover-documents.test.ts @@ -28,9 +28,9 @@ function registerChangeListener (doc: Doctype): Promise { }) } -async function createCeramic(ipfs: IpfsApi, pinsetDirectory: string) { +async function createCeramic(ipfs: IpfsApi, stateStoreDirectory: string) { const ceramic = await Ceramic.create(ipfs, { - pinsetDirectory: pinsetDirectory, + stateStoreDirectory, anchorOnRequest: false, pubsubTopic: PUBSUB_TOPIC, // necessary so Ceramic instances can talk to each other }); @@ -57,10 +57,10 @@ afterEach(async () => { }); it("re-request anchors on #recoverDocuments", async () => { - const pinsetDirectory = await tmp.tmpName(); + const stateStoreDirectory = await tmp.tmpName(); // Store - const ceramic1 = await createCeramic(ipfs1, pinsetDirectory); + const ceramic1 = await createCeramic(ipfs1, stateStoreDirectory); const controller = ceramic1.context.did.id; const doc1 = await ceramic1.createDocument( @@ -73,7 +73,7 @@ it("re-request anchors on #recoverDocuments", async () => { await ceramic1.close(); // Retrieve after being closed - const ceramic2 = await createCeramic(ipfs2, pinsetDirectory); + const ceramic2 = await createCeramic(ipfs2, stateStoreDirectory); const doc2 = await ceramic2.loadDocument(doc1.id); expect(doc2.state.anchorStatus).toEqual(AnchorStatus.PENDING); diff --git a/packages/core/src/__tests__/ceramic.test.ts b/packages/core/src/__tests__/ceramic.test.ts index a0662fb8f9..878aabfaae 100644 --- a/packages/core/src/__tests__/ceramic.test.ts +++ b/packages/core/src/__tests__/ceramic.test.ts @@ -20,7 +20,7 @@ async function delay(mills: number): Promise { const createCeramic = async (ipfs: IpfsApi, anchorOnRequest = false, docCacheLimit = 100, cacheDocumentCommits = true): Promise => { const ceramic = await Ceramic.create(ipfs, { - pinsetDirectory: await tmp.tmpName(), + stateStoreDirectory: await tmp.tmpName(), anchorOnRequest, docCacheLimit, cacheDocCommits: cacheDocumentCommits, @@ -66,8 +66,8 @@ describe('Ceramic integration', () => { }) it('can create Ceramic instance on default network', async () => { - const pinsetDirectory = await tmp.tmpName() - const ceramic = await Ceramic.create(ipfs1, {pinsetDirectory, restoreDocuments: false}) + const stateStoreDirectory = await tmp.tmpName() + const ceramic = await Ceramic.create(ipfs1, {stateStoreDirectory, restoreDocuments: false}) await delay(1000) const supportedChains = await ceramic.getSupportedChains() expect(supportedChains).toEqual(['inmemory:12345']) @@ -75,8 +75,8 @@ describe('Ceramic integration', () => { }) it('can create Ceramic instance explicitly on inmemory network', async () => { - const pinsetDirectory = await tmp.tmpName() - const ceramic = await Ceramic.create(ipfs1, { networkName: 'inmemory', pinsetDirectory, restoreDocuments: false }) + const stateStoreDirectory = await tmp.tmpName() + const ceramic = await Ceramic.create(ipfs1, { networkName: 'inmemory', stateStoreDirectory, restoreDocuments: false }) await delay(1000) const supportedChains = await ceramic.getSupportedChains() expect(supportedChains).toEqual(['inmemory:12345']) @@ -84,15 +84,15 @@ describe('Ceramic integration', () => { }) it('cannot create Ceramic instance on network not supported by our anchor service', async () => { - const pinsetDirectory = await tmp.tmpName() - await expect(Ceramic.create(ipfs1, { networkName: 'local', pinsetDirectory, restoreDocuments: false })).rejects.toThrow( + const stateStoreDirectory = await tmp.tmpName() + await expect(Ceramic.create(ipfs1, { networkName: 'local', stateStoreDirectory, restoreDocuments: false })).rejects.toThrow( "No usable chainId for anchoring was found. The ceramic network 'local' supports the chains: ['eip155:1337'], but the configured anchor service 'inmemory' only supports the chains: ['inmemory:12345']") await delay(1000) }) it('cannot create Ceramic instance on invalid network', async () => { - const pinsetDirectory = await tmp.tmpName() - await expect(Ceramic.create(ipfs1, { networkName: 'fakenetwork', pinsetDirectory, restoreDocuments: false })).rejects.toThrow("Unrecognized Ceramic network name: 'fakenetwork'. Supported networks are: 'mainnet', 'testnet-clay', 'dev-unstable', 'local', 'inmemory'") + const stateStoreDirectory = await tmp.tmpName() + await expect(Ceramic.create(ipfs1, { networkName: 'fakenetwork', stateStoreDirectory, restoreDocuments: false })).rejects.toThrow("Unrecognized Ceramic network name: 'fakenetwork'. Supported networks are: 'mainnet', 'testnet-clay', 'dev-unstable', 'local', 'inmemory'") await delay(1000) }) diff --git a/packages/core/src/ceramic.ts b/packages/core/src/ceramic.ts index 4ab9f48fac..25df506165 100644 --- a/packages/core/src/ceramic.ts +++ b/packages/core/src/ceramic.ts @@ -54,13 +54,13 @@ const TESTING = process.env.NODE_ENV == 'test' export interface CeramicConfig { ethereumRpcUrl?: string; anchorServiceUrl?: string; - pinsetDirectory?: string; + stateStoreDirectory?: string; didResolver?: Resolver; didProvider?: DIDProvider; validateDocs?: boolean; - pinningEndpoints?: string[]; + ipfsPinningEndpoints?: string[]; pinningBackends?: PinningBackendStatic[]; logLevel?: string; @@ -293,8 +293,8 @@ class Ceramic implements CeramicApi { const pinStoreProperties = { networkName: networkOptions.name, - pinsetDirectory: config.pinsetDirectory, - pinningEndpoints: config.pinningEndpoints, + pinsetDirectory: config.stateStoreDirectory, + pinningEndpoints: config.ipfsPinningEndpoints, pinningBackends: config.pinningBackends } const pinStoreFactory = new PinStoreFactory(context, pinStoreProperties)