-
Notifications
You must be signed in to change notification settings - Fork 26
Update JS SDK api to the new version #61
Conversation
…ly refers to the gitbook page
15f79dd
to
174477e
Compare
This reverts commit a8a6a81.
f1871ff
to
b09ef7d
Compare
037ba3b
to
480d630
Compare
This reverts commit 96f8a0a.
src/internal/FluencePeer.ts
Outdated
* * Multiaddr - multiaddr object, @see https://github.com/multiformats/js-multiaddr | ||
* * Node - node structure, @see Node | ||
*/ | ||
export type ConnectionSpec = string | MA | Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does Spec
mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specification. Feel free to suggest a better name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remote
/ ConnectionTarget
/ Node
/ Relay
/ Peer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just got rid of the explicit type definition
src/internal/FluencePeer.ts
Outdated
@@ -0,0 +1,350 @@ | |||
import { AirInterpreter, CallServiceResult, LogLevel, ParticleHandler, SecurityTetraplet } from '@fluencelabs/avm'; | |||
import log from 'loglevel'; | |||
import { Multiaddr as MA } from 'multiaddr'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep Multiaddress
, MA
is cryptic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/internal/FluencePeer.ts
Outdated
peerId = peerIdOrSeed; | ||
} else { | ||
// peerId is string, therefore seed | ||
peerId = await peerIdFromEd25519SK(peerIdOrSeed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if peerIdOrSeed
is malformed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to replace this logic with the help of KeyPair class
src/internal/FluencePeer.ts
Outdated
const request = this._requests.get(this._currentRequestId); | ||
const particle = request.getParticle(); | ||
if (particle === null) { | ||
throw new Error("particle can't be null here"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add some debug info to the error? At least this._currentRequestId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/internal/FluencePeer.ts
Outdated
|
||
if (res.result === undefined) { | ||
log.error( | ||
`Call to serviceId=${serviceId} fnName=${fnName} unexpectedly returned undefined result, falling back to null`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's log particle id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/internal/FluencePeer.ts
Outdated
this._requests.delete(key); | ||
} | ||
} | ||
}, 5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add todo to make 5000
configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/internal/RequestFlow.ts
Outdated
@@ -149,6 +150,7 @@ relay peer id: ${this.relayPeerId} | |||
// TODO:: keep the history of particle data mb? | |||
this.prevData = this.state.data; | |||
this.state.data = particle.data; | |||
log.debug('Received update'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/internal/defaultMiddlewares.ts
Outdated
next(); | ||
} catch (e) { | ||
resp.retCode = ResultCodes.exceptionInHandler; | ||
resp.result = e.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add more debug info to the error? Particle id maybe? service id and fnName at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
90e42f2
to
72bdea4
Compare
This is the first step of the massive JS SDK refacroing. Currently it only migrates to the new api format without major underlying changes.
Brief overview of what was changed: