Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Jan 9, 2025
1 parent c1192f3 commit 089b503
Show file tree
Hide file tree
Showing 57 changed files with 3,705 additions and 626 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SeedStep, { SeedPathStatus } from "./SeedStep";
import { analyticsFlowName, StepText } from "./shared";
import OnboardingAppInstallStep from "../../OnboardingAppInstall";
import { getOnboardingStatePolling } from "@ledgerhq/live-common/hw/getOnboardingStatePolling";
import { isAllowedOnboardingStatePollingErrorDmk } from "@ledgerhq/live-dmk";
import ContinueOnDeviceWithAnim from "./ContinueOnDeviceWithAnim";
import { RecoverState } from "~/renderer/screens/recover/Player";
import TrackPage from "~/renderer/analytics/TrackPage";
Expand Down Expand Up @@ -245,6 +246,7 @@ const SyncOnboardingCompanion: React.FC<SyncOnboardingCompanionProps> = ({
device: device || null,
pollingPeriodMs: POLLING_PERIOD_MS,
stopPolling: !isPollingOn,
allowedErrorChecks: [isAllowedOnboardingStatePollingErrorDmk],
});

const handleDeviceReady = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const useListenToHidDevices = () => {
const deviceManagementKit = useDeviceManagementKit();

useEffect(() => {
console.log("[[useListenToHidDevices]] init", deviceManagementKit);
let sub: Subscription;

function syncDevices() {
Expand Down
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"jsx": "react",
"lib": ["ES2021", "dom"],
"target": "esnext",
"module": "nodenext",
"moduleResolution": "nodenext",
"module": "ESNext",
"moduleResolution": "bundler",
"baseUrl": ".",
"rootDir": ".",
"paths": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
MAX_NOMINATIONS,
hasMinimumBondBalance,
} from "@ledgerhq/live-common/families/polkadot/logic";
import { PolkadotValidatorsRequired } from "@ledgerhq/live-common/families/polkadot/errors";
import * as PolkadotErrors from "@ledgerhq/live-common/families/polkadot/errors";
import {
usePolkadotPreloadData,
useSortedValidators,
Expand Down Expand Up @@ -245,8 +245,9 @@ function NominateSelectValidator({ navigation, route }: Props) {
const error = getFirstStatusError(status, "errors");
const warning = getFirstStatusError(status, "warnings");
const maxSelected = validators.length === MAX_NOMINATIONS;
const maybeChill = error instanceof PolkadotValidatorsRequired;
const ignoreError = error instanceof PolkadotValidatorsRequired && !nominations.length;
const maybeChill = error instanceof PolkadotErrors.PolkadotValidatorsRequired;
const ignoreError =
error instanceof PolkadotErrors.PolkadotValidatorsRequired && !nominations.length;
// Do not show error on first nominate
return (
<SafeAreaView
Expand Down
71 changes: 71 additions & 0 deletions libs/coin-modules/coin-filecoin/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env zx
/* eslint-disable no-undef */
import "zx/globals";

import * as esbuild from "esbuild";

const config = {
entryPoints: ["src/**/*"],
minify: true,
bundle: false,
treeShaking: true,
sourcemap: true,
color: true,
loader: {
".json": "copy",
},
};

const buildEsm = async () => {
console.log(chalk.blue("Building esm..."));
await esbuild.build({
...config,
outdir: "lib/esm",
format: "esm",
platform: "browser",
plugins: [
{
name: "copy-package-json",
setup(build) {
build.onEnd(async () => {
await $`cp package.json lib/esm/package.json`;
});
},
},
],
});
};

const buildCjs = async () => {
console.log(chalk.blue("Building cjs..."));
await esbuild.build({
...config,
outdir: "lib/cjs",
format: "cjs",
platform: "node",
plugins: [
{
name: "copy-package-json",
setup(build) {
build.onEnd(async () => {
await $`cp package.json lib/cjs/package.json`;
});
},
},
],
});
};

const buildTypes = async dir => {
console.log(chalk.blue("Building types..."));
await $`tsc --emitDeclarationOnly --outDir ${dir} --moduleResolution bundler -m esnext`;
};

const main = async () => {
return Promise.all([buildEsm(), buildCjs(), buildTypes("lib/types")]);
};

main().catch(error => {
console.error(error);
process.exit(1);
});
103 changes: 66 additions & 37 deletions libs/coin-modules/coin-filecoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,66 @@
"publishConfig": {
"access": "public"
},
"typesVersions": {
"*": {
"lib-es/*": [
"lib-es/*"
],
"specs": [
"lib/test/bot-specs"
],
"*": [
"lib-es/*",
"lib-es/api/*",
"lib-es/bridge/*",
"lib-es/common-logic/*",
"lib-es/signer/*",
"lib-es/test/*",
"lib-es/types/*"
]
}
},
"exports": {
"./lib-es/*": "./lib-es/*.js",
"./api": "./lib-es/api/index.js",
"./deviceTransactionConfig": "./lib-es/bridge/deviceTransactionConfig.js",
"./erc20": "./lib-es/erc20/tokenAccounts.js",
"./logic": "./lib-es/common-logic/index.js",
"./network": "./lib-es/network/index.js",
"./signer": "./lib-es/signer/index.js",
"./specs": "./lib-es/test/bot-specs.js",
"./transaction": "./lib-es/bridge/transaction.js",
"./types": "./lib-es/types/index.js",
"./*": "./lib-es/*.js",
".": "./lib-es/index.js",
"./package.json": "./package.json"
"./api": {
"types": "./lib/types/api/index.d.ts",
"require": "./lib/cjs/api/index.js",
"default": "./lib/esm/api/index.js"
},
"./deviceTransactionConfig": {
"types": "./lib/types/bridge/deviceTransactionConfig.d.ts",
"require": "./lib/cjs/bridge/deviceTransactionConfig.js",
"default": "./lib/esm/bridge/deviceTransactionConfig.js"
},
"./erc20": {
"types": "./lib/types/erc20/tokenAccounts.d.ts",
"require": "./lib/cjs/erc20/tokenAccounts.js",
"default": "./lib/esm/erc20/tokenAccounts.js"
},
"./logic": {
"types": "./lib/types/common-logic/index.d.ts",
"require": "./lib/cjs/common-logic/index.js",
"default": "./lib/esm/common-logic/index.js"
},
"./network": {
"types": "./lib/types/network/index.d.ts",
"require": "./lib/cjs/network/index.js",
"default": "./lib/esm/network/index.js"
},
"./signer": {
"types": "./lib/types/signer/index.d.ts",
"require": "./lib/cjs/signer/index.js",
"default": "./lib/esm/signer/index.js"
},
"./specs": {
"types": "./lib/types/test/bot-specs.d.ts",
"require": "./lib/cjs/test/bot-specs.js",
"default": "./lib/esm/test/bot-specs.js"
},
"./transaction": {
"types": "./lib/types/bridge/transaction.d.ts",
"require": "./lib/cjs/bridge/transaction.js",
"default": "./lib/esm/bridge/transaction.js"
},
"./types": {
"types": "./lib/types/index.d.ts",
"require": "./lib/cjs/types/index.js",
"default": "./lib/esm/types/index.js"
},
"./*": {
"types": "./lib/types/*.js",
"require": "./lib/cjs/*.js",
"default": "./lib/esm/*.js"
},
".": {
"types": "./lib/types/index.d.ts",
"require": "./lib/cjs/index.js",
"default": "./lib/esm/index.js"
},
"./package.json": {
"require": "./lib/cjs/package.json",
"default": "./lib/esm/package.json"
}
},
"license": "Apache-2.0",
"dependencies": {
Expand All @@ -78,17 +105,19 @@
"@types/jest": "^29.5.10",
"@types/lodash": "^4.14.191",
"@types/semver": "^7.5.8",
"axios": "1.7.7",
"esbuild": "0.24.2",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"axios": "1.7.7"
"ts-jest": "^29.1.1"
},
"scripts": {
"clean": "rimraf lib lib-es",
"build": "tsc --outDir lib-es",
"build": "zx build.mjs",
"coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-filecoin.json",
"prewatch": "pnpm build",
"watch": "tsc --watch",
"watch:es": "tsc --watch -m esnext --moduleResolution bundler --outDir lib-es",
"watch": "zx watch.mjs",
"watch:es": "zx watch.mjs --platform esm",
"watch:cjs": "zx watch.mjs --platform cjs",
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
"lint:fix": "pnpm lint --fix",
Expand Down
2 changes: 0 additions & 2 deletions libs/coin-modules/coin-filecoin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"rootDir": "./src",
"outDir": "lib",
"exactOptionalPropertyTypes": true,
"module": "ESNext",
"moduleResolution": "bundler"
},
"include": ["src/**/*", "deviceTransactionConfig.ts", "transaction.ts"]
}
86 changes: 86 additions & 0 deletions libs/coin-modules/coin-filecoin/watch.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env zx
/* eslint-disable no-undef */
import "zx/globals";

import * as esbuild from "esbuild";

const { platform } = argv;

const config = {
entryPoints: ["src/**/*"],
minify: true,
bundle: false,
treeShaking: true,
sourcemap: true,
color: true,
loader: {
".json": "copy",
},
};

const getEsmContext = async () => {
console.log(chalk.blue("Getting esm context..."));

return esbuild.context({
...config,
outdir: "lib/esm",
format: "esm",
platform: "browser",
plugins: [
{
name: "copy-package-json",
setup(build) {
build.onEnd(async () => {
await $`cp package.json lib/esm/package.json`;
});
},
},
],
});
};

const getCjsContext = async () => {
console.log(chalk.blue("Getting cjs context..."));

return esbuild.context({
...config,
outdir: "lib/cjs",
format: "cjs",
platform: "node",
plugins: [
{
name: "copy-package-json",
setup(build) {
build.onEnd(async () => {
await $`cp package.json lib/cjs/package.json`;
});
},
},
],
});
};

const watchTypes = async () => {
await $`tsc --watch --emitDeclarationOnly --outDir lib/types --moduleResolution bundler -m esnext`;
};

const watch = async () => {
const esmContext = await getEsmContext();
const cjsContext = await getCjsContext();

if (platform === "esm") {
console.log(chalk.blue("Watching esm..."));
await Promise.all([esmContext.watch(), watchTypes()]);
} else if (platform === "cjs") {
console.log(chalk.blue("Watching cjs..."));
await Promise.all([cjsContext.watch(), watchTypes()]);
} else {
console.log(chalk.blue("Watching all..."));
await Promise.all([esmContext.watch(), cjsContext.watch(), watchTypes()]);
}
};

watch().catch(error => {
console.error(error);
process.exitCode = error?.exitCode ?? 1;
});
Loading

0 comments on commit 089b503

Please sign in to comment.