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

Convert Lucid Instance to Effect type and set provider as optional #203

Open
solidsnakedev opened this issue Aug 11, 2024 · 1 comment
Open
Assignees

Comments

@solidsnakedev
Copy link
Contributor

Currently Lucid is not capable to init without passing a provider, this is problematic when you just want to select a wallet and signing a transaction from an api.

The ideal workflow should be as follows.

        const lucid = await Lucid(undefined, undefined);
        const api = await window.cardano[enabledWallet].enable();
        lucid.selectWallet.fromAPI(api);
        const response = await fetch("/api/buildtransaction", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({ address: usedAddresses[0] }),
        });
        const { tx } = await response.json();
        const signedTx = await lucid.fromTx(tx).sign.withWallet().complete();

At the same time the side effects from having an undefined expression is problematic as well, therefore Lucid must be converted to Effect type so we can have a better error control

export const Lucid = async (
provider: Provider,
network: Network,
): Promise<LucidEvolution> => {

@solidsnakedev solidsnakedev self-assigned this Aug 11, 2024
@SynthLuvr
Copy link

Somewhat related, I created a selectWallet.fromRandom method that creates a random wallet so I get the provider functions and all the other functions don't fail when I don't need address and UTXOs. It's quite simple in that it generates a random seed phrase, derives the address, then passes in the address and empty UTXO array into selectWallet.fromAddress

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