@ledgerhq/coin-celo 1.3.0 → 1.4.0-nightly.1

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 (200) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +3 -6
  3. package/CHANGELOG.md +24 -0
  4. package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts +2 -0
  5. package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
  6. package/lib/__tests__/bridge/buildOptimisticOperation.test.js +23 -0
  7. package/lib/__tests__/bridge/buildOptimisticOperation.test.js.map +1 -0
  8. package/lib/__tests__/bridge/buildTransaction.test.d.ts +2 -0
  9. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
  10. package/lib/__tests__/bridge/buildTransaction.test.js +412 -0
  11. package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -0
  12. package/lib/__tests__/bridge/createTransaction.test.d.ts +2 -0
  13. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
  14. package/lib/__tests__/bridge/createTransaction.test.js +22 -0
  15. package/lib/__tests__/bridge/createTransaction.test.js.map +1 -0
  16. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  17. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  18. package/lib/__tests__/bridge/deviceTransactionConfig.test.js +21 -0
  19. package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  20. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  21. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  22. package/lib/__tests__/bridge/estimateMaxSpendable.test.js +108 -0
  23. package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  24. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  25. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  26. package/lib/__tests__/bridge/getFeesForTransaction.test.js +211 -0
  27. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  28. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  29. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  30. package/lib/__tests__/bridge/getTransactionStatus.test.js +214 -0
  31. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  32. package/lib/__tests__/bridge/logic.test.d.ts +2 -0
  33. package/lib/__tests__/bridge/logic.test.d.ts.map +1 -0
  34. package/lib/__tests__/bridge/logic.test.js +490 -0
  35. package/lib/__tests__/bridge/logic.test.js.map +1 -0
  36. package/lib/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  37. package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  38. package/lib/__tests__/bridge/prepareTransaction.test.js +239 -0
  39. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  40. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
  41. package/lib/bridge/buildOptimisticOperation.js +6 -3
  42. package/lib/bridge/buildOptimisticOperation.js.map +1 -1
  43. package/lib/bridge/buildTransaction.d.ts.map +1 -1
  44. package/lib/bridge/buildTransaction.js +29 -6
  45. package/lib/bridge/buildTransaction.js.map +1 -1
  46. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  47. package/lib/bridge/estimateMaxSpendable.js +9 -1
  48. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  49. package/lib/bridge/fixtures.d.ts +36 -0
  50. package/lib/bridge/fixtures.d.ts.map +1 -0
  51. package/lib/bridge/fixtures.js +98 -0
  52. package/lib/bridge/fixtures.js.map +1 -0
  53. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  54. package/lib/bridge/getFeesForTransaction.js +32 -5
  55. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  56. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  57. package/lib/bridge/getTransactionStatus.js +18 -4
  58. package/lib/bridge/getTransactionStatus.js.map +1 -1
  59. package/lib/bridge/index.d.ts.map +1 -1
  60. package/lib/bridge/index.js.map +1 -1
  61. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  62. package/lib/bridge/prepareTransaction.js +33 -4
  63. package/lib/bridge/prepareTransaction.js.map +1 -1
  64. package/lib/bridge/serialization.d.ts.map +1 -1
  65. package/lib/bridge/serialization.js +10 -8
  66. package/lib/bridge/serialization.js.map +1 -1
  67. package/lib/bridge/signOperation.d.ts.map +1 -1
  68. package/lib/bridge/signOperation.js +11 -3
  69. package/lib/bridge/signOperation.js.map +1 -1
  70. package/lib/bridge/synchronisation.d.ts.map +1 -1
  71. package/lib/bridge/synchronisation.js +8 -3
  72. package/lib/bridge/synchronisation.js.map +1 -1
  73. package/lib/config.d.ts.map +1 -1
  74. package/lib/config.js +8 -0
  75. package/lib/config.js.map +1 -1
  76. package/lib/constants.d.ts +6 -0
  77. package/lib/constants.d.ts.map +1 -0
  78. package/lib/constants.js +15 -0
  79. package/lib/constants.js.map +1 -0
  80. package/lib/network/hubble.js +1 -1
  81. package/lib/network/hubble.js.map +1 -1
  82. package/lib/types/types.d.ts +3 -2
  83. package/lib/types/types.d.ts.map +1 -1
  84. package/lib/types/types.js.map +1 -1
  85. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts +2 -0
  86. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
  87. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js +18 -0
  88. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js.map +1 -0
  89. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts +2 -0
  90. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
  91. package/lib-es/__tests__/bridge/buildTransaction.test.js +407 -0
  92. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -0
  93. package/lib-es/__tests__/bridge/createTransaction.test.d.ts +2 -0
  94. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
  95. package/lib-es/__tests__/bridge/createTransaction.test.js +17 -0
  96. package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -0
  97. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  98. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  99. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +16 -0
  100. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  101. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  102. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  103. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +103 -0
  104. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  105. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  106. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  107. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +206 -0
  108. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  109. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  110. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  111. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +209 -0
  112. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  113. package/lib-es/__tests__/bridge/logic.test.d.ts +2 -0
  114. package/lib-es/__tests__/bridge/logic.test.d.ts.map +1 -0
  115. package/lib-es/__tests__/bridge/logic.test.js +485 -0
  116. package/lib-es/__tests__/bridge/logic.test.js.map +1 -0
  117. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  118. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  119. package/lib-es/__tests__/bridge/prepareTransaction.test.js +234 -0
  120. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  121. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
  122. package/lib-es/bridge/buildOptimisticOperation.js +6 -3
  123. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
  124. package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
  125. package/lib-es/bridge/buildTransaction.js +29 -6
  126. package/lib-es/bridge/buildTransaction.js.map +1 -1
  127. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  128. package/lib-es/bridge/estimateMaxSpendable.js +10 -2
  129. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  130. package/lib-es/bridge/fixtures.d.ts +36 -0
  131. package/lib-es/bridge/fixtures.d.ts.map +1 -0
  132. package/lib-es/bridge/fixtures.js +89 -0
  133. package/lib-es/bridge/fixtures.js.map +1 -0
  134. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  135. package/lib-es/bridge/getFeesForTransaction.js +29 -5
  136. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  137. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  138. package/lib-es/bridge/getTransactionStatus.js +18 -4
  139. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  140. package/lib-es/bridge/index.d.ts.map +1 -1
  141. package/lib-es/bridge/index.js.map +1 -1
  142. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  143. package/lib-es/bridge/prepareTransaction.js +33 -4
  144. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  145. package/lib-es/bridge/serialization.d.ts.map +1 -1
  146. package/lib-es/bridge/serialization.js +10 -8
  147. package/lib-es/bridge/serialization.js.map +1 -1
  148. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  149. package/lib-es/bridge/signOperation.js +11 -3
  150. package/lib-es/bridge/signOperation.js.map +1 -1
  151. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  152. package/lib-es/bridge/synchronisation.js +8 -3
  153. package/lib-es/bridge/synchronisation.js.map +1 -1
  154. package/lib-es/config.d.ts.map +1 -1
  155. package/lib-es/config.js +8 -0
  156. package/lib-es/config.js.map +1 -1
  157. package/lib-es/constants.d.ts +6 -0
  158. package/lib-es/constants.d.ts.map +1 -0
  159. package/lib-es/constants.js +11 -0
  160. package/lib-es/constants.js.map +1 -0
  161. package/lib-es/network/hubble.js +1 -1
  162. package/lib-es/network/hubble.js.map +1 -1
  163. package/lib-es/types/types.d.ts +3 -2
  164. package/lib-es/types/types.d.ts.map +1 -1
  165. package/lib-es/types/types.js.map +1 -1
  166. package/package.json +13 -12
  167. package/src/__tests__/bridge/buildOptimisticOperation.test.ts +29 -0
  168. package/src/__tests__/bridge/buildTransaction.test.ts +502 -0
  169. package/src/__tests__/bridge/createTransaction.test.ts +17 -0
  170. package/src/__tests__/bridge/deviceTransactionConfig.test.ts +16 -0
  171. package/src/__tests__/bridge/estimateMaxSpendable.test.ts +112 -0
  172. package/src/__tests__/bridge/getFeesForTransaction.test.ts +233 -0
  173. package/src/__tests__/bridge/getTransactionStatus.test.ts +261 -0
  174. package/src/__tests__/bridge/logic.test.ts +538 -0
  175. package/src/__tests__/bridge/prepareTransaction.test.ts +261 -0
  176. package/src/bridge/buildOptimisticOperation.ts +7 -3
  177. package/src/bridge/buildTransaction.ts +38 -7
  178. package/src/bridge/estimateMaxSpendable.ts +18 -2
  179. package/src/bridge/fixtures.ts +103 -0
  180. package/src/bridge/getFeesForTransaction.ts +39 -5
  181. package/src/bridge/getTransactionStatus.ts +21 -4
  182. package/src/bridge/index.ts +0 -1
  183. package/src/bridge/prepareTransaction.ts +39 -6
  184. package/src/bridge/serialization.ts +12 -8
  185. package/src/bridge/signOperation.ts +19 -4
  186. package/src/bridge/synchronisation.ts +11 -4
  187. package/src/config.ts +8 -0
  188. package/src/constants.ts +15 -0
  189. package/src/logic.ts +1 -1
  190. package/src/network/hubble.ts +1 -1
  191. package/src/types/types.ts +3 -2
  192. package/lib/test/please-add-coverage.test.d.ts +0 -2
  193. package/lib/test/please-add-coverage.test.d.ts.map +0 -1
  194. package/lib/test/please-add-coverage.test.js +0 -6
  195. package/lib/test/please-add-coverage.test.js.map +0 -1
  196. package/lib-es/test/please-add-coverage.test.d.ts +0 -1
  197. package/lib-es/test/please-add-coverage.test.d.ts.map +0 -1
  198. package/lib-es/test/please-add-coverage.test.js +0 -5
  199. package/lib-es/test/please-add-coverage.test.js.map +0 -1
  200. package/src/test/please-add-coverage.test.ts +0 -3
