-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
100 lines (81 loc) · 2.62 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use anchor_lang::prelude::*;
pub mod compose_msg_codec;
pub mod errors;
pub mod events;
pub mod instructions;
pub mod msg_codec;
pub mod state;
use errors::*;
use events::*;
use instructions::*;
use oapp::{
endpoint::{MessagingFee, MessagingReceipt},
LzReceiveParams,
};
use state::*;
declare_id!("GZGX6QfUo62VbPyYqPZS6t27Uke1dJmoAP6V3rw6ntTH");
pub const OFT_SEED: &[u8] = b"OFT";
pub const PEER_SEED: &[u8] = b"Peer";
pub const ENFORCED_OPTIONS_SEED: &[u8] = b"EnforcedOptions";
pub const LZ_RECEIVE_TYPES_SEED: &[u8] = oapp::LZ_RECEIVE_TYPES_SEED;
#[program]
pub mod oft {
use super::*;
pub fn oft_version(_ctx: Context<OFTVersion>) -> Result<Version> {
Ok(Version {
interface: 2,
message: 1,
})
}
pub fn init_oft(mut ctx: Context<InitOFT>, params: InitOFTParams) -> Result<()> {
InitOFT::apply(&mut ctx, ¶ms)
}
// ============================== Admin ==============================
pub fn set_oft_config(
mut ctx: Context<SetOFTConfig>,
params: SetOFTConfigParams,
) -> Result<()> {
SetOFTConfig::apply(&mut ctx, ¶ms)
}
pub fn set_peer_config(
mut ctx: Context<SetPeerConfig>,
params: SetPeerConfigParams,
) -> Result<()> {
SetPeerConfig::apply(&mut ctx, ¶ms)
}
pub fn set_pause(mut ctx: Context<SetPause>, params: SetPauseParams) -> Result<()> {
SetPause::apply(&mut ctx, ¶ms)
}
pub fn withdraw_fee(mut ctx: Context<WithdrawFee>, params: WithdrawFeeParams) -> Result<()> {
WithdrawFee::apply(&mut ctx, ¶ms)
}
// ============================== Public ==============================
pub fn quote_oft(ctx: Context<QuoteOFT>, params: QuoteOFTParams) -> Result<QuoteOFTResult> {
QuoteOFT::apply(&ctx, ¶ms)
}
pub fn quote_send(ctx: Context<QuoteSend>, params: QuoteSendParams) -> Result<MessagingFee> {
QuoteSend::apply(&ctx, ¶ms)
}
pub fn send(
mut ctx: Context<Send>,
params: SendParams,
) -> Result<(MessagingReceipt, OFTReceipt)> {
Send::apply(&mut ctx, ¶ms)
}
pub fn lz_receive(mut ctx: Context<LzReceive>, params: LzReceiveParams) -> Result<()> {
LzReceive::apply(&mut ctx, ¶ms)
}
pub fn lz_receive_types(
ctx: Context<LzReceiveTypes>,
params: LzReceiveParams,
) -> Result<Vec<oapp::endpoint_cpi::LzAccount>> {
LzReceiveTypes::apply(&ctx, ¶ms)
}
}
#[derive(Accounts)]
pub struct OFTVersion {}
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
pub struct Version {
pub interface: u64,
pub message: u64,
}