Skip to content

Commit

Permalink
Fix IDL struct
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanMarchetto authored Jul 25, 2023
1 parent 9c18b8e commit b6c8c5d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion crate/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{structs, Error};
use handlebars::{handlebars_helper, Handlebars};
use structs::{InstructionType, InstructionTypeVec, TemplateHelper, VecEnum, IDL};
use structs::{InstructionType, TemplateHelper, IDL};

pub(crate) fn create_handlebars_registry() -> Handlebars<'static> {
handlebars_helper!(snakecase: |name: String| name.chars().fold(
Expand Down
3 changes: 3 additions & 0 deletions crate/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub struct Accounts {

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Types {
#[serde(default)]
pub(crate) name: String,
#[serde(default)]
#[serde(rename = "type")]
Expand All @@ -144,6 +145,7 @@ pub struct Types {

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Event {
#[serde(default)]
pub(crate) name: String,
#[serde(default)]
pub(crate) fields: Vec<Field>,
Expand Down Expand Up @@ -210,6 +212,7 @@ impl Default for Kind {

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Field {
#[serde(default)]
pub(crate) name: String,
#[serde(rename = "type")]
pub(crate) type_: InstructionType,
Expand Down
18 changes: 10 additions & 8 deletions ui/helpers/selectTemplateFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const selectTemplateFolder = (setTemplateFolder: Function) => {
multiple: false,
title: "Select a template file",
});
invoke("update_template", { templatePath: result }).then(async () => {
setTemplateFolder(result)
await message(`Template path: ${result}`, "Template Selected");
})
.catch(async (e) => {
await message(e?.error ?? "update_template Error", { title: "Error Trying to open selected file as a template", type: "error" });
});
;
if (typeof result === "string") {
invoke("update_template", { templatePath: result })
.then(async () => {
setTemplateFolder(result)
await message(`Template path: ${result}`, "Template Selected");
})
.catch(async (e) => {
await message(e?.error ?? "update_template Error", { title: "Error Trying to open selected file as a template", type: "error" });
});
}
}
catch (e) {
await message(`${e}`, {
Expand Down
2 changes: 2 additions & 0 deletions ui/helpers/templateFromFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ const templateFromFolder = async () => {
multiple: false,
title: "Select a template file",
});
if (typeof result === "string") {
invoke("update_template", { templatePath: result })
.then(async () => {
await message(`Template path: ${result}`, "Template Selected");
}).catch(async (e) => {
await message(e?.error ?? "update_template Error", { title: "Error Trying to open the selected folder as a template", type: "error" });
});
}
}
catch (e) {
await message(`${e}`, {
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
4 changes: 1 addition & 3 deletions ui/src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions ui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "soda"
version = "0.1.0"
version = "0.1.1"
description = "Generates source code from an IDL"
authors = ["Juan Patricio Marchetto"]
license = "Apache-2.0"
Expand All @@ -19,7 +19,7 @@ tauri = { version = "1.2.5", features = ["dialog-all", "fs-create-dir", "fs-read
serde_json = "1.0.93"
serde = "1.0.164"
thiserror = "1.0.40"
soda_sol = "0.0.6"
soda_sol = { path="../../crate"}

[features]
# by default Tauri runs in production mode
Expand Down
44 changes: 22 additions & 22 deletions ui/src-tauri/src/default_template.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "soda",
"version": "0.1.0"
"version": "0.1.1"
},
"tauri": {
"allowlist": {
Expand Down

0 comments on commit b6c8c5d

Please sign in to comment.