@ledgerhq/wallet-api-simulator 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/helpers.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- import type { WalletAPIServer } from "@ledgerhq/wallet-api-server";
1
+ import type { WalletAPIServer, WalletHandlers } from "@ledgerhq/wallet-api-server";
2
2
  import type { SimulatorProfile } from "./types";
3
3
  export declare function applyProfile(serverInstance: WalletAPIServer, profile: SimulatorProfile): void;
4
+ type MockedResponse<K extends keyof WalletHandlers, H extends WalletHandlers[K] = WalletHandlers[K]> = ReturnType<H> | H;
5
+ export declare function declarativeHandler<K extends keyof WalletHandlers>(mocks: MockedResponse<K>[]): WalletHandlers[K];
6
+ export type MockedHandlers = {
7
+ [K in keyof Partial<WalletHandlers>]: MockedResponse<K>[];
8
+ };
9
+ export declare function declarativeHandlers(mocks: MockedHandlers): Partial<WalletHandlers>;
10
+ export {};
4
11
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,gBAAgB,QAM1B"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,gBAAgB,QAM1B;AAED,KAAK,cAAc,CACjB,CAAC,SAAS,MAAM,cAAc,EAC9B,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAC7C,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtB,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,EAC/D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GACzB,cAAc,CAAC,CAAC,CAAC,CAuBnB;AAED,MAAM,MAAM,cAAc,GAAG;KAC1B,CAAC,IAAI,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE;CAC1D,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,cAAc,CAAC,CAUzB"}
package/lib/helpers.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyProfile = void 0;
3
+ exports.declarativeHandlers = exports.declarativeHandler = exports.applyProfile = void 0;
4
4
  function applyProfile(serverInstance, profile) {
5
5
  serverInstance.setAccounts(profile.accounts);
6
6
  serverInstance.setCurrencies(profile.currencies);
@@ -8,4 +8,34 @@ function applyProfile(serverInstance, profile) {
8
8
  serverInstance.setHandlers(profile.methods);
9
9
  }
10
10
  exports.applyProfile = applyProfile;
11
+ function declarativeHandler(mocks) {
12
+ let numCalls = 0;
13
+ // @ts-expect-error: issue with types
14
+ return (...args) => {
15
+ // Finding the mock matching with the number of calls
16
+ // Or fallback to the first mock
17
+ const mock = numCalls > mocks.length ? mocks[0] : mocks[numCalls];
18
+ numCalls += 1;
19
+ if (!mock) {
20
+ return Promise.reject(new Error("No mock object found"));
21
+ }
22
+ if (typeof mock === "function") {
23
+ // @ts-expect-error: issue with types
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
25
+ return mock(...args);
26
+ }
27
+ return mock;
28
+ };
29
+ }
30
+ exports.declarativeHandler = declarativeHandler;
31
+ function declarativeHandlers(mocks) {
32
+ const handlers = {};
33
+ for (const key in mocks) {
34
+ // @ts-expect-error: issue with types
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
36
+ handlers[key] = declarativeHandler(mocks[key]);
37
+ }
38
+ return handlers;
39
+ }
40
+ exports.declarativeHandlers = declarativeHandlers;
11
41
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAC1B,cAA+B,EAC/B,OAAyB;IAEzB,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AARD,oCAQC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAMA,SAAgB,YAAY,CAC1B,cAA+B,EAC/B,OAAyB;IAEzB,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AARD,oCAQC;AAOD,SAAgB,kBAAkB,CAChC,KAA0B;IAE1B,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,qCAAqC;IACrC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;QACjB,qDAAqD;QACrD,gCAAgC;QAChC,MAAM,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAElE,QAAQ,IAAI,CAAC,CAAC;QAEd,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;SAC1D;QAED,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAC9B,qCAAqC;YACrC,iEAAiE;YACjE,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAzBD,gDAyBC;AAMD,SAAgB,mBAAmB,CACjC,KAAqB;IAErB,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;QACvB,qCAAqC;QACrC,iEAAiE;QACjE,QAAQ,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;KAChD;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAZD,kDAYC"}
@@ -1,5 +1,6 @@
1
1
  import type { Transport } from "@ledgerhq/wallet-api-core";
2
2
  import { CustomHandlers } from "@ledgerhq/wallet-api-server";
3
3
  import type { SimulatorProfile } from "./types";
4
+ export { declarativeHandlers } from "./helpers";
4
5
  export declare function getSimulatorTransport(profile: SimulatorProfile, customHandlers?: CustomHandlers): Transport;
5
6
  //# sourceMappingURL=transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,cAAc,EAGf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,CAkCX"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,cAAc,EAGf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,CAuCX"}
package/lib/transport.js CHANGED
@@ -1,27 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSimulatorTransport = void 0;
3
+ exports.getSimulatorTransport = exports.declarativeHandlers = void 0;
4
4
  const wallet_api_server_1 = require("@ledgerhq/wallet-api-server");
5
5
  const helpers_1 = require("./helpers");
6
+ var helpers_2 = require("./helpers");
7
+ Object.defineProperty(exports, "declarativeHandlers", { enumerable: true, get: function () { return helpers_2.declarativeHandlers; } });
6
8
  function getSimulatorTransport(profile, customHandlers) {
7
- // eslint-disable-next-line prefer-const
8
- let clientTransport;
9
9
  const serverTransport = {
10
10
  onMessage: undefined,
11
11
  send: (payload) => {
12
12
  console.info("wallet -> app", payload);
13
- if (clientTransport?.onMessage) {
14
- clientTransport.onMessage(payload);
15
- }
13
+ // Using setTimeout to simulate async call (Do we want to keep this sync ?)
14
+ // It also avoids an act warning when using RTL to test components
15
+ setTimeout(() => {
16
+ if (clientTransport.onMessage) {
17
+ clientTransport.onMessage(payload);
18
+ }
19
+ }, 0);
16
20
  },
17
21
  };
18
- clientTransport = {
22
+ const clientTransport = {
19
23
  onMessage: undefined,
20
24
  send: (payload) => {
21
25
  console.info("app -> wallet", payload);
22
- if (serverTransport?.onMessage) {
23
- serverTransport.onMessage(payload);
24
- }
26
+ // Using setTimeout to simulate async call (Do we want to keep this sync ?)
27
+ // It also avoids an act warning when using RTL to test components
28
+ setTimeout(() => {
29
+ if (serverTransport.onMessage) {
30
+ serverTransport.onMessage(payload);
31
+ }
32
+ }, 0);
25
33
  },
26
34
  };
27
35
  const serverInstance = new wallet_api_server_1.WalletAPIServer(serverTransport, profile.config, wallet_api_server_1.defaultLogger, customHandlers);
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":";;;AACA,mEAIqC;AACrC,uCAAyC;AAGzC,SAAgB,qBAAqB,CACnC,OAAyB,EACzB,cAA+B;IAE/B,wCAAwC;IACxC,IAAI,eAAsC,CAAC;IAE3C,MAAM,eAAe,GAAc;QACjC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,eAAe,EAAE,SAAS,EAAE;gBAC9B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACpC;QACH,CAAC;KACF,CAAC;IAEF,eAAe,GAAG;QAChB,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,eAAe,EAAE,SAAS,EAAE;gBAC9B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACpC;QACH,CAAC;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,mCAAe,CACxC,eAAe,EACf,OAAO,CAAC,MAAM,EACd,iCAAa,EACb,cAAc,CACf,CAAC;IAEF,IAAA,sBAAY,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEtC,OAAO,eAAe,CAAC;AACzB,CAAC;AArCD,sDAqCC"}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":";;;AACA,mEAIqC;AACrC,uCAAyC;AAGzC,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA;AAE5B,SAAgB,qBAAqB,CACnC,OAAyB,EACzB,cAA+B;IAE/B,MAAM,eAAe,GAAc;QACjC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,2EAA2E;YAC3E,kEAAkE;YAClE,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,eAAe,CAAC,SAAS,EAAE;oBAC7B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;iBACpC;YACH,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC;KACF,CAAC;IAEF,MAAM,eAAe,GAAc;QACjC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,2EAA2E;YAC3E,kEAAkE;YAClE,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,eAAe,CAAC,SAAS,EAAE;oBAC7B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;iBACpC;YACH,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,mCAAe,CACxC,eAAe,EACf,OAAO,CAAC,MAAM,EACd,iCAAa,EACb,cAAc,CACf,CAAC;IAEF,IAAA,sBAAY,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEtC,OAAO,eAAe,CAAC;AACzB,CAAC;AA1CD,sDA0CC"}
@@ -1,4 +1,11 @@
1
- import type { WalletAPIServer } from "@ledgerhq/wallet-api-server";
1
+ import type { WalletAPIServer, WalletHandlers } from "@ledgerhq/wallet-api-server";
2
2
  import type { SimulatorProfile } from "./types";
3
3
  export declare function applyProfile(serverInstance: WalletAPIServer, profile: SimulatorProfile): void;
4
+ type MockedResponse<K extends keyof WalletHandlers, H extends WalletHandlers[K] = WalletHandlers[K]> = ReturnType<H> | H;
5
+ export declare function declarativeHandler<K extends keyof WalletHandlers>(mocks: MockedResponse<K>[]): WalletHandlers[K];
6
+ export type MockedHandlers = {
7
+ [K in keyof Partial<WalletHandlers>]: MockedResponse<K>[];
8
+ };
9
+ export declare function declarativeHandlers(mocks: MockedHandlers): Partial<WalletHandlers>;
10
+ export {};
4
11
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,gBAAgB,QAM1B"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,gBAAgB,QAM1B;AAED,KAAK,cAAc,CACjB,CAAC,SAAS,MAAM,cAAc,EAC9B,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAC7C,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtB,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,EAC/D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GACzB,cAAc,CAAC,CAAC,CAAC,CAuBnB;AAED,MAAM,MAAM,cAAc,GAAG;KAC1B,CAAC,IAAI,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE;CAC1D,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,cAAc,CAAC,CAUzB"}
package/lib-es/helpers.js CHANGED
@@ -4,4 +4,32 @@ export function applyProfile(serverInstance, profile) {
4
4
  serverInstance.setPermissions(profile.permissions);
5
5
  serverInstance.setHandlers(profile.methods);
6
6
  }
7
+ export function declarativeHandler(mocks) {
8
+ let numCalls = 0;
9
+ // @ts-expect-error: issue with types
10
+ return (...args) => {
11
+ // Finding the mock matching with the number of calls
12
+ // Or fallback to the first mock
13
+ const mock = numCalls > mocks.length ? mocks[0] : mocks[numCalls];
14
+ numCalls += 1;
15
+ if (!mock) {
16
+ return Promise.reject(new Error("No mock object found"));
17
+ }
18
+ if (typeof mock === "function") {
19
+ // @ts-expect-error: issue with types
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
21
+ return mock(...args);
22
+ }
23
+ return mock;
24
+ };
25
+ }
26
+ export function declarativeHandlers(mocks) {
27
+ const handlers = {};
28
+ for (const key in mocks) {
29
+ // @ts-expect-error: issue with types
30
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
31
+ handlers[key] = declarativeHandler(mocks[key]);
32
+ }
33
+ return handlers;
34
+ }
7
35
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,YAAY,CAC1B,cAA+B,EAC/B,OAAyB;IAEzB,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,c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MAAM,GAAG,IAAI,KAAK,EAAE;QACvB,qCAAqC;QACrC,iEAAiE;QACjE,QAAQ,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;KAChD;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { Transport } from "@ledgerhq/wallet-api-core";
2
2
  import { CustomHandlers } from "@ledgerhq/wallet-api-server";
3
3
  import type { SimulatorProfile } from "./types";
4
+ export { declarativeHandlers } from "./helpers";
4
5
  export declare function getSimulatorTransport(profile: SimulatorProfile, customHandlers?: CustomHandlers): Transport;
5
6
  //# sourceMappingURL=transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,cAAc,EAGf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,CAkCX"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,cAAc,EAGf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,SAAS,CAuCX"}
@@ -1,24 +1,31 @@
1
1
  import { WalletAPIServer, defaultLogger, } from "@ledgerhq/wallet-api-server";
2
2
  import { applyProfile } from "./helpers";
3
+ export { declarativeHandlers } from "./helpers";
3
4
  export function getSimulatorTransport(profile, customHandlers) {
4
- // eslint-disable-next-line prefer-const
5
- let clientTransport;
6
5
  const serverTransport = {
7
6
  onMessage: undefined,
8
7
  send: (payload) => {
9
8
  console.info("wallet -> app", payload);
10
- if (clientTransport?.onMessage) {
11
- clientTransport.onMessage(payload);
12
- }
9
+ // Using setTimeout to simulate async call (Do we want to keep this sync ?)
10
+ // It also avoids an act warning when using RTL to test components
11
+ setTimeout(() => {
12
+ if (clientTransport.onMessage) {
13
+ clientTransport.onMessage(payload);
14
+ }
15
+ }, 0);
13
16
  },
14
17
  };
15
- clientTransport = {
18
+ const clientTransport = {
16
19
  onMessage: undefined,
17
20
  send: (payload) => {
18
21
  console.info("app -> wallet", payload);
19
- if (serverTransport?.onMessage) {
20
- serverTransport.onMessage(payload);
21
- }
22
+ // Using setTimeout to simulate async call (Do we want to keep this sync ?)
23
+ // It also avoids an act warning when using RTL to test components
24
+ setTimeout(() => {
25
+ if (serverTransport.onMessage) {
26
+ serverTransport.onMessage(payload);
27
+ }
28
+ }, 0);
22
29
  },
23
30
  };
24
31
  const serverInstance = new WalletAPIServer(serverTransport, profile.config, defaultLogger, customHandlers);
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EACf,aAAa,GACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,UAAU,qBAAqB,CACnC,OAAyB,EACzB,cAA+B;IAE/B,wCAAwC;IACxC,IAAI,eAAsC,CAAC;IAE3C,MAAM,eAAe,GAAc;QACjC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,eA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AAS;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YACvC,2EAA2E;YAC3E,kEAAkE;YAClE,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,eAAe,CAAC,SAAS,EAAE;oBAC7B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;iBACpC;YACH,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,eAAe,CACxC,eAAe,EACf,OAAO,CAAC,MAAM,EACd,aAAa,EACb,cAAc,CACf,CAAC;IAEF,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEtC,OAAO,eAAe,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/wallet-api-simulator",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,9 +27,9 @@
27
27
  "@ledgerhq/hw-transport-http": "^6.28.3",
28
28
  "rxjs": "^7.8.1",
29
29
  "ws": "^8.13.0",
30
- "@ledgerhq/wallet-api-client": "1.2.1",
31
- "@ledgerhq/wallet-api-core": "1.3.1",
32
- "@ledgerhq/wallet-api-server": "1.3.1"
30
+ "@ledgerhq/wallet-api-client": "1.4.0",
31
+ "@ledgerhq/wallet-api-core": "1.5.0",
32
+ "@ledgerhq/wallet-api-server": "1.4.1"
33
33
  },
34
34
  "scripts": {
35
35
  "format:check": "prettier --check \"src\"",