Skip to content

Conversation

@llawliet-l-l
Copy link
Contributor

Summary

Added Ton builders, utils and types to the wallets core.

Migrated TonConnect to use the new hub APIs for ton namespaces and updated documentation:

  • updated resolving namespace for ton wallets to legacy networks
  • created an initialization function to be called with TonConnect configs before using TonConnect

How did you test this change?

TonConnect was tested end-to-end within the Hub environment:

  • Connecting to Ton Wallets
  • Reconnecting on page reload if previously connected
  • Disconnecting when user disconnects from the wallet or directly from the app
  • Executing transactions from Ton namespace

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Implemented a user interface (UI) change, referencing our Figma design to ensure pixel-perfect precision.

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ProviderAPI = Record<string, any>;

export type ConnectOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove it since it's not being using.

Copy link
Contributor Author

@llawliet-l-l llawliet-l-l Dec 30, 2025

Choose a reason for hiding this comment

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

Fixed in 2ccb6c1

@@ -0,0 +1,2 @@
export const CAIP_NAMESPACE = 'ton';
Copy link
Contributor

Choose a reason for hiding this comment

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

Change it according to CAIP

Copy link
Contributor Author

@llawliet-l-l llawliet-l-l Dec 30, 2025

Choose a reason for hiding this comment

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

Fixed in 8dddf18

return async (context) => {
const tonInstance = getInstance();
await tonInstance.disconnect();
commonActions.disconnect(context);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do it separately in a and added to its action builder.

Copy link
Contributor Author

@llawliet-l-l llawliet-l-l Dec 30, 2025

Choose a reason for hiding this comment

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

Fixed in 7ee58a7

Comment on lines 29 to 31
const disconnect = new ActionBuilder<TonActions, 'disconnect'>('disconnect')
.action(tonActions.disconnect(tonConnect))
.after(changeAccountCleanup)
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use disconnect from common builders

Comment on lines 9 to 36
const changeAccountSubscriber = (getInstance: () => TonConnectUI) =>
new ChangeAccountSubscriberBuilder<
ConnectedWallet | null,
TonConnectUI,
TonActions
>()
.getInstance(getInstance)
/*
* TON wallets don't implement account change events, and we can only listen to disconnect events
* by checking the payload value.
* More info: https://github.com/ton-blockchain/ton-connect/blob/main/wallet-guidelines.md
*/
.onSwitchAccount(async (event, context) => {
event.preventDefault();
if (!event.payload) {
commonActions.disconnect(context);
}
})
.format(async () => [])
.addEventListener((instance, callback) => {
return instance.onStatusChange(callback);
})
.removeEventListener(() => {
/*
* We handle unsubscribing in the builder and by returning an unsubscribe function from 'addEventListener'
*/
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use change account subscriber builder for disconnect use another disconnect handler.

Copy link
Contributor Author

@llawliet-l-l llawliet-l-l Dec 30, 2025

Choose a reason for hiding this comment

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

Fixed in 7ee58a7

): FunctionWithContext<TonActions['disconnect'], Context> {
return async (context) => {
const tonInstance = getInstance();
await tonInstance.disconnect();
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if it's been disconnected don't disconnect again

Copy link
Contributor Author

@llawliet-l-l llawliet-l-l Dec 30, 2025

Choose a reason for hiding this comment

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

Fixed in 7ee58a7

llawliet-l-l and others added 6 commits December 31, 2025 08:18
# Conflicts:
#	wallets/core/package.json
#	wallets/core/src/hub/provider/types.ts
#	wallets/react/src/hub/helpers.ts
#	wallets/readme.md

# Conflicts:
#	wallets/provider-all/src/index.ts
#	wallets/readme.md
@llawliet-l-l llawliet-l-l force-pushed the feat/rf-2840-migrating-tonconnect-to-hub branch from 20aafa5 to 21647c9 Compare December 31, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants