Skip to content

Commit

Permalink
Add timestamp support, allow tuples with single field
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zaikin committed Jul 11, 2023
1 parent f9c01cd commit 6f023c5
Show file tree
Hide file tree
Showing 23 changed files with 502 additions and 139 deletions.
77 changes: 39 additions & 38 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion dac_codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "dac-codec"
path = "src/main.rs"

[dependencies]
tezos_core = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-core" }
tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core" }
tezos_encoding = { git = "https://github.com/emturner/tezedge.git", branch = "master", default-features = false }
tezos_rollup_encoding = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" }
clap = { version = "4.0.29", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion installer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ host = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b
mock_runtime = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" }
tezos_encoding = { git = "https://github.com/emturner/tezedge.git", branch = "master", default-features = false }
tezos_rollup_encoding = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" }
tezos_core = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-core" }
tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core" }
hex = { version = "0.4.3" }
once_cell = "1.16.0"

Expand Down
6 changes: 3 additions & 3 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ crate-type = ["cdylib", "rlib"]
tezos_ctx = { path = "../tezos_ctx" }
tezos_l2 = { path = "../tezos_l2" }
host = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" }
tezos_core = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-core", default-features = false }
tezos_operation = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-operation", default-features = false }
tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false }
tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false }

derive_more = "0.99"
hex = "*"

[dev-dependencies]
tezos_rpc = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-rpc", default-features = false }
tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false }
mock_runtime = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" }
hex = "*"
8 changes: 6 additions & 2 deletions michelson_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2023 Baking Bad <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "michelson_derive"
version = "0.1.0"
Expand All @@ -7,8 +11,8 @@ edition = "2021"
proc-macro = true

[dependencies]
tezos_michelson = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-michelson", default-features = false }
tezos_core = { git = "https://github.com/m-kus/tezos-rust-sdk", branch = "feat/ibig-drop-in", package = "tezos-core", default-features = false }
tezos_michelson = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-michelson", default-features = false }
tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false }
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0.21"
Expand Down
53 changes: 53 additions & 0 deletions michelson_derive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Michelson derive

This crate provides two procedure macros:
- #[derive(MichelsonInterop)] for `struct` and `enum`
- `michelson_tuple!` for tuples

#### Tuples

In order to derive `MichelsonInterop` trait for generic tuples:

```rust
michelson_derive::michelson_tuple!(A, B, C);
```
Currently up to 6 fields, extend if you need more:

- `pair a b` -> `(A, B)`
- `pair a b c` -> `(A, B, C)`
- `pair a b c d` -> `(A, B, C, D)`
- `pair a b c d e` -> `(A, B, C, D, E)`
- `pair a b c d e f` -> `(A, B, C, D, E, F)`

#### Structs

Structs vave to have 0 (Unit) or at least 2 fields:

- `struct S {}` -> `unit`
- `struct S ()` -> `unit`
- `struct (A, B)` -> `pair a b`
- `struct { a: A, b: B }` -> `pair (a %a) (b %b)` (named tuple)

Nested pairs are always expanded to right combs.

#### Enums

Unit, newtype, and struct variants are supported (but only with >2 fields).

```rust
enum E {
Default,
EntrypointOne(A, B),
EntrypointTwo { a: A, b: B }
}
```

Variant names are converted to snake case:

```
(or (unit %default)
(or (pair %entrypoint_one a b)
(pair %entrypoint_two (a %a) (b %b))))
```

Nested ors are always expanded to right combs.
Loading

0 comments on commit 6f023c5

Please sign in to comment.