mirror of
https://github.com/fluencelabs/examples
synced 2025-06-27 08:41:34 +00:00
update aqua, versions
This commit is contained in:
@ -15,7 +15,7 @@ Aqua Developer Resources:
|
||||
* [Aqua Playground](https://github.com/fluencelabs/aqua-playground)
|
||||
* [Aqua repo](https://github.com/fluencelabs/aqua)
|
||||
|
||||
Marine Developer Resouces:
|
||||
Marine Developer Resources:
|
||||
|
||||
* [Marine repo](https://github.com/fluencelabs/marine)
|
||||
* [Marine SDK](https://github.com/fluencelabs/marine-rs-sdk)
|
||||
@ -228,16 +228,16 @@ func get_price_par(coin: string, currency: string, getter_topo: []NodeServicePai
|
||||
|
||||
In this invocation of our application workflow, we process price quote acquisition in parallel over price_getter services deployed to many nodes. This allows us to scale our workflow and take sull advantage of the network size and service deployment commitments.
|
||||
|
||||
To compile our Aqua script, we use the `aqua-cli` tool and either compile our code to raw Air:
|
||||
To compile our Aqua script, we use the `aqua` tool and either compile our code to raw Air:
|
||||
|
||||
```text
|
||||
% aqua-cli -i aqua-scripts -o air-scripts -a
|
||||
% aqua -i aqua-scripts -o air-scripts -a
|
||||
```
|
||||
|
||||
or to a ready-made typescript stub:
|
||||
|
||||
```text
|
||||
% aqua-cli -i aqua-scripts -o air-scripts
|
||||
% aqua -i aqua-scripts -o air-scripts
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Price oracle
|
||||
|
||||
Web interface for the price oracle applicaion
|
||||
Web interface for the price oracle application
|
||||
|
||||
## Getting started
|
||||
|
||||
|
1774
aqua-examples/price-oracle/web/package-lock.json
generated
1774
aqua-examples/price-oracle/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.9.53",
|
||||
"@fluencelabs/fluence": "0.10.1",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^11.2.7",
|
||||
"@testing-library/user-event": "^12.8.3",
|
||||
@ -22,7 +22,7 @@
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"compile-aqua": "aqua-cli -i ../aqua-scripts/ -o ./src/_aqua",
|
||||
"compile-aqua": "aqua -i ../aqua-scripts/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"../aqua-scripts/**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
},
|
||||
"eslintConfig": {
|
||||
@ -44,8 +44,8 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua-cli": "0.1.9-162",
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
||||
"@fluencelabs/aqua": "0.2.2-221",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"node-sass": "^6.0.1"
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||
* Aqua version: 0.1.9-162
|
||||
* Aqua version: 0.2.2-221
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -11,6 +11,35 @@ import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
|
||||
import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow';
|
||||
|
||||
|
||||
// Services
|
||||
|
||||
//PriceGetterService
|
||||
//defaultId = undefined
|
||||
|
||||
//price_getter: (coin: string, currency: string, timestamp_ms: number) => {error_msg:string;result:number;success:boolean}
|
||||
//END PriceGetterService
|
||||
|
||||
|
||||
|
||||
|
||||
//MeanService
|
||||
//defaultId = undefined
|
||||
|
||||
//mean: (data: number[]) => {error_msg:string;result:number;success:boolean}
|
||||
//END MeanService
|
||||
|
||||
|
||||
|
||||
|
||||
//F64Op
|
||||
//defaultId = "op"
|
||||
|
||||
//identity: (x: number) => number
|
||||
//END F64Op
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
export async function get_price(client: FluenceClient, coin: string, currency: string, node: string, pg_sid: string, mean_sid: string, config?: {ttl?: number}): Promise<{error_msg:string;result:number;success:boolean}> {
|
||||
let request: RequestFlow;
|
||||
@ -107,7 +136,126 @@ h.on('getDataSrv', 'mean_sid', () => {return mean_sid;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for get_price');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
await client.initiateFlow(request!);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function get_price_par(client: FluenceClient, coin: string, currency: string, getter_topo: {node:string;service_id:string}[], mean_topo: {node:string;service_id:string}, config?: {ttl?: number}): Promise<{error_msg:string;result:number;success:boolean}> {
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{error_msg:string;result:number;success:boolean}>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "coin") [] coin)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "currency") [] currency)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "getter_topo") [] getter_topo)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "mean_topo") [] mean_topo)
|
||||
)
|
||||
(fold getter_topo topo
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call topo.$.node! ("op" "string_to_b58") [topo.$.node!] k)
|
||||
(call topo.$.node! ("peer" "timestamp_ms") [] ts_ms)
|
||||
)
|
||||
(call topo.$.node! (topo.$.service_id! "price_getter") [coin currency ts_ms] res)
|
||||
)
|
||||
(call topo.$.node! ("op" "identity") [res.$.result!] $prices)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("op" "noop") [])
|
||||
)
|
||||
(next topo)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("op" "identity") [$prices.$.[2]!])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call mean_topo.$.node! (mean_topo.$.service_id! "mean") [$prices] result)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "response") [result])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return client.relayPeerId!;
|
||||
});
|
||||
h.on('getDataSrv', 'coin', () => {return coin;});
|
||||
h.on('getDataSrv', 'currency', () => {return currency;});
|
||||
h.on('getDataSrv', 'getter_topo', () => {return getter_topo;});
|
||||
h.on('getDataSrv', 'mean_topo', () => {return mean_topo;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for get_price_par');
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
Reference in New Issue
Block a user