wormhole_sui_sdk/lib.rs
1#![cfg_attr(all(doc, not(doctest)), feature(doc_cfg))]
2
3//! Move types for the `Wormhole` Sui package.
4
5use sui_framework_sdk::table::Table;
6
7af_sui_pkg_sdk::sui_pkg_sdk!(wormhole {
8 module vaa {
9 /// Container storing verified Wormhole message info. This struct also
10 /// caches the digest, which is a double Keccak256 hash of the message body.
11 struct VAA {
12 /// Guardian set index of Guardians that attested to observing the
13 /// Wormhole message.
14 guardian_set_index: u32,
15 /// Time when Wormhole message was emitted or observed.
16 timestamp: u32,
17 /// A.K.A. Batch ID.
18 nonce: u32,
19 /// Wormhole chain ID from which network the message originated from.
20 emitter_chain: u16,
21 /// Address of contract (standardized to 32 bytes) that produced the
22 /// message.
23 emitter_address: external_address::ExternalAddress,
24 /// Sequence number of emitter's Wormhole message.
25 sequence: u64,
26 /// A.K.A. Finality.
27 consistency_level: u8,
28 /// Arbitrary payload encoding data relevant to receiver.
29 payload: vector<u8>,
30
31 /// Double Keccak256 hash of message body.
32 digest: bytes32::Bytes32
33 }
34 }
35
36 module external_address {
37 /// Container for `Bytes32`.
38 struct ExternalAddress has copy, drop, store {
39 value: bytes32::Bytes32,
40 }
41 }
42
43 module consumed_vaas {
44 /// Container storing VAA hashes (digests). This will be checked against in
45 /// `parse_verify_and_consume` so a particular VAA cannot be replayed. It
46 /// is up to the integrator to have this container live in his contract
47 /// in order to take advantage of this no-replay protection. Or an
48 /// integrator can implement his own method to prevent replay.
49 struct ConsumedVAAs has store {
50 hashes: set::Set<bytes32::Bytes32>
51 }
52 }
53
54 module set {
55 /// Empty struct. Used as the value type in mappings to encode a set
56 struct Empty has store, drop {}
57
58 /// A set containing elements of type `T` with support for membership
59 /// checking.
60 struct Set<!phantom T: copy + drop + store> has store {
61 items: Table<T, Empty>
62 }
63 }
64
65 module bytes32 {
66 /// Container for `vector<u8>`, which has length == 32.
67 struct Bytes32 has copy, drop, store {
68 data: vector<u8>,
69 }
70 }
71});