diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 6c119700..d573fa8d 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@dialectlabs/sdk", - "version": "1.9.3", + "version": "1.9.4", "type": "module", "repository": "git@github.com:dialectlabs/sdk.git", "author": "dialectlabs", diff --git a/packages/sdk/src/dapp/dapp.interface.ts b/packages/sdk/src/dapp/dapp.interface.ts index 5049ab5e..d9d8d7e9 100644 --- a/packages/sdk/src/dapp/dapp.interface.ts +++ b/packages/sdk/src/dapp/dapp.interface.ts @@ -1,10 +1,16 @@ import type { AddressType, DappAddress } from '../address/addresses.interface'; -import type { NotificationConfig, NotificationSubscription, NotificationType } from '../wallet/wallet.interface'; +import type { + NotificationConfig, + NotificationSubscription, + NotificationType, +} from '../wallet/wallet.interface'; import type { AccountAddress } from '../auth/auth.interface'; export interface Dapps { create(command: CreateDappCommand): Promise; + patch(command: PatchDappCommand): Promise; + find(query?: FindOneDappQuery): Promise; findAll(query?: FindDappQuery): Promise; @@ -59,6 +65,14 @@ export interface CreateDappCommand { blockchainType: BlockchainType; } +export interface PatchDappCommand { + name?: string; + description?: string | null; + websiteUrl?: string | null; + avatarUrl?: string | null; + heroUrl?: string | null; +} + export interface DappTelegramBotConfiguration { token: string; } @@ -81,7 +95,7 @@ interface DappMessageActionBase { type: DappMessageActionType; } -export interface DappMessageLinksAction extends DappMessageActionBase { +export interface DappMessageLinksAction extends DappMessageActionBase { type: DappMessageActionType.LINK; links: [DappMessageLinkAction]; } @@ -103,7 +117,6 @@ export interface SmartMessage { // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface SmartMessageParams {} - export interface SendDappMessageCommandBase { message: string; title?: string; @@ -113,7 +126,8 @@ export interface SendDappMessageCommandBase { // tags?: string[]; } -export interface BroadcastDappMessageCommand extends SendDappMessageCommandBase { +export interface BroadcastDappMessageCommand + extends SendDappMessageCommandBase { actionsV2?: DappMessageLinksAction; } @@ -174,4 +188,3 @@ export class DappNotificationSubscription { notificationType!: NotificationType; subscriptions!: NotificationSubscription[]; } - diff --git a/packages/sdk/src/dialect-cloud-api/data-service-dapps-api.ts b/packages/sdk/src/dialect-cloud-api/data-service-dapps-api.ts index 9d0db0d1..4ffe5b66 100644 --- a/packages/sdk/src/dialect-cloud-api/data-service-dapps-api.ts +++ b/packages/sdk/src/dialect-cloud-api/data-service-dapps-api.ts @@ -9,6 +9,8 @@ import type { BlockchainType } from '../dapp/dapp.interface'; export interface DataServiceDappsApi { create(command: Omit): Promise; + patch(command: PatchDappCommandDto): Promise; + findAll(query?: FindDappQueryDto): Promise; find(dappAddress?: string): Promise; @@ -45,6 +47,21 @@ export class DataServiceDappsApiClient implements DataServiceDappsApi { ); } + async patch(command: PatchDappCommandDto): Promise { + const token = await this.tokenProvider.get(); + return withReThrowingDataServiceError( + axios + .patch( + `${this.baseUrl}/api/v1/dapps/${token.body.sub}`, + command, + { + headers: createHeaders(token), + }, + ) + .then((it) => it.data), + ); + } + async findAllDappAddresses(): Promise { const token = await this.tokenProvider.get(); return withReThrowingDataServiceError( @@ -153,6 +170,14 @@ export class CreateDappCommandDto { readonly blockchainType?: string; } +export class PatchDappCommandDto { + readonly name?: string; + readonly description?: string | null; + readonly websiteUrl?: string | null; + readonly avatarUrl?: string | null; + readonly heroUrl?: string | null; +} + export class DappTelegramBotConfigurationDto { readonly token!: string; } diff --git a/packages/sdk/src/internal/dapp/dapp.ts b/packages/sdk/src/internal/dapp/dapp.ts index d046920c..2d44f49e 100644 --- a/packages/sdk/src/internal/dapp/dapp.ts +++ b/packages/sdk/src/internal/dapp/dapp.ts @@ -15,6 +15,7 @@ import type { Dapps, FindDappQuery, FindOneDappQuery, + PatchDappCommand, ReadOnlyDapp, } from '../../dapp/dapp.interface'; import type { DataServiceDappNotificationTypes } from './data-service-dapp-notification-types'; @@ -93,6 +94,19 @@ export class DappsImpl implements Dapps { ); return this.toDapp(dappDto); } + + async patch(command: PatchDappCommand): Promise { + const dappDto = await withErrorParsing( + this.dappsApi.patch({ + name: command.name, + description: command.description, + websiteUrl: command.websiteUrl, + avatarUrl: command.avatarUrl, + heroUrl: command.heroUrl, + }), + ); + return this.toDapp(dappDto); + } } export class DappImpl implements Dapp {