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/Sui coin module #7

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Feat/Sui coin module #7

wants to merge 18 commits into from

Conversation

ishaba
Copy link
Collaborator

@ishaba ishaba commented Jan 31, 2025

βœ… Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • ...

πŸ“ Description

Replace this text by a clear and concise description of what this pull request is about and why it is needed. Be sure to explain the problem you're addressing and the solution you're proposing.
For libraries, you can add a code sample of how to use it.
For bug fixes, you can explain the previous behaviour and how it was fixed.
In case of visual features, please attach screenshots or video recordings to demonstrate the changes.

❓ Context

  • JIRA or GitHub link:

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@ishaba ishaba force-pushed the feat/sui-coin-module branch from b781bb6 to 2d53bc7 Compare February 4, 2025 21:11
@ishaba ishaba force-pushed the feat/sui-coin-module branch from 2d53bc7 to 96a36cb Compare February 4, 2025 21:40
@@ -105,6 +105,7 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"xion",
"sui",
Copy link
Member

Choose a reason for hiding this comment

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

Should we add sui_testnet here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question actually i didn't figured out why some coins needs this _testnet version. Possible because some coins haas different configs for mainnet and testnet tokens. I didn't spot any difference for now for sui so it looks like we don't need it and is better to remove sui_testnet from everewhere?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, to be honest. Let's add testnet everywhere for consistency.

@@ -182,6 +182,9 @@ const modes: Readonly<Record<DerivationMode, ModeSpec>> = Object.freeze({
ton: {
overridesDerivation: "44'/607'/0'/0'/<account>'/0'",
},
sui: {
overridesDerivation: "44'/784'/0'/0'/0'",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should put <account> placeholder somewhere. Probably at the last position.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Possible. According to documentation https://docs.sui.io/concepts/cryptography/transaction-auth/keys-addresses it should be 44'/784'/<account>'/0'/0'

Copy link
Member

Choose a reason for hiding this comment

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

Confirmed. It's the proper way and Sui Wallet uses it

import { getEnv } from "@ledgerhq/live-env";
import { ChainAPI } from "./chain";

export function traced(api: ChainAPI): ChainAPI {
Copy link
Member

Choose a reason for hiding this comment

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

How do we use this? Is it required for anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now we don't use it. It will be required when we will implement some request to indexer or any other sui related backend services.

Copy link
Member

Choose a reason for hiding this comment

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

Is anything else use that approach besides Solana?


function formatMsg({ reqId, msg, duration }: { reqId: number; msg?: string; duration?: number }) {
const parts = [
`solana req id: ${reqId}`,
Copy link
Member

Choose a reason for hiding this comment

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

sui I guess if it's needed

default: "OUT",
};

const MODE_TO_PALLET_METHOD: Record<SuiOperationMode | "sendMax", PalletMethod> = {
Copy link
Member

Choose a reason for hiding this comment

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

I assume those are not relevant. I understand that it was inherited from polkadot. Let's revisit it later once more functions are added and refactor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question for some reason solana and polkadot for example distinguishes regular transfer and transfer of all tokens from account. For now i can't answer why we need this i just followed common pattern.

Copy link
Member

Choose a reason for hiding this comment

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

I think the reason for it is that in case of "transfer all" for native tokens we need to consider fees that are paid in native coins. On solana, there's also a special case that we should keep some SOL as an account rent fee.

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