-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4985 from LedgerHQ/feat/wallet-api-custom-handlers
feat(wallet-api): add custom handler support [LIVE-9082]
- Loading branch information
Showing
22 changed files
with
243 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"ledger-live-desktop": minor | ||
"live-mobile": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
feat(wallet-api): add custom handler support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
apps/ledger-live-mobile/src/components/Web3AppWebview/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
libs/ledger-live-common/src/wallet-api/CustomLogger/client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { CustomModule } from "@ledgerhq/wallet-api-client"; | ||
|
||
export class CustomLogger extends CustomModule { | ||
debug(message: string) { | ||
return this.request("custom.logger.debug", { message }); | ||
} | ||
|
||
error(message: string) { | ||
return this.request("custom.logger.error", { message }); | ||
} | ||
|
||
info(message: string) { | ||
return this.request("custom.logger.info", { message }); | ||
} | ||
|
||
log(message: string) { | ||
return this.request("custom.logger.log", { message }); | ||
} | ||
|
||
warn(message: string) { | ||
return this.request("custom.logger.warn", { message }); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
libs/ledger-live-common/src/wallet-api/CustomLogger/server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable no-console */ | ||
import { RPCHandler, customWrapper } from "@ledgerhq/wallet-api-server"; | ||
import { LoggerParams, LoggerResponse, MethodIds } from "./types"; | ||
|
||
type Handlers = Record<MethodIds, RPCHandler<unknown, never>>; | ||
|
||
export const handlers = { | ||
"custom.logger.debug": customWrapper<LoggerParams, LoggerResponse>(params => | ||
console.debug(params?.message), | ||
), | ||
"custom.logger.error": customWrapper<LoggerParams, LoggerResponse>(params => | ||
console.error(params?.message), | ||
), | ||
"custom.logger.info": customWrapper<LoggerParams, LoggerResponse>(params => | ||
console.info(params?.message), | ||
), | ||
"custom.logger.log": customWrapper<LoggerParams, LoggerResponse>(params => | ||
console.log(params?.message), | ||
), | ||
"custom.logger.warn": customWrapper<LoggerParams, LoggerResponse>(params => | ||
console.warn(params?.message), | ||
), | ||
} as const satisfies Handlers; |
15 changes: 15 additions & 0 deletions
15
libs/ledger-live-common/src/wallet-api/CustomLogger/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const methodIds = [ | ||
"custom.logger.debug", | ||
"custom.logger.error", | ||
"custom.logger.info", | ||
"custom.logger.log", | ||
"custom.logger.warn", | ||
] as const; | ||
|
||
export type MethodIds = (typeof methodIds)[number]; | ||
|
||
export type LoggerParams = { | ||
message: string; | ||
}; | ||
|
||
export type LoggerResponse = void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ | |
background-color: #b8b8b9; | ||
text-align: start; | ||
} | ||
|
||
pre { | ||
text-align: initial; | ||
} |
Oops, something went wrong.
64cb103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web-tools – ./apps/web-tools
ledger-live-tools.vercel.app
web-tools-ledgerhq.vercel.app
ledger-live.vercel.app
web-tools-git-develop-ledgerhq.vercel.app
live.ledger.tools