Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/required features #324

Open
wants to merge 8 commits into
base: feat/extra-currency
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
},
{
"sourceTag": "scope:ui",
"onlyDependOnLibsWithTags": ["scope:core"]
"onlyDependOnLibsWithTags": ["scope:sdk"]
},
{
"sourceTag": "scope:ui-react",
"onlyDependOnLibsWithTags": ["scope:ui"]
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
dist
.idea
.vscode
.DS_Store
22 changes: 10 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ConnectEventError {
payload: {
code: CONNECT_EVENT_ERROR_CODES;
message: string;
device?: DeviceInfo;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove changes in protocolo

};
}

Expand All @@ -28,7 +29,8 @@ export enum CONNECT_EVENT_ERROR_CODES {
MANIFEST_CONTENT_ERROR = 3,
UNKNOWN_APP_ERROR = 100,
USER_REJECTS_ERROR = 300,
METHOD_NOT_SUPPORTED = 400
METHOD_NOT_SUPPORTED = 400,
MISSING_REQUIRED_FEATURES = 430
}

export type ConnectItemReply = TonAddressItemReply | TonProofItemReply;
Expand Down
8 changes: 7 additions & 1 deletion packages/sdk/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ["../../.eslintrc.js"],
extends: ['../../.eslintrc.js'],
overrides: [
{
files: './vite.config.ts',
Expand All @@ -9,6 +9,12 @@ module.exports = {
tsconfigRootDir: __dirname,
createDefaultProgram: true
},
'@nx/enforce-module-boundaries': [
'error',
{
allow: ['scope:protocol']
}
]
}
]
};
27 changes: 11 additions & 16 deletions packages/sdk/src/wallets-list-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ export class WalletsListManager {
public async getEmbeddedWallet(): Promise<WalletInfoCurrentlyEmbedded | null> {
const walletsList = await this.getWallets();
const embeddedWallets = walletsList.filter(isWalletInfoCurrentlyEmbedded);

if (embeddedWallets.length !== 1) {
return null;
}

return embeddedWallets[0]!;
return embeddedWallets.length === 1 ? embeddedWallets[0]! : null;
}

private async fetchWalletsList(): Promise<WalletInfo[]> {
Expand All @@ -87,7 +82,7 @@ export class WalletsListManager {
if (wrongFormatWallets.length) {
logError(
`Wallet(s) ${wrongFormatWallets
.map(wallet => wallet.name)
.map(wallet => (wallet as WalletInfoDTO)?.name || 'unknown')
.join(
', '
)} config format is wrong. They were removed from the wallets list.`
Expand Down Expand Up @@ -115,7 +110,7 @@ export class WalletsListManager {

private walletConfigDTOListToWalletConfigList(walletConfigDTO: WalletInfoDTO[]): WalletInfo[] {
return walletConfigDTO.map(walletConfigDTO => {
const walletConfigBase: WalletInfoBase = {
const walletConfig: WalletInfoBase = {
name: walletConfigDTO.name,
appName: walletConfigDTO.app_name,
imageUrl: walletConfigDTO.image,
Expand All @@ -124,16 +119,13 @@ export class WalletsListManager {
platforms: walletConfigDTO.platforms
};

const walletConfig: WalletInfo = walletConfigBase as WalletInfo;

walletConfigDTO.bridge.forEach(bridge => {
if (bridge.type === 'sse') {
(walletConfig as WalletInfoRemote).bridgeUrl = bridge.url;
(walletConfig as WalletInfoRemote).universalLink =
walletConfigDTO.universal_url!;
(walletConfig as WalletInfoRemote).deepLink = walletConfigDTO.deepLink;
}

if (bridge.type === 'js') {
const jsBridgeKey = bridge.key;
(walletConfig as WalletInfoInjectable).jsBridgeKey = jsBridgeKey;
Expand All @@ -143,8 +135,7 @@ export class WalletsListManager {
InjectedProvider.isInsideWalletBrowser(jsBridgeKey);
}
});

return walletConfig;
return walletConfig as WalletInfo;
});
}

Expand Down Expand Up @@ -209,9 +200,9 @@ export class WalletsListManager {

if (sseBridge) {
if (
!('url' in sseBridge) ||
!(sseBridge && typeof sseBridge === 'object' && 'url' in sseBridge) ||
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check exception

!(sseBridge as { url: string }).url ||
!(value as { universal_url: string }).universal_url
!(value as unknown as { universal_url: string }).universal_url
) {
return false;
}
Expand All @@ -220,7 +211,11 @@ export class WalletsListManager {
const jsBridge = bridge.find(item => (item as { type: string }).type === 'js');

if (jsBridge) {
if (!('key' in jsBridge) || !(jsBridge as { key: string }).key) {
if (
typeof jsBridge !== 'object' ||
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check exception

!('key' in jsBridge) ||
!(jsBridge as { key: string }).key
) {
return false;
}
}
Expand Down
Loading