Skip to content

Commit

Permalink
Update MaxMessages for ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovNikita committed Nov 28, 2024
1 parent 7a85b92 commit 9425a26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
27 changes: 21 additions & 6 deletions packages/core/src/service/tonConnect/connectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,21 +385,36 @@ export const tonDisconnectRequest = async (options: { storage: IStorage; webView
await disconnectAccountConnection({ ...options, wallet: connection.wallet });
};

const getMaxMessages = (account: Account) => {
if (account.type === 'ledger') {
return 1;
}

const wallet = account.activeTonWallet;

return isStandardTonWallet(wallet) && wallet.version === WalletVersion.V5R1 ? 255 : 4;
};

export const saveWalletTonConnect = async (options: {
storage: IStorage;
wallet: TonContract;
account: Account;
manifest: DAppManifest;
params: TonConnectParams;
replyItems: ConnectItemReply[];
appVersion: string;
webViewUrl?: string;
}): Promise<ConnectEvent> => {
await saveAccountConnection(options);
const wallet = options.account.activeTonWallet;
await saveAccountConnection({
storage: options.storage,
wallet,
manifest: options.manifest,
params: options.params,
webViewUrl: options.webViewUrl
});

const maxMessages = getMaxMessages(options.account);

const maxMessages =
isStandardTonWallet(options.wallet) && options.wallet.version === WalletVersion.V5R1
? 255
: 4;
return {
id: Date.now(),
event: 'connect',
Expand Down
2 changes: 1 addition & 1 deletion packages/uikit/src/components/connect/connectHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const useResponseConnectionMutation = () => {
if (replyItems && manifest && data) {
const response = await saveWalletTonConnect({
storage: sdk.storage,
wallet: data.activeTonWallet,
account: data,
manifest,
params,
replyItems,
Expand Down

0 comments on commit 9425a26

Please sign in to comment.