Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
db683a5
feat: implement intent API for WalletKit
nikdim03 Feb 23, 2026
807f176
fix: align intent API with TonConnect spec
nikdim03 Feb 23, 2026
dc32a9e
feat: add support for object storage and trace ID propagation
nikdim03 Feb 25, 2026
d1eeb77
feat: improve type definitions & model generation
nikdim03 Feb 25, 2026
d8408b2
fix: unwrap { type, value } event wrapper in bridge approve/reject me…
nikdim03 Feb 25, 2026
d4ee71a
feat: update address type to UserFriendlyAddress in IntentSignDataRes…
nikdim03 Feb 26, 2026
630a663
refactor: simplify intent API methods and improve type handling
nikdim03 Feb 26, 2026
9911d08
refactor: fix lint
nikdim03 Feb 26, 2026
5b6b794
test: add unit tests for IntentHandler and IntentParser
nikdim03 Feb 26, 2026
c502e40
refactor: fix lint
nikdim03 Feb 26, 2026
0c5b9f2
feat: add approveBatchedIntent and related functionality for handling…
nikdim03 Feb 26, 2026
16952ca
refactor: remove processConnectAfterIntent and related connect reques…
nikdim03 Feb 26, 2026
ed14b6c
feat: enhance approveBatchedIntent to handle signData items and updat…
nikdim03 Feb 27, 2026
dce87ec
feat: update getSignedSendTransaction to support internal message sig…
nikdim03 Feb 27, 2026
6d63d3e
refactor: fix lint
nikdim03 Feb 27, 2026
e1c7d1e
feat: refactor intent models to flat interface unions
nikdim03 Mar 6, 2026
51492c8
feat: update intent API to use 'txDraft' and 'signMsgDraft' terminolo…
nikdim03 Mar 13, 2026
220e846
feat: update intent handling functionality in demo wallet
nikdim03 Mar 13, 2026
74266fb
feat: rename intent approval methods to use 'Draft' terminology for c…
nikdim03 Mar 13, 2026
a8d4354
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
0f9b200
feat: rename transaction draft event to transaction intent for clarity
nikdim03 Mar 13, 2026
fe27fbf
fix: fix lint
nikdim03 Mar 13, 2026
844de6a
fix: fix quality
nikdim03 Mar 13, 2026
3fe3925
fix: remove unused parameter from setupPassword test
nikdim03 Mar 13, 2026
91f2e89
fix: fix lint
nikdim03 Mar 13, 2026
6d2313f
feat: enhance isIntentUrl method to support new URL format and pre-in…
nikdim03 Mar 13, 2026
190486e
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
4d0b082
feat: update password helper text to reflect new requirements
nikdim03 Mar 13, 2026
cef4a42
chore: revert unrelated files
nikdim03 Mar 13, 2026
6209fc8
feat: refactor intent request types and validation
nikdim03 Mar 13, 2026
ff8e3e2
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
5da4e79
fix: lint
nikdim03 Mar 13, 2026
519d956
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
123ae3f
refactor: update buildInlineUrl to use method and params structure in…
nikdim03 Mar 13, 2026
b607ff8
refactor: update buildInlineUrl to use method and params structure in…
nikdim03 Mar 13, 2026
b081f97
feat: implement action intent handling with transaction and signData …
nikdim03 Mar 13, 2026
66313a7
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
fb4f2a6
fix: enhance error handling for action URL response to ensure valid JSON
nikdim03 Mar 13, 2026
95438ea
fix: enhance error handling for action URL response to ensure valid JSON
nikdim03 Mar 13, 2026
3159514
feat: implement payload decryption using NaCl crypto_box with ephemer…
nikdim03 Mar 13, 2026
d42aacb
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
8edb973
fix: lint
nikdim03 Mar 13, 2026
b1f5b1c
fix: lint
nikdim03 Mar 13, 2026
7d54d81
fix: remove redundant retry mechanism in transaction emulation
nikdim03 Mar 13, 2026
3fd48c1
Revert "fix: remove redundant retry mechanism in transaction emulation"
nikdim03 Mar 13, 2026
b84d3cb
feat: add support for https universal link scheme in IntentParser
nikdim03 Mar 13, 2026
47ad555
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 13, 2026
2c878c8
feat: add new event types and draft intents to EventStore and wallet …
nikdim03 Mar 13, 2026
6d09280
feat: update intent origin and event types to include 'connectedBridg…
nikdim03 Mar 13, 2026
58c1ff1
feat: add handling for bridge-delivered draft events and enhance Inte…
nikdim03 Mar 13, 2026
f777213
feat: route draft events directly via event emitter for existing sess…
nikdim03 Mar 13, 2026
bd4c4a1
feat: add RawBridgeEvent type import to TonWalletKit
nikdim03 Mar 13, 2026
09da596
feat: update getTonConnectFeatures to include intent features and adj…
nikdim03 Mar 13, 2026
14bebfb
feat: add SignMessage and related intent features to WalletV4R2 and W…
nikdim03 Mar 13, 2026
175cd72
fix: use correct wire response format for signMsgDraft (internal_boc)
nikdim03 Mar 15, 2026
8c3c224
fix: pass deliveryMode to sendBatchResponse so signMsgDraft returns i…
nikdim03 Mar 15, 2026
7a7c6e4
feat: add new event types and draft intents to EventStore and wallet …
nikdim03 Mar 13, 2026
c1291f3
feat: update intent origin and event types to include 'connectedBridg…
nikdim03 Mar 13, 2026
8edad0a
feat: add handling for bridge-delivered draft events and enhance Inte…
nikdim03 Mar 13, 2026
b2046cc
feat: route draft events directly via event emitter for existing sess…
nikdim03 Mar 13, 2026
b173e8d
feat: add RawBridgeEvent type import to TonWalletKit
nikdim03 Mar 13, 2026
cbad602
feat: add SignMessage and related intent features to WalletV4R2 and W…
nikdim03 Mar 13, 2026
a606961
fix: use correct wire response format for signMsgDraft (internal_boc)
nikdim03 Mar 15, 2026
44a59fb
fix: pass deliveryMode to sendBatchResponse so signMsgDraft returns i…
nikdim03 Mar 15, 2026
ee1b5a1
fix: fix quality
nikdim03 Mar 13, 2026
8ab8734
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
2fbf8c0
refactor: rename approveTransactionIntent/approveActionIntent to Draf…
nikdim03 Mar 16, 2026
23e6cb4
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
21cddde
fix: cast intent features to bypass outdated protocol types
nikdim03 Mar 16, 2026
a8768d9
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
a4b515e
refactor: clean up intent API — remove dead code, fix bugs, deduplicate
nikdim03 Mar 16, 2026
81584c5
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
8e6ce7a
fix: restore removeEvent, fix IntentParser.spec.ts formatting
nikdim03 Mar 16, 2026
333b5f2
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
48b09a9
fix: remove intent features from adapters to fix e2e connect validation
nikdim03 Mar 16, 2026
70d8f09
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
0499ad3
refactor: update intent API types and methods for consistency
nikdim03 Mar 16, 2026
5872c52
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
e59f703
Add type:'batched' discriminant to BatchedIntentEvent
nikdim03 Mar 16, 2026
0e2b927
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 16, 2026
9a53572
feat: add activeWalletId prop to IntentRequestModal and BatchedIntent…
nikdim03 Mar 16, 2026
4b48674
Filter intent features from DeviceInfo in TonConnect connect handshake
nikdim03 Mar 17, 2026
0613837
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 17, 2026
3736b69
remove stale eslint-disable comment in getTonConnectFeatures
nikdim03 Mar 17, 2026
d4be325
feat: add signMessageSupported property to supported features in Wall…
nikdim03 Mar 24, 2026
9491272
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 24, 2026
3aadfa1
feat: implement sign message request handling and approval process
nikdim03 Mar 24, 2026
54e2bac
fix: fix lint
nikdim03 Mar 24, 2026
1c35169
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 24, 2026
f5edb4c
feat: add sign message request handling and related hooks
nikdim03 Mar 24, 2026
22e2ff9
Revert "feat: add sign message request handling and related hooks"
nikdim03 Mar 24, 2026
d755479
feat: add sign message request handling and related hooks
nikdim03 Mar 24, 2026
f8268db
feat: add SignMessageRequestModal and integrate into WalletDashboard
nikdim03 Mar 24, 2026
8a3c123
feat: add SignMessageRequestModal and integrate into WalletDashboard
nikdim03 Mar 24, 2026
5b658ff
feat: update DAppInfo component props in SignMessageRequestModal
nikdim03 Mar 24, 2026
96cc313
feat: add support for signMessage event in StorageEventStore
nikdim03 Mar 24, 2026
6c568c0
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 24, 2026
4e4f2f9
fix: update address validation to use isValidAddress function
nikdim03 Mar 25, 2026
bcdc941
fix: handle address parsing errors in WalletV4R2 and WalletV5R1 adapters
nikdim03 Mar 25, 2026
f31c612
refactor: remove unused transaction preview logic in SignMessageHandler
nikdim03 Mar 25, 2026
7d6955d
fix: update address validation to use isValidAddress function
nikdim03 Mar 25, 2026
db92ce1
fix: handle address parsing errors in WalletV4R2 and WalletV5R1 adapters
nikdim03 Mar 25, 2026
bfb1a23
refactor: remove unused transaction preview logic in SignMessageHandler
nikdim03 Mar 25, 2026
5bff9d0
refactor: update type annotations to use 'unknown' for network and va…
nikdim03 Mar 25, 2026
5759993
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
ec53024
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
24beb99
refactor: enhance transaction message validation to support optional …
nikdim03 Mar 25, 2026
b78ba80
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
7971595
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
323f8b6
refactor: replace 'any' type with 'unknown' in transaction validation…
nikdim03 Mar 25, 2026
588af10
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
6d0e82b
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 25, 2026
484f0fb
fix: add MSW
nikdim03 Mar 25, 2026
bab6cb0
fix: update demo handler action type and simplify response structure
nikdim03 Mar 25, 2026
54fc8a1
fix: add missing newline in browser.ts for code consistency
nikdim03 Mar 25, 2026
bb19fcc
fix: handle MSW initialization failure gracefully in main.tsx
nikdim03 Mar 25, 2026
96c90f9
fix: add timeout to fetch manifest request in ConnectHandler
nikdim03 Mar 25, 2026
dccd4de
fix: enhance SignMessageRequestModal with loading state and success f…
nikdim03 Mar 26, 2026
7504086
fix: improve message display layout in SignMessageRequestModal
nikdim03 Mar 26, 2026
9c577a0
fix: fix lint
nikdim03 Mar 26, 2026
c4dcbfc
refactor: update device info to include all wallet-supported features
nikdim03 Mar 27, 2026
b593da3
chore: remove MSW
nikdim03 Mar 27, 2026
215a329
fix: mark several dependencies as optional in pnpm-lock.yaml
nikdim03 Mar 27, 2026
79aee43
refactor: update device info to include all wallet-supported features
nikdim03 Mar 27, 2026
e57dfd8
feat: enhance supported features in WalletV4R2 and WalletV5R1 adapters
nikdim03 Mar 27, 2026
41b7741
feat: add support for signMessage action in IntentParser
nikdim03 Mar 27, 2026
a08cbec
feat: enhance supported features in WalletV4R2 and WalletV5R1 adapters
nikdim03 Mar 27, 2026
e5abdd6
feat: add support for signMessage action in IntentParser
nikdim03 Mar 27, 2026
6cdf76f
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 27, 2026
9c85d24
fix: add timeout to fetch manifest request in ConnectHandler
nikdim03 Mar 25, 2026
bb7ebe2
fix: add retry limit and error predicate to sendBoc in IntentHandler
nikdim03 Mar 27, 2026
7ff5f7d
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
f7b7d51
revert: move demo-only sign message files back to demo wallet branch
nikdim03 Mar 30, 2026
ede6a73
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
ed932e4
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
69d0a2e
chore: restore demo files after merging ton-359 revert
nikdim03 Mar 30, 2026
4c07c9d
chore: merge main into feature/ton-359-new-intent-api-design
nikdim03 Mar 30, 2026
696dbf5
chore: merge feature/ton-359-new-intent-api-design into feature/ton-3…
nikdim03 Mar 30, 2026
b5660ea
fix: regenerate pnpm-lock.yaml after bad conflict resolution
nikdim03 Mar 30, 2026
890d4b9
fix: remove extra blank line in TonWalletKit.ts
nikdim03 Mar 30, 2026
6a606e9
fix: remove extra blank line in TonWalletKit.ts
nikdim03 Mar 30, 2026
89add74
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
21657b1
fix: update resolveAndApproveAction to return resolved event alongsid…
nikdim03 Mar 30, 2026
e17b030
fix: streamline intent response handling and add missing fields to so…
nikdim03 Mar 30, 2026
87815d9
fix: update resolveAndApproveAction to return resolved event alongsid…
nikdim03 Mar 30, 2026
42e6507
fix: streamline intent response handling and add missing fields to so…
nikdim03 Mar 30, 2026
70e352e
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
ab00722
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Mar 30, 2026
0004310
refactor: remove unused preview property from SignMessageRequestEvent
nikdim03 Mar 30, 2026
0f23804
fix: add TODO comments for future removal of type casting in Wallet a…
nikdim03 Mar 30, 2026
d082c35
fix: add comments to clarify opcode definitions in WalletV5R1Adapter
nikdim03 Mar 30, 2026
28814b1
chore: revert unrelated logic
nikdim03 Apr 1, 2026
c667f61
chore: add TODO
nikdim03 Apr 1, 2026
6e93f71
refactor: extract validation logic into separate transactionValidator…
nikdim03 Apr 1, 2026
cfdf884
refactor: remove preview property from SignMessageRequestEvent and re…
nikdim03 Apr 1, 2026
cdcccd9
fix: add BOC validation to sign message approval response
nikdim03 Apr 1, 2026
c3e0332
refactor: remove sendIntentResponse method and update IntentHandler t…
nikdim03 Apr 1, 2026
d061346
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
b561654
fix: add TODO comments for future removal of type casting in Wallet a…
nikdim03 Mar 30, 2026
348461a
fix: add comments to clarify opcode definitions in WalletV5R1Adapter
nikdim03 Mar 30, 2026
2192b60
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
a196de2
chore: revert sendIntentResponse
nikdim03 Apr 1, 2026
f52c22c
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
3634279
refactor: replace IntentParser instance with isIntentUrl function for…
nikdim03 Apr 1, 2026
3e72a09
test: enhance IntentParser tests with object storage scenarios and re…
nikdim03 Apr 1, 2026
f6102f3
refactor: streamline connect request parsing with a dedicated method …
nikdim03 Apr 1, 2026
6898551
fix: improve error handling and validation for signData and item mapp…
nikdim03 Apr 1, 2026
a1ab8e2
refactor: optimize intentItemsToTransactionRequest by using Promise.a…
nikdim03 Apr 1, 2026
d120e1f
fix: enhance URL validation in IntentParser and add timeout for fetch…
nikdim03 Apr 1, 2026
51d3a25
refactor: prevent duplicate intent request callbacks and optimize bat…
nikdim03 Apr 1, 2026
3b0f471
feat: add traceId and returnStrategy to batch processing in IntentHan…
nikdim03 Apr 1, 2026
f908ea8
refactor: streamline error handling in sendIntentResponse for batched…
nikdim03 Apr 1, 2026
8a778c2
test: add unit test for signMessage action response parsing as signOn…
nikdim03 Apr 1, 2026
4fd3cf7
refactor: rename TransactionDraftRequestEvent to TransactionIntentReq…
nikdim03 Apr 1, 2026
bf3034b
fix: remove timeout from fetch action URL to improve reliability
nikdim03 Apr 1, 2026
d33891d
Merge branch 'main' into feature/ton-359-new-intent-api-design
nikdim03 Apr 1, 2026
8e1c747
fix: remove timeout from fetch manifest
nikdim03 Apr 1, 2026
8831c48
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
b9d04fc
fix: if the transaction throws, the connect approval never runs
nikdim03 Apr 1, 2026
c333169
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
051b807
feat: enhance transaction request modal with delivery mode handling a…
nikdim03 Apr 1, 2026
edb61d3
refactor: simplify IntentRequestModal by removing unused functions an…
nikdim03 Apr 1, 2026
158bbd2
fix: restore transaction dialog
nikdim03 Apr 1, 2026
0ce6ada
feat: enhance message display in SignMessageRequestModal with improve…
nikdim03 Apr 1, 2026
2eb5257
feat: integrate IntentEventDetails into SignMessageRequestModal for t…
nikdim03 Apr 1, 2026
12cffe0
fix: handle session not found error when sending response in connecte…
nikdim03 Apr 1, 2026
a6adadd
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 1, 2026
0e45e1f
Merge branch 'main' into feature/ton-359-new-intent-api-design
nikdim03 Apr 2, 2026
d35ab87
fix: update eventEmitter type and error event handling in SignMessage…
nikdim03 Apr 2, 2026
f412104
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 2, 2026
08ffa16
fix: deliver signed body via an internal message for gasless
nikdim03 Apr 6, 2026
5ef1c61
feat: implement connectWithIntent method and associated event handling
nikdim03 Apr 6, 2026
3c26c22
Merge branch 'main' into feature/ton-359-new-intent-api-design
nikdim03 Apr 6, 2026
2173130
Merge branch 'main' into feature/ton-359-new-intent-api-design
nikdim03 Apr 6, 2026
b4a3cc0
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 6, 2026
ea64bbf
feat: update handleIntentUrl method to include optional jsBridgeConte…
nikdim03 Apr 6, 2026
99f1f4c
feat: handle connectWithIntent in background and process pending inte…
nikdim03 Apr 6, 2026
9744ba3
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 6, 2026
ce79dad
feat: extend jsBridgeContext in handleIntentUrl to include connectReq…
nikdim03 Apr 6, 2026
9249cd2
feat: add connectRequest to pending JS bridge intent handling
nikdim03 Apr 6, 2026
b4f8dab
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 6, 2026
c38cfad
Merge branch 'main' into feature/ton-359-new-intent-api-design
TrueCarry Apr 6, 2026
581609f
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
TrueCarry Apr 6, 2026
a2e5064
chore: fix quality
TrueCarry Apr 6, 2026
535bf4c
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
TrueCarry Apr 6, 2026
c7ae9ef
feat: route intent draft events and connectWithIntent through EventSt…
nikdim03 Apr 6, 2026
71660a0
Merge branch 'feature/ton-359-new-intent-api-design' into feature/ton…
nikdim03 Apr 6, 2026
87bd8df
feat: open popup for connectWithIntent JS bridge requests
nikdim03 Apr 6, 2026
6cf3686
feat: remove intents
TrueCarry Apr 8, 2026
e007835
feat: simplified pr based on new SDK spec
TrueCarry Apr 8, 2026
b8d8d30
Handle embedded requests urls
ProudOfZiggy Apr 15, 2026
3428899
Fixes comments
ProudOfZiggy Apr 15, 2026
0c9c1af
Update models according to spec
ProudOfZiggy Apr 15, 2026
d8afa86
Merge branch 'main' into dev/tim/sdk-sign-message-updates
ProudOfZiggy Apr 15, 2026
db20376
Fix annotations
ProudOfZiggy Apr 15, 2026
836952d
fix: pin alpha version of tonconnect
TrueCarry Apr 15, 2026
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
2 changes: 1 addition & 1 deletion apps/demo-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"vite-bundle-analyzer": "^1.3.2",
"webextension-polyfill": "^0.12.0"
}
}
}
198 changes: 198 additions & 0 deletions apps/demo-wallet/src/components/SignMessageRequestModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/**
* Copyright (c) TonTech.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import React, { useMemo, useState, useEffect } from 'react';
import type { SignMessageRequestEvent } from '@ton/walletkit';
import type { SavedWallet } from '@demo/wallet-core';
import { useAuth, useSignMessageRequests } from '@demo/wallet-core';
import { toast } from 'sonner';

import { Button } from './Button';
import { Card } from './Card';
import { DAppInfo } from './DAppInfo';
import { WalletPreview } from './WalletPreview';
import { HoldToSignButton } from './HoldToSignButton';
import { createComponentLogger } from '../utils/logger';

const log = createComponentLogger('SignMessageRequestModal');

interface SignMessageRequestModalProps {
request: SignMessageRequestEvent;
savedWallets: SavedWallet[];
isOpen: boolean;
}

export const SignMessageRequestModal: React.FC<SignMessageRequestModalProps> = ({ request, savedWallets, isOpen }) => {
const [isLoading, setIsLoading] = useState(false);
const [showSuccess, setShowSuccess] = useState(false);
const { holdToSign } = useAuth();
const { approveSignMessageRequest, rejectSignMessageRequest } = useSignMessageRequests();

const currentWallet = useMemo(() => {
if (!request.walletAddress) return null;
return savedWallets.find((wallet) => wallet.kitWalletId === request.walletId) || null;
}, [savedWallets, request.walletAddress, request.walletId]);

useEffect(() => {
if (!isOpen) {
setShowSuccess(false);
setIsLoading(false);
}
}, [isOpen]);

const handleApprove = async () => {
setIsLoading(true);
try {
await approveSignMessageRequest();
setIsLoading(false);
setShowSuccess(true);
} catch (error) {
log.error('Failed to approve sign message request:', error);
toast.error('Failed to approve sign message', {
description: (error as Error)?.message,
});
setIsLoading(false);
}
};

const handleReject = () => {
rejectSignMessageRequest('User rejected the sign message request');
};

if (!isOpen) return null;

if (showSuccess) {
return (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
<style>{`
@keyframes scale-in {
from { transform: scale(0.8); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}
.success-card { animation: scale-in 0.3s ease-out; }
`}</style>
<div className="bg-gradient-to-br from-green-400 to-green-600 rounded-lg max-w-md w-full p-8 relative overflow-hidden success-card">
<div className="relative z-10 text-center text-white space-y-6">
<div className="flex justify-center">
<div className="bg-white rounded-full p-4">
<svg
className="w-16 h-16 text-green-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={3}
d="M5 13l4 4L19 7"
/>
</svg>
</div>
</div>
<div>
<h2 className="text-3xl font-bold mb-2">Success!</h2>
<p className="text-green-50 text-lg">Message signed successfully</p>
</div>
</div>
</div>
</div>
);
}

const messageCount = request.request?.messages?.length ?? request.request?.items?.length ?? 0;

return (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
<div className="bg-white rounded-lg max-w-md w-full max-h-[90vh] overflow-y-auto">
<Card>
<div className="space-y-6">
<div className="text-center">
<h2 data-testid="request" className="text-xl font-bold text-gray-900">
Sign Message Request
</h2>
<p className="text-gray-600 text-sm mt-1">
A dApp wants you to sign a transaction without broadcasting it
</p>
</div>

<DAppInfo
iconUrl={request.dAppInfo?.iconUrl}
name={request.dAppInfo?.name}
url={request.dAppInfo?.url}
description={request.dAppInfo?.description}
/>

{currentWallet && (
<div>
<WalletPreview wallet={currentWallet} isActive={true} isCompact={true} />
</div>
)}

<div className="border rounded-lg p-3 bg-blue-50">
<h4 className="font-medium text-blue-900 mb-2">Transaction Details</h4>
<p className="text-sm text-blue-800">
{messageCount} message{messageCount !== 1 ? 's' : ''} to sign (not broadcast)
</p>
</div>

<div className="bg-yellow-50 border border-yellow-200 rounded-lg p-3">
<div className="flex">
<div className="flex-shrink-0">
<svg className="h-5 w-5 text-yellow-400" viewBox="0 0 20 20" fill="currentColor">
<path
fillRule="evenodd"
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
clipRule="evenodd"
/>
</svg>
</div>
<div className="ml-3">
<p className="text-sm text-yellow-800">
<strong>Warning:</strong> This will sign a transaction that the dApp can submit
later. Only approve if you trust the requesting dApp.
</p>
</div>
</div>
</div>

<div className="flex space-x-3">
<Button
data-testid="sign-message-reject"
variant="secondary"
onClick={handleReject}
disabled={isLoading}
className="flex-1"
>
Reject
</Button>
{holdToSign ? (
<HoldToSignButton
onComplete={handleApprove}
isLoading={isLoading}
disabled={isLoading}
holdDuration={3000}
/>
) : (
<Button
data-testid="sign-message-approve"
onClick={handleApprove}
isLoading={isLoading}
disabled={isLoading}
className="flex-1"
>
Sign Message
</Button>
)}
</div>
</div>
</Card>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions apps/demo-wallet/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export { StreamingStatus } from './StreamingStatus';
export { ProtectedRoute } from './ProtectedRoute';
export { RecentTransactions } from './RecentTransactions';
export { SignDataRequestModal } from './SignDataRequestModal';
export { SignMessageRequestModal } from './SignMessageRequestModal';
export { TraceRow } from './TraceRow';
export { TransactionRequestModal } from './TransactionRequestModal';
export { WalletPreview } from './WalletPreview';
Expand Down
20 changes: 19 additions & 1 deletion apps/demo-wallet/src/pages/WalletDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

import React, { useState, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { useWallet, useWalletKit, useTonConnect, useTransactionRequests, useSignDataRequests } from '@demo/wallet-core';
import {
useWallet,
useWalletKit,
useTonConnect,
useTransactionRequests,
useSignDataRequests,
useSignMessageRequests,
} from '@demo/wallet-core';

import {
AnimatedBalance,
Expand All @@ -18,6 +25,7 @@ import {
ConnectRequestModal,
TransactionRequestModal,
SignDataRequestModal,
SignMessageRequestModal,
DisconnectNotifications,
NftsCard,
RecentTransactions,
Expand Down Expand Up @@ -64,6 +72,7 @@ export const WalletDashboard: React.FC = () => {
const { pendingTransactionRequest, isTransactionModalOpen } = useTransactionRequests();
const { pendingSignDataRequest, isSignDataModalOpen, approveSignDataRequest, rejectSignDataRequest } =
useSignDataRequests();
const { pendingSignMessageRequest, isSignMessageModalOpen } = useSignMessageRequests();
const { error } = useTonWallet();

// Use the paste handler hook
Expand Down Expand Up @@ -380,6 +389,15 @@ export const WalletDashboard: React.FC = () => {
onReject={rejectSignDataRequest}
/>
)}

{/* Sign Message Request Modal */}
{pendingSignMessageRequest && (
<SignMessageRequestModal
request={pendingSignMessageRequest}
savedWallets={savedWallets}
isOpen={isSignMessageModalOpen}
/>
)}
</Layout>
);
};
1 change: 0 additions & 1 deletion apps/demo-wallet/src/utils/walletManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function getTonConnectDeviceInfo(): DeviceInfo {

export function getTonConnectFeatures(): Feature[] {
return [
'SendTransaction',
{
name: 'SendTransaction',
maxMessages: 4,
Expand Down
16 changes: 16 additions & 0 deletions demo/wallet-core/src/hooks/useWalletStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ export const useSignDataRequests = () => {
);
};

/**
* Hook for sign message requests
*/
export const useSignMessageRequests = () => {
return useWalletStore(
useShallow((state) => ({
pendingSignMessageRequest: state.tonConnect.pendingSignMessageRequestEvent,
isSignMessageModalOpen: state.tonConnect.isSignMessageModalOpen,
showSignMessageRequest: state.showSignMessageRequest,
approveSignMessageRequest: state.approveSignMessageRequest,
rejectSignMessageRequest: state.rejectSignMessageRequest,
closeSignMessageModal: state.closeSignMessageModal,
})),
);
};

/**
* Hook for disconnect events
*/
Expand Down
1 change: 1 addition & 0 deletions demo/wallet-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
useTonConnect,
useTransactionRequests,
useSignDataRequests,
useSignMessageRequests,
useDisconnectEvents,
useNfts,
useJettons,
Expand Down
Loading
Loading