@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.
- package/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +3 -6
- package/CHANGELOG.md +24 -0
- package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts +2 -0
- package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/buildOptimisticOperation.test.js +23 -0
- package/lib/__tests__/bridge/buildOptimisticOperation.test.js.map +1 -0
- package/lib/__tests__/bridge/buildTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/buildTransaction.test.js +412 -0
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/createTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/createTransaction.test.js +22 -0
- package/lib/__tests__/bridge/createTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js +21 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js +108 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +211 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.js +214 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib/__tests__/bridge/logic.test.d.ts +2 -0
- package/lib/__tests__/bridge/logic.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/logic.test.js +490 -0
- package/lib/__tests__/bridge/logic.test.js.map +1 -0
- package/lib/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/prepareTransaction.test.js +239 -0
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib/bridge/buildOptimisticOperation.js +6 -3
- package/lib/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +29 -6
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +9 -1
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/fixtures.d.ts +36 -0
- package/lib/bridge/fixtures.d.ts.map +1 -0
- package/lib/bridge/fixtures.js +98 -0
- package/lib/bridge/fixtures.js.map +1 -0
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +32 -5
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +18 -4
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +33 -4
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/serialization.d.ts.map +1 -1
- package/lib/bridge/serialization.js +10 -8
- package/lib/bridge/serialization.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +11 -3
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +8 -3
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +8 -0
- package/lib/config.js.map +1 -1
- package/lib/constants.d.ts +6 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +15 -0
- package/lib/constants.js.map +1 -0
- package/lib/network/hubble.js +1 -1
- package/lib/network/hubble.js.map +1 -1
- package/lib/types/types.d.ts +3 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js +18 -0
- package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js.map +1 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.js +407 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/createTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/createTransaction.test.js +17 -0
- package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +16 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +103 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +206 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +209 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib-es/__tests__/bridge/logic.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/logic.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/logic.test.js +485 -0
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +234 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.js +6 -3
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +29 -6
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +10 -2
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/fixtures.d.ts +36 -0
- package/lib-es/bridge/fixtures.d.ts.map +1 -0
- package/lib-es/bridge/fixtures.js +89 -0
- package/lib-es/bridge/fixtures.js.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +29 -5
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +18 -4
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +33 -4
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts.map +1 -1
- package/lib-es/bridge/serialization.js +10 -8
- package/lib-es/bridge/serialization.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +11 -3
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +8 -3
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +8 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/constants.d.ts +6 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +11 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/network/hubble.js +1 -1
- package/lib-es/network/hubble.js.map +1 -1
- package/lib-es/types/types.d.ts +3 -2
- package/lib-es/types/types.d.ts.map +1 -1
- package/lib-es/types/types.js.map +1 -1
- package/package.json +13 -12
- package/src/__tests__/bridge/buildOptimisticOperation.test.ts +29 -0
- package/src/__tests__/bridge/buildTransaction.test.ts +502 -0
- package/src/__tests__/bridge/createTransaction.test.ts +17 -0
- package/src/__tests__/bridge/deviceTransactionConfig.test.ts +16 -0
- package/src/__tests__/bridge/estimateMaxSpendable.test.ts +112 -0
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +233 -0
- package/src/__tests__/bridge/getTransactionStatus.test.ts +261 -0
- package/src/__tests__/bridge/logic.test.ts +538 -0
- package/src/__tests__/bridge/prepareTransaction.test.ts +261 -0
- package/src/bridge/buildOptimisticOperation.ts +7 -3
- package/src/bridge/buildTransaction.ts +38 -7
- package/src/bridge/estimateMaxSpendable.ts +18 -2
- package/src/bridge/fixtures.ts +103 -0
- package/src/bridge/getFeesForTransaction.ts +39 -5
- package/src/bridge/getTransactionStatus.ts +21 -4
- package/src/bridge/index.ts +0 -1
- package/src/bridge/prepareTransaction.ts +39 -6
- package/src/bridge/serialization.ts +12 -8
- package/src/bridge/signOperation.ts +19 -4
- package/src/bridge/synchronisation.ts +11 -4
- package/src/config.ts +8 -0
- package/src/constants.ts +15 -0
- package/src/logic.ts +1 -1
- package/src/network/hubble.ts +1 -1
- package/src/types/types.ts +3 -2
- package/lib/test/please-add-coverage.test.d.ts +0 -2
- package/lib/test/please-add-coverage.test.d.ts.map +0 -1
- package/lib/test/please-add-coverage.test.js +0 -6
- package/lib/test/please-add-coverage.test.js.map +0 -1
- package/lib-es/test/please-add-coverage.test.d.ts +0 -1
- package/lib-es/test/please-add-coverage.test.d.ts.map +0 -1
- package/lib-es/test/please-add-coverage.test.js +0 -5
- package/lib-es/test/please-add-coverage.test.js.map +0 -1
- 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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
+
return extra;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
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
|
-
|
|
106
|
+
return extraRaw;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
celoOperationValue
|
|
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(
|
|
44
|
+
return signer.verifyTokenInfo(
|
|
45
|
+
isTokenTransaction ? subAccount.token.contractAddress : to!,
|
|
46
|
+
chainId!,
|
|
47
|
+
);
|
|
40
48
|
});
|
|
41
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
};
|
package/src/constants.ts
ADDED
|
@@ -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";
|
package/src/network/hubble.ts
CHANGED
|
@@ -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
|
: {}),
|
package/src/types/types.ts
CHANGED
|
@@ -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
|
|
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
|
|
151
|
+
celoOperationValue?: string;
|
|
151
152
|
celoSourceValidator?: string;
|
|
152
153
|
};
|
|
153
154
|
export function isCeloOperationExtraRaw(op: OperationExtraRaw): op is CeloOperationExtraRaw {
|
|
@@ -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 +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 +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"}
|