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

feat: init Lazer Aptos contract #2381

Merged
merged 20 commits into from
Feb 25, 2025
Merged

feat: init Lazer Aptos contract #2381

merged 20 commits into from
Feb 25, 2025

Conversation

tejasbadadare
Copy link
Contributor

@tejasbadadare tejasbadadare commented Feb 14, 2025

First pass at the Aptos Lazer contract. Keeps the same API as the Solana and EVM contracts.
Uses Ed25519 signatures as recommended by Aptos docs.

Deployed to devnet here.
Example transaction of initializing the contract here.

Copy link

vercel bot commented Feb 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 25, 2025 6:23pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 25, 2025 6:23pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 25, 2025 6:23pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 6:23pm
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 6:23pm
insights ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 6:23pm

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

You'd need to use the Wormhole's deployer to make sure you can upgrade the contract later by itself (DAO)

@tejasbadadare
Copy link
Contributor Author

I will handle governance actions in the next PR to keep this one from getting too unwieldy (initializing using the Wormhole deployer, setting up a governance module that owns the lazer SignerCapability, and handling governance instructions such as contract upgrades)

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

Thank you!

/// Allows the designated admin to claim their capability
public entry fun claim_admin_capability(account: &signer) acquires PendingAdminCapability {
let pending = borrow_global<PendingAdminCapability>(@pyth_lazer);
assert!(signer::address_of(account) == pending.admin, ENO_PERMISSIONS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to invalidate the admin capability right? otherwise it seems we can mint infinite capabilities.

more for my edification: could the @pyth get admincapability itself in initialize and then later transfer it to someone else :?

Copy link
Contributor Author

@tejasbadadare tejasbadadare Feb 25, 2025

Choose a reason for hiding this comment

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

we need to invalidate the admin capability right? otherwise it seems we can mint infinite capabilities.

multiple claim attempts by the admin will fail, since there can only be a single resource of a given type under an account, and since the capabilities don't have copy there shouldn't be a way to distribute copies of the capability. i thought about explicitly destroying the PendingAdminCapability after it has been claimed, but thought it might be misleading since move already guarantees it can't be double-claimed.

But, on second thought, leaving it in global state is kinda confusing, and may invite people to try to use it. I'll destroy it after it's been claimed

more for my edification: could the @pyth get admincapability itself in initialize and then later transfer it to someone else :?

and get rid of PendingAdminCapability? yeah i think that would work, but i was following the wormhole deployer's pattern of a pending capability. i'll dig into this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I looked it up and it seems that in Aptos a non-contract cannot pass it's owned objects to the functions and therefore i don't think they can transfer an object. I'm not sure but i saw this pattern a lot that there's an entrypoint for signer everywhere and then objects are collected (like what you do now) which partially defeats the purpose of this language construct 🤷 SUI handles it properly though.

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.

4 participants