generated from thebatclaudio/ton-dapp-vue-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Claudio La Barbera
committed
Sep 9, 2024
1 parent
99bfa50
commit f315636
Showing
13 changed files
with
171 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
VITE_ENV="development" | ||
VITE_TELEGRAM_BOT_URL="" | ||
VITE_TELEGRAM_MANIFEST_URL="" | ||
VITE_JETTON_SYMBOL="" | ||
VITE_TON_CONTRACT_ADDRESS="" | ||
VITE_API_BASE_URL="https://example-api.com/api" | ||
VITE_TON_CONTRACT_ADDRESS="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
VITE_ENV="development" | ||
VITE_TELEGRAM_BOT_URL="https://t.me/DisclosureGameBot" | ||
VITE_TELEGRAM_MANIFEST_URL="https://thebatclaudio.github.io/ton-dapp-vue-template/tonconnect-manifest.json" | ||
VITE_JETTON_SYMBOL="COIN" | ||
VITE_TON_CONTRACT_ADDRESS="UQCxB9fUfl5s2s2J8IClW8cvSPoCpp3G1EXcu_j3kfjUhO0K" | ||
VITE_API_BASE_URL="http://localhost/api" | ||
VITE_TELEGRAM_BOT_URL="https://t.me/x2lotterybot" | ||
VITE_TELEGRAM_MANIFEST_URL="https://gradoally.github.io/x2lottery/tonconnect-manifest.json" | ||
VITE_TON_CONTRACT_ADDRESS="kQB0_W4oxy-FUhQAxH8wSgay0XB3BXciGJ7z0TSjo0qel3D3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "ton-dapp-vue-template", | ||
"name": "x2lottery", | ||
"private": true, | ||
"version": "0.1.0", | ||
"type": "module", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"url": "https://thebatclaudio.github.io/ton-dapp-vue-template", | ||
"name": "TON DApp Vue Template", | ||
"iconUrl": "https://thebatclaudio.github.io/ton-dapp-vue-template/icon.png" | ||
"url": "https://gradoally.github.io/x2lottery", | ||
"name": "x2lottery", | ||
"iconUrl": "https://gradoally.github.io/x2lottery/icon.png" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from '@ton/core'; | ||
export const Op = { Setup: 0, Deploy: 1, TopUp: 2, Withdraw: 3, }; | ||
export const Result = { ValueError: 0, Loss: 1, }; | ||
export type HeadsOrTailsConfig = { owner: Address, min_bet: number | bigint, max_bet: number | bigint, mul_num: number | bigint, mul_denom: number | bigint, }; | ||
export function headsOrTailsConfigToCell(config: HeadsOrTailsConfig): Cell { return beginCell() | ||
.storeAddress(config.owner) | ||
.storeCoins(config.min_bet) | ||
.storeCoins(config.max_bet) | ||
.storeUint(config.mul_num, 16) | ||
.storeUint(config.mul_denom, 16) | ||
.endCell(); } | ||
export class HeadsOrTails implements Contract { | ||
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {} | ||
static createFromAddress(address: Address) { return new HeadsOrTails(address); } | ||
static createFromConfig(config: HeadsOrTailsConfig, code: Cell, workchain = 0) { | ||
const data = headsOrTailsConfigToCell(config); | ||
const init = { code, data }; | ||
return new HeadsOrTails(contractAddress(workchain, init), init); } | ||
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) { await provider.internal(via, { | ||
value, sendMode: SendMode.PAY_GAS_SEPARATELY, body: beginCell().storeUint(Op.Deploy, 32).endCell(), }); } | ||
async sendBet(provider: ContractProvider, via: Sender, value: bigint) { | ||
await provider.internal(via, { value, sendMode: SendMode.PAY_GAS_SEPARATELY, body: beginCell().endCell(),}); } | ||
async sendTopUp(provider: ContractProvider, via: Sender, value: bigint) { | ||
await provider.internal(via, { value, sendMode: SendMode.PAY_GAS_SEPARATELY, body: beginCell().storeUint(Op.TopUp, 32).endCell(),}); } | ||
async sendSetup(provider: ContractProvider, via: Sender, value: bigint, owner: Address, min_bet: number | bigint, max_bet: number | bigint, mul_num: number | bigint, mul_denom: number | bigint, ) { | ||
await provider.internal(via, { value, sendMode: SendMode.PAY_GAS_SEPARATELY, body: beginCell().storeUint(Op.Setup, 32).storeUint(0, 64) | ||
.storeAddress(owner).storeCoins(min_bet).storeCoins(max_bet).storeUint(mul_num, 16).storeUint(mul_denom, 16).endCell(),}); } | ||
async sendWithdraw(provider: ContractProvider, via: Sender, value: bigint, w_amount: bigint) { | ||
await provider.internal(via, { value, sendMode: SendMode.PAY_GAS_SEPARATELY, body: beginCell().storeUint(Op.Withdraw, 32).storeUint(0, 64).storeCoins(w_amount).endCell(),}); } | ||
async getData(provider: ContractProvider) { | ||
const result = await provider.get('get_smc_data', []); | ||
return result.stack.readCell(); } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Address, beginCell, Sender, SenderArguments, SendMode, storeStateInit } from "@ton/ton"; | ||
import { TonConnectUI } from "@tonconnect/ui"; | ||
|
||
export class TonConnectSender implements Sender { | ||
#provider: TonConnectUI; | ||
readonly address?: Address; | ||
|
||
constructor(provider: TonConnectUI) { | ||
this.#provider = provider; | ||
if (provider.wallet) this.address = Address.parseRaw(provider.wallet?.account.address); | ||
else this.address = undefined; | ||
} | ||
|
||
async send(args: SenderArguments): Promise<void> { | ||
if (!(args.sendMode === undefined || args.sendMode == SendMode.PAY_GAS_SEPARATELY)) { | ||
throw new Error("Deployer sender does not support `sendMode` other than `PAY_GAS_SEPARATELY`"); | ||
} | ||
|
||
await this.#provider.sendTransaction({ | ||
validUntil: Date.now() + 5 * 60 * 1000, | ||
messages: [ | ||
{ | ||
address: args.to.toString(), | ||
amount: args.value.toString(), | ||
payload: args.body?.toBoc().toString("base64"), | ||
stateInit: args.init | ||
? beginCell().storeWritable(storeStateInit(args.init)).endCell().toBoc().toString("base64") | ||
: undefined, | ||
}, | ||
], | ||
}); | ||
} | ||
} |