Skip to content

Removing Base App dependencies#39

Closed
napoleond wants to merge 2 commits intomainfrom
dnr/no-base-org
Closed

Removing Base App dependencies#39
napoleond wants to merge 2 commits intomainfrom
dnr/no-base-org

Conversation

@napoleond
Copy link
Copy Markdown
Contributor

No description provided.

The downside is that it's a worse user experience (the user might not be familiar with ERC20 approvals,
and their wallet might not explain it to them), and worse security (rather than a bounded recurring limit,
the user needs to grant a single fixed amount up-front—renewing that amount requires a new approval).
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not tracking with this - does this mean that the user is just up-front transfering to the ephemeral wallet, rather than granting the ephemeral wallet permission to spend from the main wallet? Or does it mean this is still "permission to spend from the base wallet", but it won't auto-renew once the initial allowance is used up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latter

const existingData = this.loadSavedWalletAndPermission(storage, storageKey);
if (existingData) {
const ephemeralSmartWallet = await toEphemeralSmartWallet(existingData.privateKey, config.apiKey);
const ephemeralSmartWallet = await toEphemeralSmartWallet(existingData.privateKey);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking ...

Any reason not to still use the config for the apiKey and just have the default when creating the config be the env var?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly that developers using this method will look at the parameters and assume they need to plug in an API key even if the field is optional. I don't want developers bringing their own API key.

token: string;
chainId: number;
allowance: bigint;
periodInDays: number; // this is ignored
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is ignored, can we just delete it. Seems annoying / confusing to have otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that we could remove this shim if/when Coinbase gets their shit together with spend permissions in the Base app—so keeping a consistent interface seems useful from that perspective 🤷


// Use the client
const hash = await client.sendTransaction({
account: params.account as `0x${string}`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW viem has a Hex type we used in other places.

spender: params.spender,
token: params.token,
allowance: params.allowance.toString(),
period: params.periodInDays * 24 * 60 * 60,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct, or is it misleading too? If the period is no longer required, we should change the type to not require it and handle that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a bit of impedance mismatch against spend permissions. See my other comment—maybe it's not realistic to try preserving a common interface, but that was my thought process.

@robdimarco-atxp
Copy link
Copy Markdown
Contributor

Closing this PR as the code was added in #64

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.

3 participants