Add Fluence-related stack

This commit is contained in:
Pavel Murygin 2022-02-04 18:37:40 +03:00
parent 1272450064
commit 9169684b6c
6 changed files with 8997 additions and 4 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ node_modules/
jspm_packages/
.idea
src/_aqua/

3
aqua/export.aqua Normal file
View File

@ -0,0 +1,3 @@
module Export
import getRelayTimestamp from "hello-world"
export getRelayTimestamp

8
aqua/hello-world.aqua Normal file
View File

@ -0,0 +1,8 @@
module HelloWorld declares getRelayTimestamp
import "@fluencelabs/aqua-lib/builtin.aqua"
func getRelayTimestamp() -> u64:
on HOST_PEER_ID:
ts <- Peer.timestamp_ms()
<- ts

8952
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,12 @@
"version": "0.0.1",
"description": "Template project for Fluence in nodejs",
"main": "index.js",
"scripts": {},
"scripts": {
"start": "node -r ts-node/register src/index.ts",
"prestart": "npm run compile-aqua",
"compile-aqua": "aqua -i ./aqua/ -o ./src/_aqua",
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/fluencelabs/fluence-nodejs-template.git"
@ -15,6 +20,13 @@
},
"homepage": "https://github.com/fluencelabs/fluence-nodejs-template#readme",
"devDependencies": {
"typescript": "^4.0.0"
}
"@fluencelabs/aqua-lib": "^0.3.3",
"ts-node": "^10.4.0",
"typescript": "^4.0.0",
"@fluencelabs/aqua": "^0.6.0-263",
"@fluencelabs/fluence": "^0.19.0",
"@fluencelabs/fluence-network-environment": "^1.0.13",
"chokidar": "^3.5.3"
},
"dependencies": {}
}

18
src/index.ts Normal file
View File

@ -0,0 +1,18 @@
import { Fluence } from '@fluencelabs/fluence';
import { krasnodar } from '@fluencelabs/fluence-network-environment';
import { getRelayTimestamp } from './_aqua/export';
const relay = krasnodar[3];
async function main() {
await Fluence.start({
connectTo: relay,
});
const timestamp = await getRelayTimestamp();
console.log(new Date(timestamp));
await Fluence.stop();
}
main().catch((err) => console.error(err));