Commit Graph

12 Commits

Author SHA1 Message Date
Chirantan Ekbote b2ca522e73 sdk/rust: Add test with hardcoded digest
Add a test for digest calculation that uses a hardcoded digest.  The
digest for this test was calculated using the `worm` CLI to ensure
interoperability.
2023-01-23 11:53:39 -05:00
Chirantan Ekbote d19fc98091 sdk/rust: Properly support tokenbridge payload3 messages
Add the payload as an explicit field to the `TransferWithPayload` enum
variant.  This is a generic parameter that defaults to `Box<RawMessage>`
for maximum flexibility (and to avoid leaking lifetimes higher up the
stack) but users are encouraged to replace this default type parameter
with an explicit `&RawMessage` in places where the serde_wormhole data
format is used.

The main benefit of this change is that the payload is now included as
part of the actual message and no longer requires callers to awkwardly
append it after serialization.  This is especially useful in human-
readable formats like JSON (see the `transfer_with_payload` test in
token.rs for an example of this simplification).

The main downside is that this now requires explicit type annotations
when using the non-payload3 variants so that the compiler will pick up
the default generic parameter.  This is a relatively minor inconvenience
and the benefit appears to be worth the cost.

There should be no functional change.
2023-01-20 18:12:41 +09:00
Chirantan Ekbote 421a030dca sdk/rust: Remove `*_with_payload` methods
The RawMessage type provides a more flexible way to handle trailing
payloads so replace all usage of the `*_with_payload` functions to use
`RawMessage` instead.

There should be no functional change.
2023-01-18 09:33:10 +09:00
Chirantan Ekbote b400a2d51d sdk/rust: Add test for digest calculation
Add a test to ensure that calculating the digest from the structured
body, serialized data, or partial body + serialized payload all give the
same result.
2022-12-21 13:59:01 +09:00
Chirantan Ekbote 0dbeeec3d4 sdk/rust: Add `Body::with_payload`
Add the `Body::with_payload` method, which can be used to change the
type of the payload for a `Body`.  This is useful when parsing the
payload needs to be deferred until after the body is parsed.
2022-12-19 17:14:33 +09:00
Chirantan Ekbote 16b22a8cfc cosmwasm: wormhole-bindings: Use the Signature type from the SDK
Use the `Signature` type from the core SDK to avoid unnecessary
type conversions.  Cosmwasm requires its message types to implement
`JsonSchema` so also derive that impl for the `Signature` type behind a
feature flag.

This change uncovered a separate issue where the fake `WormholeKeeper`
was using regular ecdsa signatures rather than recoverable signatures
so fix the signing and verification methods to use the recoverable
signatures.
2022-12-15 12:22:37 +09:00
Chirantan Ekbote d157c7bf67 sdk/rust: Add serde-based struct defintions
Refactor the core crate to add serde-based struct definitions for the
various messages used by the different wormhole smart contracts.  This
will also make it easier to use alternate data formats (like json) for
client-side tooling.

Co-authored-by: Reisen <reisen@morphism.org>
2022-12-14 16:33:22 +09:00
Chirantan Ekbote 676d729e3a sdk/rust: Fix clippy warnings 2022-10-28 14:35:44 -04:00
Chirantan Ekbote cb20d47835 sdk/rust: Fix formatting
Also disable unstable options in the rustfmt.toml
2022-10-28 14:35:44 -04:00
Chirantan Ekbote e907a05b1e sdk, terra: Fix tests and add them to CI
The terra tests had bit rotted quite terribly. It seems no one has run
them in almost a year because the API changed with the 0.14 release of
cosmwasm_vm in April, 2021.

Completely remove cosmwasm_vm from dev-dependencies.  The tests aren't
doing anything that requires interacting with the wasm code and can just
test the relevant functions directly.

Once this goes in the tests should be running in the CI so hopefully no
one will be able to push any more breaking changes.

commit-id:537d95e6
2022-04-20 09:46:51 +09:00
Reisen e561d6de02 sdk: fixes to types and builds
Change-Id: I10b753450445cc021dbeb9f28ddb0384070e9635
2022-01-14 13:09:12 +00:00
Reisen 97566d878a sdk: add core types for wormhole projects
Change-Id: Iabaebb7b4319d5b759044896b2b396d39bda33d7
2022-01-14 13:09:12 +00:00