Skip to content

Commit 9b14843

Browse files
committed
fix: remove channelConfig, no longer needed in here
1 parent e72cedf commit 9b14843

3 files changed

Lines changed: 2 additions & 95 deletions

File tree

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
11
/* c8 ignore start */
2-
export interface ChannelConfig {
3-
channelId: string;
4-
validUntil: number;
5-
otherKey?: string;
6-
localKey?: string;
7-
walletVersion?: string;
8-
deeplinkProtocolAvailable?: boolean;
9-
relayPersistence?: boolean; // Set if the session has full relay persistence (can exchange message without the other side connected)
10-
/**
11-
* lastActive: ms value of the last time connection was ready CLIENTS_READY event.
12-
* */
13-
lastActive?: number;
14-
}
152

163
export abstract class StoreClient {
174
abstract getAnonId(): Promise<string | null>;
18-
195
abstract getExtensionId(): Promise<string | null>;
20-
21-
abstract getChannelConfig(): Promise<ChannelConfig | null>;
22-
236
abstract setExtensionId(extensionId: string): Promise<void>;
24-
257
abstract setAnonId(anonId: string): Promise<void>;
26-
27-
abstract setChannelConfig(channelConfig: ChannelConfig): Promise<void>;
28-
298
abstract removeExtensionId(): Promise<void>;
30-
319
abstract removeAnonId(): Promise<void>;
32-
3310
abstract getDebug(): Promise<string | null>;
3411
}

packages/sdk-multichain/src/store/index.test.ts

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
66

77

88
import { Store } from './index';
9-
import { StoreAdapter, type ChannelConfig } from '../domain';
9+
import { StoreAdapter } from '../domain';
1010
import { StoreAdapterWeb } from './adapters/web';
1111
import { StoreAdapterRN } from './adapters/rn';
1212
import { StoreAdapterNode } from './adapters/node';
@@ -121,64 +121,6 @@ function createStoreTests(
121121
});
122122
});
123123

124-
t.describe(`${adapterName} getChannelConfig`, () => {
125-
t.it('should return the channel config when it exists and is valid JSON', async () => {
126-
const channelConfig: ChannelConfig = {
127-
channelId: 'test-channel',
128-
validUntil: Date.now() + 3600000,
129-
otherKey: 'other-key',
130-
localKey: 'local-key',
131-
walletVersion: '1.0.0',
132-
deeplinkProtocolAvailable: true,
133-
relayPersistence: false,
134-
lastActive: Date.now()
135-
};
136-
137-
await adapter.setItem('channelConfig', JSON.stringify(channelConfig));
138-
const result = await store.getChannelConfig();
139-
140-
t.expect(result).toEqual(channelConfig);
141-
});
142-
143-
t.it('should return null when channel config does not exist', async () => {
144-
const result = await store.getChannelConfig();
145-
t.expect(result).toBeNull();
146-
});
147-
148-
t.it('should throw an error when stored JSON is invalid', async () => {
149-
await adapter.setItem('channelConfig', 'invalid-json');
150-
await t.expect(store.getChannelConfig()).rejects.toThrow();
151-
});
152-
});
153-
154-
t.describe(`${adapterName} setChannelConfig`, () => {
155-
t.it('should set the channel config successfully', async () => {
156-
const channelConfig: ChannelConfig = {
157-
channelId: 'test-channel',
158-
validUntil: Date.now() + 3600000,
159-
otherKey: 'other-key',
160-
localKey: 'local-key'
161-
};
162-
163-
await store.setChannelConfig(channelConfig);
164-
165-
const storedValue = await adapter.getItem('channelConfig');
166-
t.expect(JSON.parse(storedValue!)).toEqual(channelConfig);
167-
});
168-
169-
t.it('should handle minimal channel config', async () => {
170-
const channelConfig: ChannelConfig = {
171-
channelId: 'minimal-channel',
172-
validUntil: Date.now() + 3600000
173-
};
174-
175-
await store.setChannelConfig(channelConfig);
176-
177-
const storedValue = await adapter.getItem('channelConfig');
178-
t.expect(JSON.parse(storedValue!)).toEqual(channelConfig);
179-
});
180-
});
181-
182124
t.describe(`${adapterName} getDebug`, () => {
183125
t.it('should return the debug value when it exists', async () => {
184126
await adapter.setItem('DEBUG', 'metamask-sdk:*');

packages/sdk-multichain/src/store/index.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ChannelConfig, StoreClient, StoreAdapter } from "../domain";
1+
import type {StoreClient, StoreAdapter } from "../domain";
22

33

44
export class Store implements StoreClient {
@@ -16,18 +16,6 @@ export class Store implements StoreClient {
1616
return this.#adapter.getItem('extensionId');
1717
}
1818

19-
async getChannelConfig(): Promise<ChannelConfig | null> {
20-
const channelConfig = await this.#adapter.getItem('channelConfig');
21-
if (!channelConfig) {
22-
return null;
23-
}
24-
return JSON.parse(channelConfig)
25-
}
26-
27-
async setChannelConfig(channelConfig: ChannelConfig): Promise<void> {
28-
return this.#adapter.setItem('channelConfig', JSON.stringify(channelConfig));
29-
}
30-
3119
async setAnonId(anonId: string): Promise<void> {
3220
return this.#adapter.setItem('anonId', anonId);
3321
}

0 commit comments

Comments
 (0)