mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-03-14 20:50:50 +00:00
initial commit
This commit is contained in:
commit
5888687263
109
.gitignore
vendored
Normal file
109
.gitignore
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
.idea/
|
||||
lib/
|
||||
|
||||
.jar
|
15
.npmignore
Normal file
15
.npmignore
Normal file
@ -0,0 +1,15 @@
|
||||
.idea
|
||||
.gitignore
|
||||
node_modules
|
||||
types
|
||||
|
||||
src/
|
||||
|
||||
tsconfig.json
|
||||
webpack.config.js
|
||||
|
||||
bundle
|
||||
pkg
|
||||
|
||||
.eslintignore
|
||||
.eslintrc.js
|
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright <YEAR> <COPYRIGHT HOLDER>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
aqua-hll.jar
Normal file
BIN
aqua-hll.jar
Normal file
Binary file not shown.
2819
package-lock.json
generated
Normal file
2819
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "aquamarine-tempalte",
|
||||
"version": "0.3.9",
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"template"
|
||||
],
|
||||
"author": "FluenceLabs (https://github.com/fluencelabs)",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
"fldist": "./dist/index.js"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"cli": "node -r ts-node/register src/index.ts",
|
||||
"compile-aqua": "java -jar ./aqua-hll.jar -i ./src/aqua/ -o ./src/compiled"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.9.34",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.8"
|
||||
},
|
||||
"description": "Minimal template for aquamarine project."
|
||||
}
|
9
src/aqua/helloWorld.aqua
Normal file
9
src/aqua/helloWorld.aqua
Normal file
@ -0,0 +1,9 @@
|
||||
data ExternalAddresses:
|
||||
external_addresses: []string
|
||||
|
||||
service Peer("peer"):
|
||||
identify: -> ExternalAddresses
|
||||
|
||||
func getPeerExternalAddresses() -> []string:
|
||||
res <- Peer.identify()
|
||||
<- res.external_addresses
|
53
src/compiled/helloWorld.ts
Normal file
53
src/compiled/helloWorld.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
|
||||
|
||||
|
||||
|
||||
export async function getPeerExternalAddresses(client: FluenceClient): Promise<string[]> {
|
||||
let request;
|
||||
const promise = new Promise<string[]>((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.withRawScript(
|
||||
`
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||
(call %init_peer_id% ("peer" "identify") [] res)
|
||||
)
|
||||
(seq
|
||||
(call relay ("op" "identity") [])
|
||||
(call %init_peer_id% ("callbackSrv" "response") [res.$.external_addresses!])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', 'relay', () => {
|
||||
return client.relayPeerId;
|
||||
});
|
||||
h.on('getRelayService', 'hasReleay', () => {// Not Used
|
||||
return client.relayPeerId !== undefined;
|
||||
});
|
||||
|
||||
h.on('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
|
||||
h.on('nameOfServiceWhereToSendXorError', 'errorProbably', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return promise;
|
||||
}
|
||||
|
13
src/index.ts
Normal file
13
src/index.ts
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { createClient } from "@fluencelabs/fluence";
|
||||
import { testNet } from "@fluencelabs/fluence-network-environment";
|
||||
import { getPeerExternalAddresses } from "./compiled/helloWorld";
|
||||
|
||||
const main = async () => {
|
||||
const client = await createClient(testNet[0]);
|
||||
const addresses = getPeerExternalAddresses(client);
|
||||
console.log("Relay external addresses: ", addresses);
|
||||
};
|
||||
|
||||
main();
|
10
test/call_multiple.air
Normal file
10
test/call_multiple.air
Normal file
@ -0,0 +1,10 @@
|
||||
(seq
|
||||
(call init_relay ("peer" "identify") [] result)
|
||||
(seq
|
||||
(call %init_peer_id% ("returnService" "run") [result])
|
||||
(seq
|
||||
(call %init_peer_id% ("returnService" "run") [result])
|
||||
(call %init_peer_id% ("returnService" "run") [result])
|
||||
)
|
||||
)
|
||||
)
|
4
test/call_single.air
Normal file
4
test/call_single.air
Normal file
@ -0,0 +1,4 @@
|
||||
(seq
|
||||
(call init_relay ("peer" "identify") [] result)
|
||||
(call %init_peer_id% ("returnService" "run") [result])
|
||||
)
|
1
test/deploy/.gitignore
vendored
Normal file
1
test/deploy/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
app.deployement.json
|
42
test/deploy/app.config.json
Normal file
42
test/deploy/app.config.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"services": {
|
||||
"history": {
|
||||
"dependencies": ["history_inmemory"],
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
|
||||
},
|
||||
"user_list": {
|
||||
"dependencies": ["user_list_inmemory"],
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
"history_inmemory": {
|
||||
"file": "history.wasm",
|
||||
"config": {
|
||||
"preopened_files": ["/tmp"],
|
||||
"mapped_dirs": { "history": "/tmp" }
|
||||
}
|
||||
},
|
||||
"user_list_inmemory": {
|
||||
"file": "user_list.wasm",
|
||||
"config": {}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"set_tetraplet": {
|
||||
"file": "set_tetraplet.air",
|
||||
"variables": {
|
||||
"function": "is_authenticated",
|
||||
"json_path": "$.[\"is_authenticated\"]"
|
||||
},
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
|
||||
}
|
||||
},
|
||||
"script_storage": {
|
||||
"remove_disconnected": {
|
||||
"file": "remove_disconnected.air",
|
||||
"interval": 10,
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
|
||||
}
|
||||
}
|
||||
}
|
BIN
test/deploy/history.wasm
Normal file
BIN
test/deploy/history.wasm
Normal file
Binary file not shown.
17
test/deploy/remove_disconnected.air
Normal file
17
test/deploy/remove_disconnected.air
Normal file
@ -0,0 +1,17 @@
|
||||
(seq
|
||||
(call %init_peer_id% ({{user_list}} "is_authenticated") [] token)
|
||||
(seq
|
||||
(call %init_peer_id% ({{user_list}} "get_users") [] all_users)
|
||||
(fold all_users.$.users! u
|
||||
(par
|
||||
(seq
|
||||
(call u.$.relay_id! ("peer" "is_connected") [u.$.peer_id!] is_connected)
|
||||
(match is_connected ""
|
||||
(call %init_peer_id% ({{user_list}} "leave") [u.$.peer_id!])
|
||||
)
|
||||
)
|
||||
(next u)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
7
test/deploy/set_tetraplet.air
Normal file
7
test/deploy/set_tetraplet.air
Normal file
@ -0,0 +1,7 @@
|
||||
(seq
|
||||
(call init_relay ("op" "identity") [])
|
||||
(seq
|
||||
(call history__node (history "set_tetraplet") [user_list__node user_list function json_path] auth_result)
|
||||
(call %init_peer_id% (returnService "run") [auth_result])
|
||||
)
|
||||
)
|
BIN
test/deploy/user_list.wasm
Normal file
BIN
test/deploy/user_list.wasm
Normal file
Binary file not shown.
21
tsconfig.json
Normal file
21
tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"es7",
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": false
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user