@ledgerhq/coin-solana 0.37.0-nightly.20251125074637 → 0.38.0-nightly.20251126023856

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.
Files changed (111) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +52 -8
  3. package/lib/bridge/bridge.d.ts +2 -4
  4. package/lib/bridge/bridge.d.ts.map +1 -1
  5. package/lib/bridge/bridge.js +15 -15
  6. package/lib/bridge/bridge.js.map +1 -1
  7. package/lib/bridge/js.d.ts.map +1 -1
  8. package/lib/bridge/js.js +8 -8
  9. package/lib/bridge/js.js.map +1 -1
  10. package/lib/config.d.ts +0 -1
  11. package/lib/config.d.ts.map +1 -1
  12. package/lib/config.js.map +1 -1
  13. package/lib/network/chain/index.d.ts.map +1 -1
  14. package/lib/network/chain/index.js +29 -38
  15. package/lib/network/chain/index.js.map +1 -1
  16. package/lib/network/chain/web3.d.ts.map +1 -1
  17. package/lib/network/chain/web3.js +9 -5
  18. package/lib/network/chain/web3.js.map +1 -1
  19. package/lib/network/index.d.ts +0 -2
  20. package/lib/network/index.d.ts.map +1 -1
  21. package/lib/network/index.js +1 -5
  22. package/lib/network/index.js.map +1 -1
  23. package/lib/network/nft/index.js +3 -3
  24. package/lib/network/nft/index.js.map +1 -1
  25. package/lib/preload.d.ts +1 -1
  26. package/lib/preload.d.ts.map +1 -1
  27. package/lib/preload.js +1 -2
  28. package/lib/preload.js.map +1 -1
  29. package/lib/signOperation.d.ts +1 -1
  30. package/lib/signOperation.d.ts.map +1 -1
  31. package/lib/signOperation.js +1 -1
  32. package/lib/signOperation.js.map +1 -1
  33. package/lib/synchronization.d.ts.map +1 -1
  34. package/lib/synchronization.js +9 -5
  35. package/lib/synchronization.js.map +1 -1
  36. package/lib-es/bridge/bridge.d.ts +2 -4
  37. package/lib-es/bridge/bridge.d.ts.map +1 -1
  38. package/lib-es/bridge/bridge.js +15 -15
  39. package/lib-es/bridge/bridge.js.map +1 -1
  40. package/lib-es/bridge/js.d.ts.map +1 -1
  41. package/lib-es/bridge/js.js +9 -9
  42. package/lib-es/bridge/js.js.map +1 -1
  43. package/lib-es/config.d.ts +0 -1
  44. package/lib-es/config.d.ts.map +1 -1
  45. package/lib-es/config.js.map +1 -1
  46. package/lib-es/network/chain/index.d.ts.map +1 -1
  47. package/lib-es/network/chain/index.js +29 -38
  48. package/lib-es/network/chain/index.js.map +1 -1
  49. package/lib-es/network/chain/web3.d.ts.map +1 -1
  50. package/lib-es/network/chain/web3.js +9 -5
  51. package/lib-es/network/chain/web3.js.map +1 -1
  52. package/lib-es/network/index.d.ts +0 -2
  53. package/lib-es/network/index.d.ts.map +1 -1
  54. package/lib-es/network/index.js +0 -2
  55. package/lib-es/network/index.js.map +1 -1
  56. package/lib-es/network/nft/index.js +1 -1
  57. package/lib-es/network/nft/index.js.map +1 -1
  58. package/lib-es/preload.d.ts +1 -1
  59. package/lib-es/preload.d.ts.map +1 -1
  60. package/lib-es/preload.js +1 -2
  61. package/lib-es/preload.js.map +1 -1
  62. package/lib-es/signOperation.d.ts +1 -1
  63. package/lib-es/signOperation.d.ts.map +1 -1
  64. package/lib-es/signOperation.js +1 -1
  65. package/lib-es/signOperation.js.map +1 -1
  66. package/lib-es/synchronization.d.ts.map +1 -1
  67. package/lib-es/synchronization.js +9 -5
  68. package/lib-es/synchronization.js.map +1 -1
  69. package/package.json +6 -8
  70. package/src/__tests__/getTransactions.test.ts +81 -0
  71. package/src/__tests__/unit/hw-signMessage.unit.test.ts +0 -1
  72. package/src/bridge/bridge.ts +24 -33
  73. package/src/bridge/js.ts +9 -25
  74. package/src/config.ts +0 -1
  75. package/src/network/chain/index.ts +29 -38
  76. package/src/network/chain/web3.integration.test.ts +21 -1
  77. package/src/network/chain/web3.ts +11 -5
  78. package/src/network/index.ts +0 -2
  79. package/src/network/nft/index.ts +1 -1
  80. package/src/preload.test.ts +3 -3
  81. package/src/preload.ts +1 -3
  82. package/src/signOperation.test.ts +2 -2
  83. package/src/signOperation.ts +2 -2
  84. package/src/synchronization.ts +9 -5
  85. package/lib/network/cached.d.ts +0 -3
  86. package/lib/network/cached.d.ts.map +0 -1
  87. package/lib/network/cached.js +0 -56
  88. package/lib/network/cached.js.map +0 -1
  89. package/lib/network/queued.d.ts +0 -3
  90. package/lib/network/queued.d.ts.map +0 -1
  91. package/lib/network/queued.js +0 -27
  92. package/lib/network/queued.js.map +0 -1
  93. package/lib/network/traced.d.ts +0 -3
  94. package/lib/network/traced.d.ts.map +0 -1
  95. package/lib/network/traced.js +0 -80
  96. package/lib/network/traced.js.map +0 -1
  97. package/lib-es/network/cached.d.ts +0 -3
  98. package/lib-es/network/cached.d.ts.map +0 -1
  99. package/lib-es/network/cached.js +0 -49
  100. package/lib-es/network/cached.js.map +0 -1
  101. package/lib-es/network/queued.d.ts +0 -3
  102. package/lib-es/network/queued.d.ts.map +0 -1
  103. package/lib-es/network/queued.js +0 -23
  104. package/lib-es/network/queued.js.map +0 -1
  105. package/lib-es/network/traced.d.ts +0 -3
  106. package/lib-es/network/traced.d.ts.map +0 -1
  107. package/lib-es/network/traced.js +0 -76
  108. package/lib-es/network/traced.js.map +0 -1
  109. package/src/network/cached.ts +0 -111
  110. package/src/network/queued.ts +0 -25
  111. package/src/network/traced.ts +0 -89
