Skip to content

Commit a513c79

Browse files
authored
pin settings to fission web-api on save (#18)
1 parent 63d2e6f commit a513c79

File tree

5 files changed

+66
-100
lines changed

5 files changed

+66
-100
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# misc
1515
.DS_Store
16+
.env
1617
.env.local
1718
.env.development.local
1819
.env.test.local

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@fission-suite/client": "0.0.6",
67
"@material-ui/core": "^4.3.2",
78
"@material-ui/icons": "^4.2.1",
89
"classnames": "^2.2.6",
10+
"get-ipfs": "^0.0.3",
911
"prop-types": "^15.7.2",
1012
"react": "^16.9.0",
1113
"react-color": "^2.17.3",

src/ipfs/get-ipfs.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/ipfs/preferences.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import getIpfsWithConfig from "../ipfs/get-ipfs";
1+
import getIpfsWithConfig from "get-ipfs";
2+
import { FissionUser } from "@fission-suite/client";
3+
4+
const ipfsProvider =
5+
process.env.REACT_APP_INTERPLANETARY_FISSION_URL || "https://hostless.dev";
6+
const username = process.env.REACT_APP_INTERPLANETARY_FISSION_USERNAME;
7+
const password = process.env.REACT_APP_INTERPLANETARY_FISSION_PASSWORD;
8+
const bootstrapNode = process.env.REACT_APP_BOOTSTRAP_NODE;
9+
const fission = new FissionUser(username, password, ipfsProvider);
210

311
export const DefaultCid = "QmUMQ5Zxu94gwGq96hGEBc2hzoMkywUctbySw7YY6g8ktw";
412

513
const getIpfs = async () => {
6-
return await getIpfsWithConfig({
7-
bootstrap: [
8-
"/ip4/127.0.0.1/tcp/4002/ws/ipfs/QmY4N8hPzGQUPDJc8tMWuQokJswStUZk9SkBACCHoVZpCS"
9-
]
14+
return getIpfsWithConfig();
15+
const ipfs = await getIpfsWithConfig({
16+
bootstrap: [bootstrapNode]
1017
});
1118
};
1219

@@ -60,5 +67,11 @@ export const savePreferences = async preferences => {
6067
} catch (err) {
6168
throw new Error("Could not parse CID");
6269
}
70+
try {
71+
await fission.pin(cid);
72+
} catch (err) {
73+
console.error(err);
74+
}
75+
6376
return cid;
6477
};

yarn.lock

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,14 @@
819819
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.7.2.tgz#53211e564604beb9befa7a4400ebf8147473eeef"
820820
integrity sha512-RMtr1i6E8MXaBWwhXL3yeOU8JXRnz8GNxHvaUfVvwxokvayUY0zoBeWbKw1S9XkufmGEEdQd228pSZXFkAln8Q==
821821

822+
"@fission-suite/client@0.0.6":
823+
version "0.0.6"
824+
resolved "https://registry.yarnpkg.com/@fission-suite/client/-/client-0.0.6.tgz#6ef6a72d6ebdfc98ef43ca719b65f522dd38a714"
825+
integrity sha512-+vs/f+I9hucSGx/Sq3kwCFxcYqIWjvGxjxcOwl1KDnd60Ck57fpv5xgybl6DRPN0d4IheW6XRFiP2o8G3ZIAWQ==
826+
dependencies:
827+
axios "^0.19.0"
828+
dotenv "^8.0.0"
829+
822830
"@hapi/address@2.x.x":
823831
version "2.0.0"
824832
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.0.0.tgz#9f05469c88cb2fd3dcd624776b54ee95c312126a"
@@ -1850,6 +1858,14 @@ aws4@^1.8.0:
18501858
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
18511859
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
18521860

1861+
axios@^0.19.0:
1862+
version "0.19.0"
1863+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
1864+
integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==
1865+
dependencies:
1866+
follow-redirects "1.5.10"
1867+
is-buffer "^2.0.2"
1868+
18531869
axobject-query@^2.0.2:
18541870
version "2.0.2"
18551871
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9"
@@ -3136,6 +3152,13 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.
31363152
dependencies:
31373153
ms "2.0.0"
31383154

3155+
debug@=3.1.0:
3156+
version "3.1.0"
3157+
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
3158+
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
3159+
dependencies:
3160+
ms "2.0.0"
3161+
31393162
debug@^3.2.5, debug@^3.2.6:
31403163
version "3.2.6"
31413164
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
@@ -3440,6 +3463,11 @@ dotenv@6.2.0:
34403463
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
34413464
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
34423465

3466+
dotenv@^8.0.0:
3467+
version "8.1.0"
3468+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.1.0.tgz#d811e178652bfb8a1e593c6dd704ec7e90d85ea2"
3469+
integrity sha512-GUE3gqcDCaMltj2++g6bRQ5rBJWtkWTmqmD0fo1RnnMuUqHNCt2oTPeDnS9n6fKYvlhn7AeBkb38lymBtWBQdA==
3470+
34433471
duplexer@^0.1.1:
34443472
version "0.1.1"
34453473
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
@@ -4181,6 +4209,13 @@ flush-write-stream@^1.0.0:
41814209
inherits "^2.0.3"
41824210
readable-stream "^2.3.6"
41834211

4212+
follow-redirects@1.5.10:
4213+
version "1.5.10"
4214+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
4215+
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
4216+
dependencies:
4217+
debug "=3.1.0"
4218+
41844219
follow-redirects@^1.0.0:
41854220
version "1.7.0"
41864221
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.7.0.tgz#489ebc198dc0e7f64167bd23b03c4c19b5784c76"
@@ -4345,6 +4380,11 @@ get-caller-file@^1.0.1:
43454380
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
43464381
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
43474382

4383+
get-ipfs@^0.0.3:
4384+
version "0.0.3"
4385+
resolved "https://registry.yarnpkg.com/get-ipfs/-/get-ipfs-0.0.3.tgz#4ed9b08cebe858a34ca0573ab6f0786c5c6d0a17"
4386+
integrity sha512-YxDHnEzXRCdyg5UcMw+cUSfZu4ex/QgP9PsBVt5Mk39hRv0VwHtIzHZpu6DMkH8r+LKKcaxk8Lex5qzVFEbYrg==
4387+
43484388
get-own-enumerable-property-symbols@^3.0.0:
43494389
version "3.0.0"
43504390
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz#b877b49a5c16aefac3655f2ed2ea5b684df8d203"
@@ -5057,6 +5097,11 @@ is-buffer@^1.0.2, is-buffer@^1.1.5:
50575097
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
50585098
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
50595099

5100+
is-buffer@^2.0.2:
5101+
version "2.0.3"
5102+
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725"
5103+
integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==
5104+
50605105
is-callable@^1.1.4:
50615106
version "1.1.4"
50625107
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"

0 commit comments

Comments
 (0)