This repository was archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from JoinColony/feature/ipfs-metadata
Complete overhaul of Colony metadata parsing
- Loading branch information
Showing
29 changed files
with
1,747 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Class: CloudflareReadonlyAdapter | ||
|
||
CloudflareReadonlyAdapter | ||
|
||
A Colony SDK IPFS adapter for Cloudflare IPFS (https://developers.cloudflare.com/web3/ipfs-gateway/). It only supports reading IPFS data from the Cloudflare gateway (not uploading or pinning files). | ||
|
||
This is the default IpfsAdapter used in Colony SDK. So in order to use this, you don't have to do anything. | ||
|
||
## Implements | ||
|
||
- [`IpfsAdapter`](../interfaces/IpfsAdapter.md) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new CloudflareReadonlyAdapter**() | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` = `'CLOUDFLARE'` | ||
|
||
Name for the IpfsAdapter. All uppercase please | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[name](../interfaces/IpfsAdapter.md#name) | ||
|
||
## Methods | ||
|
||
### getIpfsUrl | ||
|
||
▸ **getIpfsUrl**(`cid`): `string` | ||
|
||
Should return the whole URL to an IPFS resource on the corresponding gateway (e.g. https://my-ipfs-gateway/ipfs/QmXxxxXXxxXxXxXxxxXXxxxXxXXx). | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `cid` | `string` | An IPFS hash (CID) | | ||
|
||
#### Returns | ||
|
||
`string` | ||
|
||
The URL to an ipfs resource | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[getIpfsUrl](../interfaces/IpfsAdapter.md#getipfsurl) | ||
|
||
___ | ||
|
||
### uploadJson | ||
|
||
▸ **uploadJson**(): `Promise`<`string`\> | ||
|
||
Function to upload a JSON string to IPFS. Takes the string as an argument (use `JSON.stringify()` if needbe). Returns a promise that resolves to the IPFS hash (CID) | ||
|
||
**`Remarks`** | ||
|
||
This function should ideally **pin** your data on the relevant service. | ||
|
||
#### Returns | ||
|
||
`Promise`<`string`\> | ||
|
||
Promise to IPFS hash (CID) | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[uploadJson](../interfaces/IpfsAdapter.md#uploadjson) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Class: PinataAdapter | ||
|
||
PinataAdapter | ||
|
||
A Colony SDK IPFS adapter for Pinata (https://pinata.cloud). In order to use this, sign up for Pinata (if you haven't already) and generate a token. Then either supply this token when instantiating the class (example below) or provide it via the environment variable `COLONY_IPFS_PINATA_TOKEN`. Then provide an instance of this class to the [ColonyNetwork](ColonyNetwork.md) or ColonyEventManger classes (depending on your needs). | ||
|
||
**`Remarks`** | ||
|
||
DO NOT CHECK IN YOUR PINATA TOKEN INTO VERSION CONTROL AND **DO NOT EMBED IT INTO YOUR FRONTEND BUNDLE**. | ||
|
||
**`Example`** | ||
|
||
```typescript | ||
import { ColonyNetwork, PinataAdapter } from '@colony/sdk'; | ||
const pinataAdapter = new PinataAdapter('YOUR_PINANTA_JWT_TOKEN'); | ||
const colonyNetwork = new ColonyNetwork({ ipfsAdapter: pinataAdapter }); | ||
``` | ||
|
||
## Implements | ||
|
||
- [`IpfsAdapter`](../interfaces/IpfsAdapter.md) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new PinataAdapter**(`pinataToken?`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `pinataToken?` | `string` | | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` = `'PINATA'` | ||
|
||
Name for the IpfsAdapter. All uppercase please | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[name](../interfaces/IpfsAdapter.md#name) | ||
|
||
## Methods | ||
|
||
### getIpfsUrl | ||
|
||
▸ **getIpfsUrl**(`cid`): `string` | ||
|
||
Should return the whole URL to an IPFS resource on the corresponding gateway (e.g. https://my-ipfs-gateway/ipfs/QmXxxxXXxxXxXxXxxxXXxxxXxXXx). | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `cid` | `string` | An IPFS hash (CID) | | ||
|
||
#### Returns | ||
|
||
`string` | ||
|
||
The URL to an ipfs resource | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[getIpfsUrl](../interfaces/IpfsAdapter.md#getipfsurl) | ||
|
||
___ | ||
|
||
### uploadJson | ||
|
||
▸ **uploadJson**(`jsonString`): `Promise`<`string`\> | ||
|
||
Function to upload a JSON string to IPFS. Takes the string as an argument (use `JSON.stringify()` if needbe). Returns a promise that resolves to the IPFS hash (CID) | ||
|
||
**`Remarks`** | ||
|
||
This function should ideally **pin** your data on the relevant service. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `jsonString` | `string` | JSON string to upload (and pin) to IPFS | | ||
|
||
#### Returns | ||
|
||
`Promise`<`string`\> | ||
|
||
Promise to IPFS hash (CID) | ||
|
||
#### Implementation of | ||
|
||
[IpfsAdapter](../interfaces/IpfsAdapter.md).[uploadJson](../interfaces/IpfsAdapter.md#uploadjson) |
Oops, something went wrong.