|
| 1 | +<script lang="ts"> |
| 2 | + import { toNano, type Sender } from "ton-core"; |
| 3 | + import { Blockchain, type SandboxContract } from "@ton-community/sandbox"; |
| 4 | + import { getExample } from "$lib/helpers"; |
| 5 | + import store from "$lib/store"; |
| 6 | +
|
| 7 | + import markdown from "./content.md?raw"; |
| 8 | + import tactCode from "./contract.tact?raw"; |
| 9 | + import { Optionals } from "./Optionals"; |
| 10 | +
|
| 11 | + let sender: Sender; |
| 12 | + let contract: SandboxContract<Optionals>; |
| 13 | +
|
| 14 | + $store = { |
| 15 | + markdown, |
| 16 | + tactCode, |
| 17 | + deploy: async () => { |
| 18 | + const blockchain = await Blockchain.create(); |
| 19 | + const deployer = await blockchain.treasury("deployer"); |
| 20 | + sender = deployer.getSender(); |
| 21 | + contract = blockchain.openContract(await Optionals.fromInit(null, null, null)); |
| 22 | + const addresses = { |
| 23 | + [deployer.address.toString()]: "deployer", |
| 24 | + [contract.address.toString()]: "contract", |
| 25 | + }; |
| 26 | + return [[contract], addresses, [await contract.send(deployer.getSender(), { value: toNano(1) }, { $$type: "Deploy", queryId: 0n })]]; |
| 27 | + }, |
| 28 | + messages: { |
| 29 | + "MsgOpts{ma:5}": async () => { |
| 30 | + return [await contract.send(sender, { value: toNano(1) }, { $$type: "MsgOpts", ma: 5n, mb: null, mc: null, md: null })]; |
| 31 | + }, |
| 32 | + }, |
| 33 | + getters: { |
| 34 | + optInt: async () => { |
| 35 | + return await contract.getOptInt(); |
| 36 | + }, |
| 37 | + optIntVal: async () => { |
| 38 | + return await contract.getOptIntVal(); |
| 39 | + }, |
| 40 | + optNested: async () => { |
| 41 | + return await contract.getOptNested(); |
| 42 | + }, |
| 43 | + }, |
| 44 | + prev: getExample(import.meta.url).prev, |
| 45 | + next: getExample(import.meta.url).next, |
| 46 | + }; |
| 47 | +</script> |
0 commit comments