Skip to content

Commit

Permalink
Merge branch 'develop' into INFRAPRJ-6604
Browse files Browse the repository at this point in the history
  • Loading branch information
dedsxc authored Aug 20, 2024
2 parents e3531a2 + 3a83f0f commit f07c5cd
Show file tree
Hide file tree
Showing 180 changed files with 8,863 additions and 968 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-pandas-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SetPluginCommand
5 changes: 5 additions & 0 deletions .changeset/brave-squids-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SendEIP712FilteringCommand
5 changes: 5 additions & 0 deletions .changeset/brown-lizards-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SignEIP712Command
5 changes: 5 additions & 0 deletions .changeset/chatty-bats-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement ProvideTokenInformationCommand
5 changes: 5 additions & 0 deletions .changeset/chatty-waves-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/device-sdk-sample": patch
---

Add ListAppsWithMetadataDeviceAction in sample app
5 changes: 5 additions & 0 deletions .changeset/gentle-zebras-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Add transaction serialized to transaction mapper result
5 changes: 5 additions & 0 deletions .changeset/good-oranges-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement ProvideNFTInformationCommand
5 changes: 5 additions & 0 deletions .changeset/happy-lions-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/device-sdk-core": patch
---

Improve code visibility
5 changes: 5 additions & 0 deletions .changeset/late-flies-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SendEIP712StructImplemCommand
5 changes: 5 additions & 0 deletions .changeset/ninety-shirts-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/device-sdk-core": minor
---

Add ManagerApi service to core
5 changes: 5 additions & 0 deletions .changeset/old-ads-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/context-module": minor
---

Bump ethers to v6.13.2
5 changes: 5 additions & 0 deletions .changeset/old-cups-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Add Set External Plugin command
5 changes: 5 additions & 0 deletions .changeset/proud-flies-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement ProvideDomainNameCommand
6 changes: 6 additions & 0 deletions .changeset/proud-turtles-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/device-sdk-core": patch
"@ledgerhq/device-sdk-sample": patch
---

Add support of Ledger Flex
5 changes: 5 additions & 0 deletions .changeset/selfish-months-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Bump ethers to v6.13.2
5 changes: 5 additions & 0 deletions .changeset/seven-beans-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Add SignPersonalMessage command
6 changes: 6 additions & 0 deletions .changeset/sixty-hotels-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/keyring-eth": patch
"@ledgerhq/device-sdk-core": patch
---

DSDK-420 Implement the EIP712 TypedData parser service
5 changes: 5 additions & 0 deletions .changeset/strong-terms-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/context-module": patch
---

Update readme file
5 changes: 5 additions & 0 deletions .changeset/thick-zoos-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SendEIP712StructDefinitionCommand
5 changes: 5 additions & 0 deletions .changeset/unlucky-pears-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/device-sdk-core": minor
---

Add ListAppsWithMetadata device action
5 changes: 5 additions & 0 deletions .changeset/witty-dancers-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/keyring-eth": patch
---

Implement SignTransactionCommand
7 changes: 7 additions & 0 deletions .changeset/witty-plums-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ledgerhq/context-module": patch
"@ledgerhq/keyring-eth": patch
"@ledgerhq/device-sdk-core": patch
---

