Skip to content

Commit 73f700a

Browse files
committed
add v2 compat mode
1 parent b41b377 commit 73f700a

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

packages/sdk/src/internal/sdk/sdk-factory.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { DataServiceApiFactory } from '../../dialect-cloud-api/data-service-api-
4545
import type { DataServiceApi } from '../../dialect-cloud-api/data-service-api';
4646
import { DataServiceWalletsApiClientV1 } from '../../dialect-cloud-api/data-service-wallets-api.v1';
4747
import { AlertsV2DappMessages } from '../dapp/alerts-v2-dapp-messages';
48-
import type { DataServiceDappsApi } from '../../dialect-cloud-api/data-service-dapps-api';
4948
import { AppV2Api } from '../../dialect-cloud-api/v2/application-api';
5049

5150
export class InternalDialectSdk<ChainSdk extends BlockchainSdk>
@@ -235,21 +234,32 @@ export class DialectSdkFactory<ChainSdk extends BlockchainSdk> {
235234
): DappMessages {
236235
const dappMessages: DappMessages[] = [];
237236

238-
if (config.dialectCloud.apiVersion === 1) {
239-
const dataServiceDappMessages = new DataServiceDappMessages(
240-
dataServiceApi.dapps,
241-
);
242-
dappMessages.push(dataServiceDappMessages);
243-
}
244-
245-
if (config.dialectCloud.apiVersion === 2) {
246-
const alertsV2DappMessages = new AlertsV2DappMessages(dappId, appV2Api);
247-
dappMessages.push(alertsV2DappMessages);
237+
const dataServiceDappMessages = new DataServiceDappMessages(
238+
dataServiceApi.dapps,
239+
);
240+
const alertsV2DappMessages = new AlertsV2DappMessages(dappId, appV2Api);
241+
242+
switch (config.dialectCloud.apiVersion) {
243+
case 1:
244+
dappMessages.push(dataServiceDappMessages);
245+
break;
246+
case 2:
247+
dappMessages.push(alertsV2DappMessages);
248+
break;
249+
case '2_compat':
250+
dappMessages.push(dataServiceDappMessages);
251+
dappMessages.push(alertsV2DappMessages);
252+
break;
253+
default:
254+
throw new IllegalArgumentError(
255+
`Unknown Dialect Cloud API version: ${config.dialectCloud.apiVersion}`,
256+
);
248257
}
249258

250259
if (blockchainSdk.dappMessages) {
251260
dappMessages.push(blockchainSdk.dappMessages);
252261
}
262+
253263
return new DappMessagesFacade(dappMessages);
254264
}
255265

@@ -309,19 +319,20 @@ export class DialectSdkFactory<ChainSdk extends BlockchainSdk> {
309319
v2Url: 'https://alerts.dialectapi.to',
310320
tokenStore: this.createTokenStore(),
311321
tokenLifetimeMinutes: this.createTokenLifetime(),
312-
walletCreation: 'implicit',
322+
walletCreation: 'none',
313323
};
324+
314325
const environment = this.config.environment;
315326
if (environment) {
316327
baseConfig.environment = environment;
317328
}
318329
if (environment === 'production') {
319330
baseConfig.url = 'https://dialectapi.to';
320-
baseConfig.v2Url = 'https://alerts.dialectapi.to';
331+
baseConfig.v2Url = 'https://alerts-api.dial.to';
321332
}
322333
if (environment === 'development') {
323334
baseConfig.url = 'https://dev.dialectapi.to';
324-
baseConfig.v2Url = 'https://alerts.dev.dialectapi.to';
335+
baseConfig.v2Url = 'https://alerts-api-dev.dial.to';
325336
}
326337
if (environment === 'local-development') {
327338
baseConfig.url = 'http://localhost:8080';
@@ -333,11 +344,11 @@ export class DialectSdkFactory<ChainSdk extends BlockchainSdk> {
333344
}
334345
if (dialectCloudEnvironment === 'production') {
335346
baseConfig.url = 'https://dialectapi.to';
336-
baseConfig.v2Url = 'https://alerts.dialectapi.to';
347+
baseConfig.v2Url = 'https://alerts-api.dial.to';
337348
}
338349
if (dialectCloudEnvironment === 'development') {
339350
baseConfig.url = 'https://dev.dialectapi.to';
340-
baseConfig.v2Url = 'https://alerts.dev.dialectapi.to';
351+
baseConfig.v2Url = 'https://alerts-api-dev.dial.to';
341352
}
342353
if (dialectCloudEnvironment === 'local-development') {
343354
baseConfig.url = 'http://localhost:8080';

packages/sdk/src/sdk/sdk.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface DialectCloudConfigProps {
8282
/**
8383
* @experimental This parameter is not guaranteed to be stable and may change in the future.
8484
* */
85-
apiVersion?: 1 | 2;
85+
apiVersion?: 1 | 2 | '2_compat';
8686
/**
8787
* @experimental This parameter is not guaranteed to be stable and may change in the future.
8888
* */
@@ -117,7 +117,7 @@ export interface Config extends ConfigProps {
117117
export interface DialectCloudConfig extends DialectCloudConfigProps {
118118
environment: DialectCloudEnvironment;
119119
clientKey?: string;
120-
apiVersion: 1 | 2;
120+
apiVersion: 1 | 2 | '2_compat';
121121
url: string;
122122
v2Url: string;
123123
tokenStore: TokenStore;

0 commit comments

Comments
 (0)