Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lower_level_interface generic #495

Open
Syther007 opened this issue Sep 3, 2024 · 2 comments
Open

Make lower_level_interface generic #495

Syther007 opened this issue Sep 3, 2024 · 2 comments

Comments

@Syther007
Copy link
Collaborator

Syther007 commented Sep 3, 2024

The data structures in this trait are not generic, will need associated_type_defaults to implement it.
see issue #29661 rust-lang/rust#29661 for more information

@Syther007 Syther007 converted this from a draft issue Sep 3, 2024
@bertllll
Copy link
Contributor

bertllll commented Sep 5, 2024

Hi @Syther007, I don't want to load you up with more work to do but could you please elaborate on what specifically you had in mind when making this card out? Some real-like piece of code or just a pseudo-one would be handy. Do you remember details of your idea?

I can suppose what you might've meant. However, I'm not convinced we would benefit much from the new feature in the Rust language you refer to. I cannot imagine why it'd be useful to have the associated types defaulted. I think it is completely fine if each implementor of this trait will define its own types, because if you said this wouldn't be necessary, then the need to make the data structures generic would not sound true in first place. I don't know all the caveats of this but I'm reasoning like this because it is quite a unique requirement having a default.

@kauri-hero kauri-hero moved this from 🆕 New to 📋 Backlog in MASQ Node v2 Sep 15, 2024
@Syther007
Copy link
Collaborator Author

This is how associated types looks in action.
Now the implementer of the trait will rely on third party code (respective to the blockchain) and not the trait.

pub trait LowBlockchainInt {
    // TODO: GH-495 The data structures in this trait are not generic, will need associated_type_defaults to implement it.
    // see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information

    type BigNumber;
    type Number;
    type Hash;
    type TxFilter;
    type TxReceipt;
    type WalletAddress;
    
    
    fn get_transaction_fee_balance(
        &self,
        address: WalletAddress,
    ) -> Box<dyn Future<Item = BigNumber, Error = BlockchainError>>;

    fn get_service_fee_balance(
        &self,
        address: WalletAddress,
    ) -> Box<dyn Future<Item = BigNumber, Error = BlockchainError>>;

    fn get_gas_price(&self) -> Box<dyn Future<Item = BigNumber, Error = BlockchainError>>;

    fn get_block_number(&self) -> Box<dyn Future<Item = Number, Error = BlockchainError>>;

    fn get_transaction_id(
        &self,
        address: WalletAddress,
    ) -> Box<dyn Future<Item = BigNumber, Error = BlockchainError>>;

    fn get_transaction_receipt_in_batch(
                                         &self,
                                         hash_vec: Vec<Hash>,
    ) -> Box<dyn Future<Item = Vec<TransactionReceiptResult>, Error = BlockchainError>>;

    fn get_contract(&self) -> Contract<Http>;

    fn get_transaction_logs(
        &self,
        filter: TxFilter,
    ) -> Box<dyn Future<Item = Vec<TxReceipt>, Error = BlockchainError>>;

    fn submit_payables_in_batch(
        &self,
        logger: Logger,
        chain: Chain,
        consuming_wallet: Wallet,
        fingerprints_recipient: Recipient<PendingPayableFingerprintSeeds>,
        affordable_accounts: Vec<PayableAccount>,
    ) -> Box<dyn Future<Item = Vec<ProcessedPayableFallible>, Error = PayableTransactionError>>;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants