Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit dfaf4ee

Browse files
authored
chore: use KeyringRpcMethod enum instead of string (#105)
1 parent 7fb0d61 commit dfaf4ee

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/KeyringClient.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
UpdateAccountResponseStruct,
2525
} from './internal/api';
2626
import type { JsonRpcRequest } from './JsonRpcRequest';
27+
import { KeyringRpcMethod } from './rpc-handler';
2728
import type { OmitUnion } from './utils';
2829
import { strictMask } from './utils';
2930

@@ -62,7 +63,7 @@ export class KeyringClient implements Keyring {
6263
async listAccounts(): Promise<KeyringAccount[]> {
6364
return strictMask(
6465
await this.#send({
65-
method: 'keyring_listAccounts',
66+
method: KeyringRpcMethod.ListAccounts,
6667
}),
6768
ListAccountsResponseStruct,
6869
);
@@ -71,7 +72,7 @@ export class KeyringClient implements Keyring {
7172
async getAccount(id: string): Promise<KeyringAccount> {
7273
return strictMask(
7374
await this.#send({
74-
method: 'keyring_getAccount',
75+
method: KeyringRpcMethod.GetAccount,
7576
params: { id },
7677
}),
7778
GetAccountResponseStruct,
@@ -83,7 +84,7 @@ export class KeyringClient implements Keyring {
8384
): Promise<KeyringAccount> {
8485
return strictMask(
8586
await this.#send({
86-
method: 'keyring_createAccount',
87+
method: KeyringRpcMethod.CreateAccount,
8788
params: { options },
8889
}),
8990
CreateAccountResponseStruct,
@@ -93,7 +94,7 @@ export class KeyringClient implements Keyring {
9394
async filterAccountChains(id: string, chains: string[]): Promise<string[]> {
9495
return strictMask(
9596
await this.#send({
96-
method: 'keyring_filterAccountChains',
97+
method: KeyringRpcMethod.FilterAccountChains,
9798
params: { id, chains },
9899
}),
99100
FilterAccountChainsResponseStruct,
@@ -103,7 +104,7 @@ export class KeyringClient implements Keyring {
103104
async updateAccount(account: KeyringAccount): Promise<void> {
104105
assert(
105106
await this.#send({
106-
method: 'keyring_updateAccount',
107+
method: KeyringRpcMethod.UpdateAccount,
107108
params: { account },
108109
}),
109110
UpdateAccountResponseStruct,
@@ -113,7 +114,7 @@ export class KeyringClient implements Keyring {
113114
async deleteAccount(id: string): Promise<void> {
114115
assert(
115116
await this.#send({
116-
method: 'keyring_deleteAccount',
117+
method: KeyringRpcMethod.DeleteAccount,
117118
params: { id },
118119
}),
119120
DeleteAccountResponseStruct,
@@ -123,7 +124,7 @@ export class KeyringClient implements Keyring {
123124
async exportAccount(id: string): Promise<KeyringAccountData> {
124125
return strictMask(
125126
await this.#send({
126-
method: 'keyring_exportAccount',
127+
method: KeyringRpcMethod.ExportAccount,
127128
params: { id },
128129
}),
129130
ExportAccountResponseStruct,
@@ -133,7 +134,7 @@ export class KeyringClient implements Keyring {
133134
async listRequests(): Promise<KeyringRequest[]> {
134135
return strictMask(
135136
await this.#send({
136-
method: 'keyring_listRequests',
137+
method: KeyringRpcMethod.ListRequests,
137138
}),
138139
ListRequestsResponseStruct,
139140
);
@@ -142,7 +143,7 @@ export class KeyringClient implements Keyring {
142143
async getRequest(id: string): Promise<KeyringRequest> {
143144
return strictMask(
144145
await this.#send({
145-
method: 'keyring_getRequest',
146+
method: KeyringRpcMethod.GetRequest,
146147
params: { id },
147148
}),
148149
GetRequestResponseStruct,
@@ -152,7 +153,7 @@ export class KeyringClient implements Keyring {
152153
async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {
153154
return strictMask(
154155
await this.#send({
155-
method: 'keyring_submitRequest',
156+
method: KeyringRpcMethod.SubmitRequest,
156157
params: request,
157158
}),
158159
SubmitRequestResponseStruct,
@@ -165,7 +166,7 @@ export class KeyringClient implements Keyring {
165166
): Promise<void> {
166167
assert(
167168
await this.#send({
168-
method: 'keyring_approveRequest',
169+
method: KeyringRpcMethod.ApproveRequest,
169170
params: { id, data },
170171
}),
171172
ApproveRequestResponseStruct,
@@ -175,7 +176,7 @@ export class KeyringClient implements Keyring {
175176
async rejectRequest(id: string): Promise<void> {
176177
assert(
177178
await this.#send({
178-
method: 'keyring_rejectRequest',
179+
method: KeyringRpcMethod.RejectRequest,
179180
params: { id },
180181
}),
181182
RejectRequestResponseStruct,

0 commit comments

Comments
 (0)