Skip to content

Commit

Permalink
fix: SDK request/response conflicts (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Jul 21, 2023
1 parent 498cf0c commit 1cdb147
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/polite-phones-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fuel-wallet/sdk': patch
---

Fix SDK to enable been used in standalone mode by adding uuid on requests
10 changes: 9 additions & 1 deletion packages/sdk/src/connections/BaseConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { JSONRPCRequest, JSONRPCResponse } from 'json-rpc-2.0';
import { JSONRPCServer, JSONRPCClient } from 'json-rpc-2.0';

import { MAX_EVENT_LISTENERS } from '../config';
import { createUUID } from '../utils/createUUID';

export class BaseConnection extends EventEmitter {
readonly client: JSONRPCClient;
Expand All @@ -21,10 +22,17 @@ export class BaseConnection extends EventEmitter {
constructor() {
super();
this.setMaxListeners(MAX_EVENT_LISTENERS);
this.client = new JSONRPCClient(this.sendRequest.bind(this));
this.client = new JSONRPCClient(
this.sendRequest.bind(this),
this.createRequestId
);
this.server = new JSONRPCServer();
}

createRequestId(): string {
return createUUID();
}

externalMethods(methods: Array<string | any>) {
methods.forEach((method) => {
let methodName = method;
Expand Down

0 comments on commit 1cdb147

Please sign in to comment.