Skip to content

Commit

Permalink
update @tonconnect/ui, dton is broke
Browse files Browse the repository at this point in the history
  • Loading branch information
designervoid committed Oct 29, 2023
1 parent 7397a74 commit 6672f25
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@solidjs/router": "^0.8.3",
"@tonconnect/ui": "2.0.0-beta.2",
"@tonconnect/ui": "2.0.0-beta.4",
"@twa-dev/sdk": "^6.9.0",
"@types/pako": "^2.0.1",
"graphql-request": "^6.1.0",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

25 changes: 10 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export interface TelegramUsernameNftAccountStates {
account_states: [TelegramUsernameNft];
};

const address = 'EQCy_jkW-aeL88vemIpoefVf_8-hTSg_CQ6wpZifdJdDUZR-';

function App() {
const { wallet, restored } = useTonConnectedWallet();
const [tonConnectUI] = useTonConnectUI();

const [walletDonateRaw, setWalletDonateRaw] = createSignal<undefined | TelegramUsernameNftAccountStates>(undefined);
const [donationAmount, setDonationAmount] = createSignal<undefined | string>(undefined);

const donate = () => {
const walletDonateRawReaded = walletDonateRaw();
const donate = async () => {
const donationAmountReaded = donationAmount();

if (Number(donationAmountReaded) <= 0) {
Expand All @@ -71,23 +71,24 @@ function App() {
return;
}

if (walletDonateRawReaded && donationAmountReaded) {
const template =
`${walletDonateRawReaded?.account_states[0].parsed_nft_owner_address_workchain}:${walletDonateRawReaded?.account_states[0].parsed_nft_owner_address_address}`; // excepted designervoid.t.me, but will show dogejetton.t.me

if (donationAmountReaded) {
const nanoAmount = (new Coins(donationAmountReaded).toNano());

const tx = {
validUntil: Math.floor(Date.now() / 1000) + 60, // 60 sec
messages: [
{
address: template, // destination address will be dogejetton.t.me in @wallet bot
address, // destination address will be dogejetton.t.me in @wallet bot
amount: nanoAmount, // toncoin in nanotons
}
]
};

tonConnectUI.sendTransaction(tx)
try {
await tonConnectUI.sendTransaction(tx);
} catch (err) {
console.error(err);
}
}
}

Expand All @@ -101,12 +102,6 @@ function App() {

onMount(() => {
WebApp.expand();

const run = async () => {
const t = await request<TelegramUsernameNftAccountStates>(endpoint, query);
setWalletDonateRaw(t);
}
run();
})

return (
Expand Down

0 comments on commit 6672f25

Please sign in to comment.