Skip to content

Commit aaa3155

Browse files
author
Andre Medeiros
committed
fix: change from deprecated ipfs-api to ipfs-http-client
1 parent bf0f439 commit aaa3155

File tree

13 files changed

+403
-231
lines changed

13 files changed

+403
-231
lines changed

dapps/templates/boilerplate/embark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"versions": {
1212
"web3": "1.0.0-beta",
1313
"solc": "0.5.0",
14-
"ipfs-api": "17.2.4"
14+
"ipfs-http-client": "30.1.3"
1515
},
1616
"plugins": {
1717
"embarkjs-connector-web3": {}

dapps/templates/demo/app/components/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class Storage extends React.Component {
161161
!this.props.enabled ?
162162
<React.Fragment>
163163
<Alert bsStyle="warning">The node you are using does not support IPFS. Please ensure <a
164-
href="https://github.com/ipfs/js-ipfs-api#cors" target="_blank">CORS</a> is setup for the IPFS
164+
href="https://github.com/ipfs/js-ipfs-http-client#cors" target="_blank">CORS</a> is setup for the IPFS
165165
node.</Alert>
166166
</React.Fragment> : ''
167167
}

dapps/templates/demo/embark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"versions": {
1111
"web3": "1.0.0-beta",
1212
"solc": "0.5.0",
13-
"ipfs-api": "17.2.4"
13+
"ipfs-http-client": "30.1.3"
1414
},
1515
"plugins": {
1616
"embarkjs-connector-web3": {}

dapps/tests/app/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h3> 3. Contract Calls </h3>
4242
</div>
4343
</div>
4444
<div role="tabpanel" class="tab-pane" id="storage">
45-
<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>
45+
<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>
4646
<div id="storage-controls">
4747

4848
<h3>Save text to IPFS</h3>

dapps/tests/app/embark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"versions": {
1818
"solc": "0.4.25",
1919
"web3": "1.0.0-beta",
20-
"ipfs-api": "17.2.7"
20+
"ipfs-http-client": "30.1.3"
2121
},
2222
"plugins": {
2323
"embark-dapp-test-service": {},

packages/embark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"http-proxy": "1.17.0",
120120
"http-shutdown": "1.2.0",
121121
"i18n": "0.8.3",
122-
"ipfs-api": "17.2.4",
122+
"ipfs-http-client": "30.1.3",
123123
"istanbul": "0.4.5",
124124
"json-parse-better-errors": "1.0.2",
125125
"live-plugin-manager-git-fix": "0.12.1",

packages/embark/src/lib/core/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Config.prototype.loadExternalContractsFiles = function() {
413413
};
414414

415415
Config.prototype.loadStorageConfigFile = function() {
416-
var versions = recursiveMerge({"ipfs-api": "17.2.4"}, this.embarkConfig.versions || {});
416+
var versions = recursiveMerge({"ipfs-http-client": "30.1.3"}, this.embarkConfig.versions || {});
417417

418418
var configObject = {
419419
"default": {

packages/embark/src/lib/modules/codeRunner/vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class VM {
4444
"eth-ens-namehash",
4545
"swarm-api",
4646
"embarkjs-whisper",
47-
"ipfs-api",
47+
"ipfs-http-client",
4848
"embarkjs-ipfs",
4949
"embarkjs-swarm",
5050
"rxjs",

packages/embark/src/lib/modules/ipfs/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const UploadIPFS = require('./upload.js');
22
const utils = require('../../utils/utils.js');
3-
const IpfsApi = require('ipfs-api');
3+
const IPFSClient = require('ipfs-http-client');
44
// TODO: not great, breaks module isolation
55
const StorageProcessesLauncher = require('../storage/storageProcessesLauncher');
66
const constants = require('../../constants.json');
@@ -35,15 +35,15 @@ class IPFS {
3535
});
3636
}
3737

38-
downloadIpfsApi(cb) {
39-
this.events.request("version:get:ipfs-api", (ipfsApiVersion) => {
40-
let currentIpfsApiVersion = require('../../../../package.json').dependencies["ipfs-api"];
41-
if (ipfsApiVersion === currentIpfsApiVersion) {
38+
downloadIPFSClient(cb) {
39+
this.events.request("version:get:ipfs-http-client", (ipfsClientVersion) => {
40+
let currentIPFSClientVersion = require('../../../../package.json').dependencies["ipfs-http-client"];
41+
if (ipfsClientVersion === currentIPFSClientVersion) {
4242
const nodePath = this.fs.embarkPath('node_modules');
43-
const ipfsPath = require.resolve("ipfs-api", {paths: [nodePath]});
43+
const ipfsPath = require.resolve("ipfs-http-client", {paths: [nodePath]});
4444
return cb(null, ipfsPath);
4545
}
46-
this.events.request("version:getPackageLocation", "ipfs-api", ipfsApiVersion, (err, location) => {
46+
this.events.request("version:getPackageLocation", "ipfs-http-client", ipfsClientVersion, (err, location) => {
4747
cb(err, this.fs.dappPath(location));
4848
});
4949
});
@@ -98,19 +98,19 @@ class IPFS {
9898
}
9999

100100
addStorageProviderToEmbarkJS() {
101-
this.events.request('version:downloadIfNeeded', 'ipfs-api', (err, location) => {
101+
this.events.request('version:downloadIfNeeded', 'ipfs-http-client', (err, location) => {
102102
if (err) {
103103
this.logger.error(__('Error downloading IPFS API'));
104104
return this.logger.error(err.message || err);
105105
}
106106
this.events.request('code-generator:ready', () => {
107-
this.events.request('code-generator:symlink:generate', location, 'ipfs-api', (err, _symlinkDest) => {
107+
this.events.request('code-generator:symlink:generate', location, 'ipfs-http-client', (err, _symlinkDest) => {
108108
if (err) {
109109
this.logger.error(__('Error creating a symlink to IPFS API'));
110110
return this.logger.error(err.message || err);
111111
}
112112

113-
this.events.emit('runcode:register', 'IpfsApi', require('ipfs-api'), () => {
113+
this.events.emit('runcode:register', 'IPFS', require('ipfs-http-client'), () => {
114114
let code = "";
115115
code += "\nconst __embarkIPFS = require('embarkjs-ipfs')";
116116
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS.default || __embarkIPFS);";
@@ -125,7 +125,7 @@ class IPFS {
125125

126126
addObjectToConsole() {
127127
const {host, port} = this._getNodeUrlConfig();
128-
let ipfs = IpfsApi(host, port);
128+
let ipfs = IPFSClient(host, port);
129129
this.events.emit("runcode:register", "ipfs", ipfs);
130130
}
131131

packages/embark/src/lib/modules/library_manager/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class LibraryManager {
2222

2323
let solcVersionInConfig = this.contractsConfig.versions.solc;
2424
let web3VersionInConfig = this.contractsConfig.versions["web3"];
25-
let ipfsApiVersion = this.storageConfig.versions["ipfs-api"];
25+
let ipfsClientVersion = this.storageConfig.versions["ipfs-http-client"];
2626

2727
this.versions['solc'] = solcVersionInConfig;
2828
this.versions['web3'] = web3VersionInConfig;
29-
this.versions['ipfs-api'] = ipfsApiVersion;
29+
this.versions['ipfs-http-client'] = ipfsClientVersion;
3030

3131
Object.keys(this.versions).forEach(versionKey => {
3232
const newVersion = this.versions[versionKey].trim();

packages/embarkjs-ipfs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"dependencies": {
5353
"@babel/runtime-corejs2": "7.3.1",
54-
"ipfs-api": "17.2.4"
54+
"ipfs-http-client": "30.1.3"
5555
},
5656
"devDependencies": {
5757
"@babel/cli": "7.2.3",

packages/embarkjs-ipfs/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const IpfsApi = require('ipfs-api');
1+
const IPFS = require('ipfs-http-client');
22

33
const __embarkIPFS = {};
44

@@ -10,7 +10,7 @@ __embarkIPFS.setProvider = function (options) {
1010
try {
1111
if (!options) {
1212
self._config = options;
13-
self._ipfsConnection = IpfsApi('localhost', '5001');
13+
self._ipfsConnection = IPFS('localhost', '5001');
1414
self._getUrl = "http://localhost:8080/ipfs/";
1515
} else {
1616
const ipfsOptions = {host: options.host || options.server, protocol: 'http'};
@@ -20,7 +20,7 @@ __embarkIPFS.setProvider = function (options) {
2020
if (options.port && options.port !== 'false') {
2121
ipfsOptions.port = options.port;
2222
}
23-
self._ipfsConnection = IpfsApi(ipfsOptions);
23+
self._ipfsConnection = IPFS(ipfsOptions);
2424
self._getUrl = options.getUrl || "http://localhost:8080/ipfs/";
2525
}
2626
resolve(self);

0 commit comments

Comments
 (0)