add HexaString to handle `0x${string}` type
6 changes: 3 additions & 3 deletions apps/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"dependencies": {
"@ledgerhq/device-sdk-core": "workspace:*",
"@ledgerhq/keyring-eth": "workspace:*",
"@ledgerhq/react-ui": "^0.15.1",
"@sentry/nextjs": "^8.13.0",
"@ledgerhq/react-ui": "^0.15.3",
"@sentry/nextjs": "^8.20.0",
"next": "14.2.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -28,7 +28,7 @@
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@types/react": "^18.3.3",
"@types/styled-components": "^5.1.25",
"autoprefixer": "^10.4.19",
"autoprefixer": "^10.4.20",
"globals": "15.8.0",
"postcss": "^8.4.38",
"typescript": "5.4.5"
Expand Down
18 changes: 13 additions & 5 deletions apps/sample/src/components/Device/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ type DeviceProps = {
onDisconnect: () => Promise<void>;
};

function getIconComponent(model: DeviceModelId) {
switch (model) {
case DeviceModelId.STAX:
return Icons.Stax;
case DeviceModelId.FLEX:
return Icons.Flex;
default:
return Icons.Nano;
}
}

export const Device: React.FC<DeviceProps> = ({
name,
type,
Expand All @@ -51,14 +62,11 @@ export const Device: React.FC<DeviceProps> = ({
sessionId,
}) => {
const sessionState = useDeviceSessionState(sessionId);
const IconComponent = getIconComponent(model);
return (
<Root>
<IconContainer>
{model === DeviceModelId.STAX ? (
<Icons.Stax size="S" />
) : (
<Icons.Nano size="S" />
)}
<IconComponent size="S" />
</IconContainer>
<Box flex={1}>
<Text variant="body">{name}</Text>
Expand Down
26 changes: 26 additions & 0 deletions apps/sample/src/components/DeviceActionsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import {
ListAppsDAOutput,
ListAppsDAError,
ListAppsDAIntermediateValue,
ListAppsWithMetadataDeviceAction,
ListAppsWithMetadataDAError,
ListAppsWithMetadataDAInput,
ListAppsWithMetadataDAIntermediateValue,
ListAppsWithMetadataDAOutput,
} from "@ledgerhq/device-sdk-core";

const UNLOCK_TIMEOUT = 60 * 1000; // 1 minute
Expand Down Expand Up @@ -118,6 +123,27 @@ export const DeviceActionsView: React.FC<{ sessionId: string }> = ({
ListAppsDAError,
ListAppsDAIntermediateValue
>,
{
title: "List apps with metadata",
description:
"List all applications installed on the device with additional metadata",
executeDeviceAction: (_, inspect) => {
const deviceAction = new ListAppsWithMetadataDeviceAction({
input: { unlockTimeout: UNLOCK_TIMEOUT },
inspect,
});
return sdk.executeDeviceAction({
sessionId: selectedSessionId,
deviceAction,
});
},
initialValues: { unlockTimeout: UNLOCK_TIMEOUT },
} satisfies DeviceActionProps<
ListAppsWithMetadataDAOutput,
ListAppsWithMetadataDAInput,
ListAppsWithMetadataDAError,
ListAppsWithMetadataDAIntermediateValue
>,
],
[],
);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.11",
"@types/node": "^22.4.0",
"concurrently": "^8.2.2",
"danger": "^12.3.3",
"eslint": "9.8.0",
Expand All @@ -44,7 +44,7 @@
"tsc-alias": "^1.8.10",
"turbo": "^2.0.9",
"typescript": "^5.5.3",
"zx": "^8.1.2"
"zx": "^8.1.4"
},
"engines": {
"node": ">=18"
Expand Down
2 changes: 1 addition & 1 deletion packages/config/jest/jest-preset.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('jest').Config} */
const config = {
preset: "ts-jest",
preset: "ts-jest/presets/js-with-ts",
transform: {
"^.+\\.ts$": "ts-jest",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/config/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"web.json"
],
"devDependencies": {
"@tsconfig/recommended": "^1.0.6",
"@tsconfig/recommended": "^1.0.7",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { types } from "./<%= moduleName %>Types";

type FactoryProps = {};

const <%= moduleName %>ModuleFactory = ({}: Partial<FactoryProps> = {}) =>
const <%= moduleName %>ModuleFactory = ({}: FactoryProps) =>
new ContainerModule((bind, _unbind, _isBound, _rebind, _unbindAsync, _onActivation, _onDeactivation) => {
bind(types.<%= h.capitalize(moduleName) %>Service).to(Default<%= h.capitalize(moduleName) %>Service);
});
Expand Down
12 changes: 8 additions & 4 deletions packages/core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/* eslint no-restricted-syntax: 0 */
import type { JestConfigWithTsJest } from "ts-jest";
import { JestConfigWithTsJest, pathsToModuleNameMapper } from "ts-jest";

import { compilerOptions } from "./tsconfig.json";

const internalPaths = pathsToModuleNameMapper(compilerOptions.paths, {
prefix: "<rootDir>/",
});

const config: JestConfigWithTsJest = {
preset: "@ledgerhq/jest-config-dsdk",
Expand All @@ -12,9 +18,7 @@ const config: JestConfigWithTsJest = {
"!src/api/index.ts",
],
moduleNameMapper: {
"^@api/(.*)$": "<rootDir>/src/api/$1",
"^@internal/(.*)$": "<rootDir>/src/internal/$1",
"^@root/(.*)$": "<rootDir>/$1",
...internalPaths,
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"@sentry/minimal": "^6.19.7",
"axios": "^1.7.2",
"inversify": "^6.0.2",
"inversify-logger-middleware": "^3.1.0",
"purify-ts": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/core/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ const run = async () => await Promise.all([buildEsm(), builCjs()]);

run().catch((e) => {
console.error(e);
process.exitCode = e.exitCode;
});
31 changes: 14 additions & 17 deletions packages/core/src/api/DeviceSdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ describe("DeviceSdk", () => {
describe("clean", () => {
beforeEach(() => {
logger = new ConsoleLogger();
sdk = new DeviceSdk({ stub: false, loggers: [logger] });
sdk = new DeviceSdk({
stub: false,
loggers: [logger],
config: {
managerApiUrl: "http://fake.url",
},
});
});

it("should create an instance", () => {
Expand Down Expand Up @@ -59,7 +65,13 @@ describe("DeviceSdk", () => {

describe("stubbed", () => {
beforeEach(() => {
sdk = new DeviceSdk({ stub: true, loggers: [] });
sdk = new DeviceSdk({
stub: true,
loggers: [],
config: {
managerApiUrl: "http://fake.url",
},
});
});

it("should create a stubbed sdk", () => {
Expand Down Expand Up @@ -94,19 +106,4 @@ describe("DeviceSdk", () => {
expect(uc.execute()).toBe("stub");
});
});

describe("without args", () => {
beforeEach(() => {
sdk = new DeviceSdk();
});

it("should create an instance", () => {
expect(sdk).toBeDefined();
expect(sdk).toBeInstanceOf(DeviceSdk);
});

it("should return a clean `version`", async () => {
expect(await sdk.getVersion()).toBe(pkg.version);
});
});
});
4 changes: 2 additions & 2 deletions packages/core/src/api/DeviceSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ import { SdkError } from "./Error";
export class DeviceSdk {
readonly container: Container;
/** @internal */
constructor({ stub, loggers }: Partial<MakeContainerProps> = {}) {
constructor({ stub, loggers, config }: MakeContainerProps) {
// NOTE: MakeContainerProps might not be the exact type here
// For the init of the project this is sufficient, but we might need to
// update the constructor arguments as we go (we might have more than just the container config)
this.container = makeContainer({ stub, loggers });
this.container = makeContainer({ stub, loggers, config });
}

/**
Expand Down
Loading

0 comments on commit f07c5cd

Please sign in to comment.