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

Commit

Permalink
feat: make options a mandatory field (i.e. cannot be null)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This API modification is incompatible with previous
versions.
  • Loading branch information
danroc committed Jul 10, 2023
1 parent e06b97a commit b602243
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/KeyringClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('KeyringClient', () => {
id: '49116980-0712-4fa5-b045-e4294f1d440e',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
},
Expand All @@ -47,7 +47,7 @@ describe('KeyringClient', () => {
id: '49116980-0712-4fa5-b045-e4294f1d440e',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
};
Expand All @@ -70,7 +70,7 @@ describe('KeyringClient', () => {
id: '49116980-0712-4fa5-b045-e4294f1d440e',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
};
Expand All @@ -81,7 +81,7 @@ describe('KeyringClient', () => {
jsonrpc: '2.0',
id: expect.any(String),
method: 'keyring_createAccount',
params: { name: 'Account 1', options: null },
params: { name: 'Account 1', options: {} },
});
expect(account).toStrictEqual(expectedResponse);
});
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('KeyringClient', () => {
id: '49116980-0712-4fa5-b045-e4294f1d440e',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
};
Expand Down
2 changes: 1 addition & 1 deletion src/KeyringClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class KeyringClient implements Keyring {

async createAccount(
name: string,
options: Record<string, Json> | null = null,
options: Record<string, Json> = {},
): Promise<KeyringAccount> {
return strictMask(
await this.#send({
Expand Down
2 changes: 1 addition & 1 deletion src/KeyringSnapControllerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('KeyringSnapControllerClient', () => {
id: '13f94041-6ae6-451f-a0fe-afdd2fda18a7',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
},
Expand Down
2 changes: 1 addition & 1 deletion src/KeyringSnapRpcClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('KeyringSnapRpcClient', () => {
id: '13f94041-6ae6-451f-a0fe-afdd2fda18a7',
name: 'Account 1',
address: '0xE9A74AACd7df8112911ca93260fC5a046f8a64Ae',
options: null,
options: {},
supportedMethods: [],
type: 'eip155:eoa',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const KeyringAccountStruct = object({
/**
* Keyring-dependent account options.
*/
options: nullable(record(string(), JsonStruct)),
options: record(string(), JsonStruct),

/**
* Account supported methods.
Expand Down Expand Up @@ -147,7 +147,7 @@ export type Keyring = {
*/
createAccount(
name: string,
options?: Record<string, Json> | null,
options?: Record<string, Json>,
): Promise<KeyringAccount>;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/internal-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const CreateAccountRequestStruct = object({
method: literal('keyring_createAccount'),
params: object({
name: string(),
options: nullable(record(string(), JsonStruct)),
options: record(string(), JsonStruct),
}),
});

Expand Down

0 comments on commit b602243

Please sign in to comment.