SVM Depository Reference - Relay
API
Version: 0.1.0 Format Version: 46
Module relay_depository
Modules
Module program
Module representing the program.
pub mod program { /* ... */ }
Types
Struct RelayDepository
Type representing the program.
pub struct RelayDepository;
Module relay_depository
pub mod relay_depository { /* ... */ }
Functions
Function initialize
Initialize the relay depository program with owner and allocator. Creates and initializes the relay depository account with the specified owner and allocator.
Parameters
ctx- The context containing the accounts
Returns
Ok(())on success
pub fn initialize(ctx: Context<''_, ''_, ''_, ''_, Initialize<''_>>) -> Result<()> { /* ... */ }
Function set_allocator
Update the allocator public key. Allows the owner to change the authorized allocator that can sign transfer requests.
Parameters
ctx- The context containing the accountsnew_allocator- The public key of the new allocator
Returns
Ok(())on successErr(error)if not authorized
pub fn set_allocator(ctx: Context<''_, ''_, ''_, ''_, SetAllocator<''_>>, new_allocator: Pubkey) -> Result<()> { /* ... */ }
Function set_owner
Update the owner public key. Allows the current owner to transfer ownership to a new address.
Parameters
ctx- The context containing the accountsnew_owner- The public key of the new owner
Returns
Ok(())on successErr(error)if not authorized
pub fn set_owner(ctx: Context<''_, ''_, ''_, ''_, SetOwner<''_>>, new_owner: Pubkey) -> Result<()> { /* ... */ }
Function deposit_native
Deposit native SOL tokens into the vault. Transfers SOL from the sender to the vault and emits a deposit event.
Parameters
ctx- The context containing the accountsamount- The amount of SOL to depositid- A unique identifier for the deposit
Returns
Ok(())on success
pub fn deposit_native(ctx: Context<''_, ''_, ''_, ''_, DepositNative<''_>>, amount: u64, id: [u8; 32]) -> Result<()> { /* ... */ }
Function deposit_token
Deposit SPL tokens into the vault. Creates the vault’s token account if needed, transfers tokens from the sender, and emits a deposit event.
Parameters
ctx- The context containing the accountsamount- The amount of tokens to depositid- A unique identifier for the deposit
Returns
Ok(())on success
pub fn deposit_token(ctx: Context<''_, ''_, ''_, ''_, DepositToken<''_>>, amount: u64, id: [u8; 32]) -> Result<()> { /* ... */ }
Function execute_transfer
Execute a transfer with allocator signature. Verifies the allocator’s signature, transfers tokens to the recipient, and marks the request as used.
Parameters
ctx- The context containing the accountsrequest- The transfer request details and signature
Returns
Ok(())on successErr(error)if signature is invalid or request can’t be processed
pub fn execute_transfer(ctx: Context<''_, ''_, ''_, ''_, ExecuteTransfer<''_>>, request: TransferRequest) -> Result<()> { /* ... */ }
Module instruction
An Anchor generated module containing the program’s set of instructions, where each method handler in the #[program] mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when specifying instructions on a client.
pub mod instruction { /* ... */ }
Types
Struct Initialize
Instruction.
pub struct Initialize;
Struct SetAllocator
Instruction.
pub struct SetAllocator {
pub new_allocator: Pubkey,
}
Fields
| Name | Type | Documentation |
|---|---|---|
new_allocator |
Pubkey |
Struct SetOwner
Instruction.
pub struct SetOwner {
pub new_owner: Pubkey,
}
Fields
| Name | Type | Documentation |
|---|---|---|
new_owner |
Pubkey |
Struct DepositNative
Instruction.
pub struct DepositNative {
pub amount: u64,
pub id: [u8; 32],
}
Fields
| Name | Type | Documentation |
|---|---|---|
amount |
u64 |
|
id |
[u8; 32] |
Struct DepositToken
Instruction.
pub struct DepositToken {
pub amount: u64,
pub id: [u8; 32],
}
Fields
| Name | Type | Documentation |
|---|---|---|
amount |
u64 |
|
id |
[u8; 32] |
Struct ExecuteTransfer
Instruction.
pub struct ExecuteTransfer {
pub request: TransferRequest,
}
Fields
| Name | Type | Documentation |
|---|---|---|
request |
TransferRequest |
Module cpi
Attributes:
#[<cfg>(feature = "cpi")]
pub mod cpi { /* ... */ }
Module accounts
An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is an AccountInfo. This is useful for CPI.
pub mod accounts { /* ... */ }
Re-exports
Re-export crate::__cpi_client_accounts_set_allocator::*
pub use crate::__cpi_client_accounts_set_allocator::*;
Re-export crate::__cpi_client_accounts_set_owner::*
pub use crate::__cpi_client_accounts_set_owner::*;
Re-export crate::__cpi_client_accounts_initialize::*
pub use crate::__cpi_client_accounts_initialize::*;
Re-export crate::__cpi_client_accounts_deposit_token::*
pub use crate::__cpi_client_accounts_deposit_token::*;
Re-export crate::__cpi_client_accounts_execute_transfer::*
pub use crate::__cpi_client_accounts_execute_transfer::*;
Re-export crate::__cpi_client_accounts_deposit_native::*
pub use crate::__cpi_client_accounts_deposit_native::*;
Types
Struct RelayDepository
Relay depository account that stores configuration and state. This account is a PDA derived from the RELAY_DEPOSITORY_SEED and contains the ownership and allocation information.
pub struct RelayDepository {
pub owner: Pubkey,
pub allocator: Pubkey,
pub vault_bump: u8,
}
Fields
| Name | Type | Documentation |
|---|---|---|
owner |
Pubkey |
The owner of the relay depository who can update settings |
allocator |
Pubkey |
The authorized allocator that can sign transfer requests |
vault_bump |
u8 |
The bump seed for the vault PDA, used for deriving the vault address |
Struct UsedRequest
Account that tracks whether a transfer request has been used. This account is created for each transfer request to prevent replay attacks.
pub struct UsedRequest {
pub is_used: bool,
}
Fields
| Name | Type | Documentation |
|---|---|---|
is_used |
bool |
Flag indicating whether the request has been processed |
Implementation Details
// Further implementation details and explanations on various code implementations follow.