Skip to content

Commit 1c826ae

Browse files
committed
Added optionals
1 parent e0f4cc9 commit 1c826ae

File tree

7 files changed

+695
-1
lines changed

7 files changed

+695
-1
lines changed

src/routes/(examples)/04-maps/contract.tact

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ contract Maps with Deployable {
8080
if (self.mi1.get(17) == null) {
8181
return "not found";
8282
}
83-
let item: TokenInfo = self.mi1.get(17)!!; // the !! will tell the compiler it's not null
83+
let item: TokenInfo = self.mi1.get(17)!!; // !! tells the compiler this can't be null
8484
return item.ticker;
8585
}
8686

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

Comments
 (0)