diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index e0e59e65..c0871b5e 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog @tonconnect/sdk +## [2.1.4](https://github.com/ton-connect/sdk/compare/sdk-2.1.3...sdk-2.1.4) (2023-08-15) + + +### Bug Fixes + +* 'platform' field added to WalletInfo ([40e0332](https://github.com/ton-connect/sdk/commit/40e0332a37886baef6aaa9942a8fad7a2e29d78b)) +* **sdk:** README updated ([900c115](https://github.com/ton-connect/sdk/commit/900c115bd71aa631026f60e55632e03d7b185784)) + + + ## [2.1.3](https://github.com/ton-connect/sdk/compare/sdk-2.1.2...sdk-2.1.3) (2023-04-03) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index dafe60ae..90b1edaa 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@tonconnect/sdk", - "version": "2.1.3", + "version": "2.1.4", "scripts": { "build": "npx rimraf types-dist && npx rimraf lib && npx rollup -c rollup.config.mjs && ttsc --project tsconfig.declarations.json && api-extractor run && npx rimraf types-dist && npx rimraf dist && npx webpack --config webpack.config.js", "test": "vitest run" diff --git a/packages/sdk/src/models/wallet/wallet-info.ts b/packages/sdk/src/models/wallet/wallet-info.ts index a1de44f4..07cd096f 100644 --- a/packages/sdk/src/models/wallet/wallet-info.ts +++ b/packages/sdk/src/models/wallet/wallet-info.ts @@ -21,6 +21,20 @@ export interface WalletInfoBase { * Info or landing page of your wallet. May be useful for TON newcomers. */ aboutUrl: string; + + /** + * OS and browsers where the wallet could be installed + */ + platforms: ( + | 'ios' + | 'android' + | 'macos' + | 'windows' + | 'linux' + | 'chrome' + | 'firefox' + | 'safari' + )[]; } /** @@ -99,6 +113,16 @@ export interface WalletInfoDTO { tondns?: string; about_url: string; universal_url?: string; + platforms: ( + | 'ios' + | 'android' + | 'macos' + | 'windows' + | 'linux' + | 'chrome' + | 'firefox' + | 'safari' + )[]; deepLink?: string; bridge: (WalletInfoBridgeRemoteDTO | WalletInfoBridgeInjectedDTO)[]; diff --git a/packages/sdk/src/provider/injected/injected-provider.ts b/packages/sdk/src/provider/injected/injected-provider.ts index ba9513e3..c4636d0c 100644 --- a/packages/sdk/src/provider/injected/injected-provider.ts +++ b/packages/sdk/src/provider/injected/injected-provider.ts @@ -63,7 +63,8 @@ export class InjectedProvider implements InternalProv tondns: wallet.tonconnect.walletInfo.tondns, jsBridgeKey, injected: true, - embedded: wallet.tonconnect.isWalletBrowser + embedded: wallet.tonconnect.isWalletBrowser, + platforms: wallet.tonconnect.walletInfo.platforms })); } diff --git a/packages/sdk/src/provider/injected/models/injected-wallet-api.ts b/packages/sdk/src/provider/injected/models/injected-wallet-api.ts index 3b36fefd..a4246d1a 100644 --- a/packages/sdk/src/provider/injected/models/injected-wallet-api.ts +++ b/packages/sdk/src/provider/injected/models/injected-wallet-api.ts @@ -12,7 +12,7 @@ import { hasProperties, hasProperty } from 'src/utils/types'; export interface InjectedWalletApi { deviceInfo: DeviceInfo; - walletInfo: Pick; + walletInfo: Pick; protocolVersion: number; isWalletBrowser: boolean; connect(protocolVersion: number, message: ConnectRequest): Promise; @@ -32,7 +32,12 @@ export function isJSBridgeWithMetadata(value: unknown): value is { tonconnect: I return false; } - return hasProperties(value.tonconnect.walletInfo, ['name', 'image', 'about_url']); + return hasProperties(value.tonconnect.walletInfo, [ + 'name', + 'image', + 'about_url', + 'platforms' + ]); } catch { return false; } diff --git a/packages/sdk/src/resources/fallback-wallets-list.ts b/packages/sdk/src/resources/fallback-wallets-list.ts index b95bbc4c..a7570eb2 100644 --- a/packages/sdk/src/resources/fallback-wallets-list.ts +++ b/packages/sdk/src/resources/fallback-wallets-list.ts @@ -16,7 +16,8 @@ export const FALLBACK_WALLETS_LIST: WalletInfoDTO[] = [ type: 'js', key: 'tonkeeper' } - ] + ], + platforms: ['ios', 'android', 'chrome', 'firefox'] }, { name: 'OpenMask', @@ -27,17 +28,90 @@ export const FALLBACK_WALLETS_LIST: WalletInfoDTO[] = [ type: 'js', key: 'openmask' } - ] + ], + platforms: ['chrome'] }, { name: 'MyTonWallet', image: 'https://mytonwallet.io/icon-256.png', about_url: 'https://mytonwallet.io', + universal_url: 'https://connect.mytonwallet.org', bridge: [ { type: 'js', key: 'mytonwallet' + }, + { + type: 'sse', + url: 'https://tonconnectbridge.mytonwallet.org/bridge/' + } + ], + platforms: ['chrome', 'windows', 'macos', 'linux'] + }, + { + name: 'Tonhub', + image: 'https://tonhub.com/tonconnect_logo.png', + about_url: 'https://tonhub.com', + universal_url: 'https://tonhub.com/ton-connect', + bridge: [ + { + type: 'js', + key: 'tonhub' + }, + { + type: 'sse', + url: 'https://connect.tonhubapi.com/tonconnect' + } + ], + platforms: ['ios', 'android'] + }, + { + name: 'TonFlow', + image: 'https://tonflow.net/assets/images/tonflow_ico_192.png', + about_url: 'https://tonflow.net', + bridge: [ + { + type: 'js', + key: 'tonflow' + } + ], + platforms: ['chrome'] + }, + { + name: 'DeWallet', + image: 'https://app.delabwallet.com/logo_black.png', + about_url: 'https://delabwallet.com', + bridge: [ + { + type: 'js', + key: 'dewallet' + } + ], + platforms: ['chrome'] + }, + { + name: 'XTONWallet', + image: 'https://xtonwallet.com/assets/img/icon-256-back.png', + about_url: 'https://xtonwallet.com', + bridge: [ + { + type: 'js', + key: 'xtonwallet' + } + ], + platforms: ['chrome', 'firefox'] + }, + { + name: 'TON Wallet', + image: 'https://wallet.ton.org/assets/ui/qr-logo.png', + about_url: + 'https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd', + bridge: [ + { + type: 'js', + key: 'tonwallet' } - ] + ], + platforms: ['chrome'] } ]; diff --git a/packages/sdk/src/wallets-list-manager.ts b/packages/sdk/src/wallets-list-manager.ts index 00b4f5aa..2bdfef15 100644 --- a/packages/sdk/src/wallets-list-manager.ts +++ b/packages/sdk/src/wallets-list-manager.ts @@ -118,7 +118,8 @@ export class WalletsListManager { name: walletConfigDTO.name, imageUrl: walletConfigDTO.image, aboutUrl: walletConfigDTO.about_url, - tondns: walletConfigDTO.tondns + tondns: walletConfigDTO.tondns, + platforms: walletConfigDTO.platforms } as WalletInfo; walletConfigDTO.bridge.forEach(bridge => { @@ -165,11 +166,19 @@ export class WalletsListManager { const containsName = 'name' in value; const containsImage = 'image' in value; const containsAbout = 'about_url' in value; + const containsPlatforms = 'platforms' in value; - if (!containsName || !containsImage || !containsAbout) { + if (!containsName || !containsImage || !containsAbout || !containsPlatforms) { return false; } + if ( + !(value as { platforms: unknown }).platforms || + !Array.isArray((value as { platforms: unknown }).platforms) || + !(value as { platforms: string[] }).platforms.length + ) { + return false; + } if ( !('bridge' in value) || !Array.isArray((value as { bridge: unknown }).bridge) ||