Skip to content

Commit 86fd907

Browse files
committed
feat: add disassember
1 parent b3dbb82 commit 86fd907

7 files changed

Lines changed: 208 additions & 40 deletions

File tree

bun.lockb

2.88 KB
Binary file not shown.

package-lock.json

Lines changed: 88 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"dependencies": {
1313
"@broxus/tvm-connect-ui": "^1.0.1",
1414
"@soerenmartius/vue3-clipboard": "^0.1.2",
15+
"@ton/core": "^0.60.1",
16+
"@ton/crypto": "^3.3.0",
17+
"@tychosdk/disasm": "^0.1.6",
1518
"bignumber.js": "^9.1.0",
1619
"everscale-inpage-provider": "^0.4.0",
1720
"fflate": "^0.8.2",

src/components/DisasmWorkspace.vue

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<script setup lang="ts">
2+
import { disasmToFift } from "@tychosdk/disasm";
3+
import { ref, shallowRef, watchEffect } from 'vue';
4+
5+
const input = ref<string>('');
6+
const state = shallowRef<{
7+
generatedCode?: string;
8+
error?: string;
9+
}>({});
10+
11+
const shared: { idx: number } = { idx: 0 };
12+
watchEffect(() => {
13+
const idx = ++shared.idx;
14+
disasmToFift(input.value).then((generatedCode) => {
15+
if (idx !== shared.idx) {
16+
return;
17+
}
18+
state.value = {
19+
generatedCode,
20+
error: undefined
21+
};
22+
}).catch((e: any) => {
23+
if (idx !== shared.idx) {
24+
return;
25+
}
26+
state.value = {
27+
generatedCode: undefined,
28+
error: e.toString()
29+
};
30+
});
31+
});
32+
33+
const onPaste = (e: Event) => {
34+
const pastedText = (e as ClipboardEvent).clipboardData.getData('text');
35+
input.value = pastedText;
36+
e.preventDefault();
37+
};
38+
</script>
39+
40+
<template>
41+
<section class="section pb-0">
42+
<div class="container is-fluid">
43+
<div class="columns">
44+
<div class="column">
45+
<div class="field">
46+
<label class="label">Enter contract code BOC:</label>
47+
<div class="control">
48+
<textarea :class="['textarea', { 'is-danger': state.error != null }]" spellcheck="false" v-model="input"
49+
@paste="onPaste" rows="5" />
50+
</div>
51+
<pre v-if="state.error != null" class="help is-danger">{{ state.error }}</pre>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
</section>
57+
58+
<section class="section">
59+
<div class="container is-fluid">
60+
<label class="label">Disassembled code:</label>
61+
<div class="control">
62+
<pre
63+
aria-hidden="true"><code class="language-html" id="highlighting-content">{{ state.generatedCode }}</code></pre>
64+
</div>
65+
</div>
66+
</section>
67+
</template>

src/components/Navbar.vue

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const balance = computed(() => fromNano(tvmConnectState.value.balance));
2525
<NavbarItem path="/deserializer">Deserializer</NavbarItem>
2626
<NavbarItem path="/signer">Signer</NavbarItem>
2727
<NavbarItem path="/debugger">Debugger</NavbarItem>
28+
<NavbarItem path="/disasm">Disasm</NavbarItem>
2829
<NavbarItem path="/microwave">Microwave</NavbarItem>
2930
<NavbarItem path="/tip3">TIP3</NavbarItem>
3031
<NavbarItem path="/tip6">TIP6</NavbarItem>
@@ -33,28 +34,20 @@ const balance = computed(() => fromNano(tvmConnectState.value.balance));
3334
<div class="navbar-end">
3435
<div class="navbar-item">
3536
<div class="wallet">
36-
<button
37-
v-if="!tvmConnectState.isReady"
37+
<button v-if="!tvmConnectState.isReady"
3838
:class="['button is-primary', { 'is-loading': tvmConnectState.isLoading }]"
39-
@click="() => tvmConnect.connect()"
40-
>
39+
@click="() => tvmConnect.connect()">
4140
<strong>Connect wallet</strong>
4241
</button>
4342
<template v-else>
4443
<div class="tag is-white is-medium">
4544
Network ID: {{ tvmConnectState.networkId }}
4645
</div>
47-
<button
48-
class="button is-white"
49-
@click="() => tvmConnect.connect()"
50-
>
46+
<button class="button is-white" @click="() => tvmConnect.connect()">
5147
{{ tvmConnectState.providerId }}
5248
</button>
53-
<button
54-
v-if="tvmConnectState.balance != null"
55-
class="button is-white"
56-
v-clipboard="tvmConnectState.balance"
57-
>
49+
<button v-if="tvmConnectState.balance != null" class="button is-white"
50+
v-clipboard="tvmConnectState.balance">
5851
{{ balance }} {{ CURRENCY }}
5952
</button>
6053
<div class="field has-addons">
@@ -64,12 +57,14 @@ const balance = computed(() => fromNano(tvmConnectState.value.balance));
6457
</button>
6558
</div>
6659
<div class="control">
67-
<button :class="['button', { 'is-loading': tvmConnectState.isLoading }]" @click="tvmConnect.changeAccount">
60+
<button :class="['button', { 'is-loading': tvmConnectState.isLoading }]"
61+
@click="tvmConnect.changeAccount">
6862
<span class="icon"><i class="fas fa-sync-alt" /></span>
6963
</button>
7064
</div>
7165
<div class="control">
72-
<button :class="['button', { 'is-loading': tvmConnectState.isLoading }]" @click="tvmConnect.disconnect">
66+
<button :class="['button', { 'is-loading': tvmConnectState.isLoading }]"
67+
@click="tvmConnect.disconnect">
7368
<span class="icon"><i class="fas fa-sign-out-alt" /></span>
7469
</button>
7570
</div>
@@ -83,8 +78,8 @@ const balance = computed(() => fromNano(tvmConnectState.value.balance));
8378
</template>
8479

8580
<style scoped>
86-
.wallet {
87-
display: flex;
88-
align-items: center;
89-
}
81+
.wallet {
82+
display: flex;
83+
align-items: center;
84+
}
9085
</style>

src/router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import SerializerWorkspace from './components/SerializerWorkspace.vue';
66
import DeserializerWorkspace from './components/DeserializerWorkspace.vue';
77
import SignerWorkspace from './components/SignerWorkspace.vue';
88
import DebuggerWorkspace from './components/DebuggerWorkspace.vue';
9+
import DisasmWorkspace from './components/DisasmWorkspace.vue';
910
import MicrowaveWorkspace from './components/MicrowaveWorkspace.vue';
1011
import Tip3Workspace from './components/Tip3Workspace.vue';
1112
import Tip6Workspace from './components/Tip6Workspace.vue';
12-
import CodegenWorkspace from "./components/CodegenWorkspace.vue";
13+
import CodegenWorkspace from './components/CodegenWorkspace.vue';
1314

1415
const router = createRouter({
1516
history: createWebHistory(),
@@ -21,6 +22,7 @@ const router = createRouter({
2122
{ path: '/deserializer', component: DeserializerWorkspace },
2223
{ path: '/signer', component: SignerWorkspace },
2324
{ path: '/debugger', component: DebuggerWorkspace },
25+
{ path: '/disasm', component: DisasmWorkspace },
2426
{ path: '/microwave', component: MicrowaveWorkspace },
2527
{ name: 'tip3', path: '/tip3/:address?', component: Tip3Workspace },
2628
{ name: 'tip6', path: '/tip6', component: Tip6Workspace },

0 commit comments

Comments
 (0)