@ledgerhq/wallet-api-simulator 0.2.0 → 0.3.0

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/dist/index.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- // src/index.ts
4
- var import_wallet_api_core = require("@ledgerhq/wallet-api-core");
5
- var import_wallet_api_server = require("@ledgerhq/wallet-api-server");
6
- var import_rxjs = require("rxjs");
7
- var dummyTransport = {
8
- onMessage: void 0,
9
- send: (payload) => {
10
- console.log("sent message: ", payload);
11
- }
12
- };
13
- var cryptoAccounts = [
14
- {
15
- id: "account-btc-1",
16
- name: "Bitcoin 1",
17
- address: "address",
18
- currency: "bitcoin",
19
- balance: "42",
20
- spendableBalance: "42",
21
- blockHeight: 1,
22
- lastSyncDate: "1995-12-17T03:24:00"
23
- },
24
- {
25
- id: "account-eth-1",
26
- name: "Ethereum 1",
27
- address: "address",
28
- currency: "ethereum",
29
- balance: "42",
30
- spendableBalance: "42",
31
- blockHeight: 1,
32
- lastSyncDate: "1995-12-17T03:24:00"
33
- }
34
- ].map(import_wallet_api_core.deserializeAccount);
35
- var serverInstance = new import_wallet_api_server.WalletAPIServer(dummyTransport);
36
- serverInstance.setAccounts(cryptoAccounts);
37
- serverInstance.setHandler(
38
- import_wallet_api_core.RFC.MethodId.ACCOUNT_REQUEST,
39
- async ({ accounts$ }) => {
40
- const accounts = await (0, import_rxjs.firstValueFrom)(accounts$);
41
- if (!accounts[0]) {
42
- throw new Error("nope");
43
- }
44
- return accounts[0];
45
- }
46
- );
47
- if (dummyTransport.onMessage) {
48
- const testMessage = {
49
- id: 1,
50
- jsonrpc: "2.0",
51
- method: import_wallet_api_core.RFC.MethodId.ACCOUNT_REQUEST,
52
- params: {
53
- currencies: ["ethereum"]
54
- }
55
- };
56
- dummyTransport.onMessage(JSON.stringify(testMessage));
57
- }
package/dist/index.mjs DELETED
@@ -1,58 +0,0 @@
1
- // src/index.ts
2
- import {
3
- deserializeAccount,
4
- RFC
5
- } from "@ledgerhq/wallet-api-core";
6
- import { WalletAPIServer } from "@ledgerhq/wallet-api-server";
7
- import { firstValueFrom } from "rxjs";
8
- var dummyTransport = {
9
- onMessage: void 0,
10
- send: (payload) => {
11
- console.log("sent message: ", payload);
12
- }
13
- };
14
- var cryptoAccounts = [
15
- {
16
- id: "account-btc-1",
17
- name: "Bitcoin 1",
18
- address: "address",
19
- currency: "bitcoin",
20
- balance: "42",
21
- spendableBalance: "42",
22
- blockHeight: 1,
23
- lastSyncDate: "1995-12-17T03:24:00"
24
- },
25
- {
26
- id: "account-eth-1",
27
- name: "Ethereum 1",
28
- address: "address",
29
- currency: "ethereum",
30
- balance: "42",
31
- spendableBalance: "42",
32
- blockHeight: 1,
33
- lastSyncDate: "1995-12-17T03:24:00"
34
- }
35
- ].map(deserializeAccount);
36
- var serverInstance = new WalletAPIServer(dummyTransport);
37
- serverInstance.setAccounts(cryptoAccounts);
38
- serverInstance.setHandler(
39
- RFC.MethodId.ACCOUNT_REQUEST,
40
- async ({ accounts$ }) => {
41
- const accounts = await firstValueFrom(accounts$);
42
- if (!accounts[0]) {
43
- throw new Error("nope");
44
- }
45
- return accounts[0];
46
- }
47
- );
48
- if (dummyTransport.onMessage) {
49
- const testMessage = {
50
- id: 1,
51
- jsonrpc: "2.0",
52
- method: RFC.MethodId.ACCOUNT_REQUEST,
53
- params: {
54
- currencies: ["ethereum"]
55
- }
56
- };
57
- dummyTransport.onMessage(JSON.stringify(testMessage));
58
- }
package/src/index.ts DELETED
@@ -1,66 +0,0 @@
1
- import {
2
- Account,
3
- deserializeAccount,
4
- RFC,
5
- RpcRequest,
6
- Transport,
7
- } from "@ledgerhq/wallet-api-core";
8
-
9
- import { WalletAPIServer } from "@ledgerhq/wallet-api-server";
10
- import { firstValueFrom } from "rxjs";
11
-
12
- const dummyTransport: Transport = {
13
- onMessage: undefined,
14
- send: (payload) => {
15
- console.log("sent message: ", payload);
16
- },
17
- };
18
-
19
- const cryptoAccounts: Account[] = [
20
- {
21
- id: "account-btc-1",
22
- name: "Bitcoin 1",
23
- address: "address",
24
- currency: "bitcoin",
25
- balance: "42",
26
- spendableBalance: "42",
27
- blockHeight: 1,
28
- lastSyncDate: "1995-12-17T03:24:00",
29
- },
30
- {
31
- id: "account-eth-1",
32
- name: "Ethereum 1",
33
- address: "address",
34
- currency: "ethereum",
35
- balance: "42",
36
- spendableBalance: "42",
37
- blockHeight: 1,
38
- lastSyncDate: "1995-12-17T03:24:00",
39
- },
40
- ].map(deserializeAccount);
41
-
42
- const serverInstance = new WalletAPIServer(dummyTransport);
43
- serverInstance.setAccounts(cryptoAccounts);
44
-
45
- serverInstance.setHandler(
46
- RFC.MethodId.ACCOUNT_REQUEST,
47
- async ({ accounts$ }) => {
48
- const accounts = await firstValueFrom(accounts$);
49
- if (!accounts[0]) {
50
- throw new Error("nope");
51
- }
52
- return accounts[0];
53
- }
54
- );
55
-
56
- if (dummyTransport.onMessage) {
57
- const testMessage: RpcRequest<RFC.MethodId, RFC.AccountRequestParams> = {
58
- id: 1,
59
- jsonrpc: "2.0",
60
- method: RFC.MethodId.ACCOUNT_REQUEST,
61
- params: {
62
- currencies: ["ethereum"],
63
- },
64
- };
65
- dummyTransport.onMessage(JSON.stringify(testMessage));
66
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@tsconfig/node16-strictest-esm/tsconfig.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "esModuleInterop": true,
6
- "declaration": true,
7
- "outDir": "./dist",
8
- "lib": ["DOM"]
9
- },
10
- "include": ["src/**/*", "tests/**/*"]
11
- }