mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-10 22:05:55 +00:00
build(deps): bump deprecated ipfs-api@17.2.4 to ipfs-http-client@39.0.2
BREAKING CHANGE: Related to #1985. Prior to Embark's minimum supported version of Node.js being bumped to to 10.17.0, Embark was incompatible with any relatively recent release of the `ipfs-http-client` package. While *internal* changes are needed re: ipfs's `Buffer` export for e.g. `embark_demo` to function correctly *(and this PR makes those changes)*, Embark otherwise runs/tests okay. Keep in mind #2033. However, if a dApp author were to explicitly `require('ifps-api')` in the front-end that wouldn't work as before; and swapping `"ipfs-http-client"` for `"ipfs-api"` might also not be enough — there are API changes that dApp authors would need to consider, regardless of Embark presently supplying the dependency and EmbarkJS wrapping around it. Closes #1994.
This commit is contained in:
parent
08933dec90
commit
978e17daa1
@ -161,7 +161,7 @@ class Storage extends React.Component {
|
|||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Alert color="warning">The node you are using does not support IPFS. If
|
<Alert color="warning">The node you are using does not support IPFS. If
|
||||||
you haven't explicitly disabled IPFS in <code>config/storage.js</code> then
|
you haven't explicitly disabled IPFS in <code>config/storage.js</code> then
|
||||||
please ensure <a href="https://github.com/ipfs/js-ipfs-api#cors"
|
please ensure <a href="https://github.com/ipfs/js-ipfs-http-client#cors"
|
||||||
target="_blank">CORS</a> is setup for the IPFS node.</Alert>
|
target="_blank">CORS</a> is setup for the IPFS node.</Alert>
|
||||||
</React.Fragment>}
|
</React.Fragment>}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="storage">
|
<div role="tabpanel" class="tab-pane" id="storage">
|
||||||
<div class="error alert alert-danger" role="alert">The node you are using does not support IPFS. Please ensure <a href="https://github.com/ipfs/js-ipfs-api#cors" target="_blank">CORS</a> is setup for the IPFS node.</div>
|
<div class="error alert alert-danger" role="alert">The node you are using does not support IPFS. Please ensure <a href="https://github.com/ipfs/js-ipfs-http-client#cors" target="_blank">CORS</a> is setup for the IPFS node.</div>
|
||||||
<div id="storage-controls">
|
<div id="storage-controls">
|
||||||
|
|
||||||
<h3>Save text to IPFS</h3>
|
<h3>Save text to IPFS</h3>
|
||||||
|
@ -46,7 +46,7 @@ class VM {
|
|||||||
// "embarkjs-swarm",
|
// "embarkjs-swarm",
|
||||||
// "embarkjs-whisper",
|
// "embarkjs-whisper",
|
||||||
// "eth-ens-namehash",
|
// "eth-ens-namehash",
|
||||||
// "ipfs-api",
|
// "ipfs-http-client",
|
||||||
"rxjs",
|
"rxjs",
|
||||||
"rxjs/operators",
|
"rxjs/operators",
|
||||||
// "web3",
|
// "web3",
|
||||||
|
@ -133,7 +133,6 @@
|
|||||||
"globule": "1.2.1",
|
"globule": "1.2.1",
|
||||||
"hosted-git-info": "2.7.1",
|
"hosted-git-info": "2.7.1",
|
||||||
"http-proxy": "1.17.0",
|
"http-proxy": "1.17.0",
|
||||||
"ipfs-api": "17.2.4",
|
|
||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
"json-parse-better-errors": "1.0.2",
|
"json-parse-better-errors": "1.0.2",
|
||||||
"lodash.clonedeep": "4.5.0",
|
"lodash.clonedeep": "4.5.0",
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime-corejs3": "7.6.3",
|
"@babel/runtime-corejs3": "7.6.3",
|
||||||
"core-js": "3.3.5",
|
"core-js": "3.3.5",
|
||||||
"ipfs-api": "17.2.4"
|
"ipfs-http-client": "39.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ajv": "6.10.2",
|
"ajv": "6.10.2",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const IpfsApi = require('ipfs-api');
|
const IpfsHttpClient = require('ipfs-http-client');
|
||||||
|
|
||||||
const __embarkIPFS = {};
|
const __embarkIPFS = {};
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ __embarkIPFS.setProvider = function (options) {
|
|||||||
try {
|
try {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
self._config = options;
|
self._config = options;
|
||||||
self._ipfsConnection = IpfsApi('localhost', '5001');
|
self._ipfsConnection = IpfsHttpClient('localhost', '5001');
|
||||||
self._getUrl = "http://localhost:8080/ipfs/";
|
self._getUrl = "http://localhost:8080/ipfs/";
|
||||||
} else {
|
} else {
|
||||||
const ipfsOptions = {host: options.host || options.server, protocol: 'http'};
|
const ipfsOptions = {host: options.host || options.server, protocol: 'http'};
|
||||||
@ -20,7 +20,7 @@ __embarkIPFS.setProvider = function (options) {
|
|||||||
if (options.port && options.port !== 'false') {
|
if (options.port && options.port !== 'false') {
|
||||||
ipfsOptions.port = options.port;
|
ipfsOptions.port = options.port;
|
||||||
}
|
}
|
||||||
self._ipfsConnection = IpfsApi(ipfsOptions);
|
self._ipfsConnection = IpfsHttpClient(ipfsOptions);
|
||||||
self._getUrl = options.getUrl || "http://localhost:8080/ipfs/";
|
self._getUrl = options.getUrl || "http://localhost:8080/ipfs/";
|
||||||
}
|
}
|
||||||
resolve(self);
|
resolve(self);
|
||||||
@ -54,7 +54,7 @@ __embarkIPFS.saveText = function (text) {
|
|||||||
if (!self._ipfsConnection) {
|
if (!self._ipfsConnection) {
|
||||||
return reject(new Error(NoConnectionError));
|
return reject(new Error(NoConnectionError));
|
||||||
}
|
}
|
||||||
self._ipfsConnection.add(self._ipfsConnection.Buffer.from(text), function (err, result) {
|
self._ipfsConnection.add(IpfsHttpClient.Buffer.from(text), function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ __embarkIPFS.uploadFile = function (inputSelector) {
|
|||||||
}
|
}
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onloadend = function () {
|
reader.onloadend = function () {
|
||||||
const buffer = self._ipfsConnection.Buffer.from(reader.result);
|
const buffer = IpfsHttpClient.Buffer.from(reader.result);
|
||||||
self._ipfsConnection.add(buffer, function (err, result) {
|
self._ipfsConnection.add(buffer, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
@ -121,7 +121,7 @@ __embarkIPFS.resolve = function (name, callback) {
|
|||||||
|
|
||||||
this._ipfsConnection.name.resolve(name)
|
this._ipfsConnection.name.resolve(name)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
callback(null, res.Path);
|
callback(null, res);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
callback(name + " is not registered");
|
callback(name + " is not registered");
|
||||||
@ -140,7 +140,7 @@ __embarkIPFS.register = function(addr, callback) {
|
|||||||
|
|
||||||
this._ipfsConnection.name.publish("/ipfs/" + addr)
|
this._ipfsConnection.name.publish("/ipfs/" + addr)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
callback(null, res.Name);
|
callback(null, res.name);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
callback(addr + " could not be registered");
|
callback(addr + " could not be registered");
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
"embark-utils": "^5.0.0-alpha.1",
|
"embark-utils": "^5.0.0-alpha.1",
|
||||||
"embarkjs": "^5.0.0-alpha.1",
|
"embarkjs": "^5.0.0-alpha.1",
|
||||||
"embarkjs-ipfs": "^5.0.0-alpha.1",
|
"embarkjs-ipfs": "^5.0.0-alpha.1",
|
||||||
"ipfs-api": "17.2.4",
|
"ipfs-http-client": "39.0.2",
|
||||||
"shelljs": "0.8.3"
|
"shelljs": "0.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {__} from 'embark-i18n';
|
import {__} from 'embark-i18n';
|
||||||
const IpfsApi = require('ipfs-api');
|
const IpfsHttpClient = require('ipfs-http-client');
|
||||||
const StorageProcessesLauncher = require('./storageProcessesLauncher.js');
|
const StorageProcessesLauncher = require('./storageProcessesLauncher.js');
|
||||||
import {buildUrlFromConfig, getJson} from 'embark-utils';
|
import {buildUrlFromConfig, getJson} from 'embark-utils';
|
||||||
const UploadIPFS = require('./upload.js');
|
const UploadIPFS = require('./upload.js');
|
||||||
@ -39,7 +39,7 @@ class IPFS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setupIpfsApi();
|
this.setupIpfsHttpClient();
|
||||||
this.setupEmbarkJS();
|
this.setupEmbarkJS();
|
||||||
|
|
||||||
this.events.request("storage:node:register", "ipfs", (readyCb) => {
|
this.events.request("storage:node:register", "ipfs", (readyCb) => {
|
||||||
@ -82,8 +82,8 @@ class IPFS {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async setupIpfsApi() {
|
async setupIpfsHttpClient() {
|
||||||
this.events.request("runcode:whitelist", 'ipfs-api', () => {});
|
this.events.request("runcode:whitelist", 'ipfs-http-client', () => {});
|
||||||
this.events.on("storage:started", this.registerIpfsObject.bind(this));
|
this.events.on("storage:started", this.registerIpfsObject.bind(this));
|
||||||
this.registerIpfsObject();
|
this.registerIpfsObject();
|
||||||
this.registerIpfsHelp();
|
this.registerIpfsHelp();
|
||||||
@ -91,7 +91,7 @@ class IPFS {
|
|||||||
|
|
||||||
async registerIpfsObject() {
|
async registerIpfsObject() {
|
||||||
const {host, port} = this.config;
|
const {host, port} = this.config;
|
||||||
let ipfs = IpfsApi(host, port);
|
let ipfs = IpfsHttpClient(host, port);
|
||||||
await this.events.request2("runcode:register", "ipfs", ipfs);
|
await this.events.request2("runcode:register", "ipfs", ipfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user