mirror of
https://github.com/fluencelabs/aqua-ipfs
synced 2025-04-24 23:42:14 +00:00
Prepare for publishing
This commit is contained in:
parent
b1a7661c5f
commit
825db2b3b4
@ -1,36 +1,32 @@
|
||||
{
|
||||
"name": "@fluencelabs/aqua-ipfs",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.7",
|
||||
"description": "Aqua IPFS library",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"main": "./typescript/dist/index.js",
|
||||
"typings": "./typescript/dist/index.d.ts",
|
||||
"files": [
|
||||
"ipfs.aqua",
|
||||
"ipfs-api.aqua",
|
||||
"dist/*"
|
||||
],
|
||||
"bic": [
|
||||
"typescript/*",
|
||||
"*.aqua",
|
||||
"package-lock.json"
|
||||
"typescript/dist/index.d.ts",
|
||||
"typescript/dist/index.js",
|
||||
"typescript/dist/ipfs-api.d.ts",
|
||||
"typescript/dist/ipfs-api.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-lib": "^0.1.9",
|
||||
"@fluencelabs/fluence": "^0.9.53",
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
||||
"ipfs-http-client": "^50.1.2",
|
||||
"it-all": "^1.0.5",
|
||||
"uint8arrays": "^2.1.5"
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.10"
|
||||
},
|
||||
"scripts": {
|
||||
"compile-aqua": "aqua-cli -i . -o ./typescript",
|
||||
"prebuild": "npm run compile-aqua",
|
||||
"build": "tsc",
|
||||
"prestart:local": "npm run build",
|
||||
"start:local": "node typescript/dist/index.js local",
|
||||
"start:local": "node typescript/dist/demo.js local",
|
||||
"prestart:remote": "npm run build",
|
||||
"start:remote": "node typescript/dist/index.js testnet",
|
||||
"start": "npm run start:remote"
|
||||
"start:remote": "node typescript/dist/demo.js testnet",
|
||||
"start": "npm run start:remote",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -48,6 +44,9 @@
|
||||
"homepage": "hhttps://github.com/fluencelabs/ipfs-adapter#readme",
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua-cli": "0.1.9-164",
|
||||
"typescript": "^3.9.5"
|
||||
"typescript": "^3.9.5",
|
||||
"ipfs-http-client": "^50.1.2",
|
||||
"it-all": "^1.0.5",
|
||||
"uint8arrays": "^2.1.5"
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
|
@ -14,80 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { put, get_from, set_timeout } from './ipfs-api';
|
||||
|
||||
import {createClient, setLogLevel} from "@fluencelabs/fluence";
|
||||
import {stage, krasnodar, Node, testNet} from "@fluencelabs/fluence-network-environment";
|
||||
const { create, globSource, urlSource } = require('ipfs-http-client');
|
||||
const all = require('it-all');
|
||||
const uint8ArrayConcat = require('uint8arrays/concat')
|
||||
|
||||
|
||||
let local: Node[] = [
|
||||
{
|
||||
peerId: "12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
|
||||
multiaddr: "/ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK"
|
||||
},
|
||||
{
|
||||
peerId: "12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv",
|
||||
multiaddr: "/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv"
|
||||
},
|
||||
{
|
||||
peerId: "12D3KooWFpQ7LHxcC9FEBUh3k4nSCC12jBhijJv3gJbi7wsNYzJ5",
|
||||
multiaddr: "/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWFpQ7LHxcC9FEBUh3k4nSCC12jBhijJv3gJbi7wsNYzJ5"
|
||||
},
|
||||
];
|
||||
|
||||
async function main(environment: Node[]) {
|
||||
// setLogLevel('DEBUG');
|
||||
const fluence = await createClient(environment[1]);
|
||||
console.log("📗 created a fluence client %s with relay %s", fluence.selfPeerId, fluence.relayPeerId);
|
||||
|
||||
let ipfsAddr = 'https://stage.fluence.dev:15001';
|
||||
let ipfsMultiaddr = '/ip4/134.209.186.43/tcp/5001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw';
|
||||
const ipfs = create(ipfsAddr);
|
||||
console.log("📗 created ipfs client");
|
||||
|
||||
await ipfs.id();
|
||||
console.log("📗 connected to ipfs");
|
||||
|
||||
let source = urlSource('https://images.adsttc.com/media/images/5ecd/d4ac/b357/65c6/7300/009d/large_jpg/02C.jpg?1590547607');
|
||||
const file = await ipfs.add(source);
|
||||
console.log("📗 uploaded file:", file);
|
||||
|
||||
let files = await ipfs.get(file.cid);
|
||||
for await (const file of files) {
|
||||
const content = uint8ArrayConcat(await all(file.content));
|
||||
console.log("📗 downloaded file of length ", content.length);
|
||||
}
|
||||
|
||||
// default IPFS timeout is 1 sec, set to 10 secs to retrieve file from remote node
|
||||
await set_timeout(fluence, environment[2].peerId, 10);
|
||||
|
||||
console.log("📘 file hash: ", file.cid);
|
||||
let getResult = await get_from(fluence, environment[2].peerId, file.cid.toString(), ipfsMultiaddr, { ttl: 10000 });
|
||||
console.log("📘 Ipfs.get", getResult);
|
||||
|
||||
let putResult = await put(fluence, environment[2].peerId, getResult.path, { ttl: 10000 });
|
||||
console.log("📘 Ipfs.put", putResult);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let args = process.argv.slice(2);
|
||||
var environment: Node[];
|
||||
if (args.length >= 1 && args[0] == "local") {
|
||||
environment = local;
|
||||
console.log("📘 Will connect to local nodes");
|
||||
} else {
|
||||
environment = testNet;
|
||||
console.log("📘 Will connect to testNet");
|
||||
}
|
||||
|
||||
main(environment)
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export * from './ipfs-api';
|
||||
|
Loading…
x
Reference in New Issue
Block a user