Fix old version of typescript code

This commit is contained in:
Pavel 2021-09-22 01:11:48 +03:00 committed by GitHub
parent ba0a17719c
commit 836b911495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,9 +31,9 @@ service Calc("calc"):
Now write the implementation for this service in typescript:
```typescript
import { FluencePeer } from "@fluencelabs/fluence";
import { Fluence } from "@fluencelabs/fluence";
import { krasnodar } from "@fluencelabs/fluence-network-environment";
import { registerCalc, CalcDef, demoCalculation } from "./_aqua/calc";
import { registerCalc, CalcDef } from "./_aqua/calc";
class Calc implements CalcDef {
private _state: number = 0;
@ -74,25 +74,23 @@ const keypress = async () => {
};
async function main() {
await FluencePeer.default.init({
await Fluence.start({
connectTo: krasnodar[0],
});
registerCalc(new Calc());
console.log("application started");
console.log("peer id is: ", FluencePeer.default.connectionInfo.selfPeerId);
console.log(
"relay is: ",
FluencePeer.default.connectionInfo.connectedRelays[0]
);
console.log("peer id is: ", Fluence.getStatus().peerId);
console.log("relay is: ", Fluence.getStatus().relayPeerId);
console.log("press any key to continue");
await keypress();
await FluencePeer.default.uninit();
await Fluence.stop();
}
main();
```
As you can see all the service logic has been implemented in typescript. You have full power of npm at your disposal.