@ledgerhq/live-common 21.30.0 → 21.32.0-hotfix.2
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/lib/__tests__/test-helpers/setup.js +1 -0
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/support.d.ts.map +1 -1
- package/lib/account/support.js.map +1 -1
- package/lib/bot/engine.js +1 -1
- package/lib/bot/engine.js.map +1 -1
- package/lib/bridge/jsHelpers.js +1 -1
- package/lib/data/icons/react/celo.d.ts +8 -0
- package/lib/data/icons/react/celo.d.ts.map +1 -0
- package/lib/data/icons/react/celo.js +32 -0
- package/lib/data/icons/react/celo.js.map +1 -0
- package/lib/data/icons/react/index.d.ts +1 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +11 -8
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/reactNative/celo.d.ts +8 -0
- package/lib/data/icons/reactNative/celo.d.ts.map +1 -0
- package/lib/data/icons/reactNative/celo.js +33 -0
- package/lib/data/icons/reactNative/celo.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +1 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +11 -8
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/env.d.ts +15 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +10 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +4 -4
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +61 -22
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +2 -3
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +75 -35
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/celo/api/hubble.d.ts +8 -0
- package/lib/families/celo/api/hubble.d.ts.map +1 -0
- package/lib/families/celo/api/hubble.js +144 -0
- package/lib/families/celo/api/hubble.js.map +1 -0
- package/lib/families/celo/api/index.d.ts +2 -0
- package/lib/families/celo/api/index.d.ts.map +1 -0
- package/lib/families/celo/api/index.js +13 -0
- package/lib/families/celo/api/index.js.map +1 -0
- package/lib/families/celo/api/sdk.d.ts +3 -0
- package/lib/families/celo/api/sdk.d.ts.map +1 -0
- package/lib/families/celo/api/sdk.js +13 -0
- package/lib/families/celo/api/sdk.js.map +1 -0
- package/lib/families/celo/bridge/js.d.ts +8 -0
- package/lib/families/celo/bridge/js.d.ts.map +1 -0
- package/lib/families/celo/bridge/js.js +87 -0
- package/lib/families/celo/bridge/js.js.map +1 -0
- package/lib/families/celo/cli-transaction.d.ts +14 -0
- package/lib/families/celo/cli-transaction.d.ts.map +1 -0
- package/lib/families/celo/cli-transaction.js +37 -0
- package/lib/families/celo/cli-transaction.js.map +1 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts +5 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts.map +1 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.js +12 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.js.map +1 -0
- package/lib/families/celo/deviceTransactionConfig.d.ts +4 -0
- package/lib/families/celo/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/families/celo/deviceTransactionConfig.js +16 -0
- package/lib/families/celo/deviceTransactionConfig.js.map +1 -0
- package/lib/families/celo/hw-app-celo.d.ts +19 -0
- package/lib/families/celo/hw-app-celo.d.ts.map +1 -0
- package/lib/families/celo/hw-app-celo.js +147 -0
- package/lib/families/celo/hw-app-celo.js.map +1 -0
- package/lib/families/celo/hw-getAddress.d.ts +2 -0
- package/lib/families/celo/hw-getAddress.d.ts.map +1 -0
- package/lib/families/celo/hw-getAddress.js +13 -0
- package/lib/families/celo/hw-getAddress.js.map +1 -0
- package/lib/families/celo/js-broadcast.d.ts +8 -0
- package/lib/families/celo/js-broadcast.d.ts.map +1 -0
- package/lib/families/celo/js-broadcast.js +58 -0
- package/lib/families/celo/js-broadcast.js.map +1 -0
- package/lib/families/celo/js-buildTransaction.d.ts +6 -0
- package/lib/families/celo/js-buildTransaction.d.ts.map +1 -0
- package/lib/families/celo/js-buildTransaction.js +89 -0
- package/lib/families/celo/js-buildTransaction.js.map +1 -0
- package/lib/families/celo/js-createTransaction.d.ts +4 -0
- package/lib/families/celo/js-createTransaction.d.ts.map +1 -0
- package/lib/families/celo/js-createTransaction.js +12 -0
- package/lib/families/celo/js-createTransaction.js.map +1 -0
- package/lib/families/celo/js-estimateMaxSpendable.d.ts +10 -0
- package/lib/families/celo/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/families/celo/js-estimateMaxSpendable.js +77 -0
- package/lib/families/celo/js-estimateMaxSpendable.js.map +1 -0
- package/lib/families/celo/js-getFeesForTransaction.d.ts +8 -0
- package/lib/families/celo/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib/families/celo/js-getFeesForTransaction.js +76 -0
- package/lib/families/celo/js-getFeesForTransaction.js.map +1 -0
- package/lib/families/celo/js-getTransactionStatus.d.ts +5 -0
- package/lib/families/celo/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/families/celo/js-getTransactionStatus.js +86 -0
- package/lib/families/celo/js-getTransactionStatus.js.map +1 -0
- package/lib/families/celo/js-prepareTransaction.d.ts +5 -0
- package/lib/families/celo/js-prepareTransaction.d.ts.map +1 -0
- package/lib/families/celo/js-prepareTransaction.js +76 -0
- package/lib/families/celo/js-prepareTransaction.js.map +1 -0
- package/lib/families/celo/js-signOperation.d.ts +13 -0
- package/lib/families/celo/js-signOperation.d.ts.map +1 -0
- package/lib/families/celo/js-signOperation.js +150 -0
- package/lib/families/celo/js-signOperation.js.map +1 -0
- package/lib/families/celo/js-synchronisation.d.ts +10 -0
- package/lib/families/celo/js-synchronisation.d.ts.map +1 -0
- package/lib/families/celo/js-synchronisation.js +88 -0
- package/lib/families/celo/js-synchronisation.js.map +1 -0
- package/lib/families/celo/specs.d.ts +7 -0
- package/lib/families/celo/specs.d.ts.map +1 -0
- package/lib/families/celo/specs.js +56 -0
- package/lib/families/celo/specs.js.map +1 -0
- package/lib/families/celo/speculos-deviceActions.d.ts +7 -0
- package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -0
- package/lib/families/celo/speculos-deviceActions.js +53 -0
- package/lib/families/celo/speculos-deviceActions.js.map +1 -0
- package/lib/families/celo/transaction.d.ts +11 -0
- package/lib/families/celo/transaction.d.ts.map +1 -0
- package/lib/families/celo/transaction.js +39 -0
- package/lib/families/celo/transaction.js.map +1 -0
- package/lib/families/celo/types.d.ts +16 -0
- package/lib/families/celo/types.d.ts.map +1 -0
- package/lib/families/celo/types.js +6 -0
- package/lib/families/celo/types.js.map +1 -0
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.d.ts +1 -0
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.d.ts.map +1 -1
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -0
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
- package/lib/families/ethereum/modules/erc1155.d.ts.map +1 -1
- package/lib/families/ethereum/modules/erc1155.js +8 -2
- package/lib/families/ethereum/modules/erc1155.js.map +1 -1
- package/lib/families/polkadot/cache.d.ts +1 -1
- package/lib/families/polkadot/cache.js +1 -1
- package/lib/families/solana/test-dataset.d.ts.map +1 -1
- package/lib/families/solana/test-dataset.js +211 -209
- package/lib/families/solana/test-dataset.js.map +1 -1
- package/lib/featureFlags/FeatureToggle.d.ts +10 -0
- package/lib/featureFlags/FeatureToggle.d.ts.map +1 -0
- package/lib/featureFlags/FeatureToggle.js +17 -0
- package/lib/featureFlags/FeatureToggle.js.map +1 -0
- package/lib/featureFlags/defaultFeatures.d.ts +3 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -0
- package/lib/featureFlags/defaultFeatures.js +9 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -0
- package/lib/featureFlags/index.d.ts +5 -0
- package/lib/featureFlags/index.d.ts.map +1 -0
- package/lib/featureFlags/index.js +17 -0
- package/lib/featureFlags/index.js.map +1 -0
- package/lib/featureFlags/provider.d.ts +13 -0
- package/lib/featureFlags/provider.d.ts.map +1 -0
- package/lib/featureFlags/provider.js +68 -0
- package/lib/featureFlags/provider.js.map +1 -0
- package/lib/featureFlags/types.d.ts +8 -0
- package/lib/featureFlags/types.d.ts.map +1 -0
- package/lib/featureFlags/types.js +3 -0
- package/lib/featureFlags/types.js.map +1 -0
- package/lib/featureFlags/useFeature.d.ts +3 -0
- package/lib/featureFlags/useFeature.d.ts.map +1 -0
- package/lib/featureFlags/useFeature.js +9 -0
- package/lib/featureFlags/useFeature.js.map +1 -0
- package/lib/generated/bridge/js.d.ts +4 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +24 -22
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +9 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/cli-transaction.js +24 -22
- package/lib/generated/cli-transaction.js.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +2 -0
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +22 -20
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/generated/hw-getAddress.d.ts +1 -0
- package/lib/generated/hw-getAddress.d.ts.map +1 -1
- package/lib/generated/hw-getAddress.js +26 -24
- package/lib/generated/hw-getAddress.js.map +1 -1
- package/lib/generated/specs.d.ts +3 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/generated/specs.js +24 -22
- package/lib/generated/specs.js.map +1 -1
- package/lib/generated/speculos-deviceActions.d.ts +3 -0
- package/lib/generated/speculos-deviceActions.d.ts.map +1 -1
- package/lib/generated/speculos-deviceActions.js +24 -22
- package/lib/generated/speculos-deviceActions.js.map +1 -1
- package/lib/generated/transaction.d.ts +5 -0
- package/lib/generated/transaction.d.ts.map +1 -1
- package/lib/generated/transaction.js +26 -24
- package/lib/generated/transaction.js.map +1 -1
- package/lib/generated/types.d.ts +12 -6
- package/lib/generated/types.d.ts.map +1 -1
- package/lib/generated/types.js +14 -12
- package/lib/generated/types.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/package.json +8 -5
- package/src/.DS_Store +0 -0
- package/src/{data/flags → __tests__}/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +0 -33226
- package/src/__tests__/test-helpers/setup.ts +1 -0
- package/src/account/support.ts +1 -0
- package/src/bot/engine.ts +1 -1
- package/src/bridge/jsHelpers.ts +1 -1
- package/src/data/icons/react/celo.tsx +12 -0
- package/src/data/icons/react/index.tsx +1 -0
- package/src/data/icons/reactNative/celo.tsx +13 -0
- package/src/data/icons/reactNative/index.tsx +1 -0
- package/src/data/icons/svg/CELO.svg +5 -0
- package/src/env.ts +10 -0
- package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +2 -2
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +21 -21
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +28 -29
- package/src/families/celo/api/hubble.ts +93 -0
- package/src/families/celo/api/index.ts +1 -0
- package/src/families/celo/api/sdk.ts +8 -0
- package/src/families/celo/bridge/js.ts +38 -0
- package/src/families/celo/cli-transaction.ts +41 -0
- package/src/families/celo/datasets/celo.scanAccounts.1.ts +20 -0
- package/src/families/celo/deviceTransactionConfig.ts +19 -0
- package/src/families/celo/hw-app-celo.ts +108 -0
- package/src/families/celo/hw-getAddress.ts +1 -0
- package/src/families/celo/js-broadcast.ts +12 -0
- package/src/families/celo/js-buildTransaction.ts +32 -0
- package/src/families/celo/js-createTransaction.ts +12 -0
- package/src/families/celo/js-estimateMaxSpendable.ts +28 -0
- package/src/families/celo/js-getFeesForTransaction.ts +38 -0
- package/src/families/celo/js-getTransactionStatus.ts +67 -0
- package/src/families/celo/js-prepareTransaction.ts +28 -0
- package/src/families/celo/js-signOperation.ts +149 -0
- package/src/families/celo/js-synchronisation.ts +40 -0
- package/src/families/celo/specs.ts +53 -0
- package/src/families/celo/speculos-deviceActions.ts +51 -0
- package/src/families/celo/transaction.ts +39 -0
- package/src/families/celo/types.ts +20 -0
- package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +1 -0
- package/src/families/ethereum/modules/erc1155.ts +9 -0
- package/src/families/polkadot/cache.ts +1 -1
- package/src/families/solana/test-dataset.ts +340 -337
- package/src/featureFlags/FeatureToggle.tsx +24 -0
- package/src/featureFlags/defaultFeatures.ts +7 -0
- package/src/featureFlags/index.ts +4 -0
- package/src/featureFlags/provider.tsx +48 -0
- package/src/featureFlags/types.ts +9 -0
- package/src/featureFlags/useFeature.ts +8 -0
- package/src/generated/bridge/js.ts +3 -0
- package/src/generated/cli-transaction.ts +3 -0
- package/src/generated/deviceTransactionConfig.ts +3 -0
- package/src/generated/hw-getAddress.ts +3 -0
- package/src/generated/specs.ts +3 -0
- package/src/generated/speculos-deviceActions.ts +3 -0
- package/src/generated/transaction.ts +3 -0
- package/src/generated/types.ts +14 -0
- package/src/types/index.ts +1 -0
package/src/account/support.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { getAccountBridge } from "../bridge";
|
|
|
21
21
|
import jsBridges from "../generated/bridge/js";
|
|
22
22
|
|
|
23
23
|
const experimentalIntegrations = ["algorand", "tezos"];
|
|
24
|
+
|
|
24
25
|
export function shouldUseJS(currency: CryptoCurrency) {
|
|
25
26
|
const jsBridge = jsBridges[currency.family];
|
|
26
27
|
if (!jsBridge) return false;
|
package/src/bot/engine.ts
CHANGED
|
@@ -401,7 +401,7 @@ export async function runOnAccount<T extends Transaction>({
|
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
// without recovering
|
|
404
|
+
// without recovering mechanism, we simply assume an error is a failure
|
|
405
405
|
if (errors.length) {
|
|
406
406
|
throw errors[0];
|
|
407
407
|
}
|
package/src/bridge/jsHelpers.ts
CHANGED
|
@@ -97,7 +97,7 @@ Operation[] {
|
|
|
97
97
|
newOps.forEach((op) => {
|
|
98
98
|
newOpsIds[op.id] = op;
|
|
99
99
|
});
|
|
100
|
-
// return
|
|
100
|
+
// return existing when there is no real new operations
|
|
101
101
|
if (newOps.length === 0) return existing;
|
|
102
102
|
// edge case, existing can be empty. return the sorted list.
|
|
103
103
|
if (existing.length === 0) return Object.values(newOpsIds);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface Props {
|
|
4
|
+
size: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function celo({size, color = "currentColor"}: Props) {
|
|
9
|
+
return <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.1053 19.1053C12.9834 19.1053 15.3158 16.7728 15.3158 13.8947C15.3158 11.0166 12.9834 8.68421 10.1053 8.68421C7.22716 8.68421 4.89474 11.0166 4.89474 13.8947C4.89474 16.7728 7.22716 19.1053 10.1053 19.1053ZM10.1053 21C6.18126 21 3 17.8187 3 13.8947C3 9.97074 6.18126 6.78947 10.1053 6.78947C14.0293 6.78947 17.2105 9.97074 17.2105 13.8947C17.2105 17.8187 14.0293 21 10.1053 21Z" fill={color} /><path d="M13.8947 15.3158C16.7728 15.3158 19.1053 12.9834 19.1053 10.1053C19.1053 7.22716 16.7728 4.89474 13.8947 4.89474C11.0166 4.89474 8.68421 7.22716 8.68421 10.1053C8.68421 12.9834 11.0166 15.3158 13.8947 15.3158ZM13.8947 17.2105C9.97074 17.2105 6.78947 14.0293 6.78947 10.1053C6.78947 6.18126 9.97074 3 13.8947 3C17.8187 3 21 6.18126 21 10.1053C21 14.0293 17.8187 17.2105 13.8947 17.2105Z" fill={color} /><path d="M14.1297 17.2105C14.6223 16.6137 14.9747 15.9145 15.1623 15.1623C15.9126 14.9747 16.6118 14.6223 17.2105 14.1297C17.184 14.9994 16.9964 15.8558 16.6573 16.6592C15.8558 16.9964 14.9994 17.184 14.1297 17.2105ZM8.83768 8.83768C8.08737 9.02526 7.38821 9.37768 6.78947 9.87032C6.816 9.00063 7.00358 8.14421 7.34274 7.34274C8.14421 7.00547 9.00253 6.81789 9.87032 6.78947C9.37768 7.38632 9.02526 8.08547 8.83768 8.83768Z" fill={color} /></svg>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default celo;
|
|
@@ -78,6 +78,7 @@ export { default as call } from "./call";
|
|
|
78
78
|
export { default as cc } from "./cc";
|
|
79
79
|
export { default as cdn } from "./cdn";
|
|
80
80
|
export { default as cdt } from "./cdt";
|
|
81
|
+
export { default as celo } from "./celo";
|
|
81
82
|
export { default as cenz } from "./cenz";
|
|
82
83
|
export { default as chain } from "./chain";
|
|
83
84
|
export { default as chat } from "./chat";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import Svg, { Path } from "react-native-svg";
|
|
4
|
+
interface Props {
|
|
5
|
+
size: number;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function celo({ size, color }: Props) {
|
|
10
|
+
return <Svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><Path d="M10.1053 19.1053C12.9834 19.1053 15.3158 16.7728 15.3158 13.8947C15.3158 11.0166 12.9834 8.68421 10.1053 8.68421C7.22716 8.68421 4.89474 11.0166 4.89474 13.8947C4.89474 16.7728 7.22716 19.1053 10.1053 19.1053ZM10.1053 21C6.18126 21 3 17.8187 3 13.8947C3 9.97074 6.18126 6.78947 10.1053 6.78947C14.0293 6.78947 17.2105 9.97074 17.2105 13.8947C17.2105 17.8187 14.0293 21 10.1053 21Z" fill={color} /><Path d="M13.8947 15.3158C16.7728 15.3158 19.1053 12.9834 19.1053 10.1053C19.1053 7.22716 16.7728 4.89474 13.8947 4.89474C11.0166 4.89474 8.68421 7.22716 8.68421 10.1053C8.68421 12.9834 11.0166 15.3158 13.8947 15.3158ZM13.8947 17.2105C9.97074 17.2105 6.78947 14.0293 6.78947 10.1053C6.78947 6.18126 9.97074 3 13.8947 3C17.8187 3 21 6.18126 21 10.1053C21 14.0293 17.8187 17.2105 13.8947 17.2105Z" fill={color} /><Path d="M14.1297 17.2105C14.6223 16.6137 14.9747 15.9145 15.1623 15.1623C15.9126 14.9747 16.6118 14.6223 17.2105 14.1297C17.184 14.9994 16.9964 15.8558 16.6573 16.6592C15.8558 16.9964 14.9994 17.184 14.1297 17.2105ZM8.83768 8.83768C8.08737 9.02526 7.38821 9.37768 6.78947 9.87032C6.816 9.00063 7.00358 8.14421 7.34274 7.34274C8.14421 7.00547 9.00253 6.81789 9.87032 6.78947C9.37768 7.38632 9.02526 8.08547 8.83768 8.83768Z" fill={color} /></Svg>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default celo;
|
|
@@ -78,6 +78,7 @@ export { default as call } from "./call";
|
|
|
78
78
|
export { default as cc } from "./cc";
|
|
79
79
|
export { default as cdn } from "./cdn";
|
|
80
80
|
export { default as cdt } from "./cdt";
|
|
81
|
+
export { default as celo } from "./celo";
|
|
81
82
|
export { default as cenz } from "./cenz";
|
|
82
83
|
export { default as chain } from "./chain";
|
|
83
84
|
export { default as chat } from "./chat";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M10.1053 19.1053C12.9834 19.1053 15.3158 16.7728 15.3158 13.8947C15.3158 11.0166 12.9834 8.68421 10.1053 8.68421C7.22716 8.68421 4.89474 11.0166 4.89474 13.8947C4.89474 16.7728 7.22716 19.1053 10.1053 19.1053ZM10.1053 21C6.18126 21 3 17.8187 3 13.8947C3 9.97074 6.18126 6.78947 10.1053 6.78947C14.0293 6.78947 17.2105 9.97074 17.2105 13.8947C17.2105 17.8187 14.0293 21 10.1053 21Z" fill="#42D689"/>
|
|
3
|
+
<path d="M13.8947 15.3158C16.7728 15.3158 19.1053 12.9834 19.1053 10.1053C19.1053 7.22716 16.7728 4.89474 13.8947 4.89474C11.0166 4.89474 8.68421 7.22716 8.68421 10.1053C8.68421 12.9834 11.0166 15.3158 13.8947 15.3158ZM13.8947 17.2105C9.97074 17.2105 6.78947 14.0293 6.78947 10.1053C6.78947 6.18126 9.97074 3 13.8947 3C17.8187 3 21 6.18126 21 10.1053C21 14.0293 17.8187 17.2105 13.8947 17.2105Z" fill="#42D689"/>
|
|
4
|
+
<path d="M14.1297 17.2105C14.6223 16.6137 14.9747 15.9145 15.1623 15.1623C15.9126 14.9747 16.6118 14.6223 17.2105 14.1297C17.184 14.9994 16.9964 15.8558 16.6573 16.6592C15.8558 16.9964 14.9994 17.184 14.1297 17.2105ZM8.83768 8.83768C8.08737 9.02526 7.38821 9.37768 6.78947 9.87032C6.816 9.00063 7.00358 8.14421 7.34274 7.34274C8.14421 7.00547 9.00253 6.81789 9.87032 6.78947C9.37768 7.38632 9.02526 8.08547 8.83768 8.83768Z" fill="#42D689"/>
|
|
5
|
+
</svg>
|
package/src/env.ts
CHANGED
|
@@ -40,6 +40,16 @@ const envDefinitions = {
|
|
|
40
40
|
parser: stringParser,
|
|
41
41
|
desc: "Node API endpoint for algorand",
|
|
42
42
|
},
|
|
43
|
+
API_CELO_INDEXER: {
|
|
44
|
+
def: "https://celo.coin.ledger.com/indexer/",
|
|
45
|
+
parser: stringParser,
|
|
46
|
+
desc: "Explorer API for celo",
|
|
47
|
+
},
|
|
48
|
+
API_CELO_NODE: {
|
|
49
|
+
def: "https://celo.coin.ledger.com/archive/",
|
|
50
|
+
parser: stringParser,
|
|
51
|
+
desc: "Node endpoint for celo",
|
|
52
|
+
},
|
|
43
53
|
API_COSMOS_BLOCKCHAIN_EXPLORER_API_ENDPOINT: {
|
|
44
54
|
def: "https://cosmoshub4.coin.ledger.com/",
|
|
45
55
|
parser: stringParser,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { publicKeyTweakAdd } from "secp256k1";
|
|
2
2
|
import createHmac from "create-hmac";
|
|
3
3
|
|
|
4
4
|
// the BIP32 class is inspired from https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js
|
|
@@ -28,7 +28,7 @@ class BIP32 {
|
|
|
28
28
|
const I = createHmac("sha512", this.chainCode).update(data).digest();
|
|
29
29
|
const IL = I.slice(0, 32);
|
|
30
30
|
const IR = I.slice(32);
|
|
31
|
-
const Ki =
|
|
31
|
+
const Ki = Buffer.from(publicKeyTweakAdd(this.publicKey, IL));
|
|
32
32
|
return new BIP32(Ki, IR, this.network, this.depth + 1, index);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
2
|
// @ts-ignore
|
|
3
|
-
import { toOutputScript } from "bitcoinjs-lib/src/address";
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
-
// @ts-ignore
|
|
6
3
|
import zec from "zcash-bitcore-lib";
|
|
7
4
|
import bs58check from "bs58check";
|
|
8
|
-
import
|
|
5
|
+
import * as bjs from "bitcoinjs-lib";
|
|
9
6
|
import { InvalidAddress } from "@ledgerhq/errors";
|
|
10
7
|
import { DerivationModes } from "../types";
|
|
11
|
-
import { ICrypto } from "./types";
|
|
12
8
|
import Base from "./base";
|
|
13
9
|
|
|
14
|
-
class ZCash
|
|
10
|
+
class ZCash extends Base {
|
|
15
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
12
|
network: any;
|
|
17
13
|
|
|
18
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
15
|
constructor({ network }: { network: any }) {
|
|
16
|
+
super({ network });
|
|
20
17
|
this.network = network;
|
|
21
18
|
this.network.dustThreshold = 10000;
|
|
22
19
|
this.network.dustPolicy = "FIXED";
|
|
@@ -32,19 +29,13 @@ class ZCash implements ICrypto {
|
|
|
32
29
|
return bs58check.encode(Buffer.from(taddr));
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
private static toBitcoinAddr(taddr: string) {
|
|
36
|
-
// refer to https://runkitcdn.com/gojomo/baddr2taddr/1.0.2
|
|
37
|
-
const baddr = new Uint8Array(21);
|
|
38
|
-
baddr.set(bs58check.decode(taddr).slice(2), 1);
|
|
39
|
-
return bs58check.encode(Buffer.from(baddr));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
32
|
// eslint-disable-next-line
|
|
43
33
|
getLegacyAddress(xpub: string, account: number, index: number): string {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const pk = bjs.crypto.hash160(this.getPubkeyAt(xpub, account, index));
|
|
35
|
+
const payload = Buffer.allocUnsafe(22);
|
|
36
|
+
payload.writeUInt16BE(this.network.pubKeyHash, 0);
|
|
37
|
+
pk.copy(payload, 2);
|
|
38
|
+
return bs58check.encode(payload);
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
getAddress(
|
|
@@ -78,11 +69,20 @@ class ZCash implements ICrypto {
|
|
|
78
69
|
if (!this.validateAddress(address)) {
|
|
79
70
|
throw new InvalidAddress();
|
|
80
71
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
ZCash.toBitcoinAddr(address),
|
|
84
|
-
coininfo.bitcoin.main.toBitcoinJS()
|
|
72
|
+
const version = Number(
|
|
73
|
+
"0x" + bs58check.decode(address).slice(0, 2).toString("hex")
|
|
85
74
|
);
|
|
75
|
+
if (version === this.network.pubKeyHash) {
|
|
76
|
+
//Pay-to-PubkeyHash
|
|
77
|
+
return bjs.payments.p2pkh({ hash: bs58check.decode(address).slice(2) })
|
|
78
|
+
.output as Buffer;
|
|
79
|
+
}
|
|
80
|
+
if (version === this.network.scriptHash) {
|
|
81
|
+
//Pay-to-Script-Hash
|
|
82
|
+
return bjs.payments.p2sh({ hash: bs58check.decode(address).slice(2) })
|
|
83
|
+
.output as Buffer;
|
|
84
|
+
}
|
|
85
|
+
throw new InvalidAddress();
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import { toOutputScript } from "bitcoinjs-lib/src/address";
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import zec from "zcash-bitcore-lib";
|
|
7
1
|
import bs58check from "bs58check";
|
|
8
|
-
import coininfo from "coininfo";
|
|
9
2
|
import { InvalidAddress } from "@ledgerhq/errors";
|
|
10
3
|
import { DerivationModes } from "../types";
|
|
11
|
-
import { ICrypto } from "./types";
|
|
12
4
|
import Base from "./base";
|
|
5
|
+
import * as bjs from "bitcoinjs-lib";
|
|
13
6
|
|
|
14
|
-
class Zen
|
|
7
|
+
class Zen extends Base {
|
|
15
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
9
|
network: any;
|
|
17
10
|
|
|
18
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
12
|
constructor({ network }: { network: any }) {
|
|
13
|
+
super({ network });
|
|
20
14
|
// refer to https://github.com/HorizenOfficial/zen/blob/master/src/chainparams.cpp for the blockchain params
|
|
21
15
|
this.network = network;
|
|
22
16
|
this.network.versions = {
|
|
@@ -26,15 +20,15 @@ class Zen implements ICrypto {
|
|
|
26
20
|
},
|
|
27
21
|
bip44: 121,
|
|
28
22
|
private: 0x80,
|
|
29
|
-
public:
|
|
30
|
-
scripthash:
|
|
23
|
+
public: 0x2089,
|
|
24
|
+
scripthash: 0x2096,
|
|
31
25
|
};
|
|
32
26
|
this.network.name = "Zencash";
|
|
33
27
|
this.network.unit = "ZEN";
|
|
34
28
|
this.network.messagePrefix = "Zencash Signed Message:\n";
|
|
35
29
|
this.network.wif = 0x80;
|
|
36
|
-
this.network.pubKeyHash =
|
|
37
|
-
this.network.scriptHash =
|
|
30
|
+
this.network.pubKeyHash = 0x2089;
|
|
31
|
+
this.network.scriptHash = 0x2096;
|
|
38
32
|
this.network.dustThreshold = 10000;
|
|
39
33
|
this.network.dustPolicy = "FIXED";
|
|
40
34
|
this.network.usesTimestampedTransaction = false;
|
|
@@ -50,21 +44,13 @@ class Zen implements ICrypto {
|
|
|
50
44
|
return bs58check.encode(Buffer.from(taddr));
|
|
51
45
|
}
|
|
52
46
|
|
|
53
|
-
private static toBitcoinAddr(taddr: string) {
|
|
54
|
-
// refer to https://runkitcdn.com/gojomo/baddr2taddr/1.0.2
|
|
55
|
-
const baddr = new Uint8Array(21);
|
|
56
|
-
baddr.set(bs58check.decode(taddr).slice(2), 1);
|
|
57
|
-
return bs58check.encode(Buffer.from(baddr));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
47
|
// eslint-disable-next-line
|
|
61
48
|
getLegacyAddress(xpub: string, account: number, index: number): string {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return this.baddrToTaddr(bs58check.encode(Buffer.from(baddr)));
|
|
49
|
+
const pk = bjs.crypto.hash160(this.getPubkeyAt(xpub, account, index));
|
|
50
|
+
const payload = Buffer.allocUnsafe(22);
|
|
51
|
+
payload.writeUInt16BE(this.network.pubKeyHash, 0);
|
|
52
|
+
pk.copy(payload, 2);
|
|
53
|
+
return bs58check.encode(payload);
|
|
68
54
|
}
|
|
69
55
|
|
|
70
56
|
getAddress(
|
|
@@ -98,10 +84,23 @@ class Zen implements ICrypto {
|
|
|
98
84
|
if (!this.validateAddress(address)) {
|
|
99
85
|
throw new InvalidAddress();
|
|
100
86
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
87
|
+
let outputScript: Buffer;
|
|
88
|
+
const version = Number(
|
|
89
|
+
"0x" + bs58check.decode(address).slice(0, 2).toString("hex")
|
|
104
90
|
);
|
|
91
|
+
if (version === this.network.pubKeyHash) {
|
|
92
|
+
//Pay-to-PubkeyHash
|
|
93
|
+
outputScript = bjs.payments.p2pkh({
|
|
94
|
+
hash: bs58check.decode(address).slice(2),
|
|
95
|
+
}).output as Buffer;
|
|
96
|
+
} else if (version === this.network.scriptHash) {
|
|
97
|
+
//Pay-to-Script-Hash
|
|
98
|
+
outputScript = bjs.payments.p2sh({
|
|
99
|
+
hash: bs58check.decode(address).slice(2),
|
|
100
|
+
}).output as Buffer;
|
|
101
|
+
} else {
|
|
102
|
+
throw new InvalidAddress();
|
|
103
|
+
}
|
|
105
104
|
// refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/scripts/BitcoinLikeScript.cpp#L139 and https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/networks.cpp#L39 for bip115 Script and its network parameters
|
|
106
105
|
const bip115Script = Buffer.from(
|
|
107
106
|
"209ec9845acb02fab24e1c0368b3b517c1a4488fba97f0e3459ac053ea0100000003c01f02b4",
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import network from "../../../network";
|
|
3
|
+
import { getEnv } from "../../../env";
|
|
4
|
+
import { Operation, OperationType } from "../../../types";
|
|
5
|
+
import { encodeOperationId } from "../../../operation";
|
|
6
|
+
|
|
7
|
+
const DEFAULT_TRANSACTIONS_LIMIT = 200;
|
|
8
|
+
const getUrl = (route): string => `${getEnv("API_CELO_INDEXER")}${route || ""}`;
|
|
9
|
+
|
|
10
|
+
// Indexer returns both account data and transactions in one call.
|
|
11
|
+
// Transactions are just limited, there's no block height offset
|
|
12
|
+
const fetchAccountDetails = async (
|
|
13
|
+
address: string,
|
|
14
|
+
transactionsLimit: number = DEFAULT_TRANSACTIONS_LIMIT
|
|
15
|
+
) => {
|
|
16
|
+
const { data } = await network({
|
|
17
|
+
method: "GET",
|
|
18
|
+
url: getUrl(`/account_details/${address}?limit=${transactionsLimit}`),
|
|
19
|
+
});
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const fetchStatus = async () => {
|
|
24
|
+
const { data } = await network({
|
|
25
|
+
method: "GET",
|
|
26
|
+
url: getUrl(`/status`),
|
|
27
|
+
});
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getOperationType = (type: string): OperationType => {
|
|
32
|
+
switch (type) {
|
|
33
|
+
case "InternalTransferSent":
|
|
34
|
+
return "OUT";
|
|
35
|
+
case "InternalTransferReceived":
|
|
36
|
+
return "IN";
|
|
37
|
+
case "AccountSlashed":
|
|
38
|
+
return "SLASH";
|
|
39
|
+
default:
|
|
40
|
+
return "NONE";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const transactionToOperation = (
|
|
45
|
+
address: string,
|
|
46
|
+
accountId: string,
|
|
47
|
+
transaction
|
|
48
|
+
): Operation => {
|
|
49
|
+
const type: OperationType = getOperationType(transaction.kind);
|
|
50
|
+
const hasFailed = transaction.data.success
|
|
51
|
+
? !transaction.data.success
|
|
52
|
+
: false;
|
|
53
|
+
const senders = transaction.data.from ? [transaction.data.from] : [];
|
|
54
|
+
const recipients = transaction.data.to ? [transaction.data.to] : [];
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
id: encodeOperationId(accountId, transaction.transaction_hash, type),
|
|
58
|
+
hash: transaction.transaction_hash,
|
|
59
|
+
accountId,
|
|
60
|
+
fee: new BigNumber(0),
|
|
61
|
+
value: new BigNumber(transaction.amount),
|
|
62
|
+
type,
|
|
63
|
+
blockHeight: transaction.height,
|
|
64
|
+
date: new Date(transaction.time),
|
|
65
|
+
senders,
|
|
66
|
+
recipients,
|
|
67
|
+
hasFailed,
|
|
68
|
+
blockHash: null,
|
|
69
|
+
extra: {},
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const getAccountDetails = async (address: string, accountId: string) => {
|
|
74
|
+
const accountDetails = await fetchAccountDetails(address);
|
|
75
|
+
const spendableBalance = new BigNumber(accountDetails.gold_balance);
|
|
76
|
+
const lockedBalance = new BigNumber(accountDetails.total_locked_gold);
|
|
77
|
+
const balance = spendableBalance.plus(lockedBalance);
|
|
78
|
+
const indexerStatus = await fetchStatus();
|
|
79
|
+
|
|
80
|
+
const allTransactions = accountDetails.internal_transfers.concat(
|
|
81
|
+
accountDetails.transactions
|
|
82
|
+
);
|
|
83
|
+
const operations = allTransactions.map((transaction) =>
|
|
84
|
+
transactionToOperation(address, accountId, transaction)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
blockHeight: indexerStatus.last_indexed_height,
|
|
89
|
+
balance,
|
|
90
|
+
spendableBalance,
|
|
91
|
+
operations,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getAccountDetails } from "./hubble";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AccountBridge, CurrencyBridge } from "../../../types";
|
|
2
|
+
import type { Transaction } from "../types";
|
|
3
|
+
import { makeAccountBridgeReceive } from "../../../bridge/jsHelpers";
|
|
4
|
+
import { sync, scanAccounts } from "../js-synchronisation";
|
|
5
|
+
import signOperation from "../js-signOperation";
|
|
6
|
+
import getTransactionStatus from "../js-getTransactionStatus";
|
|
7
|
+
import broadcast from "../js-broadcast";
|
|
8
|
+
import estimateMaxSpendable from "../js-estimateMaxSpendable";
|
|
9
|
+
import prepareTransaction from "../js-prepareTransaction";
|
|
10
|
+
import createTransaction from "../js-createTransaction";
|
|
11
|
+
|
|
12
|
+
const updateTransaction = (t, patch) => ({ ...t, ...patch });
|
|
13
|
+
|
|
14
|
+
const receive = makeAccountBridgeReceive();
|
|
15
|
+
|
|
16
|
+
const preload = async () => Promise.resolve({});
|
|
17
|
+
const hydrate = (): void => {};
|
|
18
|
+
|
|
19
|
+
const currencyBridge: CurrencyBridge = {
|
|
20
|
+
preload,
|
|
21
|
+
hydrate,
|
|
22
|
+
scanAccounts,
|
|
23
|
+
};
|
|
24
|
+
const accountBridge: AccountBridge<Transaction> = {
|
|
25
|
+
estimateMaxSpendable,
|
|
26
|
+
createTransaction,
|
|
27
|
+
updateTransaction,
|
|
28
|
+
getTransactionStatus,
|
|
29
|
+
prepareTransaction,
|
|
30
|
+
sync,
|
|
31
|
+
receive,
|
|
32
|
+
signOperation,
|
|
33
|
+
broadcast,
|
|
34
|
+
};
|
|
35
|
+
export default {
|
|
36
|
+
currencyBridge,
|
|
37
|
+
accountBridge,
|
|
38
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import invariant from "invariant";
|
|
2
|
+
import flatMap from "lodash/flatMap";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
Transaction,
|
|
6
|
+
Account,
|
|
7
|
+
AccountLike,
|
|
8
|
+
AccountLikeArray,
|
|
9
|
+
} from "../../types";
|
|
10
|
+
|
|
11
|
+
const options = [];
|
|
12
|
+
|
|
13
|
+
function inferAccounts(account: Account): AccountLikeArray {
|
|
14
|
+
invariant(account.currency.family === "celo", "celo family");
|
|
15
|
+
|
|
16
|
+
const accounts: Account[] = [account];
|
|
17
|
+
return accounts;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function inferTransactions(
|
|
21
|
+
transactions: Array<{
|
|
22
|
+
account: AccountLike;
|
|
23
|
+
transaction: Transaction;
|
|
24
|
+
mainAccount: Account;
|
|
25
|
+
}>
|
|
26
|
+
): Transaction[] {
|
|
27
|
+
return flatMap(transactions, ({ transaction }) => {
|
|
28
|
+
invariant(transaction.family === "celo", "celo family");
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
...transaction,
|
|
32
|
+
family: "celo",
|
|
33
|
+
} as Transaction;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
options,
|
|
39
|
+
inferAccounts,
|
|
40
|
+
inferTransactions,
|
|
41
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CurrenciesData } from "../../../types";
|
|
2
|
+
import type { Transaction } from "../types";
|
|
3
|
+
|
|
4
|
+
const dataset: CurrenciesData<Transaction> = {
|
|
5
|
+
scanAccounts: [
|
|
6
|
+
{
|
|
7
|
+
name: "celo seed 1",
|
|
8
|
+
apdus: `
|
|
9
|
+
=> e002000009028000002c8000ce10
|
|
10
|
+
<= 41040106794f46b69e1ae56dff904510959e59074a37341f8cc740e9ce7a0b24421c42e7023481f5ef03926739baa6bb26cac7bf48f249a24793264711d48499499528433235323935323541463035434134313939633236413838623438393463383342303330433733399000
|
|
11
|
+
=> e002000015058000002c8000ce10800000000000000000000000
|
|
12
|
+
<= 41044f4998c3f81966645f25e95082f9fe7d104b1ba4286486a8ecd8fd11f79ef02bd8110f086b390a418ab619a650f3df59a3c84912ce1ea125386d7aa7732fcd0b28393634313334336638346535304143304334434133626644313244433063346231653732363544359000
|
|
13
|
+
=> e002000015058000002c8000ce10800000010000000000000000
|
|
14
|
+
<= 4104630b6447b0f690520a5612f1dc57da90b84f6b59dfeb375bed1113fb34a8d0f9181ec63e40f9fde05761084dbd022ba76711eb2b36442cf4b5d2bc19def9156428343435306565646238623532333931354534393639633239646241653944354563303646453837349000
|
|
15
|
+
`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default dataset;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DeviceTransactionField } from "../../transaction";
|
|
2
|
+
|
|
3
|
+
function getDeviceTransactionConfig(): Array<DeviceTransactionField> {
|
|
4
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
5
|
+
|
|
6
|
+
fields.push({
|
|
7
|
+
type: "amount",
|
|
8
|
+
label: "Amount",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
fields.push({
|
|
12
|
+
type: "fees",
|
|
13
|
+
label: "Fees",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return fields;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default getDeviceTransactionConfig;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
2
|
+
import { decode, encode } from "rlp";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Heavily inspiried by celo-web-wallet
|
|
6
|
+
* https://github.com/celo-tools/celo-web-wallet/blob/master/src/features/ledger/CeloLedgerApp.ts
|
|
7
|
+
*/
|
|
8
|
+
export class CeloApp {
|
|
9
|
+
transport: Transport;
|
|
10
|
+
|
|
11
|
+
constructor(transport: any) {
|
|
12
|
+
this.transport = transport;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async signTransaction(
|
|
16
|
+
path: string,
|
|
17
|
+
rawTxHex: string
|
|
18
|
+
): Promise<{
|
|
19
|
+
s: string;
|
|
20
|
+
v: string;
|
|
21
|
+
r: string;
|
|
22
|
+
}> {
|
|
23
|
+
const paths = splitPath(path);
|
|
24
|
+
const rawTx = Buffer.from(rawTxHex, "hex");
|
|
25
|
+
let offset = 0;
|
|
26
|
+
let response;
|
|
27
|
+
|
|
28
|
+
const rlpTx = decode(rawTx);
|
|
29
|
+
let rlpOffset = 0;
|
|
30
|
+
if (rlpTx.length > 6) {
|
|
31
|
+
const rlpVrs = encode(rlpTx.slice(-3));
|
|
32
|
+
rlpOffset = rawTx.length - (rlpVrs.length - 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
while (offset !== rawTx.length) {
|
|
36
|
+
const first = offset === 0;
|
|
37
|
+
const maxChunkSize = first ? 150 - 1 - paths.length * 4 : 150;
|
|
38
|
+
let chunkSize =
|
|
39
|
+
offset + maxChunkSize > rawTx.length
|
|
40
|
+
? rawTx.length - offset
|
|
41
|
+
: maxChunkSize;
|
|
42
|
+
if (rlpOffset != 0 && offset + chunkSize == rlpOffset) {
|
|
43
|
+
// Make sure that the chunk doesn't end right on the EIP 155 marker if set
|
|
44
|
+
chunkSize--;
|
|
45
|
+
}
|
|
46
|
+
const buffer = Buffer.alloc(
|
|
47
|
+
first ? 1 + paths.length * 4 + chunkSize : chunkSize
|
|
48
|
+
);
|
|
49
|
+
if (first) {
|
|
50
|
+
buffer[0] = paths.length;
|
|
51
|
+
paths.forEach((element, index) => {
|
|
52
|
+
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
53
|
+
});
|
|
54
|
+
rawTx.copy(buffer, 1 + 4 * paths.length, offset, offset + chunkSize);
|
|
55
|
+
} else {
|
|
56
|
+
rawTx.copy(buffer, 0, offset, offset + chunkSize);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
response = await this.transport
|
|
60
|
+
.send(0xe0, 0x04, first ? 0x00 : 0x80, 0x00, buffer)
|
|
61
|
+
.catch((e) => {
|
|
62
|
+
throw e;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
offset += chunkSize;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const v = response.slice(0, 1).toString("hex");
|
|
69
|
+
const r = response.slice(1, 1 + 32).toString("hex");
|
|
70
|
+
const s = response.slice(1 + 32, 1 + 32 + 32).toString("hex");
|
|
71
|
+
return { v, r, s };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
provideERC20TokenInformation({ data }: { data: Buffer }): Promise<boolean> {
|
|
75
|
+
return provideERC20TokenInformation(this.transport, data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function splitPath(path: string): number[] {
|
|
80
|
+
const result: number[] = [];
|
|
81
|
+
const components = path.split("/");
|
|
82
|
+
components.forEach((element) => {
|
|
83
|
+
let number = parseInt(element, 10);
|
|
84
|
+
if (isNaN(number)) {
|
|
85
|
+
return; // FIXME shouldn't it throws instead?
|
|
86
|
+
}
|
|
87
|
+
if (element.length > 1 && element[element.length - 1] === "'") {
|
|
88
|
+
number += 0x80000000;
|
|
89
|
+
}
|
|
90
|
+
result.push(number);
|
|
91
|
+
});
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function provideERC20TokenInformation(
|
|
96
|
+
transport: Transport,
|
|
97
|
+
data: Buffer
|
|
98
|
+
): Promise<boolean> {
|
|
99
|
+
return transport.send(0xe0, 0x0a, 0x00, 0x00, data).then(
|
|
100
|
+
() => true,
|
|
101
|
+
(e) => {
|
|
102
|
+
if (e && e.statusCode === 0x6d00) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "../ethereum/hw-getAddress";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { patchOperationWithHash } from "../../operation";
|
|
2
|
+
import { celoKit } from "./api/sdk";
|
|
3
|
+
|
|
4
|
+
const broadcast = async ({ signedOperation: { operation, signature } }) => {
|
|
5
|
+
const kit = celoKit();
|
|
6
|
+
const { transactionHash } = await kit.web3.eth.sendSignedTransaction(
|
|
7
|
+
signature
|
|
8
|
+
);
|
|
9
|
+
return patchOperationWithHash(operation, transactionHash);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default broadcast;
|