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

expose publicKey and add wallet to provider constructor #3

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

0xBraunGuy
Copy link
Contributor

upgrading from an AnchorProvider is tough because it exposes the publicKey directly, this will help.

also adds an optional wallet parameter so creating a new BankrunProvider from an existing context (multiple signers) is easier.

@kevinheavey
Copy link
Owner

thanks, could you show me an example of what you mean here?

so creating a new BankrunProvider from an existing context (multiple signers) is easier.

@0xBraunGuy
Copy link
Contributor Author

thanks, could you show me an example of what you mean here?

so creating a new BankrunProvider from an existing context (multiple signers) is easier.

something like :

const alice = new NodeWallet(Keypair.generate());
const bob = new NodeWallet(Keypair.generate());

const context = startAnchor(...);

const aliceProvider = new BankrunProvider(context, alice);
const bobProvider = new BankrunProvider(context, bob);

@kevinheavey
Copy link
Owner

And I suppose you'll fund those accounts using the accounts parameter of startAnchor? The ctx.payer account gets funded by the solana-program-test code but other accounts will need to be funded separately

@0xBraunGuy
Copy link
Contributor Author

I think we can intercept connection.requestAirdrop() and add it to the ConnectionInterface. Ideally a user would be able to generate keypairs on demand and fund them. At least this would make porting my Anchor integration tests over.

Can throw out a few more MR's if you like this approach.

@kevinheavey
Copy link
Owner

kevinheavey commented Aug 28, 2023

I don't like relying on the ConnectionInterface too much. Ideally it wouldn't exist, but the Anchor TS client relies on having a web3.js Connection attribute. I would prefer if the Provider interface didn't require a web3.js Connection.

I would also like if the fake Connection object in BankrunProvider wasn't available to the user at all since it's a footgun, but I don't think there's nice way to make it available to anchor-ts but unavailable to anchor-bankrun users.

If we intercept connection.requestAirdrop() we're encouraging users to rely on the fake Connection which kills type safety and is generally hazardous.

@kevinheavey kevinheavey merged commit ff56fcf into kevinheavey:main Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants