Skip to content

Commit 94dfd6f

Browse files
committed
Merge branch 'main' into katana/fgw-sync
2 parents fde2d2b + ebcc23d commit 94dfd6f

File tree

8 files changed

+64
-23
lines changed

8 files changed

+64
-23
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/rust
33
{
44
"name": "Rust",
5-
"image": "ghcr.io/dojoengine/dojo-dev:v1.0.1",
5+
"image": "ghcr.io/dojoengine/dojo-dev:v1.0.2",
66
"runArgs": [
77
"--cap-add=SYS_PTRACE",
88
"--security-opt",

.github/workflows/bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
bench-katana:
1515
runs-on: ubuntu-latest
1616
container:
17-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
17+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
1818
steps:
1919
- uses: actions/checkout@v3
2020
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
@@ -36,7 +36,7 @@ jobs:
3636
bench-sozo:
3737
runs-on: ubuntu-latest
3838
container:
39-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
39+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
4040
steps:
4141
- uses: actions/checkout@v3
4242
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
CARGO_TERM_COLOR: always
11-
RUST_VERSION: 1.79.0
11+
RUST_VERSION: 1.80.0
1212

1313
jobs:
1414
build:
@@ -31,7 +31,7 @@ jobs:
3131
needs: ensure-docker
3232
runs-on: ubuntu-latest-32-cores
3333
container:
34-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
34+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
3535
steps:
3636
- uses: actions/checkout@v3
3737
- uses: Swatinem/rust-cache@v2
@@ -56,7 +56,7 @@ jobs:
5656
ensure-wasm:
5757
runs-on: ubuntu-latest
5858
container:
59-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
59+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
6060
steps:
6161
- uses: actions/checkout@v3
6262
- uses: Swatinem/rust-cache@v2
@@ -123,7 +123,7 @@ jobs:
123123
needs: build
124124
runs-on: ubuntu-latest
125125
container:
126-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
126+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
127127
steps:
128128
- uses: actions/download-artifact@v4
129129
with:
@@ -139,7 +139,7 @@ jobs:
139139
needs: build
140140
runs-on: ubuntu-latest
141141
container:
142-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
142+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
143143
steps:
144144
- uses: actions/download-artifact@v4
145145
with:
@@ -154,7 +154,7 @@ jobs:
154154
clippy:
155155
runs-on: ubuntu-latest-4-cores
156156
container:
157-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
157+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
158158
steps:
159159
- uses: actions/checkout@v3
160160
- uses: Swatinem/rust-cache@v2
@@ -163,7 +163,7 @@ jobs:
163163
fmt:
164164
runs-on: ubuntu-latest
165165
container:
166-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
166+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
167167
steps:
168168
- uses: actions/checkout@v3
169169
- uses: Swatinem/rust-cache@v2
@@ -172,7 +172,7 @@ jobs:
172172
docs:
173173
runs-on: ubuntu-latest
174174
container:
175-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
175+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
176176
steps:
177177
- uses: actions/checkout@v3
178178
- uses: Swatinem/rust-cache@v2

.github/workflows/devcontainer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
# We have to use a PAT in order to trigger ci
102102
token: ${{ secrets.CREATE_PR_TOKEN }}
103-
title: "Update devcontainer image: ${{ needs.build-and-push.outputs.tag_name }}"
103+
title: "chore(devcontainer): update image: ${{ needs.build-and-push.outputs.tag_name }}"
104104
commit-message: "Update devcontainer image: ${{ needs.build-and-push.outputs.tag_name }}"
105105
branch: bump-devcontainer
106106
base: main

.github/workflows/release-dispatch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
contents: write
1515
runs-on: ubuntu-latest
1616
container:
17-
image: ghcr.io/dojoengine/dojo-dev:v1.0.1
17+
image: ghcr.io/dojoengine/dojo-dev:v1.0.2
1818
env:
1919
VERSION: ""
2020
steps:

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ warp = "0.3"
241241

242242
# gRPC
243243
prost = "0.12"
244-
tonic = { version = "0.11", features = [ "gzip", "tls", "tls-roots" ] }
244+
tonic = { version = "0.11", features = [ "gzip", "tls", "tls-roots", "tls-webpki-roots" ] }
245245
tonic-build = "0.11"
246246
tonic-reflection = "0.11"
247247
tonic-web = "0.11"

crates/dojo/bindgen/src/plugins/typescript/generator/function.rs

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cainome::parser::tokens::{CompositeType, Function, Token};
1+
use cainome::parser::tokens::{CompositeType, Function, StateMutability, Token};
22
use convert_case::{Case, Casing};
33
use dojo_world::contracts::naming;
44

@@ -35,8 +35,9 @@ impl TsFunctionGenerator {
3535
contract_name: &str,
3636
token: &Function,
3737
) -> String {
38-
format!(
39-
"\tconst {contract_name}_{} = async ({}) => {{
38+
match token.state_mutability {
39+
StateMutability::External => format!(
40+
"\tconst {contract_name}_{} = async ({}) => {{
4041
\t\ttry {{
4142
\t\t\treturn await provider.execute(
4243
\t\t\t\tsnAccount,
@@ -51,15 +52,36 @@ impl TsFunctionGenerator {
5152
\t\t\tconsole.error(error);
5253
\t\t}}
5354
\t}};\n",
54-
token.name.to_case(Case::Camel),
55-
self.format_function_inputs(token),
56-
token.name,
57-
self.format_function_calldata(token)
58-
)
55+
token.name.to_case(Case::Camel),
56+
self.format_function_inputs(token),
57+
token.name,
58+
self.format_function_calldata(token)
59+
),
60+
StateMutability::View => format!(
61+
"\tconst {contract_name}_{} = async ({}) => {{
62+
\t\ttry {{
63+
\t\t\treturn await provider.call(\"{namespace}\", {{
64+
\t\t\t\tcontractName: \"{contract_name}\",
65+
\t\t\t\tentrypoint: \"{}\",
66+
\t\t\t\tcalldata: [{}],
67+
\t\t\t}});
68+
\t\t}} catch (error) {{
69+
\t\t\tconsole.error(error);
70+
\t\t}}
71+
\t}};\n",
72+
token.name.to_case(Case::Camel),
73+
self.format_function_inputs(token),
74+
token.name,
75+
self.format_function_calldata(token)
76+
),
77+
}
5978
}
6079