@@ -1,15 +1,18 @@
1
- import BigNumber from "bignumber.js";
2
1
  import { AccountBridge } from "@ledgerhq/types-live";
2
+ import BigNumber from "bignumber.js";
3
3
  import { isValidAddress } from "@celo/utils/lib/address";
4
4
  import getFeesForTransaction from "./getFeesForTransaction";
5
5
  import { CeloAccount, Transaction } from "../types";
6
-
7
- const sameFees = (a: BigNumber | null | undefined, b: BigNumber) => (!a || !b ? a === b : a.eq(b));
6
+ import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
7
+ import { CELO_STABLE_TOKENS, MAX_PRIORITY_FEE_PER_GAS } from "../constants";
8
+ import { celoKit } from "../network/sdk";
8
9
 
9
10
  export const prepareTransaction: AccountBridge<
10
11
  Transaction,
11
12
  CeloAccount
12
13
  >["prepareTransaction"] = async (account, transaction) => {
14
+ const kit = celoKit();
15
+
13
16
  if (transaction.recipient && !isValidAddress(transaction.recipient)) return transaction;
14
17
 
15
18
  if (["send", "vote"].includes(transaction.mode) && !transaction.recipient) return transaction;
@@ -23,11 +26,41 @@ export const prepareTransaction: AccountBridge<
23
26
 
24
27
  const fees = await getFeesForTransaction({ account, transaction });
25
28
 
26
- if (!sameFees(transaction.fees, fees)) {
27
- return { ...transaction, fees };
29
+ const tokenAccount = findSubAccountById(account, transaction.subAccountId || "");
30
+ const isTokenTransaction = tokenAccount?.type === "TokenAccount";
31
+
32
+ const amount =
33
+ transaction.useAllAmount && isTokenTransaction ? tokenAccount.balance : transaction.amount;
34
+
35
+ let token;
36
+ if (isTokenTransaction) {
37
+ if (CELO_STABLE_TOKENS.includes(tokenAccount.token.id)) {
38
+ token = await kit.contracts.getStableToken();
39
+ } else {
40
+ token = await kit.contracts.getErc20(tokenAccount.token.contractAddress);
41
+ }
42
+ } else {
43
+ token = await kit.contracts.getGoldToken();
28
44
  }
29
45
 
30
- return transaction;
46
+ const block = await kit.connection.web3.eth.getBlock("latest");
47
+ const baseFee = BigInt(block.baseFeePerGas || MAX_PRIORITY_FEE_PER_GAS);
48
+ const maxFeePerGas = baseFee + MAX_PRIORITY_FEE_PER_GAS;
49
+
50
+ return {
51
+ ...transaction,
52
+ amount,
53
+ fees,
54
+ maxFeePerGas: maxFeePerGas.toString(),
55
+ maxPriorityFeePerGas: await kit.connection.getMaxPriorityFeePerGas(),
56
+ ...(isTokenTransaction
57
+ ? {
58
+ data: Buffer.from(
59
+ token.transfer(transaction.recipient, amount.toFixed()).txo.encodeABI(),
60
+ ),
61
+ }
62
+ : {}),
63
+ };
31
64
  };
32
65
 
33
66
  export default prepareTransaction;
@@ -82,13 +82,15 @@ export function assignFromAccountRaw(accountRaw: AccountRaw, account: Account) {
82
82
  }
83
83
 
84
84
  export function fromOperationExtraRaw(extraRaw: OperationExtraRaw): OperationExtra {
85
+ const extra: CeloOperationExtra = {};
86
+
85
87
  if (!isCeloOperationExtraRaw(extraRaw)) {
86
- throw new Error("Unsupported OperationExtra");
88
+ return extra;
87
89
  }
88
90
 
89
- const extra: CeloOperationExtra = {
90
- celoOperationValue: new BigNumber(extraRaw.celoOperationValue),
91
- };
91
+ if (extraRaw.celoOperationValue) {
92
+ extra.celoOperationValue = BigNumber(extraRaw.celoOperationValue);
93
+ }
92
94
 
93
95
  if (extraRaw.celoSourceValidator) {
94
96
  extra.celoSourceValidator = extraRaw.celoSourceValidator;
@@ -98,13 +100,15 @@ export function fromOperationExtraRaw(extraRaw: OperationExtraRaw): OperationExt
98
100
  }
99
101
 
100
102
  export function toOperationExtraRaw(extra: OperationExtra): OperationExtraRaw {
103
+ const extraRaw: CeloOperationExtraRaw = {};
104
+
101
105
  if (!isCeloOperationExtra(extra)) {
102
- throw new Error("Unsupported OperationExtra");
106
+ return extraRaw;
103
107
  }
104
108
 
105
- const extraRaw: CeloOperationExtraRaw = {
106
- celoOperationValue: extra.celoOperationValue.toString(),
107
- };
109
+ if (extra.celoOperationValue) {
110
+ extraRaw.celoOperationValue = extra.celoOperationValue.toString();
111
+ }
108
112
 
109
113
  if (extra.celoSourceValidator) {
110
114
  extraRaw.celoSourceValidator = extra.celoSourceValidator;
@@ -3,7 +3,7 @@ import { Observable } from "rxjs";
3
3
  import { FeeNotLoaded } from "@ledgerhq/errors";
4
4
  import type { Account, AccountBridge, DeviceId, SignOperationEvent } from "@ledgerhq/types-live";
5
5
  import { encodeTransaction, recoverTransaction } from "@celo/wallet-base";
6
-
6
+ import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
7
7
  import { buildOptimisticOperation } from "./buildOptimisticOperation";
8
8
  import type { Transaction, CeloAccount } from "../types/types";
9
9
  import buildTransaction from "./buildTransaction";
@@ -11,6 +11,7 @@ import { SignerContext } from "@ledgerhq/coin-framework/signer";
11
11
  import { EvmSignature } from "@ledgerhq/coin-evm/types/signer";
12
12
  import { determineFees } from "../network/sdk";
13
13
  import { CeloSigner } from "../signer";
14
+ import { CeloTx } from "@celo/connect";
14
15
 
15
16
  /**
16
17
  * Sign Transaction with Ledger hardware
@@ -33,15 +34,29 @@ export const buildSignOperation =
33
34
  const { fees } = transaction;
34
35
  if (!fees) throw new FeeNotLoaded();
35
36
  const unsignedTransaction = await buildTransaction(account as CeloAccount, transaction);
37
+
36
38
  const { chainId, to } = unsignedTransaction;
37
39
 
40
+ const subAccount = findSubAccountById(account, transaction.subAccountId ?? "");
41
+ const isTokenTransaction = subAccount?.type === "TokenAccount";
42
+
38
43
  await signerContext(deviceId, signer => {
39
- return signer.verifyTokenInfo(to!, chainId!);
44
+ return signer.verifyTokenInfo(
45
+ isTokenTransaction ? subAccount.token.contractAddress : to!,
46
+ chainId!,
47
+ );
40
48
  });
41
- await determineFees(unsignedTransaction);
49
+
50
+ const finalTransaction: CeloTx = {
51
+ ...unsignedTransaction,
52
+ to: isTokenTransaction ? subAccount.token.contractAddress : to!,
53
+ value: isTokenTransaction ? 0 : unsignedTransaction.value!,
54
+ };
55
+
56
+ await determineFees(finalTransaction);
42
57
 
43
58
  const rlpEncodedTransaction = await signerContext(deviceId, signer => {
44
- return signer.rlpEncodedTxForLedger(unsignedTransaction);
59
+ return signer.rlpEncodedTxForLedger(finalTransaction);
45
60
  });
46
61
  o.next({ type: "device-signature-requested" });
47
62
 
@@ -2,13 +2,15 @@ import { getAccountRegistrationStatus, getPendingWithdrawals, getVotes } from ".
2
2
  import { makeSync, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
3
3
  import type { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers";
4
4
  import { encodeAccountId } from "@ledgerhq/coin-framework/account";
5
+ import { getEnv } from "@ledgerhq/live-env";
5
6
  import { getAccountDetails } from "../network";
6
7
  import { CeloAccount } from "../types/types";
7
8
  import { celoKit } from "../network/sdk";
9
+ import { getAccountShape as evmGetAccountShape } from "@ledgerhq/coin-evm/bridge/synchronization";
8
10
 
9
11
  const kit = celoKit();
10
12
 
11
- export const getAccountShape: GetAccountShape<CeloAccount> = async info => {
13
+ export const getAccountShape: GetAccountShape<CeloAccount> = async (info, config) => {
12
14
  const { address, currency, initialAccount, derivationMode } = info;
13
15
  const oldOperations = initialAccount?.operations || [];
14
16
  const election = await kit.contracts.getElection();
@@ -36,13 +38,18 @@ export const getAccountShape: GetAccountShape<CeloAccount> = async info => {
36
38
 
37
39
  const votes = accountRegistrationStatus ? await getVotes(address) : [];
38
40
 
41
+ const fromEvm = await evmGetAccountShape(info, config);
42
+
39
43
  const operations = mergeOps(oldOperations, newOperations);
40
- const shape = {
44
+
45
+ const shape: Partial<CeloAccount> = {
41
46
  id: accountId,
42
47
  balance,
43
- spendableBalance,
44
- operationsCount: operations.length,
45
48
  blockHeight,
49
+ operationsCount: operations.length,
50
+ spendableBalance,
51
+ subAccounts: getEnv("ENABLE_CELO_TOKENS") === false ? [] : fromEvm.subAccounts || [],
52
+ syncHash: fromEvm.syncHash,
46
53
  celoResources: {
47
54
  registrationStatus: accountRegistrationStatus,
48
55
  lockedBalance,
package/src/config.ts CHANGED
@@ -7,6 +7,14 @@ export const celoConfig: Record<string, ConfigInfo> = {
7
7
  status: {
8
8
  type: "active",
9
9
  },
10
+ node: {
11
+ type: "external",
12
+ uri: "https://celo.coin.ledger.com/archive",
13
+ },
14
+ explorer: {
15
+ type: "blockscout",
16
+ uri: "https://celo.blockscout.com/api",
17
+ },
10
18
  },
11
19
  },
12
20
  };
@@ -0,0 +1,15 @@
1
+ import { StableToken } from "@celo/contractkit";
2
+
3
+ const CELO_STAKE_TOKENS_PAIR: Record<string, StableToken> = {
4
+ cEUR: StableToken.cEUR,
5
+ cREAL: StableToken.cREAL,
6
+ cUSD: StableToken.cUSD,
7
+ };
8
+
9
+ export const CELO_STABLE_TOKENS = Object.keys(CELO_STAKE_TOKENS_PAIR);
10
+
11
+ export const getStableTokenEnum = (tokenTicker: string): StableToken =>
12
+ CELO_STAKE_TOKENS_PAIR[tokenTicker];
13
+
14
+ export const MAX_PRIORITY_FEE_PER_GAS = 1_000_000_000n;
15
+ export const MAX_FEES_THRESHOLD_MULTIPLIER = 4;
package/src/logic.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  PendingStakingOperationAmounts,
8
8
  } from "./types/types";
9
9
  import { BigNumber } from "bignumber.js";
10
- import { Operation } from "@ledgerhq/types-live";
10
+ import { Account, Operation, TokenAccount } from "@ledgerhq/types-live";
11
11
 
12
12
  export const PRELOAD_MAX_AGE = 10 * 60 * 1000; // 10 minutes, used for max age in preload strategy
13
13
  const LEDGER_BY_FIGMENT_VALIDATOR_GROUP_ADDRESS = "0x0861a61Bf679A30680510EcC238ee43B82C5e843";
@@ -99,9 +99,9 @@ const transactionToOperation = (
99
99
  hasFailed,
100
100
  blockHash: null,
101
101
  extra: {
102
- celoOperationValue: new BigNumber(transaction.amount),
103
102
  ...(["ACTIVATE", "VOTE", "REVOKE"].includes(type)
104
103
  ? {
104
+ celoOperationValue: new BigNumber(transaction.amount),
105
105
  celoSourceValidator: recipient ? recipient : "",
106
106
  }
107
107
  : {}),
@@ -60,6 +60,7 @@ export type Transaction = TransactionCommon & {
60
60
  fees: BigNumber | null | undefined;
61
61
  mode: CeloOperationMode;
62
62
  index: number | null | undefined;
63
+ data?: Buffer | null | undefined;
63
64
  };
64
65
  export type TransactionRaw = TransactionCommonRaw & {
65
66
  family: "celo";
@@ -140,14 +141,14 @@ export type CeloOperation = Operation<CeloOperationExtra>;
140
141
  export type CeloOperationRaw = OperationRaw<CeloOperationExtraRaw>;
141
142
 
142
143
  export type CeloOperationExtra = {
143
- celoOperationValue: BigNumber;
144
+ celoOperationValue?: BigNumber;
144
145
  celoSourceValidator?: string;
145
146
  };
146
147
  export function isCeloOperationExtra(op: OperationExtra): op is CeloOperationExtra {
147
148
  return op !== null && typeof op === "object" && "celoOperationValue" in op;
148
149
  }
149
150
  export type CeloOperationExtraRaw = {
150
- celoOperationValue: string;
151
+ celoOperationValue?: string;
151
152
  celoSourceValidator?: string;
152
153
  };
153
154
  export function isCeloOperationExtraRaw(op: OperationExtraRaw): op is CeloOperationExtraRaw {
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=please-add-coverage.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"please-add-coverage.test.d.ts","sourceRoot":"","sources":["../../src/test/please-add-coverage.test.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- describe("Celo", () => {
4
- it.todo("should be tested");
5
- });
6
- //# sourceMappingURL=please-add-coverage.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"please-add-coverage.test.js","sourceRoot":"","sources":["../../src/test/please-add-coverage.test.ts"],"names":[],"mappings":";;AAAA,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=please-add-coverage.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"please-add-coverage.test.d.ts","sourceRoot":"","sources":["../../src/test/please-add-coverage.test.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- describe("Celo", () => {
3
- it.todo("should be tested");
4
- });
5
- //# sourceMappingURL=please-add-coverage.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"please-add-coverage.test.js","sourceRoot":"","sources":["../../src/test/please-add-coverage.test.ts"],"names":[],"mappings":";AAAA,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- describe("Celo", () => {
2
- it.todo("should be tested");
3
- });