Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

Commit

Permalink
Pre release QA Part 2 (#58)
Browse files Browse the repository at this point in the history
* Storage -> Store

* Export core/messages
  • Loading branch information
wilwade committed Jun 9, 2021
1 parent 8391c7f commit 0fb5a0c
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dist
*.js
*.d.ts
docs
core
/core

### ignore typechain types
/src/types/typechain/*
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ setConfig({
Amazon S3 is supported when adding the following configuration:
```typescript
import { setConfig } from "@dsnp/sdk";
import { S3Node } from "@dsnp/sdk/core/storage";
import { S3Node } from "@dsnp/sdk/core/store";

setConfig({
...,
Expand All @@ -59,7 +59,7 @@ setConfig({
```
Other storage solutions can be added so as long it contains the following interface.
```typescript
interface StorageInterface {
interface StoreInterface {
put: (targetPath: string, content: Content) => Promise<URL>;
get?: (targetPath: string) => Promise<string>;
}
Expand All @@ -68,7 +68,7 @@ interface StorageInterface {
```
config
.setConfig({
storage: new MyStorage()
store: new MyStore()
});
```

Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ethers } from "ethers";

import MemoryQueue from "./core/queue/memoryQueue";
import { QueueInterface } from "./core/queue/queue";
import { StorageInterface } from "./core/storage/storage";
import { QueueInterface } from "./core/queue";
import { StoreInterface } from "./core/store";
import { HexString } from "./types/Strings";

/**
Expand All @@ -16,7 +16,7 @@ export interface Config {
/** The queue manages Announcements waiting to be batched */
queue: QueueInterface;
/** The Storage handles storing batch, content, and other media files at a publicly accessible location */
store?: StorageInterface;
store?: StoreInterface;
/** Contracts are different addresses for specific contracts or for running custom tests */
contracts: {
/** The Address of the Batch Announce contract */
Expand Down
8 changes: 4 additions & 4 deletions src/content.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import * as config from "../config/config";
// import * as storage from "../storage/storage";
// import * as store from "../store";
import { ActivityPubOpts } from "./core/activityPub/activityPub";
import { ConfigOpts } from "./config";
import { NotImplementedError } from "./core/utilities/errors";
Expand All @@ -20,7 +20,7 @@ export const broadcast = async (_content: ActivityPubOpts, _opts?: ConfigOpts):
//
// const activityPubObject = activityPub.create(activityPubOpts);
// const activityPubHash = activityPub.hash(activityPubObject);
// const uri = storage.store(activityPubObject, opts);
// const uri = store.put(activityPubObject, opts);
//
// return events.createBroadcastEvent(uri, activityPubHash);
};
Expand All @@ -41,7 +41,7 @@ export const reply = async (_content: ActivityPubOpts, _opts?: ConfigOpts): Prom
// const inReplyTo = activityPubOpts.inReplyTo;
// const activityPubObject = activityPub.create(activityPubOpts);
// const activityPubHash = activityPub.hash(activityPubObject);
// const uri = storage.store(activityPubObject, opts);
// const uri = store.put(activityPubObject, opts);
//
// return events.createReplyEvent(uri, inReplyTo, activityPubHash);
};
Expand All @@ -63,7 +63,7 @@ export const react = async (_emoji: string, _inReplyTo: string, _opts?: ConfigOp
// const inReplyTo = activityPubOpts.inReplyTo;
// const activityPubObject = activityPub.create(activityPubOpts);
// const activityPubHash = activityPub.hash(activityPubObject);
// const uri = storage.store(activityPubObject, opts);
// const uri = store.put(activityPubObject, opts);
//
// return events.createReactionEvent(uri, inReplyTo, activityPubHash);
};
7 changes: 5 additions & 2 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ export const batch = batchImport;
import * as contractsImport from "./contracts";
export const contracts = contractsImport;

import * as messagesImport from "./messages";
export const messages = messagesImport;

import * as queueImport from "./queue";
export const queue = queueImport;

import * as storageImport from "./storage";
export const storage = storageImport;
import * as storeImport from "./store";
export const store = storeImport;

import * as utilitiesImport from "./utilities";
export const utilities = utilitiesImport;
2 changes: 1 addition & 1 deletion src/core/storage/index.ts → src/core/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* - `import { foo } from "@dsnp/sdk/contracts"; foo.functionInFoo();`
*/

export * from "./storage";
export * from "./interface";
export * from "./s3Node";
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getConfig } from "../../config";
import { MissingStoreError, NotImplementedError } from "../utilities";
import { get, put } from "./storage";
import { get, put } from "./interface";

jest.mock("../../config");

describe("storage", () => {
describe("store", () => {
describe("#get", () => {
describe("when store configuration is not set", () => {
beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/storage/storage.ts → src/core/store/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export type File = Buffer | string;
export type Content = string | Buffer;

/**
* StorageInterface is the interface a storage adapter is expected to implement to
* StoreInterface is the interface a storage adapter is expected to implement to
* be used with high-level methods in this SDK. The require methods consist of
* an put function, a dequeue function and a get function.
*/
export interface StorageInterface {
export interface StoreInterface {
put: (targetPath: string, content: Content) => Promise<URL>;
get?: (targetPath: string) => Promise<File>;
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/core/storage/s3Node.ts → src/core/store/s3Node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { S3Client, S3ClientConfig, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
import { StorageInterface } from "./storage";
import { StoreInterface } from "./interface";
import { Readable } from "stream";

/**
Expand All @@ -16,7 +16,7 @@ export interface S3Credentials extends S3ClientConfig {
* S3Node provides a storage solution for saving DSNP messages
* This adapter is provided for convenience can be used in other applications configuration.
*/
export class S3Node implements StorageInterface {
export class S3Node implements StoreInterface {
client: S3Client;
bucket: string;
region: string;
Expand Down

0 comments on commit 0fb5a0c

Please sign in to comment.