Skip to content

Commit 9e2233f

Browse files
committed
Added emit
1 parent 1c826ae commit 9e2233f

File tree

7 files changed

+608
-0
lines changed

7 files changed

+608
-0
lines changed

src/routes/(examples)/+layout.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@
110110
}
111111
}
112112
}
113+
for (let i = 0; i < transaction.outMessagesCount; i++) {
114+
const outMessage = transaction.outMessages.get(i);
115+
if (outMessage?.info.type == "external-out") {
116+
if (outMessage.info.dest == null) {
117+
const name = messageName(outMessage.body);
118+
terminalLog(`Log emitted: ${name}, from ${shorten(outMessage.info.src)}`);
119+
}
120+
}
121+
}
113122
for (const event of transaction.events) {
114123
if (event.type == "message_sent") {
115124
const name = messageName(event.body);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 { Emit } from "./Emit";
10+
11+
let sender: Sender;
12+
let contract: SandboxContract<Emit>;
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 Emit.fromInit());
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+
action: async () => {
30+
return [await contract.send(sender, { value: toNano(1) }, "action")];
31+
},
32+
transfer: async () => {
33+
return [await contract.send(sender, { value: toNano(1) }, "transfer")];
34+
},
35+
stake: async () => {
36+
return [await contract.send(sender, { value: toNano(1) }, "stake")];
37+
},
38+
},
39+
getters: {},
40+
prev: getExample(import.meta.url).prev,
41+
next: getExample(import.meta.url).next,
42+
};
43+
</script>

0 commit comments

Comments
 (0)