@@ -1,111 +0,0 @@
1
- import { makeLRUCache, minutes, seconds } from "@ledgerhq/live-network/cache";
2
- import { PublicKey, TransactionInstruction, TransactionMessage } from "@solana/web3.js";
3
- import hash from "object-hash";
4
- import { ChainAPI } from "./chain";
5
-
6
- const cacheKeyAddress = (address: string) => address;
7
- const cacheKeyEmpty = () => "" as const;
8
- const cacheKeyAssocTokenAccAddress = (owner: string, mint: string) => `${owner}:${mint}`;
9
- const cacheKeyMinimumBalanceForRentExemption = (dataLengt: number) => dataLengt.toString();
10
-
11
- const cacheKeyTransactions = (signatures: string[]) => hash([...signatures].sort());
12
- const cacheKeyAddresses = (addresses: string[]) => hash([...addresses].sort());
13
- const cacheKeyInstructions = (ixs: TransactionInstruction[], payer: PublicKey) => {
14
- return hash(
15
- new TransactionMessage({
16
- instructions: ixs,
17
- payerKey: payer,
18
- recentBlockhash: payer.toString(),
19
- })
20
- .compileToLegacyMessage()
21
- .serialize(),
22
- );
23
- };
24
-
25
- const cacheKeyByArgs = (...args: unknown[]) => hash(args);
26
-
27
- export function cached(api: ChainAPI): ChainAPI {
28
- return {
29
- findAssocTokenAccAddress: makeLRUCache(
30
- api.findAssocTokenAccAddress,
31
- cacheKeyAssocTokenAccAddress,
32
- minutes(1000),
33
- ),
34
-
35
- getAccountInfo: makeLRUCache(api.getAccountInfo, cacheKeyAddress, seconds(30)),
36
-
37
- getMultipleAccounts: makeLRUCache(api.getMultipleAccounts, cacheKeyAddresses, seconds(30)),
38
-
39
- getAssocTokenAccMinNativeBalance: makeLRUCache(
40
- api.getAssocTokenAccMinNativeBalance,
41
- cacheKeyEmpty,
42
- minutes(5),
43
- ),
44
-
45
- getBalance: makeLRUCache(api.getBalance, cacheKeyAddress, seconds(30)),
46
-
47
- getBalanceAndContext: makeLRUCache(api.getBalanceAndContext, cacheKeyAddress, seconds(30)),
48
-
49
- getParsedTransactions: makeLRUCache(
50
- api.getParsedTransactions,
51
- cacheKeyTransactions,
52
- seconds(30),
53
- ),
54
-
55
- getParsedTokenAccountsByOwner: makeLRUCache(
56
- api.getParsedTokenAccountsByOwner,
57
- cacheKeyAddress,
58
- minutes(1),
59
- ),
60
-
61
- getParsedToken2022AccountsByOwner: makeLRUCache(
62
- api.getParsedToken2022AccountsByOwner,
63
- cacheKeyAddress,
64
- minutes(1),
65
- ),
66
-
67
- // cached by default in api
68
- getStakeAccountsByStakeAuth: api.getStakeAccountsByStakeAuth,
69
- getStakeAccountsByWithdrawAuth: api.getStakeAccountsByWithdrawAuth,
70
-
71
- getInflationReward: makeLRUCache(api.getInflationReward, cacheKeyByArgs, minutes(5)),
72
-
73
- getVoteAccounts: makeLRUCache(api.getVoteAccounts, cacheKeyEmpty, minutes(1)),
74
-
75
- getLatestBlockhash: makeLRUCache(api.getLatestBlockhash, cacheKeyEmpty, seconds(15)),
76
-
77
- getFeeForMessage: makeLRUCache(
78
- api.getFeeForMessage,
79
- msg => msg.serialize().toString(),
80
- minutes(1),
81
- ),
82
-
83
- getSignaturesForAddress: makeLRUCache(api.getSignaturesForAddress, cacheKeyByArgs, seconds(30)),
84
-
85
- getMinimumBalanceForRentExemption: makeLRUCache(
86
- api.getMinimumBalanceForRentExemption,
87
- cacheKeyMinimumBalanceForRentExemption,
88
- minutes(5),
89
- ),
90
-
91
- // do not cache
92
- sendRawTransaction: api.sendRawTransaction,
93
-
94
- getEpochInfo: makeLRUCache(api.getEpochInfo, cacheKeyEmpty, minutes(1)),
95
-
96
- getRecentPrioritizationFees: makeLRUCache(
97
- api.getRecentPrioritizationFees,
98
- cacheKeyByArgs,
99
- seconds(30),
100
- ),
101
-
102
- getSimulationComputeUnits: makeLRUCache(
103
- api.getSimulationComputeUnits,
104
- cacheKeyInstructions,
105
- seconds(30),
106
- ),
107
-
108
- config: api.config,
109
- connection: api.connection,
110
- };
111
- }
@@ -1,25 +0,0 @@
1
- import { asyncQueue } from "../utils";
2
- import { ChainAPI } from "./chain";
3
-
4
- export function queued(api: ChainAPI, delayBetweenRuns = 100): ChainAPI {
5
- const q = asyncQueue({
6
- delayBetweenRuns,
7
- });
8
-
9
- const proxy: ChainAPI = new Proxy(api, {
10
- get(target, propKey, receiver) {
11
- const targetValue = Reflect.get(target, propKey, receiver);
12
- if (typeof targetValue === "function") {
13
- return function (...args: unknown[]) {
14
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
- // @ts-ignore: TS-2683
16
- return q.submit(() => targetValue.apply(this, args));
17
- };
18
- } else {
19
- return targetValue;
20
- }
21
- },
22
- });
23
-
24
- return proxy;
25
- }
@@ -1,89 +0,0 @@
1
- import { log } from "@ledgerhq/logs";
2
- import { getEnv } from "@ledgerhq/live-env";
3
- import { ChainAPI } from "./chain";
4
-
5
- export function traced(api: ChainAPI): ChainAPI {
6
- const state = {
7
- reqId: 0,
8
- reqStartTime: new Map<number, number>(),
9
- };
10
-
11
- const startReqTrace = () => {
12
- state.reqId += 1;
13
- state.reqStartTime.set(state.reqId, Date.now());
14
- return state.reqId;
15
- };
16
-
17
- const stopReqTrace = (reqId: number) => {
18
- const reqStartTime = state.reqStartTime.get(reqId);
19
- if (reqStartTime === undefined) {
20
- log("warn", `request start time not found for request id <${reqId}>`);
21
- return {
22
- duration: 0,
23
- };
24
- }
25
- state.reqStartTime.delete(reqId);
26
- return {
27
- duration: Date.now() - reqStartTime,
28
- };
29
- };
30
-
31
- const proxy: ChainAPI = new Proxy(api, {
32
- get(target, propKey, receiver) {
33
- if (typeof propKey === "symbol") {
34
- throw new Error("symbols not supported");
35
- }
36
- const targetValue = Reflect.get(target, propKey, receiver);
37
- if (typeof targetValue === "function") {
38
- return function (...args: unknown[]) {
39
- const reqId = startReqTrace();
40
- log("network", formatMsg({ reqId, msg: `calling <${propKey}>` }), {
41
- args,
42
- });
43
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
- // @ts-ignore: TS-2683
45
- const result = targetValue.apply(this, args);
46
- if (result instanceof Promise) {
47
- return result
48
- .then(answer => {
49
- const { duration } = stopReqTrace(reqId);
50
- log(
51
- "network-success",
52
- formatMsg({ reqId, msg: "success", duration }),
53
- getEnv("DEBUG_HTTP_RESPONSE") ? { answer } : undefined,
54
- );
55
- return answer;
56
- })
57
- .catch(error => {
58
- const { duration } = stopReqTrace(reqId);
59
- log("network-error", formatMsg({ reqId, msg: "error", duration }), { error });
60
- throw error;
61
- });
62
- } else {
63
- const { duration } = stopReqTrace(reqId);
64
- log(
65
- "info",
66
- formatMsg({ reqId, msg: "sync result", duration }),
67
- getEnv("DEBUG_HTTP_RESPONSE") ? { result } : undefined,
68
- );
69
- return result;
70
- }
71
- };
72
- } else {
73
- return targetValue;
74
- }
75
- },
76
- });
77
-
78
- return proxy;
79
- }
80
-
81
- function formatMsg({ reqId, msg, duration }: { reqId: number; msg?: string; duration?: number }) {
82
- const parts = [
83
- `solana req id: ${reqId}`,
84
- msg ?? "",
85
- duration === undefined ? "" : `took ${duration.toFixed(0)}ms`,
86
- ];
87
-
88
- return parts.join(", ");
89
- }