Skip to content

Commit

Permalink
feat: add masterchain support and bump @ton/sandbox (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulyadav-57 authored Jan 22, 2025
1 parent 03d947d commit b427d23
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@tact-lang/compiler": "^1.5.3",
"@ton-community/func-js": "^0.5.0",
"@ton/core": "^0.56.3",
"@ton/sandbox": "^0.16.0",
"@ton/sandbox": "^0.20.0",
"@ton/ton": "^13.11.1",
"@tonconnect/ui-react": "1.0.0-beta.4",
"@types/node": "18.14.0",
Expand Down
13 changes: 13 additions & 0 deletions src/components/workspace/WorkspaceSidebar/WorkspaceSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ const WorkspaceSidebar: FC<Props> = ({ activeMenu, onMenuClicked }) => {
getSettingStateByKey,
updateEditorMode,
toggleExternalMessage,
toggleMasterChain,
} = useSettingAction();

const editorMode = getSettingStateByKey('editorMode');
const isExternalMessage = getSettingStateByKey('isExternalMessage');
const isMasterChainEnabled = getSettingStateByKey('masterchain');

const themeContext = useContext(ThemeContext);

const menuItems: MenuItem[] = [
Expand Down Expand Up @@ -96,6 +99,16 @@ const WorkspaceSidebar: FC<Props> = ({ activeMenu, onMenuClicked }) => {
/>
</Form.Item>
</div>
<div className={s.settingItem}>
<Form.Item label="Masterchain" valuePropName="checked">
<Switch
checked={!!isMasterChainEnabled}
onChange={(toggleState) => {
toggleMasterChain(toggleState);
}}
/>
</Form.Item>
</div>
<div className={s.settingItem}>
<Form.Item label="Format code on save" valuePropName="checked">
<Switch
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/project.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function useProjectActions() {
const { writeFiles, projectFiles } = useProject();
const { getFile } = useFile();
const isExternalMessage = getSettingStateByKey('isExternalMessage');
const isMasterChainEnabled = getSettingStateByKey('masterchain');

return {
compileFuncProgram,
Expand Down Expand Up @@ -152,6 +153,7 @@ export function useProjectActions() {
options: {
debug: isContractDebugEnabled(),
external: !!isExternalMessage,
masterchain: !!isMasterChainEnabled,
},
},
project: fs,
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/setting.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function useSettingAction() {
toggleAutoBuildAndDeploy,
updateEditorMode,
toggleExternalMessage,
toggleMasterChain,
};

async function init() {
Expand Down Expand Up @@ -110,4 +111,10 @@ export function useSettingAction() {
isExternalMessage: active,
});
}

function toggleMasterChain(active: boolean = !setting.isExternalMessage) {
updateStateByKey({
masterchain: active,
});
}
}
1 change: 1 addition & 0 deletions src/interfaces/setting.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface SettingInterface {
editorMode: 'default' | 'vim';
isExternalMessage?: boolean;
theme?: 'light' | 'dark';
masterchain?: boolean;
}
2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function App({
"jest": "29.6.2",
"@ton/core": "^0.56.3",
"@ton/test-utils": "0.4.2",
"@ton/sandbox": "^0.15.0"
"@ton/sandbox": "^0.20.0"
}
}`,
},
Expand Down

0 comments on commit b427d23

Please sign in to comment.