Commit Graph

279 Commits

Author SHA1 Message Date
justinschuldt 220a869b7b wormchain - contract deploy + test 2023-01-23 15:10:22 -06:00
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
tbjump 5323453b81
node: add channel read/write type constraints (#1931) 2023-01-20 13:15:13 -08: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 3c6702b6f7 sdk/rust: Add serde_wormhole::RawMessage
Add a RawMessage type that can be used to defer parsing parts of a
payload, similar to the `json.RawMessage` from Go.  The implementation
is inspired by `serde_json::RawValue`, which does a similar thing.

When serializing, RawMessage will serialize to a base64-encoded string
if it detects that the data format is human readable (like JSON).
Otherwise it will simply forward the raw bytes to the serializer.

RawMessage has both borrowed and boxed versions.  The borrowed version
is the most efficient as it enables zero-copy handling of the input data
but also requires that the input data already contains raw bytes and is
not suitable when dealing with human-readable formats like JSON.

The boxed version is more flexible as it supports byte slices, base64-
encoded strings, and byte sequences but is slightly less efficient as it
requires copying or decoding the input data.
2023-01-18 09:29:05 +09:00
bruce-riley 3f61661051
sdk: Add Aptos NFT bridge address (#2244) 2023-01-13 15:03:15 -06:00
Kevin Peters 5f6782e67d sdk/js: Use BN.toArrayLike in `tokenIdToMint` function for browserify compatibility. 2023-01-11 13:38:54 -05:00
Evan Gray 735ce417b6 sdk/js: generate docs fixes #1821 2023-01-11 13:01:46 -05:00
Chirantan Ekbote e05176c9be sdk/rust: Remove `expiration_time` from `GuardianSetInfo`
This field doesn't actually appear in `GuardianSetUpgrade` governance
messages and was already being skipped by serde so just remove it
completely.  Contracts that need to keep track of this information can
encapsulate the `GuardianSetInfo` inside another struct that has an
`expiration_time` field.
2023-01-04 16:17:14 +09:00
Chirantan Ekbote 3a1dd9eccd sdk/rust: Simplify quorum calculation
Also add tests.
2023-01-04 16:17:14 +09:00
Chirantan Ekbote ab172b4da5 sdk/rust: Ensure chain conversions are isomorphic
Ensure that converting `Chain` to/from a u16 or to/from a string is
always isomorphic.  This requires changing the `FromStr` impl so that in
can handle strings like "Unknown(27)".
2023-01-04 16:17:14 +09:00
Chris Sentman 0f066614b3 sdk: tests for vaa.UnmarshalBody()
Full coverage save for a non-empty payload read error.
2023-01-03 09:59:56 -05:00
Chris Sentman 66c8399dcb sdk: test ChainID.String()
Completing coverage for method.
2023-01-03 09:59:56 -05:00
Jeff Schroeder bc1edba32c sdk: full test coverage of ChainID.FromString()
The optimism coverage was a lie as it wasn't explicitly tested.
2023-01-03 09:59:56 -05:00
Jeff Schroeder 2b6ede0d54 sdk: test vaa.Address.UnmarshalJSON()
Full coverage including the error condition.
2023-01-03 09:59:56 -05:00
Jeff Schroeder 6ea4cf054a sdk: test BodyWormchainInstantiateContract.Serialize()
This completes full test coverage of sdk/vaa/payloads.go!
2023-01-03 09:59:56 -05:00
Jeff Schroeder a2857e3b1d sdk: test BodyWormchainStoreCode.Serialize() 2023-01-03 09:59:56 -05:00
Jeff Schroeder 1cc177bf64 sdk: cleanup vaa payloads test
Less duplication of the addr.
2023-01-03 09:59:56 -05:00
Jeff Schroeder 7a439e4cfd sdk: BodyTokenBridgeRegisterChain.Serialize() test
* Switch the BodyTokenBridgeRegisterChain.Serialize() test to table driven
  and add coverage for the panic condition.
2023-01-03 09:59:56 -05:00
Jonathan Claudius 98c843e85d
sdk: Add unit-tests for quorum calculation (#2127)
* sdk: Add unit-tests for quorum calculation

* sdk: fix go imports error

* node: remove duplicate sdk unit-test
2022-12-27 13:27:47 -05:00
Kevin Peters a7be5a639c sdk/js: 0.9.8 version bump 2022-12-22 12:57:20 -06:00
Kevin Peters 88e0c6cddf sdk/js: Use BN.toArrayLike for compatibility with browserify and similar tools.
Fixes this error when calling `deriveWrappedMintKey` in the browser:
TypeError: (intermediate value).toBuffer is not a function
2022-12-22 12:57:20 -06:00
Kevin Peters 49de9ef8f2 sdk/js: 0.9.7 version bump 2022-12-21 11:05:40 -06:00
guibescos 43035fcc44
sdk/js: Add instruction decoder to solana (#2095)
* Bump package

* Refactor coder add decoder

* Refactor

* Fix

* Fix u64

* Simplify encode

* Add comment

* Fix verify signatures

* Fix package lock

* Revert "Fix package lock"

This reverts commit 9f219bc6fc21d2d0f8bf33fedafd6c204a00e659.

* Fix deps

* Fix import for bs58
2022-12-21 06:35:37 -05: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 4ea369d7a9 sdk/rust: Implement Display for Address
This will be used later by the accounting contract.
2022-12-19 17:14:33 +09:00
Nikhil Suri eff4eb2ebd wormchain: add accounting contract bindings 2022-12-16 08:51:41 -05: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
Kevin Peters 5ce3290ba3 sdk/js: 0.9.6 version bump 2022-12-14 13:16:23 -05:00
A5 Pickle b71181a404 sdk/js: fix account and instruction serialization 2022-12-14 11:00:20 -06:00
A5 Pickle 1616df817e sdk/js: fix token bridge cpi accounts 2022-12-14 11:00:20 -06:00
Bojan Angjelkoski 612ae1a7e5 sdk/js: injective package bump 2022-12-14 11:40:49 -05:00
Chirantan Ekbote b3d68b0db6 sdk/rust: Drop references to `de::Unexpected`
The `de::Unexpected` enum from serde has a `Float(f64)` variant.
Referencing this enum anywhere in the code will cause the compiler to
emit its `fmt::Display` impl, which includes an `f64.load` instruction
on wasm targets.  Even if this instruction is never executed, its mere
existence will cause cosmos chains to reject any cosmwasm contract that
has it.

Fix this by removing all references to `de::Unexpected`.
2022-12-14 16:33:22 +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 92cb3d28a3 sdk/rust: Add serde_wormhole crate
The serde_wormhole crate implements the wormhole wire format as a serde
data format.  This will let us replace all the hand-rolled
serialization with auto-generated code, which is less error-prone and
easier to review.
2022-12-14 16:33:22 +09:00
Chirantan Ekbote 6e25b6c801 sdk/rust: Move profile settings to workspace 2022-12-14 16:33:22 +09:00
aki a408a5b8ff clients: replace references to sdk consts
this will require another pass in the future, once we cut a new release of the sdk with the deployer address consts
2022-12-13 08:21:49 -08:00
A5 Pickle 26069907b2 sdk/js: fix payload ID 2022-12-12 17:09:05 -05:00
jumpsiegel 82651e4c55
Node fix register chain vaa format error (#2100)
* Node: Fix register chain VAA format error

Change-Id: If60ae2e072da025029b8a817272d8175585baa7d

* sdk_tests: adding sdk vaa tests

* sdk/vaa: share governance serialization

Co-authored-by: Bruce Riley <briley@jumptrading.com>
Co-authored-by: Evan Gray <battledingo@gmail.com>
2022-12-12 13:58:38 -06:00
kev1n-peters c94ad13c8c
node: Injective mainnet support (#2084) 2022-12-07 13:43:44 -06:00
Nikhil Suri 235fb59d05
wormchain: move governance consts to sdk (#2086) 2022-12-07 09:20:11 -08:00
kev1n-peters d7198a74d7
sdk/js: Added injective mainnet addresses (#2085) 2022-12-06 22:53:19 -05:00
Nikhil Suri 0e7c085d71
node: inject wormchain cosmwasm governance messages (#2057)
* node: inject wormchain cosmwasm governance messages

* Use nested hash for defense in depth

* Use keccak.Reset() instead of creating new hash objects

* fix msg_server_wasmd_test

* Updated based on jynnantonix comments

* Check return value of binary.Write

* Include actual error in binary.Write panic case
2022-12-06 11:10:32 -08:00
bruce-riley b38dfc015f
sdk/go: Add unmarshal for vaa.Address (#2076)
* sdk/go: Add unmarshal for vaa.Address

Change-Id: I1beb99f82673d1fc3225a8c6628a0019648d7e01

* sdk/go: review rework

Change-Id: I7c9179e674c019f46eebff13a071f997f20572f3
2022-12-06 07:18:16 -06:00
Evan Gray 22304b94a1 sdk/js: avoid terra test1 key in CI 2022-12-01 17:41:00 -05:00
bruce-riley b2fdebb9cb
SDK: Redeploy Neon Testnet (#2035)
* sdk: redeploy neon testnet

* sdk/js: 0.9.4 version bump

Co-authored-by: Kevin Peters <kpeters@jumptrading.com>
2022-11-30 18:54:43 -06:00
Nikhil Suri 88293f36eb
sdk: enforce single canonical VerifySignatures method (#1995) 2022-11-30 10:42:07 -08:00
Conor Patrick 63a5654c02 wormchain: add admin-sign command to continue wormchain validator enrollment 2022-11-30 09:23:19 -06:00