Skip to content

Commit 7759852

Browse files
committed
Extract Signer typescript interface to a file.
1 parent afbb71e commit 7759852

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

linera-web/src/signer.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Interface for signing and key management compatible with Ethereum (EVM) addresses.
3+
*/
4+
export interface Signer {
5+
/**
6+
* Signs a given value using the private key associated with the specified EVM address.
7+
* The signing process must follow the EIP-191 standard.
8+
*
9+
* @param owner - The EVM address whose private key will be used to sign the value.
10+
* @param value - The data to be signed, as a `Uint8Array`.
11+
* @returns A promise that resolves to the EIP-191-compatible signature in hexadecimal string format.
12+
*/
13+
sign(owner: string, value: Uint8Array): Promise<string>;
14+
15+
/**
16+
* Retrieves the public key corresponding to the private key associated with the specified EVM address.
17+
*
18+
* @param owner - The EVM address for which to retrieve the public key.
19+
* @returns A promise that resolves to the public key as a hexadecimal string.
20+
*/
21+
getPublicKey(owner: string): Promise<string>;
22+
23+
/**
24+
* Checks whether the instance holds a key whose associated address matches the given EVM address.
25+
*
26+
* @param owner - The EVM address to check for.
27+
* @returns A promise that resolves to `true` if the key exists and matches the given address, otherwise `false`.
28+
*/
29+
containsKey(owner: string): Promise<boolean>;
30+
}"

linera-web/src/signer.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,7 @@ impl std::error::Error for JsSignerError {}
5959

6060
// An interface that will be compiled to TypeScript and exported for use in the browser.
6161
#[wasm_bindgen(typescript_custom_section)]
62-
const SIGNER_INTERFACE: &'static str = r#"
63-
/**
64-
* Interface for signing and key management compatible with Ethereum (EVM) addresses.
65-
*/
66-
export interface Signer {
67-
/**
68-
* Signs a given value using the private key associated with the specified EVM address.
69-
* The signing process must follow the EIP-191 standard.
70-
*
71-
* @param owner - The EVM address whose private key will be used to sign the value.
72-
* @param value - The data to be signed, as a `Uint8Array`.
73-
* @returns A promise that resolves to the EIP-191-compatible signature in hexadecimal string format.
74-
*/
75-
sign(owner: string, value: Uint8Array): Promise<string>;
76-
77-
/**
78-
* Retrieves the public key corresponding to the private key associated with the specified EVM address.
79-
*
80-
* @param owner - The EVM address for which to retrieve the public key.
81-
* @returns A promise that resolves to the public key as a hexadecimal string.
82-
*/
83-
getPublicKey(owner: string): Promise<string>;
84-
85-
/**
86-
* Checks whether the instance holds a key whose associated address matches the given EVM address.
87-
*
88-
* @param owner - The EVM address to check for.
89-
* @returns A promise that resolves to `true` if the key exists and matches the given address, otherwise `false`.
90-
*/
91-
containsKey(owner: string): Promise<boolean>;
92-
}"#;
62+
const SIGNER_INTERFACE: &'static str = include_str!("signer.d.ts");
9363

9464
#[wasm_bindgen]
9565
extern "C" {

0 commit comments

Comments
 (0)