6180
fn format_function_inputs(&self, token: &Function) -> String {
62-
let inputs = vec!["snAccount: Account".to_owned()];
81+
let inputs = match token.state_mutability {
82+
StateMutability::External => vec!["snAccount: Account".to_owned()],
83+
StateMutability::View => Vec::new(),
84+
};
6385
token
6486
.inputs
6587
.iter()
@@ -273,6 +295,13 @@ mod tests {
273295
let expected = "snAccount: Account, value: BigNumberish";
274296
assert_eq!(expected, generator.format_function_inputs(&function))
275297
}
298+
#[test]
299+
fn test_format_function_inputs_view() {
300+
let generator = TsFunctionGenerator {};
301+
let function = create_basic_view_function();
302+
let expected = "";
303+
assert_eq!(expected, generator.format_function_inputs(&function))
304+
}
276305

277306
#[test]
278307
fn test_format_function_inputs_complex() {
@@ -408,6 +437,17 @@ mod tests {
408437
)],
409438
)
410439
}
440+
441+
fn create_basic_view_function() -> Function {
442+
Function {
443+
name: "allowance".to_owned(),
444+
state_mutability: cainome::parser::tokens::StateMutability::View,
445+
inputs: vec![],
446+
outputs: vec![],
447+
named_outputs: vec![],
448+
}
449+
}
450+
411451
fn create_change_theme_function_camelized() -> Function {
412452
create_test_function(
413453
"changeTheme",

0 commit comments

Comments
 (0)