@ledgerhq/coin-stellar 0.2.0-nightly.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.
Files changed (233) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +35 -0
  4. package/CHANGELOG.md +13 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +8 -0
  7. package/lib/bridge/bridge.integration.test.d.ts +4 -0
  8. package/lib/bridge/bridge.integration.test.d.ts.map +1 -0
  9. package/lib/bridge/bridge.integration.test.js +317 -0
  10. package/lib/bridge/bridge.integration.test.js.map +1 -0
  11. package/lib/bridge/index.d.ts +10 -0
  12. package/lib/bridge/index.d.ts.map +1 -0
  13. package/lib/bridge/index.js +72 -0
  14. package/lib/bridge/index.js.map +1 -0
  15. package/lib/broadcast.d.ts +9 -0
  16. package/lib/broadcast.d.ts.map +1 -0
  17. package/lib/broadcast.js +26 -0
  18. package/lib/broadcast.js.map +1 -0
  19. package/lib/buildOptimisticOperation.d.ts +4 -0
  20. package/lib/buildOptimisticOperation.d.ts.map +1 -0
  21. package/lib/buildOptimisticOperation.js +72 -0
  22. package/lib/buildOptimisticOperation.js.map +1 -0
  23. package/lib/buildTransaction.d.ts +10 -0
  24. package/lib/buildTransaction.d.ts.map +1 -0
  25. package/lib/buildTransaction.js +97 -0
  26. package/lib/buildTransaction.js.map +1 -0
  27. package/lib/cli.d.ts +38 -0
  28. package/lib/cli.d.ts.map +1 -0
  29. package/lib/cli.js +83 -0
  30. package/lib/cli.js.map +1 -0
  31. package/lib/config.d.ts +5 -0
  32. package/lib/config.d.ts.map +1 -0
  33. package/lib/config.js +17 -0
  34. package/lib/config.js.map +1 -0
  35. package/lib/createTransaction.d.ts +10 -0
  36. package/lib/createTransaction.d.ts.map +1 -0
  37. package/lib/createTransaction.js +26 -0
  38. package/lib/createTransaction.js.map +1 -0
  39. package/lib/deviceTransactionConfig.d.ts +24 -0
  40. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  41. package/lib/deviceTransactionConfig.js +41 -0
  42. package/lib/deviceTransactionConfig.js.map +1 -0
  43. package/lib/errors.d.ts +37 -0
  44. package/lib/errors.d.ts.map +1 -0
  45. package/lib/errors.js +17 -0
  46. package/lib/errors.js.map +1 -0
  47. package/lib/estimateMaxSpendable.d.ts +5 -0
  48. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  49. package/lib/estimateMaxSpendable.js +32 -0
  50. package/lib/estimateMaxSpendable.js.map +1 -0
  51. package/lib/getTransactionStatus.d.ts +5 -0
  52. package/lib/getTransactionStatus.d.ts.map +1 -0
  53. package/lib/getTransactionStatus.js +170 -0
  54. package/lib/getTransactionStatus.js.map +1 -0
  55. package/lib/hw-getAddress.d.ts +6 -0
  56. package/lib/hw-getAddress.d.ts.map +1 -0
  57. package/lib/hw-getAddress.js +28 -0
  58. package/lib/hw-getAddress.js.map +1 -0
  59. package/lib/logic.d.ts +36 -0
  60. package/lib/logic.d.ts.map +1 -0
  61. package/lib/logic.js +289 -0
  62. package/lib/logic.js.map +1 -0
  63. package/lib/network/horizon.d.ts +71 -0
  64. package/lib/network/horizon.d.ts.map +1 -0
  65. package/lib/network/horizon.js +300 -0
  66. package/lib/network/horizon.js.map +1 -0
  67. package/lib/network/index.d.ts +2 -0
  68. package/lib/network/index.d.ts.map +1 -0
  69. package/lib/network/index.js +20 -0
  70. package/lib/network/index.js.map +1 -0
  71. package/lib/prepareTransaction.d.ts +5 -0
  72. package/lib/prepareTransaction.d.ts.map +1 -0
  73. package/lib/prepareTransaction.js +41 -0
  74. package/lib/prepareTransaction.js.map +1 -0
  75. package/lib/signOperation.d.ts +6 -0
  76. package/lib/signOperation.d.ts.map +1 -0
  77. package/lib/signOperation.js +56 -0
  78. package/lib/signOperation.js.map +1 -0
  79. package/lib/specs.d.ts +7 -0
  80. package/lib/specs.d.ts.map +1 -0
  81. package/lib/specs.js +234 -0
  82. package/lib/specs.js.map +1 -0
  83. package/lib/speculos-deviceActions.d.ts +4 -0
  84. package/lib/speculos-deviceActions.d.ts.map +1 -0
  85. package/lib/speculos-deviceActions.js +99 -0
  86. package/lib/speculos-deviceActions.js.map +1 -0
  87. package/lib/synchronization.d.ts +4 -0
  88. package/lib/synchronization.d.ts.map +1 -0
  89. package/lib/synchronization.js +73 -0
  90. package/lib/synchronization.js.map +1 -0
  91. package/lib/tokens.d.ts +12 -0
  92. package/lib/tokens.d.ts.map +1 -0
  93. package/lib/tokens.js +58 -0
  94. package/lib/tokens.js.map +1 -0
  95. package/lib/transaction.d.ts +15 -0
  96. package/lib/transaction.d.ts.map +1 -0
  97. package/lib/transaction.js +63 -0
  98. package/lib/transaction.js.map +1 -0
  99. package/lib/types/index.d.ts +89 -0
  100. package/lib/types/index.d.ts.map +1 -0
  101. package/lib/types/index.js +26 -0
  102. package/lib/types/index.js.map +1 -0
  103. package/lib/types/signer.d.ts +10 -0
  104. package/lib/types/signer.d.ts.map +1 -0
  105. package/lib/types/signer.js +3 -0
  106. package/lib/types/signer.js.map +1 -0
  107. package/lib-es/bridge/bridge.integration.test.d.ts +4 -0
  108. package/lib-es/bridge/bridge.integration.test.d.ts.map +1 -0
  109. package/lib-es/bridge/bridge.integration.test.js +311 -0
  110. package/lib-es/bridge/bridge.integration.test.js.map +1 -0
  111. package/lib-es/bridge/index.d.ts +10 -0
  112. package/lib-es/bridge/index.d.ts.map +1 -0
  113. package/lib-es/bridge/index.js +65 -0
  114. package/lib-es/bridge/index.js.map +1 -0
  115. package/lib-es/broadcast.d.ts +9 -0
  116. package/lib-es/broadcast.d.ts.map +1 -0
  117. package/lib-es/broadcast.js +22 -0
  118. package/lib-es/broadcast.js.map +1 -0
  119. package/lib-es/buildOptimisticOperation.d.ts +4 -0
  120. package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
  121. package/lib-es/buildOptimisticOperation.js +65 -0
  122. package/lib-es/buildOptimisticOperation.js.map +1 -0
  123. package/lib-es/buildTransaction.d.ts +10 -0
  124. package/lib-es/buildTransaction.d.ts.map +1 -0
  125. package/lib-es/buildTransaction.js +90 -0
  126. package/lib-es/buildTransaction.js.map +1 -0
  127. package/lib-es/cli.d.ts +38 -0
  128. package/lib-es/cli.d.ts.map +1 -0
  129. package/lib-es/cli.js +77 -0
  130. package/lib-es/cli.js.map +1 -0
  131. package/lib-es/config.d.ts +5 -0
  132. package/lib-es/config.d.ts.map +1 -0
  133. package/lib-es/config.js +12 -0
  134. package/lib-es/config.js.map +1 -0
  135. package/lib-es/createTransaction.d.ts +10 -0
  136. package/lib-es/createTransaction.d.ts.map +1 -0
  137. package/lib-es/createTransaction.js +22 -0
  138. package/lib-es/createTransaction.js.map +1 -0
  139. package/lib-es/deviceTransactionConfig.d.ts +24 -0
  140. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  141. package/lib-es/deviceTransactionConfig.js +39 -0
  142. package/lib-es/deviceTransactionConfig.js.map +1 -0
  143. package/lib-es/errors.d.ts +37 -0
  144. package/lib-es/errors.d.ts.map +1 -0
  145. package/lib-es/errors.js +14 -0
  146. package/lib-es/errors.js.map +1 -0
  147. package/lib-es/estimateMaxSpendable.d.ts +5 -0
  148. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  149. package/lib-es/estimateMaxSpendable.js +25 -0
  150. package/lib-es/estimateMaxSpendable.js.map +1 -0
  151. package/lib-es/getTransactionStatus.d.ts +5 -0
  152. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  153. package/lib-es/getTransactionStatus.js +166 -0
  154. package/lib-es/getTransactionStatus.js.map +1 -0
  155. package/lib-es/hw-getAddress.d.ts +6 -0
  156. package/lib-es/hw-getAddress.d.ts.map +1 -0
  157. package/lib-es/hw-getAddress.js +26 -0
  158. package/lib-es/hw-getAddress.js.map +1 -0
  159. package/lib-es/logic.d.ts +36 -0
  160. package/lib-es/logic.d.ts.map +1 -0
  161. package/lib-es/logic.js +274 -0
  162. package/lib-es/logic.js.map +1 -0
  163. package/lib-es/network/horizon.d.ts +71 -0
  164. package/lib-es/network/horizon.d.ts.map +1 -0
  165. package/lib-es/network/horizon.js +285 -0
  166. package/lib-es/network/horizon.js.map +1 -0
  167. package/lib-es/network/index.d.ts +2 -0
  168. package/lib-es/network/index.d.ts.map +1 -0
  169. package/lib-es/network/index.js +2 -0
  170. package/lib-es/network/index.js.map +1 -0
  171. package/lib-es/prepareTransaction.d.ts +5 -0
  172. package/lib-es/prepareTransaction.d.ts.map +1 -0
  173. package/lib-es/prepareTransaction.js +34 -0
  174. package/lib-es/prepareTransaction.js.map +1 -0
  175. package/lib-es/signOperation.d.ts +6 -0
  176. package/lib-es/signOperation.d.ts.map +1 -0
  177. package/lib-es/signOperation.js +52 -0
  178. package/lib-es/signOperation.js.map +1 -0
  179. package/lib-es/specs.d.ts +7 -0
  180. package/lib-es/specs.d.ts.map +1 -0
  181. package/lib-es/specs.js +229 -0
  182. package/lib-es/specs.js.map +1 -0
  183. package/lib-es/speculos-deviceActions.d.ts +4 -0
  184. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  185. package/lib-es/speculos-deviceActions.js +96 -0
  186. package/lib-es/speculos-deviceActions.js.map +1 -0
  187. package/lib-es/synchronization.d.ts +4 -0
  188. package/lib-es/synchronization.d.ts.map +1 -0
  189. package/lib-es/synchronization.js +69 -0
  190. package/lib-es/synchronization.js.map +1 -0
  191. package/lib-es/tokens.d.ts +12 -0
  192. package/lib-es/tokens.d.ts.map +1 -0
  193. package/lib-es/tokens.js +50 -0
  194. package/lib-es/tokens.js.map +1 -0
  195. package/lib-es/transaction.d.ts +15 -0
  196. package/lib-es/transaction.d.ts.map +1 -0
  197. package/lib-es/transaction.js +59 -0
  198. package/lib-es/transaction.js.map +1 -0
  199. package/lib-es/types/index.d.ts +89 -0
  200. package/lib-es/types/index.d.ts.map +1 -0
  201. package/lib-es/types/index.js +9 -0
  202. package/lib-es/types/index.js.map +1 -0
  203. package/lib-es/types/signer.d.ts +10 -0
  204. package/lib-es/types/signer.d.ts.map +1 -0
  205. package/lib-es/types/signer.js +2 -0
  206. package/lib-es/types/signer.js.map +1 -0
  207. package/package.json +80 -0
  208. package/src/bridge/bridge.integration.test.ts +373 -0
  209. package/src/bridge/index.ts +77 -0
  210. package/src/broadcast.ts +20 -0
  211. package/src/buildOptimisticOperation.ts +63 -0
  212. package/src/buildTransaction.ts +106 -0
  213. package/src/cli.ts +107 -0
  214. package/src/config.ts +18 -0
  215. package/src/createTransaction.ts +25 -0
  216. package/src/deviceTransactionConfig.ts +75 -0
  217. package/src/errors.ts +20 -0
  218. package/src/estimateMaxSpendable.ts +29 -0
  219. package/src/getTransactionStatus.ts +207 -0
  220. package/src/hw-getAddress.ts +24 -0
  221. package/src/logic.ts +371 -0
  222. package/src/network/horizon.ts +352 -0
  223. package/src/network/index.ts +17 -0
  224. package/src/prepareTransaction.ts +35 -0
  225. package/src/signOperation.ts +58 -0
  226. package/src/specs.ts +290 -0
  227. package/src/speculos-deviceActions.ts +117 -0
  228. package/src/synchronization.ts +80 -0
  229. package/src/tokens.ts +98 -0
  230. package/src/transaction.ts +99 -0
  231. package/src/types/index.ts +112 -0
  232. package/src/types/signer.ts +9 -0
  233. package/tsconfig.json +13 -0
