mirror of
https://github.com/fluencelabs/aqua-ipfs
synced 2025-03-15 21:20:49 +00:00
Pass environment to index.ts, remove bic
This commit is contained in:
parent
1eb0e5ce09
commit
ac976f6967
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,3 +14,6 @@
|
|||||||
**/dist
|
**/dist
|
||||||
.DS_store
|
.DS_store
|
||||||
.bic_cache
|
.bic_cache
|
||||||
|
|
||||||
|
aqua/typescript/
|
||||||
|
!aqua/typescript/index.ts
|
||||||
|
74
aqua/package-lock.json
generated
74
aqua/package-lock.json
generated
@ -4677,22 +4677,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cush/relative": {
|
|
||||||
"version": "0.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@cush/relative/-/relative-0.1.0.tgz",
|
|
||||||
"integrity": "sha512-pnF2c2hhHyC520CmYYKq3hGOS0kipkGBgRnp3z7wx7lDzykaUwQW3wPQmiX9YtbHUcgUu1qQtzstixmeYMwQoA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@fluencelabs/aqua-cli": {
|
"@fluencelabs/aqua-cli": {
|
||||||
"version": "0.1.8-160",
|
"version": "0.1.9-163",
|
||||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-cli/-/aqua-cli-0.1.8-160.tgz",
|
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-cli/-/aqua-cli-0.1.9-163.tgz",
|
||||||
"integrity": "sha512-ZZxfhxp9EHFVmkg6nWApvTQMm9WC06YEaj7NPHafnQShqsHtmV4srAZCcUBjVsLw3OyFTbke9e+hlUhP332bfA==",
|
"integrity": "sha512-OgKIwelqasxOBamr5jzhaI8GBDk1d4Bky9wyuBPUwwHED/yWi/32D9J0iZ3zZxpzitYQIvqT2KDB3OUkzk2+fQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@fluencelabs/aqua-lib": {
|
"@fluencelabs/aqua-lib": {
|
||||||
"version": "0.1.6",
|
"version": "0.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-lib/-/aqua-lib-0.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-lib/-/aqua-lib-0.1.9.tgz",
|
||||||
"integrity": "sha512-SMl6eFvI/6DIMu5RsLk5Uy3HIvy/CIkvbIhSYAba/UMVMc/Yszm6L6FvNXp5R/wogRXtFdZ3WCF7NVPgyiYmRA=="
|
"integrity": "sha512-WLvwrH98R4BT7NHrzYkJE8f0G61BZi3lVog/W3pmyzYjufxTtxoAS28Zqycbt0ZVpUTfIC016QKu58b4SbhZWw=="
|
||||||
},
|
},
|
||||||
"@fluencelabs/avm": {
|
"@fluencelabs/avm": {
|
||||||
"version": "0.10.5",
|
"version": "0.10.5",
|
||||||
@ -4915,12 +4909,6 @@
|
|||||||
"uri-js": "^4.2.2"
|
"uri-js": "^4.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ansi-256-colors": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz",
|
|
||||||
"integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"any-signal": {
|
"any-signal": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/any-signal/-/any-signal-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/any-signal/-/any-signal-2.1.2.tgz",
|
||||||
@ -5126,18 +5114,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/bufio/-/bufio-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/bufio/-/bufio-1.0.7.tgz",
|
||||||
"integrity": "sha512-bd1dDQhiC+bEbEfg56IdBv7faWa6OipMs/AFFFvtFnB3wAYjlwQpQRZ0pm6ZkgtfL0pILRXhKxOiQj6UzoMR7A=="
|
"integrity": "sha512-bd1dDQhiC+bEbEfg56IdBv7faWa6OipMs/AFFFvtFnB3wAYjlwQpQRZ0pm6ZkgtfL0pILRXhKxOiQj6UzoMR7A=="
|
||||||
},
|
},
|
||||||
"build-if-changed": {
|
|
||||||
"version": "1.5.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/build-if-changed/-/build-if-changed-1.5.5.tgz",
|
|
||||||
"integrity": "sha512-Ev9XU5r+HWulJYf58ZyeIIB0TYywReSiWdfxtW37FyGm7p4xHEAYza+c/Gj3IZxnMSYydrW+Xu1a7brJjs1W3A==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-256-colors": "^1.1.0",
|
|
||||||
"has-flag": "^4.0.0",
|
|
||||||
"recrawl": "^1.1.1",
|
|
||||||
"saxon": "^0.1.15"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"call-bind": {
|
"call-bind": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
||||||
@ -5506,18 +5482,6 @@
|
|||||||
"assert-plus": "^1.0.0"
|
"assert-plus": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"glob-regex": {
|
|
||||||
"version": "0.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob-regex/-/glob-regex-0.3.2.tgz",
|
|
||||||
"integrity": "sha512-m5blUd3/OqDTWwzBBtWBPrGlAzatRywHameHeekAZyZrskYouOGdNB8T/q6JucucvJXtOuyHIn0/Yia7iDasDw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"graceful-fs": {
|
|
||||||
"version": "4.2.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
|
|
||||||
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
||||||
@ -8294,17 +8258,6 @@
|
|||||||
"ms": "^2.1.1"
|
"ms": "^2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recrawl": {
|
|
||||||
"version": "1.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/recrawl/-/recrawl-1.2.3.tgz",
|
|
||||||
"integrity": "sha512-BJjwjefrfI4/OYPrZ+I2SEfSE3+BoIom15KpNYLabNJJ/G0zn/2niS4AILT60aRjqLR4+IucD5YU8D96z32EvQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@cush/relative": "^0.1.0",
|
|
||||||
"glob-regex": "^0.3.0",
|
|
||||||
"tslib": "^1.9.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"relative-url": {
|
"relative-url": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/relative-url/-/relative-url-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/relative-url/-/relative-url-1.0.2.tgz",
|
||||||
@ -8377,15 +8330,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
},
|
},
|
||||||
"saxon": {
|
|
||||||
"version": "0.1.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/saxon/-/saxon-0.1.18.tgz",
|
|
||||||
"integrity": "sha512-JMdJjBJCSquNY7Glyl+FNMQyZhbny6wKta8KE5PWrEbU5oB2FfONbtBPHlMOXJrFc9FqUYBJ9QsavygJW1QiBg==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"graceful-fs": "^4.1.11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"secp256k1": {
|
"secp256k1": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz",
|
||||||
@ -8544,12 +8488,6 @@
|
|||||||
"utf8-byte-length": "^1.0.1"
|
"utf8-byte-length": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslib": {
|
|
||||||
"version": "1.14.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
|
||||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"tunnel-agent": {
|
"tunnel-agent": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
"package-lock.json"
|
"package-lock.json"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aqua-lib": "^0.1.5",
|
"@fluencelabs/aqua-lib": "^0.1.9",
|
||||||
"@fluencelabs/fluence": "^0.9.50",
|
"@fluencelabs/fluence": "^0.9.53",
|
||||||
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
||||||
"ipfs-http-client": "^50.1.2",
|
"ipfs-http-client": "^50.1.2",
|
||||||
"it-all": "^1.0.5",
|
"it-all": "^1.0.5",
|
||||||
@ -26,8 +26,10 @@
|
|||||||
"compile-aqua": "aqua-cli -i . -o ./typescript",
|
"compile-aqua": "aqua-cli -i . -o ./typescript",
|
||||||
"prebuild": "npm run compile-aqua",
|
"prebuild": "npm run compile-aqua",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"prestart": "npx bic -s",
|
"prestart": "npm run build",
|
||||||
"start": "node typescript/dist/index.js"
|
"start:local": "node typescript/dist/index.js local",
|
||||||
|
"start:remote": "node typescript/dist/index.js testnet",
|
||||||
|
"start": "npm run start:remote"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -44,8 +46,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/fluencelabs/aqua-dht#readme",
|
"homepage": "https://github.com/fluencelabs/aqua-dht#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fluencelabs/aqua-cli": "^0.1.8-160",
|
"@fluencelabs/aqua-cli": "0.1.9-163",
|
||||||
"build-if-changed": "^1.5.5",
|
|
||||||
"typescript": "^3.9.5"
|
"typescript": "^3.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,40 +38,50 @@ let local: Node[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main(environment: Node[]) {
|
||||||
// setLogLevel('DEBUG');
|
// setLogLevel('DEBUG');
|
||||||
const fluence = await createClient(testNet[1]);
|
const fluence = await createClient(environment[1]);
|
||||||
console.log("created a fluence client %s with relay %s", fluence.selfPeerId, fluence.relayPeerId);
|
console.log("📗 created a fluence client %s with relay %s", fluence.selfPeerId, fluence.relayPeerId);
|
||||||
|
|
||||||
let ipfsAddr = 'https://stage.fluence.dev:15001';
|
let ipfsAddr = 'https://stage.fluence.dev:15001';
|
||||||
let ipfsMultiaddr = '/ip4/134.209.186.43/tcp/4001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw';
|
let ipfsMultiaddr = '/ip4/134.209.186.43/tcp/4001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw';
|
||||||
const ipfs = create(ipfsAddr);
|
const ipfs = create(ipfsAddr);
|
||||||
console.log("created ipfs client");
|
console.log("📗 created ipfs client");
|
||||||
|
|
||||||
await ipfs.id();
|
await ipfs.id();
|
||||||
console.log("connected to ipfs");
|
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');
|
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);
|
const file = await ipfs.add(source);
|
||||||
console.log("uploaded file:", file);
|
console.log("📗 uploaded file:", file);
|
||||||
|
|
||||||
let files = await ipfs.get(file.cid);
|
let files = await ipfs.get(file.cid);
|
||||||
for await (const file of files) {
|
for await (const file of files) {
|
||||||
const content = uint8ArrayConcat(await all(file.content));
|
const content = uint8ArrayConcat(await all(file.content));
|
||||||
console.log("downloaded file of length ", content.length);
|
console.log("📗 downloaded file of length ", content.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("file hash: ", file.cid);
|
console.log("📘 file hash: ", file.cid);
|
||||||
let getResult = await get_from(fluence, testNet[2].peerId, file.cid.toString(), ipfsMultiaddr, { ttl: 10000 });
|
let getResult = await get_from(fluence, environment[2].peerId, file.cid.toString(), ipfsMultiaddr, { ttl: 10000 });
|
||||||
console.log("Ipfs.get", getResult);
|
console.log("📘 Ipfs.get", getResult);
|
||||||
|
|
||||||
let putResult = await put(fluence, testNet[2].peerId, getResult.path, { ttl: 10000 });
|
let putResult = await put(fluence, environment[2].peerId, getResult.path, { ttl: 10000 });
|
||||||
console.log("Ipfs.put", putResult);
|
console.log("📘 Ipfs.put", putResult);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
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))
|
.then(() => process.exit(0))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user