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

Use Safe SDK #15

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Use Safe SDK #15

wants to merge 1 commit into from

Conversation

bh2smith
Copy link
Collaborator

@bh2smith bh2smith commented Jun 28, 2024

Attempting to simplify the manually implemented safe.ts in favour of relay-kit and (apparently also api-kit).

There is a GIST here with some additional notes:

https://gist.github.com/bh2smith/27f177a627a0e8679847b857c4d40d66

The kit is not very user friendly and missing some features as of now.

Unfortunately, the signature appears to be invalid: I suspect its something to do with the way we "add signature".

@bh2smith bh2smith marked this pull request as draft June 28, 2024 12:21
@bh2smith bh2smith mentioned this pull request Jun 28, 2024
src/alt-safe.ts Outdated
Comment on lines 81 to 94
// This should be part of the kit!
export async function getSafeOpHash(
provider: ethers.JsonRpcProvider,
safeKit: Safe4337Pack,
safeOp: EthSafeOperation,
) {
return calculateSafeUserOperationHash(
safeOp.data,
BigInt(await safeKit.getChainId()),
// The safe isn't deployed so we have to fetch the fallback Handler on our own:
// await safeKit.protocolKit.getFallbackHandler()
await getSafeModuleAddress(provider),
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the content of safe-global/safe-core-sdk#888

src/alt-safe.ts Outdated
import { calculateSafeUserOperationHash } from "@safe-global/relay-kit/dist/src/packs/safe-4337/utils";
import { ethers } from "ethers";
import { getDeployment } from "./safe";
import { getSafeModuleSetupDeployment } from "@safe-global/safe-modules-deployments";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should also be part of the kit.

src/alt-safe.ts Outdated
@@ -0,0 +1,94 @@
import SafeApiKit, { SafeInfoResponse } from "@safe-global/api-kit";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would love to have avoided this too... its a checky hack to determine if the safe the user wants to use exists already or not. This could be determined by the setup (i.e. seed) data.

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.

1 participant