@@ -0,0 +1,89 @@
1
+ import { Horizon } from "@stellar/stellar-sdk";
2
+ import type { BigNumber } from "bignumber.js";
3
+ import type { Account, Operation, OperationType, TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
4
+ export type NetworkInfo = {
5
+ family: "stellar";
6
+ fees: BigNumber;
7
+ baseFee: BigNumber;
8
+ baseReserve: BigNumber;
9
+ networkCongestionLevel?: NetworkCongestionLevel | undefined;
10
+ };
11
+ export type NetworkInfoRaw = {
12
+ family: "stellar";
13
+ fees: string;
14
+ baseFee: string;
15
+ baseReserve: string;
16
+ networkCongestionLevel?: NetworkCongestionLevel | undefined;
17
+ };
18
+ export declare enum NetworkCongestionLevel {
19
+ LOW = "LOW",
20
+ MEDIUM = "MEDIUM",
21
+ HIGH = "HIGH"
22
+ }
23
+ export declare const StellarMemoType: string[];
24
+ export type StellarTransactionMode = "send" | "changeTrust";
25
+ export type Transaction = TransactionCommon & {
26
+ family: "stellar";
27
+ networkInfo?: NetworkInfo | null | undefined;
28
+ fees?: BigNumber | null;
29
+ baseReserve?: BigNumber | null;
30
+ memoType?: string | null;
31
+ memoValue?: string | null;
32
+ mode: StellarTransactionMode;
33
+ assetCode?: string;
34
+ assetIssuer?: string;
35
+ };
36
+ export type TransactionRaw = TransactionCommonRaw & {
37
+ family: "stellar";
38
+ networkInfo?: NetworkInfoRaw | null | undefined;
39
+ fees?: string | null;
40
+ baseReserve?: string | null;
41
+ memoType?: string | null;
42
+ memoValue?: string | null;
43
+ mode: StellarTransactionMode;
44
+ assetCode?: string;
45
+ assetIssuer?: string;
46
+ };
47
+ export type BalanceAsset = {
48
+ balance: string;
49
+ limit: string;
50
+ buying_liabilities: string;
51
+ selling_liabilities: string;
52
+ last_modified_ledger: number;
53
+ is_authorized: boolean;
54
+ is_authorized_to_maintain_liabilities: boolean;
55
+ asset_type: string;
56
+ asset_code: string;
57
+ asset_issuer: string;
58
+ liquidity_pool_id?: string;
59
+ };
60
+ export type RawOperation = Horizon.ServerApi.OperationRecord & {
61
+ asset_code?: string;
62
+ asset_issuer?: string;
63
+ from?: string;
64
+ to?: string;
65
+ to_muxed?: string;
66
+ funder?: string;
67
+ trustor?: string;
68
+ account?: string;
69
+ transaction_successful: boolean;
70
+ };
71
+ export type Signer = {
72
+ weight: number;
73
+ key: string;
74
+ type: string;
75
+ };
76
+ export type TransactionStatus = TransactionStatusCommon;
77
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
78
+ export type StellarOperation = Operation<StellarOperationExtra>;
79
+ export type StellarOperationExtra = {
80
+ pagingToken?: string;
81
+ assetCode?: string;
82
+ assetIssuer?: string;
83
+ assetAmount?: string | undefined;
84
+ ledgerOpType: OperationType;
85
+ memo?: string;
86
+ };
87
+ export type StellarAccount = Account;
88
+ export * from "./signer";
89
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ export var NetworkCongestionLevel;
2
+ (function (NetworkCongestionLevel) {
3
+ NetworkCongestionLevel["LOW"] = "LOW";
4
+ NetworkCongestionLevel["MEDIUM"] = "MEDIUM";
5
+ NetworkCongestionLevel["HIGH"] = "HIGH";
6
+ })(NetworkCongestionLevel || (NetworkCongestionLevel = {}));
7
+ export const StellarMemoType = ["NO_MEMO", "MEMO_TEXT", "MEMO_ID", "MEMO_HASH", "MEMO_RETURN"];
8
+ export * from "./signer";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,uCAAa,CAAA;AACf,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AA6E/F,cAAc,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ export interface StellarSigner {
3
+ getPublicKey(path: string, display?: boolean): Promise<{
4
+ rawPublicKey: Buffer;
5
+ }>;
6
+ signTransaction(path: string, transaction: Buffer): Promise<{
7
+ signature: Buffer;
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":";AAAA,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjF,eAAe,CACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@ledgerhq/coin-stellar",
3
+ "version": "0.2.0-nightly.0",
4
+ "description": "Ledger Stellar Coin integration",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "Ledger",
8
+ "LedgerWallet",
9
+ "Stellar",
10
+ "Hardware Wallet"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/LedgerHQ/ledger-live.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
18
+ },
19
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-stellar",
20
+ "dependencies": {
21
+ "@stellar/stellar-sdk": "^11.3.0",
22
+ "bignumber.js": "^9.1.2",
23
+ "expect": "^27.4.6",
24
+ "invariant": "^2.2.2",
25
+ "rxjs": "^7.8.1",
26
+ "@ledgerhq/coin-framework": "^0.15.1-nightly.0",
27
+ "@ledgerhq/cryptoassets": "^13.1.1",
28
+ "@ledgerhq/devices": "^8.4.1-nightly.1",
29
+ "@ledgerhq/errors": "^6.18.0-nightly.1",
30
+ "@ledgerhq/live-env": "^2.1.0",
31
+ "@ledgerhq/live-network": "^1.3.1-nightly.1",
32
+ "@ledgerhq/logs": "^6.12.0",
33
+ "@ledgerhq/types-cryptoassets": "^7.14.0-nightly.0",
34
+ "@ledgerhq/types-live": "^6.49.0-nightly.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/invariant": "^2.2.2",
38
+ "@types/jest": "^29.5.10",
39
+ "jest": "^29.7.0",
40
+ "ts-jest": "^29.1.1"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "typesVersions": {
46
+ "*": {
47
+ "lib/*": [
48
+ "lib/*"
49
+ ],
50
+ "lib-es/*": [
51
+ "lib-es/*"
52
+ ],
53
+ "*": [
54
+ "lib/*"
55
+ ]
56
+ }
57
+ },
58
+ "exports": {
59
+ "./lib/*": "./lib/*.js",
60
+ "./lib-es/*": "./lib-es/*.js",
61
+ "./*": {
62
+ "require": "./lib/*.js",
63
+ "default": "./lib-es/*.js"
64
+ },
65
+ "./package.json": "./package.json"
66
+ },
67
+ "scripts": {
68
+ "clean": "rimraf lib lib-es",
69
+ "build": "tsc && tsc -m ES6 --outDir lib-es",
70
+ "coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-stellar.json",
71
+ "prewatch": "pnpm build",
72
+ "watch": "tsc --watch",
73
+ "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
74
+ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
75
+ "lint:fix": "pnpm lint --fix",
76
+ "test": "jest",
77
+ "typecheck": "tsc --noEmit",
78
+ "unimported": "unimported"
79
+ }
80
+ }
@@ -0,0 +1,373 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { DatasetTest } from "@ledgerhq/types-live";
3
+ import {
4
+ InvalidAddressBecauseDestinationIsAlsoSource,
5
+ NotEnoughSpendableBalance,
6
+ NotEnoughBalanceBecauseDestinationNotCreated,
7
+ } from "@ledgerhq/errors";
8
+ import type { Transaction } from "../types/index";
9
+ import transactionTransformer from "../transaction";
10
+ import { StellarWrongMemoFormat } from "../errors";
11
+
12
+ export const dataset: DatasetTest<Transaction> = {
13
+ implementations: ["js"],
14
+ currencies: {
15
+ stellar: {
16
+ scanAccounts: [
17
+ {
18
+ name: "stellar seed 1",
19
+ apdus: `
20
+ => e00200000d038000002c8000009480000000
21
+ <= 27c586f8499294c64d57f8d7956eef4431de58ab20e1c88001f6cf131c97d6f39000
22
+ => e00200000d038000002c8000009480000001
23
+ <= 1174242cc3e722e843ac37db3a745897941396d486456e303001b06b417db1f89000
24
+ => e00200000d038000002c8000009480000002
25
+ <= 8636fa7a5a5bb9fe4fb2615f04425f54dc74c16fefc1325958c9719ee03ef5379000
26
+ => e00200000d038000002c8000009480000003
27
+ <= 0f052ff4b74726a6f668380927c3d23e9c16d538cb6c272add871e069336bead9000
28
+ => e00200000d038000002c8000009480000004
29
+ <= 60c75356c268ff0158eeca556526830761327693a93cf4754020fadbe04d0f2b9000
30
+ => e00200000d038000002c8000009480000005
31
+ <= 124516f8ffb161c9492486e54b4432a2c11e4817414dea54fb8bde13b5ac49439000
32
+ `,
33
+ },
34
+ ],
35
+ accounts: [
36
+ {
37
+ FIXME_tests: ["balance is sum of ops"],
38
+ raw: {
39
+ id: "libcore:1:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
40
+ seedIdentifier: "3544cee0d67187d277cd9c7e26a2bf70425b1bee8e92003f45d150c5513d531a",
41
+ name: "Stellar 1",
42
+ xpub: "GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
43
+ derivationMode: "sep5",
44
+ index: 0,
45
+ freshAddress: "GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
46
+ freshAddressPath: "44'/148'/0'",
47
+ // @ts-expect-error wat
48
+ unit: {
49
+ name: "Lumen",
50
+ code: "XLM",
51
+ magnitude: 7,
52
+ },
53
+ blockHeight: 28884793,
54
+ operations: [],
55
+ pendingOperations: [],
56
+ currencyId: "stellar",
57
+ lastSyncDate: "",
58
+ balance: "371210662",
59
+ spendableBalance: "371210662",
60
+ },
61
+ transactions: [
62
+ {
63
+ name: "Same as Recipient",
64
+ transaction: t => ({
65
+ ...t,
66
+ amount: new BigNumber(100),
67
+ recipient: "GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
68
+ }),
69
+ expectedStatus: {
70
+ errors: {
71
+ recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
72
+ },
73
+ warnings: {},
74
+ },
75
+ },
76
+ {
77
+ name: "Send To New Account - amount is too low",
78
+ transaction: transactionTransformer.fromTransactionRaw({
79
+ amount: "1000",
80
+ recipient: "GAW46JE3SHIAYLNNNQCAZFQ437WB5ZH7LDRDWR5LVDWHCTHCKYB6RCCH",
81
+ // Have to use an address from the test seed, here is from one coin int testing device
82
+ useAllAmount: false,
83
+ family: "stellar",
84
+ baseReserve: "1500000",
85
+ networkInfo: {
86
+ family: "stellar",
87
+ fees: "100",
88
+ baseFee: "100",
89
+ baseReserve: "1500000",
90
+ },
91
+ fees: "100",
92
+ memoType: null,
93
+ memoValue: null,
94
+ mode: "send",
95
+ assetCode: "",
96
+ assetIssuer: "",
97
+ }),
98
+ expectedStatus: {
99
+ errors: {
100
+ amount: new NotEnoughBalanceBecauseDestinationNotCreated(),
101
+ },
102
+ warnings: {},
103
+ },
104
+ },
105
+ {
106
+ name: "send amount more than fees + base reserve",
107
+ transaction: (t, account) => ({
108
+ ...t,
109
+ amount: account.balance,
110
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
111
+ }),
112
+ expectedStatus: {
113
+ errors: {
114
+ amount: new NotEnoughSpendableBalance(),
115
+ },
116
+ warnings: {},
117
+ },
118
+ },
119
+ {
120
+ name: "send more than base reserve",
121
+ transaction: (t, account) => ({
122
+ ...t,
123
+ amount: account.balance.minus("100"),
124
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
125
+ }),
126
+ expectedStatus: {
127
+ errors: {
128
+ amount: new NotEnoughSpendableBalance(),
129
+ },
130
+ warnings: {},
131
+ },
132
+ },
133
+ {
134
+ name: "send max to new account (explicit)",
135
+ transaction: transactionTransformer.fromTransactionRaw({
136
+ amount: "0",
137
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
138
+ useAllAmount: true,
139
+ family: "stellar",
140
+ baseReserve: "1500000",
141
+ networkInfo: {
142
+ family: "stellar",
143
+ fees: "100",
144
+ baseFee: "100",
145
+ baseReserve: "1500000",
146
+ },
147
+ fees: "100",
148
+ memoType: null,
149
+ memoValue: null,
150
+ mode: "send",
151
+ assetCode: "",
152
+ assetIssuer: "",
153
+ }),
154
+ expectedStatus: account => ({
155
+ errors: {},
156
+ warnings: {},
157
+ estimatedFees: new BigNumber("100"),
158
+ amount: account.spendableBalance.minus("100"),
159
+ totalSpent: account.spendableBalance.minus("100"),
160
+ }),
161
+ },
162
+ {
163
+ name: "memo text - success",
164
+ transaction: t => ({
165
+ ...t,
166
+ amount: new BigNumber(100),
167
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
168
+ memoType: "MEMO_TEXT",
169
+ memoValue: "01234",
170
+ }),
171
+ expectedStatus: {
172
+ errors: {},
173
+ warnings: {},
174
+ },
175
+ },
176
+ {
177
+ name: "memo text - error",
178
+ transaction: t => ({
179
+ ...t,
180
+ amount: new BigNumber(100),
181
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
182
+ memoType: "MEMO_TEXT",
183
+ memoValue: "0123456789012345678901234567890123456789",
184
+ }),
185
+ expectedStatus: {
186
+ errors: {
187
+ transaction: new StellarWrongMemoFormat(),
188
+ },
189
+ warnings: {},
190
+ },
191
+ },
192
+ {
193
+ name: "memo id - success",
194
+ transaction: t => ({
195
+ ...t,
196
+ amount: new BigNumber(100),
197
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
198
+ memoType: "MEMO_ID",
199
+ memoValue: "22",
200
+ }),
201
+ expectedStatus: {
202
+ errors: {},
203
+ warnings: {},
204
+ },
205
+ },
206
+ {
207
+ name: "memo id - error",
208
+ transaction: t => ({
209
+ ...t,
210
+ amount: new BigNumber(100),
211
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
212
+ memoType: "MEMO_ID",
213
+ memoValue: "btest2",
214
+ }),
215
+ expectedStatus: {
216
+ errors: {
217
+ transaction: new StellarWrongMemoFormat(),
218
+ },
219
+ warnings: {},
220
+ },
221
+ },
222
+ {
223
+ name: "memo hash - error",
224
+ transaction: t => ({
225
+ ...t,
226
+ amount: new BigNumber(100),
227
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
228
+ memoType: "MEMO_HASH",
229
+ memoValue: "dsadsdasdsasseeee",
230
+ }),
231
+ expectedStatus: {
232
+ errors: {
233
+ transaction: new StellarWrongMemoFormat(),
234
+ },
235
+ warnings: {},
236
+ },
237
+ },
238
+ ],
239
+ },
240
+ {
241
+ FIXME_tests: [
242
+ "balance is sum of ops", // We prevent user to do anything if we detect that he is a multisign user
243
+ // SourceHasMultiSign will be launch first
244
+ "Default empty recipient have a recipientError",
245
+ "invalid recipient have a recipientError",
246
+ ],
247
+ raw: {
248
+ id: "libcore:2:stellar:GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS:sep5",
249
+ seedIdentifier: "3544cee0d67187d277cd9c7e26a2bf70425b1bee8e92003f45d150c5513d531a",
250
+ xpub: "GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS",
251
+ derivationMode: "sep5",
252
+ index: 2,
253
+ freshAddress: "GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS",
254
+ freshAddressPath: "44'/148'/2'",
255
+ name: "Stellar 3",
256
+ // @ts-expect-error wat
257
+ unit: {
258
+ name: "Lumen",
259
+ code: "XLM",
260
+ magnitude: 7,
261
+ },
262
+ blockHeight: 28884848,
263
+ operations: [],
264
+ pendingOperations: [],
265
+ currencyId: "stellar",
266
+ lastSyncDate: "",
267
+ balance: "59999500",
268
+ spendableBalance: "59999500",
269
+ },
270
+ transactions: [
271
+ {
272
+ name: "Multisign - error",
273
+ transaction: t => ({
274
+ ...t,
275
+ amount: new BigNumber(100),
276
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
277
+ memoType: "MEMO_HASH",
278
+ memoValue: "dsadsdasdsasseeee",
279
+ }),
280
+ expectedStatus: {
281
+ errors: {
282
+ transaction: new StellarWrongMemoFormat(),
283
+ },
284
+ warnings: {},
285
+ },
286
+ },
287
+ ],
288
+ },
289
+ {
290
+ FIXME_tests: ["balance is sum of ops"],
291
+ raw: {
292
+ id: "js:1:stellar:f30b743cb3a8bc8c3ea8fe8455c6a52221cc6cf867f7f1f5861dd52aba1d0b8a:sep5",
293
+ seedIdentifier: "gre",
294
+ name: "GRE's Stellar 2",
295
+ xpub: "f30b743cb3a8bc8c3ea8fe8455c6a52221cc6cf867f7f1f5861dd52aba1d0b8a",
296
+ derivationMode: "sep5",
297
+ index: 1,
298
+ freshAddress: "",
299
+ freshAddressPath: "44'/148'/1'",
300
+ balance: "0",
301
+ blockHeight: 0,
302
+ currencyId: "stellar",
303
+ lastSyncDate: "",
304
+ operations: [],
305
+ pendingOperations: [],
306
+ },
307
+ },
308
+ {
309
+ FIXME_tests: ["balance is sum of ops"],
310
+ raw: {
311
+ id: "js:1:stellar:GD7G4RE27CMFTUUUVZBJJ2GBK5GCTD5JQFE5FJCENAUD6AFAVMOBZTSK:sep5",
312
+ seedIdentifier: "LIVE-3170",
313
+ name: "Large Stellar account",
314
+ xpub: "GD7G4RE27CMFTUUUVZBJJ2GBK5GCTD5JQFE5FJCENAUD6AFAVMOBZTSK",
315
+ derivationMode: "sep5",
316
+ index: 1,
317
+ freshAddress: "",
318
+ freshAddressPath: "44'/148'/1'",
319
+ balance: "0",
320
+ blockHeight: 0,
321
+ currencyId: "stellar",
322
+ lastSyncDate: "",
323
+ operations: [],
324
+ pendingOperations: [],
325
+ },
326
+ },
327
+ {
328
+ FIXME_tests: ["balance is sum of ops"],
329
+ raw: {
330
+ id: "libcore:1:stellar:GAS5NQ2VU6LA3QPDSCVBH66IHP2RE52VFCLFQKSGRF7VKMZA2KTLGI3M:sep5",
331
+ seedIdentifier: "25d6c355a7960dc1e390aa13fbc83bf51277552896582a46897f553320d2a6b3",
332
+ name: "Stellar 4",
333
+ xpub: "GAS5NQ2VU6LA3QPDSCVBH66IHP2RE52VFCLFQKSGRF7VKMZA2KTLGI3M",
334
+ derivationMode: "sep5",
335
+ index: 0,
336
+ freshAddress: "GAS5NQ2VU6LA3QPDSCVBH66IHP2RE52VFCLFQKSGRF7VKMZA2KTLGI3M",
337
+ freshAddressPath: "44'/148'/0'",
338
+ balance: "0",
339
+ blockHeight: 0,
340
+ currencyId: "stellar",
341
+ lastSyncDate: "",
342
+ operations: [],
343
+ pendingOperations: [],
344
+ },
345
+ transactions: [
346
+ {
347
+ name: "check spendable balance (selling_liabilities is not zero)",
348
+ transaction: t => ({
349
+ ...t,
350
+ useAllAmount: true,
351
+ fees: new BigNumber("0"),
352
+ recipient: "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
353
+ }),
354
+ expectedStatus: {
355
+ // You can get the spendable balance here
356
+ // https://stellar.expert/explorer/public/account/GAS5NQ2VU6LA3QPDSCVBH66IHP2RE52VFCLFQKSGRF7VKMZA2KTLGI3M
357
+ amount: new BigNumber(12486627),
358
+ errors: {},
359
+ warnings: {},
360
+ },
361
+ },
362
+ ],
363
+ },
364
+ ],
365
+ },
366
+ },
367
+ };
368
+
369
+ describe("Stellar bridge", () => {
370
+ test.todo(
371
+ "This is an empty test to make jest command pass. Remove it once there is a real test.",
372
+ );
373
+ });
@@ -0,0 +1,77 @@
1
+ import type { Account, AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
2
+ import {
3
+ defaultUpdateTransaction,
4
+ makeAccountBridgeReceive,
5
+ makeScanAccounts,
6
+ makeSync,
7
+ } from "@ledgerhq/coin-framework/bridge/jsHelpers";
8
+ import { estimateMaxSpendable } from "../estimateMaxSpendable";
9
+ import { getTransactionStatus } from "../getTransactionStatus";
10
+ import type { StellarSigner, Transaction, TransactionStatus } from "../types";
11
+ import { prepareTransaction } from "../prepareTransaction";
12
+ import { createTransaction } from "../createTransaction";
13
+ import { buildSignOperation } from "../signOperation";
14
+ import { broadcast } from "../broadcast";
15
+ import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
16
+ import resolver from "../hw-getAddress";
17
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
18
+ import { getAccountShape } from "../synchronization";
19
+ import { CoinConfig } from "@ledgerhq/coin-framework/config";
20
+ import { StellarCoinConfig, setCoinConfig } from "../config";
21
+
22
+ const PRELOAD_MAX_AGE = 30 * 60 * 1000; // 30 minutes
23
+
24
+ function buildCurrencyBridge(signerContext: SignerContext<StellarSigner>): CurrencyBridge {
25
+ const getAddress = resolver(signerContext);
26
+
27
+ const scanAccounts = makeScanAccounts({
28
+ getAccountShape,
29
+ getAddressFn: getAddress,
30
+ });
31
+
32
+ function getPreloadStrategy() {
33
+ return {
34
+ preloadMaxAge: PRELOAD_MAX_AGE,
35
+ };
36
+ }
37
+
38
+ return {
39
+ getPreloadStrategy,
40
+ preload: async () => {},
41
+ hydrate: () => {},
42
+ scanAccounts,
43
+ };
44
+ }
45
+
46
+ function buildAccountBridge(signerContext: SignerContext<StellarSigner>) {
47
+ const getAddress = resolver(signerContext);
48
+ const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
49
+ const signOperation = buildSignOperation(signerContext);
50
+ const sync = makeSync({ getAccountShape });
51
+
52
+ const accountBridge: AccountBridge<Transaction, Account, TransactionStatus> = {
53
+ createTransaction,
54
+ updateTransaction: defaultUpdateTransaction,
55
+ prepareTransaction,
56
+ estimateMaxSpendable,
57
+ getTransactionStatus,
58
+ sync,
59
+ receive,
60
+ signOperation,
61
+ broadcast,
62
+ };
63
+
64
+ return accountBridge;
65
+ }
66
+
67
+ export function createBridges(
68
+ signerContext: SignerContext<StellarSigner>,
69
+ coinConfig: CoinConfig<StellarCoinConfig>,
70
+ ) {
71
+ setCoinConfig(coinConfig);
72
+
73
+ return {
74
+ currencyBridge: buildCurrencyBridge(signerContext),
75
+ accountBridge: buildAccountBridge(signerContext),
76
+ };
77
+ }
@@ -0,0 +1,20 @@
1
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
2
+ import type { AccountBridge, Operation, SignedOperation } from "@ledgerhq/types-live";
3
+ import { broadcastTransaction as apiBroadcast } from "./network";
4
+ import { Transaction } from "./types";
5
+
6
+ /**
7
+ * Broadcast a signed transaction
8
+ * @param {signature: string, operation: string} signedOperation
9
+ */
10
+ export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
11
+ signedOperation,
12
+ }: {
13
+ signedOperation: SignedOperation;
14
+ }): Promise<Operation> => {
15
+ const { signature, operation } = signedOperation;
16
+ const hash = await apiBroadcast(signature);
17
+ return patchOperationWithHash(operation, hash);
18
+ };
19
+
20
+ export default broadcast;