Skip to content

LIT-Protocol/datil-lit-blockchain-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datil-lit-blockchain-lite

Lit - Blockchain related crate ( for the older Datil Network )

Overview

This is a stripped down version of the lit-blockchain crate that has dependencies on only ethers.rs and serde. It's mostly generated code, and it's source is actually lit-blockchain that has been refactored to allow it work in WASM based apps, by ensuring that the public stack stays under limit. ( Effectively just seperating code blocks into functions that fit within WASM memory structure params, so from a functional perspective, the access to chain data has identical scope support ).

Where lit-blockchain-lite differs somewhat is that there is no implicit middleware provided (lit-blockchain is self contained and references node credentials to connect with and mutate the chain ) - while it's still trivial to read chain data, writing data requires the wiring of appropriate providers - typically we use metamask or walletconnect.

Updating ABIs

make update 

Note that the make update in this case comes from the lit-blockchain folder, since this repo is merely a lightly refactored copy of lit-blockchain.

Adding a new contract

First make sure you have checked out the lit-os repo as well as LitNodeContracts and they are up to date (git pull).

make update

Add contract key

Modify blockchain/contracts/contracts/lit-os/ContractResolver.sol and add a constant:

bytes32 public constant ALLOWLIST_CONTRACT = keccak256("ALLOWLIST");

Add contract constructors

Modify src/contracts/mod.rs and add a constant to the top:

pub const ALLOWLIST_CONTRACT: &'static str = "ALLOWLIST";

Then add the constructors towards the bottom:

// Allowlist

impl Allowlist<Provider<Http>> {
    pub(crate) fn load(cfg: &LitConfig, address: H160) -> Result<Allowlist<Provider<Http>>> {
        Ok(Allowlist::new(address, default_local_client_no_wallet(cfg)?))
    }
}

impl Allowlist<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>> {
    pub(crate) fn load_with_signer(
        cfg: &LitConfig, address: H160, wallet_key: Option<&str>,
    ) -> Result<Allowlist<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>> {
        Ok(Allowlist::new(address, default_local_client(cfg, wallet_key)?))
    }
}

Add the contract resolver accessors

Modify src/resolver/contract/mod.rs and add (at the bottom of the existing similar definitions):

// Allowlist

pub async fn allowlist_contract(&self, cfg: &LitConfig) -> Result<Allowlist<Provider<Http>>> {
    Allowlist::load(cfg, self.resolve(cfg, ALLOWLIST_CONTRACT).await?.address().clone())
}

pub async fn allowlist_contract_with_signer(
    &self, cfg: &LitConfig,
) -> Result<Allowlist<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>> {
    Allowlist::load_with_signer(
        cfg,
        self.resolve(cfg, ALLOWLIST_CONTRACT).await?.address().clone(),
        self.wallet_key_as_str(),
    )
}

About

Lit-Blockchain-lite - copied from the latest Datil release.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages