Lit - Blockchain related crate ( for the older Datil Network )
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.
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.
First make sure you have checked out the lit-os repo as well as LitNodeContracts and they are
up to date (git pull).
make updateModify blockchain/contracts/contracts/lit-os/ContractResolver.sol and add a constant:
bytes32 public constant ALLOWLIST_CONTRACT = keccak256("ALLOWLIST");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)?))
}
}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(),
)
}