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

Upgrade @solana/spl-token to "0.4.9" #3447

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

yanCode
Copy link
Contributor

@yanCode yanCode commented Dec 23, 2024

This PR is created to fix #3446

all the tests in git action workflow are passed: the running result based latest code can be seen in my folked project of anchor https://github.com/yanCode/anchor/actions/runs/12459231512

What has been done:

Apart from the fixes described in the issue below refactory is made.

  • The deprecated findProgramAddressmethod is replaced with findProgramAddressSync in the code affected by this PR. but there are still many other parts code containing findProgramAddress in the whole project , including the core package ts/packages/anchor, which i think we might need to add an interface idlAddressSync to deprecated the sync one.
    https://github.com/coral-xyz/anchor/blob/master/ts/packages/anchor/src/idl.ts#L275-L278

      export async function idlAddress(programId: PublicKey): Promise<PublicKey> {
        const base = (await PublicKey.findProgramAddress([], programId))[0];
       return await PublicKey.createWithSeed(base, seed(), programId);
      }

    I will track & fix them after this PR is resolved.

  • Replaced the lamports unit from 10000000000 to 10 * LAMPORTS_PER_SOL, to make it a little bit better human readble.

  • As required by latest version of @solana/spl-token, typescript as a dependency of it, is also required to upgrade to version 5, that's why I upgraded "typescript": "^5.7.2". also tsconfig.json in the sub projects is simplified to extend from a parent tsconfig.json located in tests/ to avoid violating Don't Repeat Yourself rule.

  • Another improvement when creating many mint accounts together, I used Promise.all to sumbit them to the chain concurrently. Because solana blockchain can support concurrent execution of transactions on batch. (This is one of the reasons why solana is faster).

  • After calling the instruction handler, it needs to pass in the accounts used in this intruction. There are methods inlcuding accountsPartial and accounts. If you check the doc, it says account method only accepts accounts that cannot be resolved. but in current logic, the account parameters of many parts include some resolvable accounts like SystemProgram.programId and PDA. after upgrading to typescript 5, npx tsc --noEmit command from the workflow can detect and complain about this kind of issue. so I repaced it with accountsPartial which is more inclusive than accounts method when any resolvable accounts are in the account parameter.

What hasn't been done:

  • In tests/auction-house, current logic is based on an old version of "@metaplex/js": "^4.4.1", to upgrade @solana/spl-token, it also should be upgraded. to avoid the scope of this PR is too big. I keep this project using the old version of dependencies in tests/auction-house/package.json.
  "dependencies": {
    "@solana/spl-token": "^0.1.8",
    "@solana/web3.js": "^1.68.0",
    "@metaplex/js": "^4.4.1"
  }

I take a note here, I will track and fix it after this PR is resolved.

  • In tests/ido-pool, it use setTimeout to stop the execution of logic to ensure previous transaction is done. this can waste much more time than necessary, which breaches the fact: solana is faster. Actually, javascript/typescript is full async and event-driven. so it only need to async await the execution of the transction, with the commitment level to be confirmed.

  • The projects are execulded from github workflow is not changed and tested.

Copy link

vercel bot commented Dec 23, 2024

@yanCode is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

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.

[Improvement][tests] in tests project, the version of dependency "@solana/spl-token": "^0.1.8" is too old
1 participant