mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-06-24 09:41:35 +00:00
update topology
This commit is contained in:
145
src/compiled/topology.ts
Normal file
145
src/compiled/topology.ts
Normal file
@ -0,0 +1,145 @@
|
||||
/**
|
||||
*
|
||||
* 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.1-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
|
||||
|
||||
|
||||
|
||||
export async function id(client: FluenceClient): Promise<void> {
|
||||
let request;
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||
(call %init_peer_id% ("op" "identity") [])
|
||||
)
|
||||
(seq
|
||||
(call relay ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', 'relay', () => {
|
||||
return client.relayPeerId!;
|
||||
});
|
||||
h.on('getRelayService', 'hasRelay', () => {// Not Used
|
||||
return client.relayPeerId !== undefined;
|
||||
});
|
||||
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for id');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function topologyTest(client: FluenceClient, me: string, myRelay: string, friend: string, friendRelay: string): Promise<string> {
|
||||
let request;
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
|
||||
(call %init_peer_id% ("getDataSrv" "me") [] me)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "myRelay") [] myRelay)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "friend") [] friend)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "friendRelay") [] friendRelay)
|
||||
)
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call relay ("op" "identity") [])
|
||||
(call friendRelay ("op" "identity") [])
|
||||
)
|
||||
(call friend ("testo" "getString") ["friends string via"] str2)
|
||||
)
|
||||
(call friendRelay ("op" "identity") [])
|
||||
)
|
||||
(call relay ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("lp" "print") ["my string in par"])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("lp" "print") [str2])
|
||||
)
|
||||
(call %init_peer_id% ("callbackSrv" "response") ["finish"])
|
||||
)
|
||||
(seq
|
||||
(call relay ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', 'relay', () => {
|
||||
return client.relayPeerId!;
|
||||
});
|
||||
h.on('getRelayService', 'hasRelay', () => {// Not Used
|
||||
return client.relayPeerId !== undefined;
|
||||
});
|
||||
h.on('getDataSrv', 'me', () => {return me;});
|
||||
h.on('getDataSrv', 'myRelay', () => {return myRelay;});
|
||||
h.on('getDataSrv', 'friend', () => {return friend;});
|
||||
h.on('getDataSrv', 'friendRelay', () => {return friendRelay;});
|
||||
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 topologyTest');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return promise;
|
||||
}
|
||||
|
Reference in New Issue
Block a user