solitaire: Infer entry point argument type in solitaire! macro (#927)
The type of the `ix_data` binding withing the solitaire! macro expansion is explicitly annotated with its type, which comes from the macro's pattern binding `$kind`. However, this type annotation is entirely optional, since `ix_data` is passed in as an argument to `$fn`, whose type forecs `ix_data` anyway, and rust will happily infer that from the application. So we remove the explicit annotation which makes the entry point macro easier to use. commit-id:d428306c
This commit is contained in:
parent
b718225e45
commit
f60acc59ab
|
@ -17,5 +17,5 @@ pub use api::{
|
||||||
};
|
};
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
PostMessage(PostMessageData) => post_message,
|
PostMessage => post_message,
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,12 @@ pub use vaa::{
|
||||||
};
|
};
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
Initialize(InitializeData) => initialize,
|
Initialize => initialize,
|
||||||
PostMessage(PostMessageData) => post_message,
|
PostMessage => post_message,
|
||||||
PostVAA(PostVAAData) => post_vaa,
|
PostVAA => post_vaa,
|
||||||
SetFees(SetFeesData) => set_fees,
|
SetFees => set_fees,
|
||||||
TransferFees(TransferFeesData) => transfer_fees,
|
TransferFees => transfer_fees,
|
||||||
UpgradeContract(UpgradeContractData) => upgrade_contract,
|
UpgradeContract => upgrade_contract,
|
||||||
UpgradeGuardianSet(UpgradeGuardianSetData) => upgrade_guardian_set,
|
UpgradeGuardianSet => upgrade_guardian_set,
|
||||||
VerifySignatures(VerifySignaturesData) => verify_signatures,
|
VerifySignatures => verify_signatures,
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub use api::{
|
||||||
use bridge::PostVAAData;
|
use bridge::PostVAAData;
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
Initialize(InitializeData) => initialize,
|
Initialize => initialize,
|
||||||
PostMessage(PostMessageData) => post_message,
|
PostMessage => post_message,
|
||||||
PostVAA(PostVAAData) => post_vaa,
|
PostVAA => post_vaa,
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ impl From<MigrationError> for SolitaireError {
|
||||||
}
|
}
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
AddLiquidity(AddLiquidityData) => add_liquidity,
|
AddLiquidity => add_liquidity,
|
||||||
RemoveLiquidity(RemoveLiquidityData) => remove_liquidity,
|
RemoveLiquidity => remove_liquidity,
|
||||||
ClaimShares(ClaimSharesData) => claim_shares,
|
ClaimShares => claim_shares,
|
||||||
CreatePool(CreatePoolData) => create_pool,
|
CreatePool => create_pool,
|
||||||
MigrateTokens(MigrateTokensData) => migrate_tokens,
|
MigrateTokens => migrate_tokens,
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,12 @@ impl From<TokenBridgeError> for SolitaireError {
|
||||||
}
|
}
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
Initialize(InitializeData) => initialize,
|
Initialize => initialize,
|
||||||
CompleteNative(CompleteNativeData) => complete_native,
|
CompleteNative => complete_native,
|
||||||
CompleteWrapped(CompleteWrappedData) => complete_wrapped,
|
CompleteWrapped => complete_wrapped,
|
||||||
CompleteWrappedMeta(CompleteWrappedMetaData) => complete_wrapped_meta,
|
CompleteWrappedMeta => complete_wrapped_meta,
|
||||||
TransferWrapped(TransferWrappedData) => transfer_wrapped,
|
TransferWrapped => transfer_wrapped,
|
||||||
TransferNative(TransferNativeData) => transfer_native,
|
TransferNative => transfer_native,
|
||||||
RegisterChain(RegisterChainData) => register_chain,
|
RegisterChain => register_chain,
|
||||||
UpgradeContract(UpgradeContractData) => upgrade_contract,
|
UpgradeContract => upgrade_contract,
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,13 @@ impl From<TokenBridgeError> for SolitaireError {
|
||||||
}
|
}
|
||||||
|
|
||||||
solitaire! {
|
solitaire! {
|
||||||
Initialize(InitializeData) => initialize,
|
Initialize => initialize,
|
||||||
AttestToken(AttestTokenData) => attest_token,
|
AttestToken => attest_token,
|
||||||
CompleteNative(CompleteNativeData) => complete_native,
|
CompleteNative => complete_native,
|
||||||
CompleteWrapped(CompleteWrappedData) => complete_wrapped,
|
CompleteWrapped => complete_wrapped,
|
||||||
TransferWrapped(TransferWrappedData) => transfer_wrapped,
|
TransferWrapped => transfer_wrapped,
|
||||||
TransferNative(TransferNativeData) => transfer_native,
|
TransferNative => transfer_native,
|
||||||
RegisterChain(RegisterChainData) => register_chain,
|
RegisterChain => register_chain,
|
||||||
CreateWrapped(CreateWrappedData) => create_wrapped,
|
CreateWrapped => create_wrapped,
|
||||||
UpgradeContract(UpgradeContractData) => upgrade_contract,
|
UpgradeContract => upgrade_contract,
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ macro_rules! trace_impl {
|
||||||
/// - A set of client calls scoped to the module `api` that can generate instructions.
|
/// - A set of client calls scoped to the module `api` that can generate instructions.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! solitaire {
|
macro_rules! solitaire {
|
||||||
{ $($row:ident($kind:ty) => $fn:ident),+ $(,)* } => {
|
{ $($row:ident => $fn:ident),+ $(,)* } => {
|
||||||
pub mod instruction {
|
pub mod instruction {
|
||||||
use super::*;
|
use super::*;
|
||||||
use borsh::{
|
use borsh::{
|
||||||
|
@ -66,7 +66,7 @@ macro_rules! solitaire {
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn execute<'a, 'b: 'a, 'c>(p: &Pubkey, a: &'c [AccountInfo<'b>], d: &[u8]) -> Result<()> {
|
pub fn execute<'a, 'b: 'a, 'c>(p: &Pubkey, a: &'c [AccountInfo<'b>], d: &[u8]) -> Result<()> {
|
||||||
let ix_data: $kind = BorshDeserialize::try_from_slice(d).map_err(|e| SolitaireError::InstructionDeserializeFailed(e))?;
|
let ix_data = BorshDeserialize::try_from_slice(d).map_err(|e| SolitaireError::InstructionDeserializeFailed(e))?;
|
||||||
let mut accounts = FromAccounts::from(p, &mut a.iter(), &())?;
|
let mut accounts = FromAccounts::from(p, &mut a.iter(), &())?;
|
||||||
$fn(&ExecutionContext{program_id: p, accounts: a}, &mut accounts, ix_data)?;
|
$fn(&ExecutionContext{program_id: p, accounts: a}, &mut accounts, ix_data)?;
|
||||||
Persist::persist(&accounts, p)?;
|
Persist::persist(&accounts, p)?;
|
||||||
|
|
Loading…
Reference in New Issue