sdk/rust: prepare to publish crate (#3849)

* sdk/rust: organize workspace

* sdk/rust: add serde_wormhole to deps

* sdk/rust: serde_wormhole -> wormhole-raw-serde

* sdk/rust: add supported-chains; serde_wormhole -> wormhole-vaas-serde

* cosmwasm: fix deps

* sdk/rust: fix fmt

* sdk/rust: jk

* sdk/rust: add desc

* sdk/rust: rm Cargo.lock

* .github: fix workflow

---------

Co-authored-by: A5 Pickle <a5-pickle@users.noreply.github.com>
This commit is contained in:
A5 Pickle 2024-03-25 13:09:54 -05:00 committed by GitHub
parent d036e70740
commit 22e31affe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 146 additions and 370 deletions

View File

@ -348,9 +348,13 @@ jobs:
strategy:
matrix:
manifest:
- cosmwasm/Cargo.toml
- terra/Cargo.toml
- sdk/rust/Cargo.toml
- path: cosmwasm/Cargo.toml
args: "--workspace --locked"
- path: terra/Cargo.toml
args: "--workspace --locked"
- path: sdk/rust/Cargo.toml
args: "--all-features --all-targets"
name: rust-lint-and-tests (${{ matrix.manifest.path }})
steps:
- name: Check out source
uses: actions/checkout@v3
@ -364,7 +368,7 @@ jobs:
- name: Create cache key
id: cachekey
env:
MANIFEST: ${{ matrix.manifest }}
MANIFEST: ${{ matrix.manifest.path }}
run: |
LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
NAME="${MANIFEST%%/*}"
@ -378,20 +382,16 @@ jobs:
path: ~/.cargo/registry
key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
restore-keys: |
${{ runner.os }}-build-${{ matrix.manifest }}-
${{ runner.os }}-build-${{ matrix.manifest.path }}-
- name: Run `rustfmt`
env:
MANIFEST: ${{ matrix.manifest }}
# In its infinite wisdom, `cargo fmt --all` will also format path-based dependencies so
# instead we have to manually format each ".rs" file.
run: find "$(dirname "${MANIFEST}")" -name '*.rs' -exec rustfmt --check {} +
run: cd $(dirname ${{ matrix.manifest.path }}) && cargo fmt --check
- name: Run `cargo clippy`
run: cargo clippy --workspace --tests --locked --manifest-path ${{ matrix.manifest }}
run: cargo clippy ${{ matrix.manifest.args }} --tests --manifest-path ${{ matrix.manifest.path }}
- name: Run unit tests
run: cargo test --workspace --locked --manifest-path ${{ matrix.manifest }}
run: cargo test ${{ matrix.manifest.args }} --manifest-path ${{ matrix.manifest.path }}
docker:
runs-on: ubuntu-latest

23
cosmwasm/Cargo.lock generated
View File

@ -951,7 +951,7 @@ dependencies = [
"thiserror",
"tinyvec",
"wormhole-bindings",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -1039,7 +1039,7 @@ dependencies = [
"token-bridge-cosmwasm",
"wormhole-bindings",
"wormhole-cosmwasm",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -1284,7 +1284,7 @@ dependencies = [
"tinyvec",
"wormhole-bindings",
"wormhole-io",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -2602,7 +2602,7 @@ dependencies = [
"serde_wormhole",
"thiserror",
"wormhole-bindings",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -2617,7 +2617,7 @@ dependencies = [
"schemars",
"serde",
"serde_wormhole",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -2650,7 +2650,7 @@ dependencies = [
"serde_wormhole",
"thiserror",
"wormhole-cosmwasm",
"wormhole-sdk",
"wormhole-vaas-serde",
]
[[package]]
@ -2660,7 +2660,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b021a14ea7bcef9517ed9f81d4466c4a663dd90e726c5724707a976fa83ad8f3"
[[package]]
name = "wormhole-sdk"
name = "wormhole-supported-chains"
version = "0.1.0"
dependencies = [
"serde",
"thiserror",
]
[[package]]
name = "wormhole-vaas-serde"
version = "0.1.0"
dependencies = [
"anyhow",
@ -2670,6 +2678,7 @@ dependencies = [
"serde_wormhole",
"sha3 0.10.7",
"thiserror",
"wormhole-supported-chains",
]
[[package]]

View File

@ -31,16 +31,23 @@ panic = 'abort'
incremental = false
overflow-checks = true
[workspace.dependencies.serde_wormhole]
version = "0.1.0"
path = "../sdk/rust/serde_wormhole"
[workspace.dependencies.wormhole-sdk]
package = "wormhole-vaas-serde"
version = "0.1.0"
path = "../sdk/rust/vaas-serde"
[patch.crates-io]
accountant = { path = "packages/accountant" }
cw_transcode = { path = "packages/cw_transcode" }
cw20-wrapped-2 = { path = "contracts/cw20-wrapped" }
serde_wormhole = { path = "../sdk/rust/serde_wormhole" }
token-bridge-cosmwasm = { path = "contracts/token-bridge" }
global-accountant = { path = "contracts/global-accountant" }
ntt-global-accountant = { path = "contracts/ntt-global-accountant" }
wormhole-bindings = { path = "packages/wormhole-bindings" }
wormhole-cosmwasm = { path = "contracts/wormhole" }
wormhole-sdk = { path = "../sdk/rust/core" }
wormchain-ibc-receiver = { path = "contracts/wormchain-ibc-receiver" }
wormhole-ibc = { path = "contracts/wormhole-ibc" }

View File

@ -24,11 +24,11 @@ cw2 = "0.13.2"
hex = { version = "0.4.3", features = ["serde"] }
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_wormhole = "0.1.0"
serde_wormhole.workspace = true
thiserror = { version = "1.0.31" }
tinyvec = { version = "1.6", default-features = false, features = ["alloc", "serde"]}
wormhole-bindings = "0.1.0"
wormhole-sdk = { version = "0.1.0", features = ["schemars"] }
wormhole-sdk = { workspace = true, features = ["schemars"] }
[dev-dependencies]
anyhow = { version = "1", features = ["backtrace"] }

View File

@ -25,11 +25,11 @@ cw20 = "0.13.2"
cw20-base = { version = "0.13.2", features = ["library"] }
cw20-wrapped-2 = { version = "0.1.0", features = ["library"] }
serde-json-wasm = "0.5.1"
serde_wormhole = "0.1.0"
serde_wormhole.workspace = true
token-bridge-cosmwasm = { version = "0.1.0", features = ["library"] }
wormhole-bindings = "0.1.0"
wormhole-cosmwasm = { version = "0.1.0", features = ["library"] }
wormhole-sdk = { version = "0.1.0", features = ["schemars"] }
wormhole-sdk = { workspace = true, features = ["schemars"] }
[dev-dependencies]
cosmwasm-crypto = { version = "1.2.7" }

View File

@ -26,12 +26,12 @@ hex = { version = "0.4.3", features = ["serde"] }
ntt-messages = { git = "https://github.com/wormhole-foundation/example-native-token-transfers.git", rev = "cd1f8fe13b9aba3bf1a38938d952841c98cb7288" }
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_wormhole = "0.1.0"
serde_wormhole.workspace = true
thiserror = { version = "1.0.31" }
tinyvec = { version = "1.6", default-features = false, features = ["alloc", "serde"]}
wormhole-bindings = "0.1.0"
wormhole-io = "0.1.3"
wormhole-sdk = { version = "0.1.0", features = ["schemars"] }
wormhole-sdk = { workspace = true, features = ["schemars"] }
[dev-dependencies]
anyhow = { version = "1", features = ["backtrace"] }

View File

@ -18,5 +18,5 @@ anyhow = "1"
semver = "1.0.16"
thiserror = "1.0.31"
wormhole-bindings = "0.1.0"
wormhole-sdk = { version = "0.1.0", features = ["schemars"] }
serde_wormhole = "0.1.0"
wormhole-sdk = { workspace = true, features = ["schemars"] }
serde_wormhole.workspace = true

View File

@ -20,8 +20,8 @@ schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
semver = "1.0.16"
thiserror = "1.0.31"
serde_wormhole = "0.1.0"
wormhole-sdk = { version = "0.1.0", features = ["schemars"] }
serde_wormhole.workspace = true
wormhole-sdk = { workspace = true, features = ["schemars"] }
[dev-dependencies]
hex = "0.4.3"

View File

@ -13,7 +13,7 @@ cosmwasm-schema = "1"
cosmwasm-std = "1"
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_wormhole = { version = "0.1.0", optional = true }
serde_wormhole = { workspace = true, optional = true }
cw-multi-test = { version = "0.13.2", optional = true }
k256 = { version = "0.11", optional = true, features = ["ecdsa", "keccak256"] }
wormhole-sdk = "0.1.0"
wormhole-sdk.workspace = true

1
sdk/rust/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Cargo.lock

298
sdk/rust/Cargo.lock generated
View File

@ -1,298 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anyhow"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "block-buffer"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
dependencies = [
"generic-array",
]
[[package]]
name = "bstr"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd"
dependencies = [
"memchr",
"once_cell",
"regex-automata",
"serde",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "dyn-clone"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2"
[[package]]
name = "generic-array"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "itoa"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]]
name = "keccak"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "once_cell"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]]
name = "proc-macro2"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "ryu"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]]
name = "schemars"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307"
dependencies = [
"dyn-clone",
"schemars_derive",
"serde",
"serde_json",
]
[[package]]
name = "schemars_derive"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9"
dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
"syn",
]
[[package]]
name = "serde"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_bytes"
version = "0.11.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_derive_internals"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_repr"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_wormhole"
version = "0.1.0"
dependencies = [
"base64",
"itoa",
"serde",
"serde_bytes",
"serde_json",
"serde_repr",
"thiserror",
]
[[package]]
name = "sha3"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9"
dependencies = [
"digest",
"keccak",
]
[[package]]
name = "syn"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "typenum"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wormhole-sdk"
version = "0.1.0"
dependencies = [
"anyhow",
"bstr",
"schemars",
"serde",
"serde_json",
"serde_wormhole",
"sha3",
"thiserror",
]

View File

@ -1,10 +1,43 @@
[workspace]
members = [
"core/",
"serde_wormhole",
"supported-chains",
"vaas-serde",
]
resolver = "2"
[profile.release]
opt-level = 3
lto = "thin"
[workspace.package]
version = "0.1.0"
edition = "2021"
authors = ["Wormhole Contributors"]
license = "Apache-2.0"
homepage = "https://github.com/wormhole-foundation/wormhole"
repository = "https://github.com/wormhole-foundation/wormhole"
[workspace.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[workspace.dependencies.wormhole-supported-chains]
version = "0.1.0"
path = "supported-chains"
[workspace.dependencies.serde_wormhole]
version = "0.1.0"
path = "serde_wormhole"
[workspace.dependencies]
anyhow = "1"
thiserror = "1"
bstr = { version = "1", features = ["serde"] }
schemars = "0.8.8"
serde = { version = "1", default-features = false }
serde_bytes = "0.11.5"
serde_json = "1"
serde_repr = "0.1.7"
sha3 = "0.10.4"
base64 = "0.13"
itoa = "1.0.1"

View File

@ -1,23 +0,0 @@
[package]
name = "wormhole-sdk"
version = "0.1.0"
edition = "2021"
[lib]
name = "wormhole_sdk"
[features]
schemars = ["dep:schemars"]
default = ["schemars"]
[dependencies]
anyhow = "1"
bstr = { version = "1", features = ["serde"] }
schemars = { version = "0.8.8", optional = true }
serde = { version = "1", default-features = false, features = ["alloc", "derive"] }
serde_wormhole = {path = "../serde_wormhole"}
sha3 = "0.10.4"
thiserror = "1"
[dev-dependencies]
serde_json = "1"

View File

@ -1,17 +1,21 @@
[package]
name = "serde_wormhole"
version = "0.1.0"
edition = "2021"
description = "Serde data format for VAA payloads"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[dependencies]
base64 = "0.13"
itoa = "1.0.1"
serde = { version = "1.0.103", default-features = false }
serde_bytes = "0.11.5"
thiserror = "1.0"
base64.workspace = true
itoa.workspace = true
serde.workspace = true
serde_bytes.workspace = true
thiserror.workspace = true
[dev-dependencies]
serde = { version = "1.0.103", default-features = false, features = ["alloc", "derive"] }
serde_json = "1"
serde_repr = "0.1.7"
serde = { workspace = true, features = ["alloc", "derive"] }
serde_json.workspace = true
serde_repr.workspace = true

View File

@ -0,0 +1,13 @@
[package]
name = "wormhole-supported-chains"
description = "Wormhole Supported Chain IDs and Names"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[dependencies]
serde.workspace = true
thiserror.workspace = true

View File

@ -0,0 +1,30 @@
[package]
name = "wormhole-vaas-serde"
description = "Serde Support for Wormhole VAAs"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[lib]
name = "wormhole_sdk"
[features]
schemars = ["dep:schemars"]
default = ["schemars"]
[dependencies]
wormhole-supported-chains.workspace = true
serde_wormhole.workspace = true
anyhow.workspace = true
bstr.workspace = true
schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["alloc", "derive"] }
sha3.workspace = true
thiserror.workspace = true
[dev-dependencies]
serde_json.workspace = true

View File

@ -18,7 +18,6 @@ use serde::{Deserialize, Serialize};
pub mod accountant;
pub mod accountant_modification;
mod arraystring;
mod chain;
pub mod core;
pub mod ibc_receiver;
pub mod ibc_translator;
@ -29,7 +28,8 @@ mod serde_array;
pub mod token;
pub mod vaa;
pub use {chain::Chain, vaa::Vaa};
pub use vaa::Vaa;
pub use wormhole_supported_chains::Chain;
/// The `GOVERNANCE_EMITTER` is a special address Wormhole guardians trust to observe governance
/// actions from. The value is "0000000000000000000000000000000000000000000000000000000000000004".