ton-connect / sdk

SDK for TON Connect 2.0 — a comprehensive communication protocol between wallets and apps in TON ecosystem
Apache License 2.0
317 stars 86 forks source link

Add ui-vue package. #4

Open DanielKOcean opened 1 year ago

DanielKOcean commented 1 year ago

Add Ton Connect Vue Kit.

siandreev commented 1 year ago

Hi, thanks for your suggestion.

Unfortunately, we do not plan to create such a package ourselves in the near future. However, we will gladly include community developments in the SDK.

d0rich commented 11 months ago

I just implemented this UI kit in Vue looking on React implementation: https://github.com/d0rich/esprit/tree/d-frontend/apps/d.d0rich.me/src/features/tonconnect

Here you can find not only tonconnect ui, but some other TON libs.

And I wanted to keep it in Pinia storage. More reliable way is to make it simple composable.

wizidot commented 4 months ago

I just implemented this UI kit in Vue looking on React implementation: https://github.com/d0rich/esprit/tree/d-frontend/apps/d.d0rich.me/src/features/tonconnect

Here you can find not only tonconnect ui, but some other TON libs.

And I wanted to keep it in Pinia storage. More reliable way is to make it simple composable.

Your link is dead . but i've found this repo (not tested) https://github.com/TownSquareXYZ/tonconnect-ui-vue/tree/main

afeezaziz commented 4 months ago

I just implemented this UI kit in Vue looking on React implementation: https://github.com/d0rich/esprit/tree/d-frontend/apps/d.d0rich.me/src/features/tonconnect Here you can find not only tonconnect ui, but some other TON libs. And I wanted to keep it in Pinia storage. More reliable way is to make it simple composable.

Your link is dead . but i've found this repo (not tested) https://github.com/TownSquareXYZ/tonconnect-ui-vue/tree/main

I am trying to npm install this but it would not work.

wizidot commented 4 months ago

yes me too, it doesn't work with vue 3/Nuxt/TypeScript... So i've implemented the cdn script :

onMounted(() => {
    console.log('Mounted')
    if (props.project.isConnected==false) {
  useHead({
      script: [
          {
              src: 'https://unpkg.com/@tonconnect/ui@latest/dist/tonconnect-ui.min.js',
              type: 'text/javascript',
              onload(el) {
                //console.log('tonconnect-ui.min.js LOADED')
                initializeTonConnect();                
              },
          },
      ],
  }, { mode: 'client' });
}
});

and

const  initializeTonConnect = async ()  => {
    tonConnectUI.value= new TON_CONNECT_UI.TonConnectUI({
        manifestUrl: 'https://xxx/tonconnect-manifest.json',
        buttonRootId: 'ton-connect'
    });
    const unsubscribeModal = await tonConnectUI.value.onModalStateChange(
    (state) => {
              // update state/reactive variables to show updates in the ui
        // state.status will be 'opened' or 'closed'
        // if state.status is 'closed', you can check state.closeReason to find out the reason
        if( state.status=="opened"){
          getWallet()
        }
    }
);
const unsubscribe = tonConnectUI.value.onStatusChange(
    (walletAndwalletInfo) => {
       //console.log('onStatusChange',walletAndwalletInfo)
       if(walletAndwalletInfo.account){
          props.project.isConnected=true;
          tonConnexionStatus.value = Boolean(walletAndwalletInfo.account.address!='')
          changeAddress(walletAndwalletInfo);

       }
    } 
);
mahdi4187 commented 3 months ago

hey guys

i use this, works for first view page in nuxt 3 but after page change and back to page get this error

Uncaught (in promise) DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "tc-root" has already been used with this registry

please guide me

wizidot commented 3 months ago

Ok, i think you have two buttonRootId no ? This error happened to me when I wanted to put two tonconnect buttons on the same page.

mahdi4187 commented 3 months ago
<template>
  <div id="ton-connect"></div>
</template>

No only have one div

mahdi4187 commented 3 months ago

https://github.com/ton-connect/sdk/issues/218

I fully explained in the above link