浏览代码

ts: Remove SPL coders from Anchor package (#2155)

* ts: Remove SPL coders from Anchor package

* Replace old SPL custom coder tests

* Build and link new SPL packages before tests and decode token account for AccountStore

* Fix Github actions ts setup

* Fix u64 buffer length

* Update submodules

* Update CHANGELOG

* Checkout correct submodule commits

* Add filler program to generate idls in order for anchor test to pass
acheron 2 年之前
父节点
当前提交
af115999c6
共有 35 个文件被更改,包括 226 次插入2574 次删除
  1. 5 2
      .github/actions/setup-ts/action.yaml
  2. 4 0
      CHANGELOG.md
  3. 1 4
      tests/custom-coder/Anchor.toml
  4. 2 2
      tests/custom-coder/package.json
  5. 0 20
      tests/custom-coder/programs/custom-coder/Cargo.toml
  6. 0 2
      tests/custom-coder/programs/custom-coder/Xargo.toml
  7. 0 14
      tests/custom-coder/programs/custom-coder/src/lib.rs
  8. 1 1
      tests/custom-coder/programs/spl-associated-token/Cargo.toml
  9. 3 27
      tests/custom-coder/programs/spl-associated-token/src/lib.rs
  10. 4 334
      tests/custom-coder/programs/spl-token/src/lib.rs
  11. 21 29
      tests/custom-coder/tests/spl-associated-token-coder.ts
  12. 66 56
      tests/custom-coder/tests/spl-token-coder.ts
  13. 2 0
      tests/package.json
  14. 87 39
      tests/yarn.lock
  15. 0 1
      ts/build-packages.sh
  16. 0 1
      ts/packages/anchor/src/coder/index.ts
  17. 0 42
      ts/packages/anchor/src/coder/spl-associated-token/accounts.ts
  18. 0 14
      ts/packages/anchor/src/coder/spl-associated-token/events.ts
  19. 0 26
      ts/packages/anchor/src/coder/spl-associated-token/index.ts
  20. 0 22
      ts/packages/anchor/src/coder/spl-associated-token/instruction.ts
  21. 0 13
      ts/packages/anchor/src/coder/spl-associated-token/state.ts
  22. 0 13
      ts/packages/anchor/src/coder/spl-associated-token/types.ts
  23. 0 97
      ts/packages/anchor/src/coder/spl-token/accounts.ts
  24. 0 14
      ts/packages/anchor/src/coder/spl-token/events.ts
  25. 0 26
      ts/packages/anchor/src/coder/spl-token/index.ts
  26. 0 349
      ts/packages/anchor/src/coder/spl-token/instruction.ts
  27. 0 13
      ts/packages/anchor/src/coder/spl-token/state.ts
  28. 0 13
      ts/packages/anchor/src/coder/spl-token/types.ts
  29. 0 1
      ts/packages/anchor/src/index.ts
  30. 3 4
      ts/packages/anchor/src/program/accounts-resolver.ts
  31. 1 1
      ts/packages/anchor/src/program/namespace/methods.ts
  32. 26 25
      ts/packages/anchor/src/program/token-account-layout.ts
  33. 0 120
      ts/packages/anchor/src/spl/associated-token.ts
  34. 0 20
      ts/packages/anchor/src/spl/index.ts
  35. 0 1229
      ts/packages/anchor/src/spl/token.ts

+ 5 - 2
.github/actions/setup-ts/action.yaml

@@ -22,8 +22,11 @@ runs:
           key: solana-${{ runner.os }}-v0000-${{ env.NODE_VERSION }}-${{ hashFiles('./ts/**/*.ts') }}  
           key: solana-${{ runner.os }}-v0000-${{ env.NODE_VERSION }}-${{ hashFiles('./ts/**/*.ts') }}  
       - run: cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
       - run: cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
         shell: bash
         shell: bash
+      - run: cd ts/packages/spl-associated-token-account && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
+        shell: bash
+      - run: cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
+        shell: bash
       - run: cd examples/tutorial && yarn link @project-serum/anchor && yarn --frozen-lockfile && cd ../../
       - run: cd examples/tutorial && yarn link @project-serum/anchor && yarn --frozen-lockfile && cd ../../
         shell: bash
         shell: bash
-      - run: cd tests && yarn link @project-serum/anchor && yarn --frozen-lockfile && cd ..
+      - run: cd tests && yarn link @project-serum/anchor && yarn link @project-serum/spl-associated-token-account && yarn link @project-serum/spl-token && yarn --frozen-lockfile && cd ..
         shell: bash
         shell: bash
-        

+ 4 - 0
CHANGELOG.md

@@ -36,6 +36,10 @@ The minor version will be incremented upon a breaking change and the patch versi
 * ts: Update seeds inference to allow nested user defined structs within the seeds ([#2198](https://github.com/coral-xyz/anchor/pull/2198))
 * ts: Update seeds inference to allow nested user defined structs within the seeds ([#2198](https://github.com/coral-xyz/anchor/pull/2198))
 * event: Fix multiple event listeners with the same name. ([#2165](https://github.com/coral-xyz/anchor/pull/2165))
 * event: Fix multiple event listeners with the same name. ([#2165](https://github.com/coral-xyz/anchor/pull/2165))
 
 
+### Breaking
+
+* ts: SPL coders have been removed from the main Anchor package. ([#2155](https://github.com/coral-xyz/anchor/pull/2155))
+
 ## [0.25.0] - 2022-07-05
 ## [0.25.0] - 2022-07-05
 
 
 ### Features
 ### Features

+ 1 - 4
tests/custom-coder/Anchor.toml

@@ -1,8 +1,7 @@
 [programs.localnet]
 [programs.localnet]
-custom_coder = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
-spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w"
 native_system = "9NxAd91hhJ3ZBTHytYP894y4ESRKG7n8VbLgdyYGJFLB"
 native_system = "9NxAd91hhJ3ZBTHytYP894y4ESRKG7n8VbLgdyYGJFLB"
 spl_associated_token = "4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh"
 spl_associated_token = "4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh"
+spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w"
 
 
 [registry]
 [registry]
 url = "https://anchor.projectserum.com"
 url = "https://anchor.projectserum.com"
@@ -13,5 +12,3 @@ wallet = "~/.config/solana/id.json"
 
 
 [scripts]
 [scripts]
 test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
 test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
-
-[features]

+ 2 - 2
tests/custom-coder/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "custom-coder",
   "name": "custom-coder",
-  "version": "0.20.0",
+  "version": "0.25.0",
   "license": "(MIT OR Apache-2.0)",
   "license": "(MIT OR Apache-2.0)",
   "homepage": "https://github.com/coral-xyz/anchor#readme",
   "homepage": "https://github.com/coral-xyz/anchor#readme",
   "bugs": {
   "bugs": {
@@ -14,7 +14,7 @@
     "node": ">=11"
     "node": ">=11"
   },
   },
   "scripts": {
   "scripts": {
-    "test": "anchor test"
+    "test": "anchor test --skip-lint"
   },
   },
   "dependencies": {
   "dependencies": {
     "mocha": "^10.0.0",
     "mocha": "^10.0.0",

+ 0 - 20
tests/custom-coder/programs/custom-coder/Cargo.toml

@@ -1,20 +0,0 @@
-[package]
-name = "custom-coder"
-version = "0.1.0"
-description = "Created with Anchor"
-rust-version = "1.56"
-edition = "2021"
-
-[lib]
-crate-type = ["cdylib", "lib"]
-name = "custom_coder"
-
-[features]
-no-entrypoint = []
-no-idl = []
-no-log-ix-name = []
-cpi = ["no-entrypoint"]
-default = []
-
-[dependencies]
-anchor-lang = { path = "../../../../lang" }

+ 0 - 2
tests/custom-coder/programs/custom-coder/Xargo.toml

@@ -1,2 +0,0 @@
-[target.bpfel-unknown-unknown.dependencies.std]
-features = []

+ 0 - 14
tests/custom-coder/programs/custom-coder/src/lib.rs

@@ -1,14 +0,0 @@
-use anchor_lang::prelude::*;
-
-declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
-
-#[program]
-pub mod custom_coder {
-    use super::*;
-    pub fn initialize(_ctx: Context<Initialize>, a: Option<u8>) -> Result<()> {
-        Ok(())
-    }
-}
-
-#[derive(Accounts)]
-pub struct Initialize {}

+ 1 - 1
tests/custom-coder/programs/spl-associated-token/Cargo.toml

@@ -19,4 +19,4 @@ default = []
 overflow-checks = true
 overflow-checks = true
 
 
 [dependencies]
 [dependencies]
-anchor-lang = { path = "../../../../lang" }
+anchor-lang = { path = "../../../../lang" }

+ 3 - 27
tests/custom-coder/programs/spl-associated-token/src/lib.rs

@@ -1,33 +1,9 @@
-// This file is autogenerated with https://github.com/acheroncrypto/native-to-anchor
+// See https://github.com/coral-xyz/anchor/blob/master/ts/packages/spl-associated-token-account/program/lib.rs
 
 
 use anchor_lang::prelude::*;
 use anchor_lang::prelude::*;
 
 
 declare_id!("4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh");
 declare_id!("4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh");
 
 
+// See https://solana.stackexchange.com/a/1858/471
 #[program]
 #[program]
-pub mod spl_associated_token {
-    use super::*;
-
-    pub fn create(ctx: Context<Create>) -> Result<()> {
-        Ok(())
-    }
-}
-
-#[derive(Accounts)]
-pub struct Create<'info> {
-    #[account(mut)]
-    authority: Signer<'info>,
-    #[account(mut)]
-    /// CHECK:
-    associated_account: AccountInfo<'info>,
-    /// CHECK:
-    owner: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    /// CHECK:
-    system_program: AccountInfo<'info>,
-    /// CHECK:
-    token_program: AccountInfo<'info>,
-    /// CHECK:
-    rent: AccountInfo<'info>,
-}
+pub mod spl_associated_token {}

+ 4 - 334
tests/custom-coder/programs/spl-token/src/lib.rs

@@ -1,339 +1,9 @@
+// See https://github.com/coral-xyz/anchor/blob/master/ts/packages/spl-token/program/lib.rs
+
 use anchor_lang::prelude::*;
 use anchor_lang::prelude::*;
 
 
 declare_id!("FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w");
 declare_id!("FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w");
 
 
-// This program is simply used to generate the IDL for the token program.
-//
-// Note that we manually add the COption<Pubkey> type to the IDL after
-// compiling.
-//
+// See https://solana.stackexchange.com/a/1858/471
 #[program]
 #[program]
-pub mod spl_token {
-    use super::*;
-
-    pub fn initialize_mint(
-        ctx: Context<InitializeMint>,
-        decimals: u8,
-        mint_authority: Pubkey,
-        //        freeze_authority: COption<Pubkey>,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_account(ctx: Context<InitializeAccount>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_multisig(ctx: Context<InitializeMultisig>, m: u8) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn transfer(ctx: Context<Transfer>, amount: u64) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn approve(ctx: Context<Approve>, amount: u64) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn revoke(ctx: Context<Revoke>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn set_authority(
-        ctx: Context<SetAuthority>,
-        authority_type: u8,
-        //        new_authority: COption<Pubkey>,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn mint_to(ctx: Context<MintTo>, amount: u64) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn burn(ctx: Context<Burn>, amount: u64) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn close_account(ctx: Context<CloseAccount>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn freeze_account(ctx: Context<FreezeAccount>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn thaw_account(ctx: Context<ThawAccount>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn transfer_checked(
-        ctx: Context<TransferChecked>,
-        amount: u64,
-        decimals: u8,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn approve_checked(
-        ctx: Context<ApproveChecked>,
-        amount: u64,
-        decimals: u8,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn mint_to_checked(
-        ctx: Context<MintToChecked>,
-        amount: u64,
-        decimals: u8,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn burn_checked(ctx: Context<BurnChecked>, amount: u64, decimals: u8) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_account_2(
-        ctx: Context<InitializeAccount2>,
-        authority: Pubkey,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn sync_native(ctx: Context<SyncNative>) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_account3(
-        ctx: Context<InitializeAccount3>,
-        authority: Pubkey,
-    ) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_multisig_2(ctx: Context<InitializeMultisig2>, m: u8) -> Result<()> {
-        Ok(())
-    }
-
-    pub fn initialize_mint_2(
-        ctx: Context<InitializeMint2>,
-        decimals: u8,
-        mint_authority: Pubkey,
-        //        freeze_authority: COption<Pubkey>,
-    ) -> Result<()> {
-        Ok(())
-    }
-}
-
-#[derive(Accounts)]
-pub struct InitializeMint<'info> {
-    #[account(mut)]
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    /// CHECK:
-    rent: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeAccount<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    /// CHECK:
-    authority: AccountInfo<'info>,
-    /// CHECK:
-    rent: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeMultisig<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    rent: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct Transfer<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    destination: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct Approve<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    /// CHECK:
-    delegate: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct Revoke<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct SetAuthority<'info> {
-    #[account(mut)]
-    /// CHECK:
-    pub mint: AccountInfo<'info>,
-    pub authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct MintTo<'info> {
-    #[account(mut)]
-    /// CHECK:
-    pub mint: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    pub to: AccountInfo<'info>,
-    pub authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct Burn<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct CloseAccount<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    destination: AccountInfo<'info>,
-    /// CHECK:
-    authority: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct FreezeAccount<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct ThawAccount<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct TransferChecked<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    destination: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct ApproveChecked<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    /// CHECK:
-    delegate: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct MintToChecked<'info> {
-    #[account(mut)]
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    to: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct BurnChecked<'info> {
-    #[account(mut)]
-    /// CHECK:
-    source: AccountInfo<'info>,
-    #[account(mut)]
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    authority: Signer<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeAccount2<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-    /// CHECK:
-    rent: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct SyncNative<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeAccount3<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-    /// CHECK:
-    mint: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeMultisig2<'info> {
-    #[account(mut)]
-    /// CHECK:
-    account: AccountInfo<'info>,
-}
-
-#[derive(Accounts)]
-pub struct InitializeMint2<'info> {
-    #[account(mut)]
-    /// CHECK:
-    mint: AccountInfo<'info>,
-}
+pub mod spl_token {}

+ 21 - 29
tests/custom-coder/tests/spl-associated-token-coder.ts

@@ -1,28 +1,27 @@
-import * as anchor from "@project-serum/anchor";
-import { Native, Spl } from "@project-serum/anchor";
-import { Keypair, PublicKey } from "@solana/web3.js";
+import { Native, AnchorProvider, setProvider } from "@project-serum/anchor";
+import { splAssociatedTokenAccountProgram } from "@project-serum/spl-associated-token-account";
+import { splTokenProgram } from "@project-serum/spl-token";
+import { Keypair, PublicKey, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
 import * as assert from "assert";
 import * as assert from "assert";
-import BN from "bn.js";
 
 
 describe("spl-associated-token-coder", () => {
 describe("spl-associated-token-coder", () => {
   // Configure the client to use the local cluster.
   // Configure the client to use the local cluster.
-  const provider = anchor.AnchorProvider.env();
-  anchor.setProvider(provider);
+  const provider = AnchorProvider.env();
+  setProvider(provider);
 
 
   // Client.
   // Client.
-  const program = Spl.associatedToken();
+  const program = splAssociatedTokenAccountProgram({
+    provider,
+  });
   const systemProgram = Native.system();
   const systemProgram = Native.system();
-  const tokenProgram = Spl.token();
+  const tokenProgram = splTokenProgram({
+    provider,
+  });
 
 
   it("Creates an account", async () => {
   it("Creates an account", async () => {
     // arrange
     // arrange
     const mintKeypair = Keypair.generate();
     const mintKeypair = Keypair.generate();
     const mintDecimals = 6;
     const mintDecimals = 6;
-    const mintSize = tokenProgram.coder.accounts.size(
-      tokenProgram.idl.accounts[0]
-    );
-    const mintRentExemption =
-      await provider.connection.getMinimumBalanceForRentExemption(mintSize);
     const [associatedToken] = await PublicKey.findProgramAddress(
     const [associatedToken] = await PublicKey.findProgramAddress(
       [
       [
         provider.publicKey.toBuffer(),
         provider.publicKey.toBuffer(),
@@ -36,28 +35,21 @@ describe("spl-associated-token-coder", () => {
     await program.methods
     await program.methods
       .create()
       .create()
       .accounts({
       .accounts({
-        authority: provider.wallet.publicKey,
-        mint: mintKeypair.publicKey,
-        owner: provider.wallet.publicKey,
-        associatedAccount: associatedToken,
+        associatedAccountAddress: associatedToken,
+        fundingAddress: provider.wallet.publicKey,
+        systemProgram: systemProgram.programId,
+        tokenMintAddress: mintKeypair.publicKey,
+        tokenProgram: tokenProgram.programId,
+        walletAddress: provider.wallet.publicKey,
       })
       })
       .preInstructions(
       .preInstructions(
         await Promise.all([
         await Promise.all([
-          systemProgram.methods
-            .createAccount(
-              new BN(mintRentExemption),
-              new BN(mintSize),
-              tokenProgram.programId
-            )
-            .accounts({
-              from: provider.wallet.publicKey,
-              to: mintKeypair.publicKey,
-            })
-            .instruction(),
+          tokenProgram.account.mint.createInstruction(mintKeypair),
           tokenProgram.methods
           tokenProgram.methods
             .initializeMint(mintDecimals, provider.wallet.publicKey, null)
             .initializeMint(mintDecimals, provider.wallet.publicKey, null)
             .accounts({
             .accounts({
               mint: mintKeypair.publicKey,
               mint: mintKeypair.publicKey,
+              rent: SYSVAR_RENT_PUBKEY,
             })
             })
             .instruction(),
             .instruction(),
         ])
         ])
@@ -65,7 +57,7 @@ describe("spl-associated-token-coder", () => {
       .signers([mintKeypair])
       .signers([mintKeypair])
       .rpc();
       .rpc();
     // assert
     // assert
-    const tokenAccount = await tokenProgram.account.token.fetch(
+    const tokenAccount = await tokenProgram.account.account.fetch(
       associatedToken
       associatedToken
     );
     );
     assert.ok(tokenAccount.mint.equals(mintKeypair.publicKey));
     assert.ok(tokenAccount.mint.equals(mintKeypair.publicKey));

+ 66 - 56
tests/custom-coder/tests/custom-coder.ts → tests/custom-coder/tests/spl-token-coder.ts

@@ -1,16 +1,18 @@
-import * as anchor from "@project-serum/anchor";
-import { Spl } from "@project-serum/anchor";
-import { assert } from "chai";
+import { AnchorProvider, setProvider } from "@project-serum/anchor";
+import { splTokenProgram } from "@project-serum/spl-token";
+import { Keypair, SYSVAR_RENT_PUBKEY, PublicKey } from "@solana/web3.js";
 import BN from "bn.js";
 import BN from "bn.js";
-import { Keypair, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
+import { assert } from "chai";
 
 
-describe("custom-coder", () => {
+describe("spl-token", () => {
   // Configure the client to use the local cluster.
   // Configure the client to use the local cluster.
-  const provider = anchor.AnchorProvider.env();
-  anchor.setProvider(provider);
+  const provider = AnchorProvider.env();
+  setProvider(provider);
 
 
   // Client.
   // Client.
-  const program = Spl.token();
+  const program = splTokenProgram({
+    provider,
+  });
 
 
   // Constants.
   // Constants.
   const mintKeypair = Keypair.generate();
   const mintKeypair = Keypair.generate();
@@ -19,18 +21,21 @@ describe("custom-coder", () => {
   const rent = SYSVAR_RENT_PUBKEY;
   const rent = SYSVAR_RENT_PUBKEY;
 
 
   it("Creates a mint", async () => {
   it("Creates a mint", async () => {
-    await program.rpc.initializeMint(6, provider.wallet.publicKey, null, {
-      accounts: {
+    await program.methods
+      .initializeMint(6, provider.wallet.publicKey, null)
+      .accounts({
         mint: mintKeypair.publicKey,
         mint: mintKeypair.publicKey,
         rent,
         rent,
-      },
-      signers: [mintKeypair],
-      preInstructions: [
+      })
+      .signers([mintKeypair])
+      .preInstructions([
         await program.account.mint.createInstruction(mintKeypair),
         await program.account.mint.createInstruction(mintKeypair),
-      ],
-    });
+      ])
+      .rpc();
     const mintAccount = await program.account.mint.fetch(mintKeypair.publicKey);
     const mintAccount = await program.account.mint.fetch(mintKeypair.publicKey);
-    assert.isTrue(mintAccount.mintAuthority.equals(provider.wallet.publicKey));
+    assert.isTrue(
+      (mintAccount.mintAuthority as PublicKey).equals(provider.wallet.publicKey)
+    );
     assert.isNull(mintAccount.freezeAuthority);
     assert.isNull(mintAccount.freezeAuthority);
     assert.strictEqual(mintAccount.decimals, 6);
     assert.strictEqual(mintAccount.decimals, 6);
     assert.isTrue(mintAccount.isInitialized);
     assert.isTrue(mintAccount.isInitialized);
@@ -38,41 +43,43 @@ describe("custom-coder", () => {
   });
   });
 
 
   it("Creates a token account for alice", async () => {
   it("Creates a token account for alice", async () => {
-    await program.rpc.initializeAccount({
-      accounts: {
+    await program.methods
+      .initializeAccount()
+      .accounts({
         account: aliceTokenKeypair.publicKey,
         account: aliceTokenKeypair.publicKey,
         mint: mintKeypair.publicKey,
         mint: mintKeypair.publicKey,
-        authority: provider.wallet.publicKey,
+        owner: provider.wallet.publicKey,
         rent,
         rent,
-      },
-      signers: [aliceTokenKeypair],
-      preInstructions: [
-        await program.account.token.createInstruction(aliceTokenKeypair),
-      ],
-    });
-    const token = await program.account.token.fetch(
+      })
+      .signers([aliceTokenKeypair])
+      .preInstructions([
+        await program.account.account.createInstruction(aliceTokenKeypair),
+      ])
+      .rpc();
+    const token = await program.account.account.fetch(
       aliceTokenKeypair.publicKey
       aliceTokenKeypair.publicKey
     );
     );
-    assert.isTrue(token.authority.equals(provider.wallet.publicKey));
+    assert.isTrue(token.owner.equals(provider.wallet.publicKey));
     assert.isTrue(token.mint.equals(mintKeypair.publicKey));
     assert.isTrue(token.mint.equals(mintKeypair.publicKey));
     assert.strictEqual(token.amount.toNumber(), 0);
     assert.strictEqual(token.amount.toNumber(), 0);
     assert.isNull(token.delegate);
     assert.isNull(token.delegate);
-    assert.strictEqual(token.state, 1);
+    assert.strictEqual(Object.keys(token.state)[0], "initialized");
     assert.isNull(token.isNative);
     assert.isNull(token.isNative);
     assert.strictEqual(token.delegatedAmount.toNumber(), 0);
     assert.strictEqual(token.delegatedAmount.toNumber(), 0);
     assert.isNull(token.closeAuthority);
     assert.isNull(token.closeAuthority);
   });
   });
 
 
   it("Mints a token to alice", async () => {
   it("Mints a token to alice", async () => {
-    await program.rpc.mintTo(new BN(2), {
-      accounts: {
+    await program.methods
+      .mintTo(new BN(2))
+      .accounts({
         mint: mintKeypair.publicKey,
         mint: mintKeypair.publicKey,
-        to: aliceTokenKeypair.publicKey,
-        authority: provider.wallet.publicKey,
-      },
-    });
+        account: aliceTokenKeypair.publicKey,
+        owner: provider.wallet.publicKey,
+      })
+      .rpc();
 
 
-    const token = await program.account.token.fetch(
+    const token = await program.account.account.fetch(
       aliceTokenKeypair.publicKey
       aliceTokenKeypair.publicKey
     );
     );
     const mint = await program.account.mint.fetch(mintKeypair.publicKey);
     const mint = await program.account.mint.fetch(mintKeypair.publicKey);
@@ -81,32 +88,34 @@ describe("custom-coder", () => {
   });
   });
 
 
   it("Creates a token for bob", async () => {
   it("Creates a token for bob", async () => {
-    await program.rpc.initializeAccount({
-      accounts: {
+    await program.methods
+      .initializeAccount()
+      .accounts({
         account: bobTokenKeypair.publicKey,
         account: bobTokenKeypair.publicKey,
         mint: mintKeypair.publicKey,
         mint: mintKeypair.publicKey,
-        authority: provider.wallet.publicKey,
+        owner: provider.wallet.publicKey,
         rent,
         rent,
-      },
-      signers: [bobTokenKeypair],
-      preInstructions: [
-        await program.account.token.createInstruction(bobTokenKeypair),
-      ],
-    });
+      })
+      .signers([bobTokenKeypair])
+      .preInstructions([
+        await program.account.account.createInstruction(bobTokenKeypair),
+      ])
+      .rpc();
   });
   });
 
 
   it("Transfer a token from alice to bob", async () => {
   it("Transfer a token from alice to bob", async () => {
-    await program.rpc.transfer(new BN(1), {
-      accounts: {
+    await program.methods
+      .transfer(new BN(1))
+      .accounts({
         source: aliceTokenKeypair.publicKey,
         source: aliceTokenKeypair.publicKey,
         destination: bobTokenKeypair.publicKey,
         destination: bobTokenKeypair.publicKey,
         authority: provider.wallet.publicKey,
         authority: provider.wallet.publicKey,
-      },
-    });
-    const aliceToken = await program.account.token.fetch(
+      })
+      .rpc();
+    const aliceToken = await program.account.account.fetch(
       aliceTokenKeypair.publicKey
       aliceTokenKeypair.publicKey
     );
     );
-    const bobToken = await program.account.token.fetch(
+    const bobToken = await program.account.account.fetch(
       bobTokenKeypair.publicKey
       bobTokenKeypair.publicKey
     );
     );
     assert.strictEqual(aliceToken.amount.toNumber(), 1);
     assert.strictEqual(aliceToken.amount.toNumber(), 1);
@@ -114,14 +123,15 @@ describe("custom-coder", () => {
   });
   });
 
 
   it("Alice burns a token", async () => {
   it("Alice burns a token", async () => {
-    await program.rpc.burn(new BN(1), {
-      accounts: {
-        source: aliceTokenKeypair.publicKey,
+    await program.methods
+      .burn(new BN(1))
+      .accounts({
+        account: aliceTokenKeypair.publicKey,
         mint: mintKeypair.publicKey,
         mint: mintKeypair.publicKey,
         authority: provider.wallet.publicKey,
         authority: provider.wallet.publicKey,
-      },
-    });
-    const aliceToken = await program.account.token.fetch(
+      })
+      .rpc();
+    const aliceToken = await program.account.account.fetch(
       aliceTokenKeypair.publicKey
       aliceTokenKeypair.publicKey
     );
     );
     const mint = await program.account.mint.fetch(mintKeypair.publicKey);
     const mint = await program.account.mint.fetch(mintKeypair.publicKey);

+ 2 - 0
tests/package.json

@@ -41,6 +41,8 @@
   ],
   ],
   "dependencies": {
   "dependencies": {
     "@project-serum/anchor": "file:../ts/packages/anchor",
     "@project-serum/anchor": "file:../ts/packages/anchor",
+    "@project-serum/spl-associated-token-account": "file:../ts/packages/spl-associated-token-account",
+    "@project-serum/spl-token": "file:../ts/packages/spl-token",
     "@project-serum/common": "^0.0.1-beta.3",
     "@project-serum/common": "^0.0.1-beta.3",
     "@project-serum/serum": "^0.13.60",
     "@project-serum/serum": "^0.13.60",
     "@solana/spl-token": "^0.1.8",
     "@solana/spl-token": "^0.1.8",

+ 87 - 39
tests/yarn.lock

@@ -37,68 +37,68 @@
     "@ethersproject/logger" "^5.5.0"
     "@ethersproject/logger" "^5.5.0"
     hash.js "1.1.7"
     hash.js "1.1.7"
 
 
+"@native-to-anchor/buffer-layout@=0.1.0":
+  version "0.1.0"
+  resolved "https://registry.yarnpkg.com/@native-to-anchor/buffer-layout/-/buffer-layout-0.1.0.tgz#ff0cb66341bc820b8ee73bb1d1d43bae7e3554b0"
+  integrity sha512-7Ykz9KRAm53XqHj5blDUKPX+OXAPO4GZBW4zJhfHGIAbzmqsUFh9kMqR66Bak3mp6wyv1OVTwSr8ZGHKswPxDg==
+  dependencies:
+    "@solana/buffer-layout" "=4.0.0"
+    "@solana/buffer-layout-utils" "=0.2.0"
+
 "@noble/ed25519@^1.7.0":
 "@noble/ed25519@^1.7.0":
-  version "1.7.1"
-  resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.1.tgz#6899660f6fbb97798a6fbd227227c4589a454724"
-  integrity sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==
+  version "1.7.0"
+  resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.0.tgz#583ac38340a479314b9e348d4572101ed9492f9d"
+  integrity sha512-LeAxFK0+181zQOhOUuKE8Jnd3duzYhDNd3iCLxpmzA5K+e4I1FdbrK3Ot0ZHBwZMeRD/6EojyUfTbpHZ+hkQHg==
 
 
 "@noble/hashes@^1.1.2":
 "@noble/hashes@^1.1.2":
-  version "1.1.3"
-  resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.3.tgz#360afc77610e0a61f3417e497dcf36862e4f8111"
-  integrity sha512-CE0FCR57H2acVI5UOzIGSSIYxZ6v/HOhDR0Ro9VLyhnzLwx0o8W1mmgaqlEUx4049qJDlIBRztv5k+MM8vbO3A==
+  version "1.1.2"
+  resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183"
+  integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==
 
 
 "@noble/secp256k1@^1.6.3":
 "@noble/secp256k1@^1.6.3":
-  version "1.7.0"
-  resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1"
-  integrity sha512-kbacwGSsH/CTout0ZnZWxnW1B+jH/7r/WAAKLBtrRJ/+CUH7lgmQzl3GTrQua3SGKWNSDsS6lmjnDpIJ5Dxyaw==
+  version "1.6.3"
+  resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.6.3.tgz#7eed12d9f4404b416999d0c87686836c4c5c9b94"
+  integrity sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ==
 
 
-"@project-serum/anchor@^0.11.1":
-  version "0.11.1"
-  resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.11.1.tgz#155bff2c70652eafdcfd5559c81a83bb19cec9ff"
-  integrity sha512-oIdm4vTJkUy6GmE6JgqDAuQPKI7XM4TPJkjtoIzp69RZe0iAD9JP2XHx7lV1jLdYXeYHqDXfBt3zcq7W91K6PA==
+"@project-serum/anchor@=0.25.0", "@project-serum/anchor@file:../ts/packages/anchor":
+  version "0.25.0"
   dependencies:
   dependencies:
-    "@project-serum/borsh" "^0.2.2"
-    "@solana/web3.js" "^1.17.0"
+    "@project-serum/borsh" "^0.2.5"
+    "@solana/web3.js" "^1.64.0"
     base64-js "^1.5.1"
     base64-js "^1.5.1"
     bn.js "^5.1.2"
     bn.js "^5.1.2"
     bs58 "^4.0.1"
     bs58 "^4.0.1"
-    buffer-layout "^1.2.0"
+    buffer-layout "^1.2.2"
     camelcase "^5.3.1"
     camelcase "^5.3.1"
+    cross-fetch "^3.1.5"
     crypto-hash "^1.3.0"
     crypto-hash "^1.3.0"
     eventemitter3 "^4.0.7"
     eventemitter3 "^4.0.7"
-    find "^0.3.0"
     js-sha256 "^0.9.0"
     js-sha256 "^0.9.0"
     pako "^2.0.3"
     pako "^2.0.3"
     snake-case "^3.0.4"
     snake-case "^3.0.4"
+    superstruct "^0.15.4"
     toml "^3.0.0"
     toml "^3.0.0"
 
 
-"@project-serum/anchor@file:../ts/packages/anchor":
-  version "0.25.0"
+"@project-serum/anchor@^0.11.1":
+  version "0.11.1"
+  resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.11.1.tgz#155bff2c70652eafdcfd5559c81a83bb19cec9ff"
+  integrity sha512-oIdm4vTJkUy6GmE6JgqDAuQPKI7XM4TPJkjtoIzp69RZe0iAD9JP2XHx7lV1jLdYXeYHqDXfBt3zcq7W91K6PA==
   dependencies:
   dependencies:
-    "@project-serum/borsh" "^0.2.5"
-    "@solana/web3.js" "^1.64.0"
+    "@project-serum/borsh" "^0.2.2"
+    "@solana/web3.js" "^1.17.0"
     base64-js "^1.5.1"
     base64-js "^1.5.1"
     bn.js "^5.1.2"
     bn.js "^5.1.2"
     bs58 "^4.0.1"
     bs58 "^4.0.1"
-    buffer-layout "^1.2.2"
+    buffer-layout "^1.2.0"
     camelcase "^5.3.1"
     camelcase "^5.3.1"
-    cross-fetch "^3.1.5"
     crypto-hash "^1.3.0"
     crypto-hash "^1.3.0"
     eventemitter3 "^4.0.7"
     eventemitter3 "^4.0.7"
+    find "^0.3.0"
     js-sha256 "^0.9.0"
     js-sha256 "^0.9.0"
     pako "^2.0.3"
     pako "^2.0.3"
     snake-case "^3.0.4"
     snake-case "^3.0.4"
-    superstruct "^0.15.4"
     toml "^3.0.0"
     toml "^3.0.0"
 
 
-"@project-serum/borsh@^0.2.2":
-  version "0.2.2"
-  resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.2.tgz#63e558f2d6eb6ab79086bf499dea94da3182498f"
-  integrity sha512-Ms+aWmGVW6bWd3b0+MWwoaYig2QD0F90h0uhr7AzY3dpCb5e2S6RsRW02vFTfa085pY2VLB7nTZNbFECQ1liTg==
-  dependencies:
-    bn.js "^5.1.2"
-    buffer-layout "^1.2.0"
-
 "@project-serum/borsh@^0.2.5":
 "@project-serum/borsh@^0.2.5":
   version "0.2.5"
   version "0.2.5"
   resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz#6059287aa624ecebbfc0edd35e4c28ff987d8663"
   resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz#6059287aa624ecebbfc0edd35e4c28ff987d8663"
@@ -127,20 +127,42 @@
     bn.js "^5.1.2"
     bn.js "^5.1.2"
     buffer-layout "^1.2.0"
     buffer-layout "^1.2.0"
 
 
-"@solana/buffer-layout@^3.0.0":
-  version "3.0.0"
-  resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-3.0.0.tgz#b9353caeb9a1589cb77a1b145bcb1a9a93114326"
-  integrity sha512-MVdgAKKL39tEs0l8je0hKaXLQFb7Rdfb0Xg2LjFZd8Lfdazkg6xiS98uAZrEKvaoF3i4M95ei9RydkGIDMeo3w==
+"@project-serum/spl-associated-token-account@file:../ts/packages/spl-associated-token-account":
+  version "1.1.1"
   dependencies:
   dependencies:
-    buffer "~6.0.3"
+    "@native-to-anchor/buffer-layout" "=0.1.0"
+    "@project-serum/anchor" "=0.25.0"
+
+"@project-serum/spl-token@file:../ts/packages/spl-token":
+  version "3.3.0"
+  dependencies:
+    "@native-to-anchor/buffer-layout" "=0.1.0"
+    "@project-serum/anchor" "=0.25.0"
 
 
-"@solana/buffer-layout@^4.0.0":
+"@solana/buffer-layout-utils@=0.2.0":
+  version "0.2.0"
+  resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca"
+  integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==
+  dependencies:
+    "@solana/buffer-layout" "^4.0.0"
+    "@solana/web3.js" "^1.32.0"
+    bigint-buffer "^1.1.5"
+    bignumber.js "^9.0.1"
+
+"@solana/buffer-layout@=4.0.0", "@solana/buffer-layout@^4.0.0":
   version "4.0.0"
   version "4.0.0"
   resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz#75b1b11adc487234821c81dfae3119b73a5fd734"
   resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz#75b1b11adc487234821c81dfae3119b73a5fd734"
   integrity sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==
   integrity sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==
   dependencies:
   dependencies:
     buffer "~6.0.3"
     buffer "~6.0.3"
 
 
+"@solana/buffer-layout@^3.0.0":
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-3.0.0.tgz#b9353caeb9a1589cb77a1b145bcb1a9a93114326"
+  integrity sha512-MVdgAKKL39tEs0l8je0hKaXLQFb7Rdfb0Xg2LjFZd8Lfdazkg6xiS98uAZrEKvaoF3i4M95ei9RydkGIDMeo3w==
+  dependencies:
+    buffer "~6.0.3"
+
 "@solana/spl-token@^0.1.6", "@solana/spl-token@^0.1.8":
 "@solana/spl-token@^0.1.6", "@solana/spl-token@^0.1.8":
   version "0.1.8"
   version "0.1.8"
   resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.1.8.tgz#f06e746341ef8d04165e21fc7f555492a2a0faa6"
   resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.1.8.tgz#f06e746341ef8d04165e21fc7f555492a2a0faa6"
@@ -153,7 +175,7 @@
     buffer-layout "^1.2.0"
     buffer-layout "^1.2.0"
     dotenv "10.0.0"
     dotenv "10.0.0"
 
 
-"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0":
+"@solana/web3.js@^1.21.0":
   version "1.30.2"
   version "1.30.2"
   resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.30.2.tgz#e85da75e0825dc64f53eb64a1ff0115b27bec135"
   resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.30.2.tgz#e85da75e0825dc64f53eb64a1ff0115b27bec135"
   integrity sha512-hznCj+rkfvM5taRP3Z+l5lumB7IQnDrB4l55Wpsg4kDU9Zds8pE5YOH5Z9bbF/pUzZJKQjyBjnY/6kScBm3Ugg==
   integrity sha512-hznCj+rkfvM5taRP3Z+l5lumB7IQnDrB4l55Wpsg4kDU9Zds8pE5YOH5Z9bbF/pUzZJKQjyBjnY/6kScBm3Ugg==
@@ -173,6 +195,27 @@
     superstruct "^0.14.2"
     superstruct "^0.14.2"
     tweetnacl "^1.0.0"
     tweetnacl "^1.0.0"
 
 
+"@solana/web3.js@^1.32.0":
+  version "1.66.2"
+  resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.66.2.tgz#80b43c5868b846124fe3ebac7d3943930c3fa60c"
+  integrity sha512-RyaHMR2jGmaesnYP045VLeBGfR/gAW3cvZHzMFGg7bkO+WOYOYp1nEllf0/la4U4qsYGKCsO9eEevR5fhHiVHg==
+  dependencies:
+    "@babel/runtime" "^7.12.5"
+    "@noble/ed25519" "^1.7.0"
+    "@noble/hashes" "^1.1.2"
+    "@noble/secp256k1" "^1.6.3"
+    "@solana/buffer-layout" "^4.0.0"
+    bigint-buffer "^1.1.5"
+    bn.js "^5.0.0"
+    borsh "^0.7.0"
+    bs58 "^4.0.1"
+    buffer "6.0.1"
+    fast-stable-stringify "^1.0.0"
+    jayson "^3.4.4"
+    node-fetch "2"
+    rpc-websockets "^7.5.0"
+    superstruct "^0.14.2"
+
 "@solana/web3.js@^1.64.0":
 "@solana/web3.js@^1.64.0":
   version "1.64.0"
   version "1.64.0"
   resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.64.0.tgz#b7f5a976976039a0161242e94d6e1224ab5d30f9"
   resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.64.0.tgz#b7f5a976976039a0161242e94d6e1224ab5d30f9"
@@ -346,6 +389,11 @@ bigint-buffer@^1.1.5:
   dependencies:
   dependencies:
     bindings "^1.3.0"
     bindings "^1.3.0"
 
 
+bignumber.js@^9.0.1:
+  version "9.1.0"
+  resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62"
+  integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==
+
 binary-extensions@^2.0.0:
 binary-extensions@^2.0.0:
   version "2.2.0"
   version "2.2.0"
   resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
   resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"

+ 0 - 1
ts/build-packages.sh

@@ -6,4 +6,3 @@ for D in */;
         cd $D && yarn init:yarn; cd ..;
         cd $D && yarn init:yarn; cd ..;
     fi
     fi
 done
 done
-

+ 0 - 1
ts/packages/anchor/src/coder/index.ts

@@ -2,7 +2,6 @@ import { IdlEvent, IdlTypeDef } from "../idl.js";
 import { Event } from "../program/event.js";
 import { Event } from "../program/event.js";
 
 
 export * from "./borsh/index.js";
 export * from "./borsh/index.js";
-export * from "./spl-token/index.js";
 export * from "./system/index.js";
 export * from "./system/index.js";
 
 
 /**
 /**

+ 0 - 42
ts/packages/anchor/src/coder/spl-associated-token/accounts.ts

@@ -1,42 +0,0 @@
-import { AccountsCoder } from "../index.js";
-import { Idl, IdlTypeDef } from "../../idl.js";
-import { accountSize } from "../common";
-
-export class SplAssociatedTokenAccountsCoder<A extends string = string>
-  implements AccountsCoder
-{
-  constructor(private idl: Idl) {}
-
-  public async encode<T = any>(accountName: A, account: T): Promise<Buffer> {
-    switch (accountName) {
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  public decode<T = any>(accountName: A, ix: Buffer): T {
-    return this.decodeUnchecked(accountName, ix);
-  }
-
-  public decodeUnchecked<T = any>(accountName: A, ix: Buffer): T {
-    switch (accountName) {
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  // TODO: this won't use the appendData.
-  public memcmp(accountName: A, _appendData?: Buffer): any {
-    switch (accountName) {
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  public size(idlAccount: IdlTypeDef): number {
-    return accountSize(this.idl, idlAccount) ?? 0;
-  }
-}

+ 0 - 14
ts/packages/anchor/src/coder/spl-associated-token/events.ts

@@ -1,14 +0,0 @@
-import { EventCoder } from "../index.js";
-import { Idl } from "../../idl.js";
-import { Event } from "../../program/event";
-import { IdlEvent } from "../../idl";
-
-export class SplAssociatedTokenEventsCoder implements EventCoder {
-  constructor(_idl: Idl) {}
-
-  decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(
-    _log: string
-  ): Event<E, T> | null {
-    throw new Error("SPL associated token program does not have events");
-  }
-}

+ 0 - 26
ts/packages/anchor/src/coder/spl-associated-token/index.ts

@@ -1,26 +0,0 @@
-import { Idl } from "../../idl.js";
-import { Coder } from "../index.js";
-import { SplAssociatedTokenInstructionCoder } from "./instruction.js";
-import { SplAssociatedTokenStateCoder } from "./state.js";
-import { SplAssociatedTokenAccountsCoder } from "./accounts.js";
-import { SplAssociatedTokenEventsCoder } from "./events.js";
-import { SplAssociatedTokenTypesCoder } from "./types.js";
-
-/**
- * Coder for the SPL token program.
- */
-export class SplAssociatedTokenCoder implements Coder {
-  readonly instruction: SplAssociatedTokenInstructionCoder;
-  readonly accounts: SplAssociatedTokenAccountsCoder;
-  readonly state: SplAssociatedTokenStateCoder;
-  readonly events: SplAssociatedTokenEventsCoder;
-  readonly types: SplAssociatedTokenTypesCoder;
-
-  constructor(idl: Idl) {
-    this.instruction = new SplAssociatedTokenInstructionCoder(idl);
-    this.accounts = new SplAssociatedTokenAccountsCoder(idl);
-    this.events = new SplAssociatedTokenEventsCoder(idl);
-    this.state = new SplAssociatedTokenStateCoder(idl);
-    this.types = new SplAssociatedTokenTypesCoder(idl);
-  }
-}

+ 0 - 22
ts/packages/anchor/src/coder/spl-associated-token/instruction.ts

@@ -1,22 +0,0 @@
-import camelCase from "camelcase";
-import { Idl } from "../../idl.js";
-import { InstructionCoder } from "../index.js";
-
-export class SplAssociatedTokenInstructionCoder implements InstructionCoder {
-  constructor(_: Idl) {}
-
-  encode(ixName: string, _: any): Buffer {
-    switch (camelCase(ixName)) {
-      case "create": {
-        return Buffer.alloc(0);
-      }
-      default: {
-        throw new Error(`Invalid instruction: ${ixName}`);
-      }
-    }
-  }
-
-  encodeState(_ixName: string, _ix: any): Buffer {
-    throw new Error("SPL associated token does not have state");
-  }
-}

+ 0 - 13
ts/packages/anchor/src/coder/spl-associated-token/state.ts

@@ -1,13 +0,0 @@
-import { StateCoder } from "../index.js";
-import { Idl } from "../../idl";
-
-export class SplAssociatedTokenStateCoder implements StateCoder {
-  constructor(_idl: Idl) {}
-
-  encode<T = any>(_name: string, _account: T): Promise<Buffer> {
-    throw new Error("SPL associated token does not have state");
-  }
-  decode<T = any>(_ix: Buffer): T {
-    throw new Error("SPL associated token does not have state");
-  }
-}

+ 0 - 13
ts/packages/anchor/src/coder/spl-associated-token/types.ts

@@ -1,13 +0,0 @@
-import { TypesCoder } from "../index.js";
-import { Idl } from "../../idl.js";
-
-export class SplAssociatedTokenTypesCoder implements TypesCoder {
-  constructor(_idl: Idl) {}
-
-  encode<T = any>(_name: string, _type: T): Buffer {
-    throw new Error("SPL associated token does not have user-defined types");
-  }
-  decode<T = any>(_name: string, _typeData: Buffer): T {
-    throw new Error("SPL associated token does not have user-defined types");
-  }
-}

+ 0 - 97
ts/packages/anchor/src/coder/spl-token/accounts.ts

@@ -1,97 +0,0 @@
-import * as BufferLayout from "buffer-layout";
-import { publicKey, uint64, coption, bool } from "./buffer-layout.js";
-import { AccountsCoder } from "../index.js";
-import { Idl, IdlTypeDef } from "../../idl.js";
-import { accountSize } from "../common";
-
-export class SplTokenAccountsCoder<A extends string = string>
-  implements AccountsCoder
-{
-  constructor(private idl: Idl) {}
-
-  public async encode<T = any>(accountName: A, account: T): Promise<Buffer> {
-    switch (accountName) {
-      case "token": {
-        const buffer = Buffer.alloc(165);
-        const len = TOKEN_ACCOUNT_LAYOUT.encode(account, buffer);
-        return buffer.slice(0, len);
-      }
-      case "mint": {
-        const buffer = Buffer.alloc(82);
-        const len = MINT_ACCOUNT_LAYOUT.encode(account, buffer);
-        return buffer.slice(0, len);
-      }
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  public decode<T = any>(accountName: A, ix: Buffer): T {
-    return this.decodeUnchecked(accountName, ix);
-  }
-
-  public decodeUnchecked<T = any>(accountName: A, ix: Buffer): T {
-    switch (accountName) {
-      case "token": {
-        return decodeTokenAccount(ix);
-      }
-      case "mint": {
-        return decodeMintAccount(ix);
-      }
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  // TODO: this won't use the appendData.
-  public memcmp(accountName: A, _appendData?: Buffer): any {
-    switch (accountName) {
-      case "token": {
-        return {
-          dataSize: 165,
-        };
-      }
-      case "mint": {
-        return {
-          dataSize: 82,
-        };
-      }
-      default: {
-        throw new Error(`Invalid account name: ${accountName}`);
-      }
-    }
-  }
-
-  public size(idlAccount: IdlTypeDef): number {
-    return accountSize(this.idl, idlAccount) ?? 0;
-  }
-}
-
-function decodeMintAccount<T = any>(ix: Buffer): T {
-  return MINT_ACCOUNT_LAYOUT.decode(ix) as T;
-}
-
-function decodeTokenAccount<T = any>(ix: Buffer): T {
-  return TOKEN_ACCOUNT_LAYOUT.decode(ix) as T;
-}
-
-const MINT_ACCOUNT_LAYOUT = BufferLayout.struct([
-  coption(publicKey(), "mintAuthority"),
-  uint64("supply"),
-  BufferLayout.u8("decimals"),
-  bool("isInitialized"),
-  coption(publicKey(), "freezeAuthority"),
-]);
-
-const TOKEN_ACCOUNT_LAYOUT = BufferLayout.struct([
-  publicKey("mint"),
-  publicKey("authority"),
-  uint64("amount"),
-  coption(publicKey(), "delegate"),
-  BufferLayout.u8("state"),
-  coption(uint64(), "isNative"),
-  uint64("delegatedAmount"),
-  coption(publicKey(), "closeAuthority"),
-]);

+ 0 - 14
ts/packages/anchor/src/coder/spl-token/events.ts

@@ -1,14 +0,0 @@
-import { EventCoder } from "../index.js";
-import { Idl } from "../../idl.js";
-import { Event } from "../../program/event";
-import { IdlEvent } from "../../idl";
-
-export class SplTokenEventsCoder implements EventCoder {
-  constructor(_idl: Idl) {}
-
-  decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(
-    _log: string
-  ): Event<E, T> | null {
-    throw new Error("SPL token program does not have events");
-  }
-}

+ 0 - 26
ts/packages/anchor/src/coder/spl-token/index.ts

@@ -1,26 +0,0 @@
-import { Idl } from "../../idl.js";
-import { Coder } from "../index.js";
-import { SplTokenInstructionCoder } from "./instruction.js";
-import { SplTokenStateCoder } from "./state.js";
-import { SplTokenAccountsCoder } from "./accounts.js";
-import { SplTokenEventsCoder } from "./events.js";
-import { SplTokenTypesCoder } from "./types.js";
-
-/**
- * Coder for the SPL token program.
- */
-export class SplTokenCoder implements Coder {
-  readonly instruction: SplTokenInstructionCoder;
-  readonly accounts: SplTokenAccountsCoder;
-  readonly state: SplTokenStateCoder;
-  readonly events: SplTokenEventsCoder;
-  readonly types: SplTokenTypesCoder;
-
-  constructor(idl: Idl) {
-    this.instruction = new SplTokenInstructionCoder(idl);
-    this.accounts = new SplTokenAccountsCoder(idl);
-    this.events = new SplTokenEventsCoder(idl);
-    this.state = new SplTokenStateCoder(idl);
-    this.types = new SplTokenTypesCoder(idl);
-  }
-}

+ 0 - 349
ts/packages/anchor/src/coder/spl-token/instruction.ts

@@ -1,349 +0,0 @@
-import * as BufferLayout from "buffer-layout";
-import camelCase from "camelcase";
-import { PublicKey } from "@solana/web3.js";
-import { InstructionCoder } from "../index.js";
-import { Idl } from "../../idl.js";
-
-export class SplTokenInstructionCoder implements InstructionCoder {
-  constructor(_: Idl) {}
-
-  encode(ixName: string, ix: any): Buffer {
-    switch (camelCase(ixName)) {
-      case "initializeMint": {
-        return encodeInitializeMint(ix);
-      }
-      case "initializeAccount": {
-        return encodeInitializeAccount(ix);
-      }
-      case "initializeMultisig": {
-        return encodeInitializeMultisig(ix);
-      }
-      case "transfer": {
-        return encodeTransfer(ix);
-      }
-      case "approve": {
-        return encodeApprove(ix);
-      }
-      case "revoke": {
-        return encodeRevoke(ix);
-      }
-      case "setAuthority": {
-        return encodeSetAuthority(ix);
-      }
-      case "mintTo": {
-        return encodeMintTo(ix);
-      }
-      case "burn": {
-        return encodeBurn(ix);
-      }
-      case "closeAccount": {
-        return encodeCloseAccount(ix);
-      }
-      case "freezeAccount": {
-        return encodeFreezeAccount(ix);
-      }
-      case "thawAccount": {
-        return encodeThawAccount(ix);
-      }
-      case "transferChecked": {
-        return encodeTransferChecked(ix);
-      }
-      case "approvedChecked": {
-        return encodeApproveChecked(ix);
-      }
-      case "mintToChecked": {
-        return encodeMintToChecked(ix);
-      }
-      case "burnChecked": {
-        return encodeBurnChecked(ix);
-      }
-      case "intializeAccount2": {
-        return encodeInitializeAccount2(ix);
-      }
-      case "syncNative": {
-        return encodeSyncNative(ix);
-      }
-      case "initializeAccount3": {
-        return encodeInitializeAccount3(ix);
-      }
-      case "initializeMultisig2": {
-        return encodeInitializeMultisig2(ix);
-      }
-      case "initializeMint2": {
-        return encodeInitializeMint2(ix);
-      }
-      default: {
-        throw new Error(`Invalid instruction: ${ixName}`);
-      }
-    }
-  }
-
-  encodeState(_ixName: string, _ix: any): Buffer {
-    throw new Error("SPL token does not have state");
-  }
-}
-
-function encodeInitializeMint({
-  decimals,
-  mintAuthority,
-  freezeAuthority,
-}: any): Buffer {
-  return encodeData({
-    initializeMint: {
-      decimals,
-      mintAuthority: mintAuthority.toBuffer(),
-      freezeAuthorityOption: !!freezeAuthority,
-      freezeAuthority: (freezeAuthority || PublicKey.default).toBuffer(),
-    },
-  });
-}
-
-function encodeInitializeAccount(_ix: any): Buffer {
-  return encodeData({
-    initializeAccount: {},
-  });
-}
-
-function encodeInitializeMultisig({ m }: any): Buffer {
-  return encodeData({
-    initializeMultisig: {
-      m,
-    },
-  });
-}
-
-function encodeTransfer({ amount }: any): Buffer {
-  return encodeData({
-    transfer: { amount },
-  });
-}
-
-function encodeApprove({ amount }: any): Buffer {
-  return encodeData({
-    approve: { amount },
-  });
-}
-
-function encodeRevoke(_ix: any): Buffer {
-  return encodeData({
-    revoke: {},
-  });
-}
-
-function encodeSetAuthority({ authorityType, newAuthority }: any): Buffer {
-  return encodeData({
-    setAuthority: { authorityType, newAuthority },
-  });
-}
-
-function encodeMintTo({ amount }: any): Buffer {
-  return encodeData({
-    mintTo: { amount },
-  });
-}
-
-function encodeBurn({ amount }: any): Buffer {
-  return encodeData({
-    burn: { amount },
-  });
-}
-
-function encodeCloseAccount(_: any): Buffer {
-  return encodeData({
-    closeAccount: {},
-  });
-}
-
-function encodeFreezeAccount(_: any): Buffer {
-  return encodeData({
-    freezeAccount: {},
-  });
-}
-
-function encodeThawAccount(_: any): Buffer {
-  return encodeData({
-    thawAccount: {},
-  });
-}
-
-function encodeTransferChecked({ amount, decimals }: any): Buffer {
-  return encodeData({
-    transferChecked: { amount, decimals },
-  });
-}
-
-function encodeApproveChecked({ amount, decimals }: any): Buffer {
-  return encodeData({
-    approveChecked: { amount, decimals },
-  });
-}
-
-function encodeMintToChecked({ amount, decimals }: any): Buffer {
-  return encodeData({
-    mintToChecked: { amount, decimals },
-  });
-}
-
-function encodeBurnChecked({ amount, decimals }: any): Buffer {
-  return encodeData({
-    burnChecked: { amount, decimals },
-  });
-}
-
-function encodeInitializeAccount2({ authority }: any): Buffer {
-  return encodeData({
-    initilaizeAccount2: { authority },
-  });
-}
-
-function encodeSyncNative(_: any): Buffer {
-  return encodeData({
-    syncNative: {},
-  });
-}
-
-function encodeInitializeAccount3({ authority }: any): Buffer {
-  return encodeData({
-    initializeAccount3: { authority },
-  });
-}
-
-function encodeInitializeMultisig2({ m }: any): Buffer {
-  return encodeData({
-    initializeMultisig2: { m },
-  });
-}
-
-function encodeInitializeMint2({
-  decimals,
-  mintAuthority,
-  freezeAuthority,
-}: any): Buffer {
-  return encodeData({
-    encodeInitializeMint2: { decimals, mintAuthority, freezeAuthority },
-  });
-}
-
-const LAYOUT = BufferLayout.union(BufferLayout.u8("instruction"));
-LAYOUT.addVariant(
-  0,
-  BufferLayout.struct([
-    BufferLayout.u8("decimals"),
-    BufferLayout.blob(32, "mintAuthority"),
-    BufferLayout.u8("freezeAuthorityOption"),
-    publicKey("freezeAuthority"),
-  ]),
-  "initializeMint"
-);
-LAYOUT.addVariant(1, BufferLayout.struct([]), "initializeAccount");
-LAYOUT.addVariant(
-  2,
-  BufferLayout.struct([BufferLayout.u8("m")]),
-  "initializeMultisig"
-);
-LAYOUT.addVariant(
-  3,
-  BufferLayout.struct([BufferLayout.nu64("amount")]),
-  "transfer"
-);
-LAYOUT.addVariant(
-  4,
-  BufferLayout.struct([BufferLayout.nu64("amount")]),
-  "approve"
-);
-LAYOUT.addVariant(5, BufferLayout.struct([]), "revoke");
-LAYOUT.addVariant(
-  6,
-  BufferLayout.struct([
-    BufferLayout.u8("authorityType"),
-    BufferLayout.u8("newAuthorityOption"),
-    publicKey("newAuthority"),
-  ]),
-  "setAuthority"
-);
-LAYOUT.addVariant(
-  7,
-  BufferLayout.struct([BufferLayout.nu64("amount")]),
-  "mintTo"
-);
-LAYOUT.addVariant(
-  8,
-  BufferLayout.struct([BufferLayout.nu64("amount")]),
-  "burn"
-);
-LAYOUT.addVariant(9, BufferLayout.struct([]), "closeAccount");
-LAYOUT.addVariant(10, BufferLayout.struct([]), "freezeAccount");
-LAYOUT.addVariant(11, BufferLayout.struct([]), "thawAccount");
-LAYOUT.addVariant(
-  12,
-  BufferLayout.struct([
-    BufferLayout.nu64("amount"),
-    BufferLayout.u8("decimals"),
-  ]),
-  "transferChecked"
-);
-LAYOUT.addVariant(
-  13,
-  BufferLayout.struct([
-    BufferLayout.nu64("amount"),
-    BufferLayout.u8("decimals"),
-  ]),
-  "approvedChecked"
-);
-LAYOUT.addVariant(
-  14,
-  BufferLayout.struct([
-    BufferLayout.nu64("amount"),
-    BufferLayout.u8("decimals"),
-  ]),
-  "mintToChecked"
-);
-LAYOUT.addVariant(
-  15,
-  BufferLayout.struct([
-    BufferLayout.nu64("amount"),
-    BufferLayout.u8("decimals"),
-  ]),
-  "burnedChecked"
-);
-LAYOUT.addVariant(
-  16,
-  BufferLayout.struct([publicKey("authority")]),
-  "InitializeAccount2"
-);
-LAYOUT.addVariant(17, BufferLayout.struct([]), "syncNative");
-LAYOUT.addVariant(
-  18,
-  BufferLayout.struct([publicKey("authority")]),
-  "initializeAccount3"
-);
-LAYOUT.addVariant(
-  19,
-  BufferLayout.struct([BufferLayout.u8("m")]),
-  "initializeMultisig2"
-);
-LAYOUT.addVariant(
-  20,
-  BufferLayout.struct([
-    BufferLayout.u8("decimals"),
-    publicKey("mintAuthority"),
-    BufferLayout.u8("freezeAuthorityOption"),
-    publicKey("freezeAuthority"),
-  ]),
-  "initializeMint2"
-);
-
-function publicKey(property: string): any {
-  return BufferLayout.blob(32, property);
-}
-
-function encodeData(instruction: any): Buffer {
-  let b = Buffer.alloc(instructionMaxSpan);
-  let span = LAYOUT.encode(instruction, b);
-  return b.slice(0, span);
-}
-
-const instructionMaxSpan = Math.max(
-  // @ts-ignore
-  ...Object.values(LAYOUT.registry).map((r) => r.span)
-);

+ 0 - 13
ts/packages/anchor/src/coder/spl-token/state.ts

@@ -1,13 +0,0 @@
-import { StateCoder } from "../index.js";
-import { Idl } from "../../idl";
-
-export class SplTokenStateCoder implements StateCoder {
-  constructor(_idl: Idl) {}
-
-  encode<T = any>(_name: string, _account: T): Promise<Buffer> {
-    throw new Error("SPL token does not have state");
-  }
-  decode<T = any>(_ix: Buffer): T {
-    throw new Error("SPL token does not have state");
-  }
-}

+ 0 - 13
ts/packages/anchor/src/coder/spl-token/types.ts

@@ -1,13 +0,0 @@
-import { TypesCoder } from "../index.js";
-import { Idl } from "../../idl.js";
-
-export class SplTokenTypesCoder implements TypesCoder {
-  constructor(_idl: Idl) {}
-
-  encode<T = any>(_name: string, _type: T): Buffer {
-    throw new Error("SPL token does not have user-defined types");
-  }
-  decode<T = any>(_name: string, _typeData: Buffer): T {
-    throw new Error("SPL token does not have user-defined types");
-  }
-}

+ 0 - 1
ts/packages/anchor/src/index.ts

@@ -17,7 +17,6 @@ export { CustomAccountResolver } from "./program/accounts-resolver.js";
 export * from "./coder/index.js";
 export * from "./coder/index.js";
 export * as utils from "./utils/index.js";
 export * as utils from "./utils/index.js";
 export * from "./program/index.js";
 export * from "./program/index.js";
-export * from "./spl/index.js";
 export * from "./native/index.js";
 export * from "./native/index.js";
 
 
 export declare const workspace: any;
 export declare const workspace: any;

+ 3 - 4
ts/packages/anchor/src/program/accounts-resolver.ts

@@ -12,7 +12,6 @@ import {
   IdlAccountItem,
   IdlAccountItem,
   IdlAccounts,
   IdlAccounts,
   IdlTypeDef,
   IdlTypeDef,
-  IdlTypeDefStruct,
   IdlTypeDefTyStruct,
   IdlTypeDefTyStruct,
   IdlType,
   IdlType,
 } from "../idl.js";
 } from "../idl.js";
@@ -21,8 +20,8 @@ import { TOKEN_PROGRAM_ID, ASSOCIATED_PROGRAM_ID } from "../utils/token.js";
 import { AllInstructions } from "./namespace/types.js";
 import { AllInstructions } from "./namespace/types.js";
 import Provider from "../provider.js";
 import Provider from "../provider.js";
 import { AccountNamespace } from "./namespace/account.js";
 import { AccountNamespace } from "./namespace/account.js";
-import { coder } from "../spl/token";
 import { BorshAccountsCoder } from "src/coder/index.js";
 import { BorshAccountsCoder } from "src/coder/index.js";
+import { decodeTokenAccount } from "./token-account-layout";
 import { Program } from "./index.js";
 import { Program } from "./index.js";
 
 
 type Accounts = { [name: string]: PublicKey | Accounts };
 type Accounts = { [name: string]: PublicKey | Accounts };
@@ -36,7 +35,7 @@ export type CustomAccountResolver<IDL extends Idl> = (params: {
 }) => Promise<{ accounts: Accounts; resolved: number }>;
 }) => Promise<{ accounts: Accounts; resolved: number }>;
 
 
 // Populates a given accounts context with PDAs and common missing accounts.
 // Populates a given accounts context with PDAs and common missing accounts.
-export class AccountsResolver<IDL extends Idl, I extends AllInstructions<IDL>> {
+export class AccountsResolver<IDL extends Idl> {
   _args: Array<any>;
   _args: Array<any>;
   static readonly CONST_ACCOUNTS = {
   static readonly CONST_ACCOUNTS = {
     associatedTokenProgram: ASSOCIATED_PROGRAM_ID,
     associatedTokenProgram: ASSOCIATED_PROGRAM_ID,
@@ -489,7 +488,7 @@ export class AccountStore<IDL extends Idl> {
         if (accountInfo === null) {
         if (accountInfo === null) {
           throw new Error(`invalid account info for ${address}`);
           throw new Error(`invalid account info for ${address}`);
         }
         }
-        const data = coder().accounts.decode("token", accountInfo.data);
+        const data = decodeTokenAccount(accountInfo.data);
         this._cache.set(address, data);
         this._cache.set(address, data);
       } else if (name) {
       } else if (name) {
         const accounts = await this.ensureIdl(programId);
         const accounts = await this.ensureIdl(programId);

+ 1 - 1
ts/packages/anchor/src/program/namespace/methods.ts

@@ -79,7 +79,7 @@ export class MethodsBuilder<IDL extends Idl, I extends AllInstructions<IDL>> {
   private _signers: Array<Signer> = [];
   private _signers: Array<Signer> = [];
   private _preInstructions: Array<TransactionInstruction> = [];
   private _preInstructions: Array<TransactionInstruction> = [];
   private _postInstructions: Array<TransactionInstruction> = [];
   private _postInstructions: Array<TransactionInstruction> = [];
-  private _accountsResolver: AccountsResolver<IDL, I>;
+  private _accountsResolver: AccountsResolver<IDL>;
   private _autoResolveAccounts: boolean = true;
   private _autoResolveAccounts: boolean = true;
   private _args: Array<any>;
   private _args: Array<any>;
 
 

+ 26 - 25
ts/packages/anchor/src/coder/spl-token/buffer-layout.ts → ts/packages/anchor/src/program/token-account-layout.ts

@@ -3,7 +3,7 @@ import * as BufferLayout from "buffer-layout";
 import { Layout } from "buffer-layout";
 import { Layout } from "buffer-layout";
 import { PublicKey } from "@solana/web3.js";
 import { PublicKey } from "@solana/web3.js";
 
 
-export function uint64(property?: string): Layout<u64 | null> {
+function uint64(property?: string): Layout<u64 | null> {
   return new WrappedLayout(
   return new WrappedLayout(
     BufferLayout.blob(8),
     BufferLayout.blob(8),
     (b: Buffer) => u64.fromBuffer(b),
     (b: Buffer) => u64.fromBuffer(b),
@@ -12,11 +12,7 @@ export function uint64(property?: string): Layout<u64 | null> {
   );
   );
 }
 }
 
 
-export function bool(property?: string): Layout<boolean> {
-  return new WrappedLayout(BufferLayout.u8(), decodeBool, encodeBool, property);
-}
-
-export function publicKey(property?: string): Layout<PublicKey> {
+function publicKey(property?: string): Layout<PublicKey> {
   return new WrappedLayout(
   return new WrappedLayout(
     BufferLayout.blob(32),
     BufferLayout.blob(32),
     (b: Buffer) => new PublicKey(b),
     (b: Buffer) => new PublicKey(b),
@@ -25,10 +21,7 @@ export function publicKey(property?: string): Layout<PublicKey> {
   );
   );
 }
 }
 
 
-export function coption<T>(
-  layout: Layout<T>,
-  property?: string
-): Layout<T | null> {
+function coption<T>(layout: Layout<T>, property?: string): Layout<T | null> {
   return new COptionLayout<T>(layout, property);
   return new COptionLayout<T>(layout, property);
 }
 }
 
 
@@ -62,7 +55,7 @@ class WrappedLayout<T, U> extends Layout<U> {
   }
   }
 }
 }
 
 
-export class COptionLayout<T> extends Layout<T | null> {
+class COptionLayout<T> extends Layout<T | null> {
   layout: Layout<T>;
   layout: Layout<T>;
   discriminator: Layout<number>;
   discriminator: Layout<number>;
 
 
@@ -95,20 +88,7 @@ export class COptionLayout<T> extends Layout<T | null> {
   }
   }
 }
 }
 
 
-function decodeBool(value: number): boolean {
-  if (value === 0) {
-    return false;
-  } else if (value === 1) {
-    return true;
-  }
-  throw new Error("Invalid bool: " + value);
-}
-
-function encodeBool(value: boolean): number {
-  return value ? 1 : 0;
-}
-
-export class u64 extends BN {
+class u64 extends BN {
   /**
   /**
    * Convert to Buffer representation
    * Convert to Buffer representation
    */
    */
@@ -143,3 +123,24 @@ export class u64 extends BN {
     );
     );
   }
   }
 }
 }
+
+const TOKEN_ACCOUNT_LAYOUT = BufferLayout.struct([
+  publicKey("mint"),
+  publicKey("owner"),
+  uint64("amount"),
+  coption(publicKey(), "delegate"),
+  ((p: string) => {
+    const U = BufferLayout.union(BufferLayout.u8("discriminator"), null, p);
+    U.addVariant(0, BufferLayout.struct([]), "uninitialized");
+    U.addVariant(1, BufferLayout.struct([]), "initialized");
+    U.addVariant(2, BufferLayout.struct([]), "frozen");
+    return U;
+  })("state"),
+  coption(uint64(), "isNative"),
+  uint64("delegatedAmount"),
+  coption(publicKey(), "closeAuthority"),
+]);
+
+export function decodeTokenAccount(b: Buffer) {
+  return TOKEN_ACCOUNT_LAYOUT.decode(b);
+}

+ 0 - 120
ts/packages/anchor/src/spl/associated-token.ts

@@ -1,120 +0,0 @@
-import { PublicKey } from "@solana/web3.js";
-import { Program } from "../program/index.js";
-import Provider from "../provider.js";
-import { SplAssociatedTokenCoder } from "../coder/spl-associated-token/index.js";
-
-const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(
-  "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
-);
-
-export function program(provider?: Provider): Program<SplAssociatedToken> {
-  return new Program<SplAssociatedToken>(
-    IDL,
-    ASSOCIATED_TOKEN_PROGRAM_ID,
-    provider,
-    coder()
-  );
-}
-
-export function coder(): SplAssociatedTokenCoder {
-  return new SplAssociatedTokenCoder(IDL);
-}
-
-/**
- * SplAssociatedToken IDL.
- */
-export type SplAssociatedToken = {
-  version: "0.1.0";
-  name: "spl_associated_token";
-  instructions: [
-    {
-      name: "create";
-      accounts: [
-        {
-          name: "authority";
-          isMut: true;
-          isSigner: true;
-        },
-        {
-          name: "associatedAccount";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "owner";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "systemProgram";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "tokenProgram";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "rent";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [];
-    }
-  ];
-};
-
-export const IDL: SplAssociatedToken = {
-  version: "0.1.0",
-  name: "spl_associated_token",
-  instructions: [
-    {
-      name: "create",
-      accounts: [
-        {
-          name: "authority",
-          isMut: true,
-          isSigner: true,
-        },
-        {
-          name: "associatedAccount",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "owner",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "systemProgram",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "tokenProgram",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "rent",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [],
-    },
-  ],
-};

+ 0 - 20
ts/packages/anchor/src/spl/index.ts

@@ -1,20 +0,0 @@
-import { Program, Provider } from "../index.js";
-import {
-  program as associatedTokenProgram,
-  SplAssociatedToken,
-} from "./associated-token.js";
-import { program as tokenProgram, SplToken } from "./token.js";
-
-export { SplToken } from "./token.js";
-
-export class Spl {
-  public static token(provider?: Provider): Program<SplToken> {
-    return tokenProgram(provider);
-  }
-
-  public static associatedToken(
-    provider?: Provider
-  ): Program<SplAssociatedToken> {
-    return associatedTokenProgram(provider);
-  }
-}

+ 0 - 1229
ts/packages/anchor/src/spl/token.ts

@@ -1,1229 +0,0 @@
-import { PublicKey } from "@solana/web3.js";
-import { Program } from "../program/index.js";
-import Provider from "../provider.js";
-import { SplTokenCoder } from "../coder/spl-token/index.js";
-
-const TOKEN_PROGRAM_ID = new PublicKey(
-  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
-);
-
-export function program(provider?: Provider): Program<SplToken> {
-  return new Program<SplToken>(IDL, TOKEN_PROGRAM_ID, provider, coder());
-}
-
-export function coder(): SplTokenCoder {
-  return new SplTokenCoder(IDL);
-}
-
-/**
- * SplToken IDL.
- */
-export type SplToken = {
-  version: "0.1.0";
-  name: "spl_token";
-  instructions: [
-    {
-      name: "initializeMint";
-      accounts: [
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "rent";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "decimals";
-          type: "u8";
-        },
-        {
-          name: "mintAuthority";
-          type: "publicKey";
-        },
-        {
-          name: "freezeAuthority";
-          type: {
-            coption: "publicKey";
-          };
-        }
-      ];
-    },
-    {
-      name: "initializeAccount";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "rent";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "initializeMultisig";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "rent";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "m";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "transfer";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "destination";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        }
-      ];
-    },
-    {
-      name: "approve";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "delegate";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        }
-      ];
-    },
-    {
-      name: "revoke";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "setAuthority";
-      accounts: [
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "authorityType";
-          type: "u8";
-        },
-        {
-          name: "newAuthority";
-          type: {
-            coption: "publicKey";
-          };
-        }
-      ];
-    },
-    {
-      name: "mintTo";
-      accounts: [
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "to";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        }
-      ];
-    },
-    {
-      name: "burn";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        }
-      ];
-    },
-    {
-      name: "closeAccount";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "destination";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "freezeAccount";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "thawAccount";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "transferChecked";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "destination";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        },
-        {
-          name: "decimals";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "approveChecked";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "delegate";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        },
-        {
-          name: "decimals";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "mintToChecked";
-      accounts: [
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "to";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        },
-        {
-          name: "decimals";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "burnChecked";
-      accounts: [
-        {
-          name: "source";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "authority";
-          isMut: false;
-          isSigner: true;
-        }
-      ];
-      args: [
-        {
-          name: "amount";
-          type: "u64";
-        },
-        {
-          name: "decimals";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "initializeAccount2";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        },
-        {
-          name: "rent";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "authority";
-          type: "publicKey";
-        }
-      ];
-    },
-    {
-      name: "syncNative";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        }
-      ];
-      args: [];
-    },
-    {
-      name: "initializeAccount3";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        },
-        {
-          name: "mint";
-          isMut: false;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "authority";
-          type: "publicKey";
-        }
-      ];
-    },
-    {
-      name: "initializeMultisig2";
-      accounts: [
-        {
-          name: "account";
-          isMut: true;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "m";
-          type: "u8";
-        }
-      ];
-    },
-    {
-      name: "initializeMint2";
-      accounts: [
-        {
-          name: "mint";
-          isMut: true;
-          isSigner: false;
-        }
-      ];
-      args: [
-        {
-          name: "decimals";
-          type: "u8";
-        },
-        {
-          name: "mintAuthority";
-          type: "publicKey";
-        },
-        {
-          name: "freezeAuthority";
-          type: {
-            coption: "publicKey";
-          };
-        }
-      ];
-    }
-  ];
-  accounts: [
-    {
-      name: "mint";
-      type: {
-        kind: "struct";
-        fields: [
-          {
-            name: "mintAuthority";
-            type: {
-              coption: "publicKey";
-            };
-          },
-          {
-            name: "supply";
-            type: "u64";
-          },
-          {
-            name: "decimals";
-            type: "u8";
-          },
-          {
-            name: "isInitialized";
-            type: "bool";
-          },
-          {
-            name: "freezeAuthority";
-            type: {
-              coption: "publicKey";
-            };
-          }
-        ];
-      };
-    },
-    {
-      name: "token";
-      type: {
-        kind: "struct";
-        fields: [
-          {
-            name: "mint";
-            type: "publicKey";
-          },
-          {
-            name: "authority";
-            type: "publicKey";
-          },
-          {
-            name: "amount";
-            type: "u64";
-          },
-          {
-            name: "delegate";
-            type: {
-              coption: "publicKey";
-            };
-          },
-          {
-            name: "state";
-            type: "u8";
-          },
-          {
-            name: "isNative";
-            type: {
-              coption: "u64";
-            };
-          },
-          {
-            name: "delegatedAmount";
-            type: "u64";
-          },
-          {
-            name: "closeAuthority";
-            type: {
-              coption: "publicKey";
-            };
-          }
-        ];
-      };
-    }
-  ];
-};
-
-export const IDL: SplToken = {
-  version: "0.1.0",
-  name: "spl_token",
-  instructions: [
-    {
-      name: "initializeMint",
-      accounts: [
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "rent",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "decimals",
-          type: "u8",
-        },
-        {
-          name: "mintAuthority",
-          type: "publicKey",
-        },
-        {
-          name: "freezeAuthority",
-          type: {
-            coption: "publicKey",
-          },
-        },
-      ],
-    },
-    {
-      name: "initializeAccount",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "rent",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "initializeMultisig",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "rent",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "m",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "transfer",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "destination",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-      ],
-    },
-    {
-      name: "approve",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "delegate",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-      ],
-    },
-    {
-      name: "revoke",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "setAuthority",
-      accounts: [
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "authorityType",
-          type: "u8",
-        },
-        {
-          name: "newAuthority",
-          type: {
-            coption: "publicKey",
-          },
-        },
-      ],
-    },
-    {
-      name: "mintTo",
-      accounts: [
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "to",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-      ],
-    },
-    {
-      name: "burn",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-      ],
-    },
-    {
-      name: "closeAccount",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "destination",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "freezeAccount",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "thawAccount",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "transferChecked",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "destination",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-        {
-          name: "decimals",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "approveChecked",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "delegate",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-        {
-          name: "decimals",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "mintToChecked",
-      accounts: [
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "to",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-        {
-          name: "decimals",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "burnChecked",
-      accounts: [
-        {
-          name: "source",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "authority",
-          isMut: false,
-          isSigner: true,
-        },
-      ],
-      args: [
-        {
-          name: "amount",
-          type: "u64",
-        },
-        {
-          name: "decimals",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "initializeAccount2",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-        {
-          name: "rent",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "authority",
-          type: "publicKey",
-        },
-      ],
-    },
-    {
-      name: "syncNative",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-      ],
-      args: [],
-    },
-    {
-      name: "initializeAccount3",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-        {
-          name: "mint",
-          isMut: false,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "authority",
-          type: "publicKey",
-        },
-      ],
-    },
-    {
-      name: "initializeMultisig2",
-      accounts: [
-        {
-          name: "account",
-          isMut: true,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "m",
-          type: "u8",
-        },
-      ],
-    },
-    {
-      name: "initializeMint2",
-      accounts: [
-        {
-          name: "mint",
-          isMut: true,
-          isSigner: false,
-        },
-      ],
-      args: [
-        {
-          name: "decimals",
-          type: "u8",
-        },
-        {
-          name: "mintAuthority",
-          type: "publicKey",
-        },
-        {
-          name: "freezeAuthority",
-          type: {
-            coption: "publicKey",
-          },
-        },
-      ],
-    },
-  ],
-  accounts: [
-    {
-      name: "mint",
-      type: {
-        kind: "struct",
-        fields: [
-          {
-            name: "mintAuthority",
-            type: {
-              coption: "publicKey",
-            },
-          },
-          {
-            name: "supply",
-            type: "u64",
-          },
-          {
-            name: "decimals",
-            type: "u8",
-          },
-          {
-            name: "isInitialized",
-            type: "bool",
-          },
-          {
-            name: "freezeAuthority",
-            type: {
-              coption: "publicKey",
-            },
-          },
-        ],
-      },
-    },
-    {
-      name: "token",
-      type: {
-        kind: "struct",
-        fields: [
-          {
-            name: "mint",
-            type: "publicKey",
-          },
-          {
-            name: "authority",
-            type: "publicKey",
-          },
-          {
-            name: "amount",
-            type: "u64",
-          },
-          {
-            name: "delegate",
-            type: {
-              coption: "publicKey",
-            },
-          },
-          {
-            name: "state",
-            type: "u8",
-          },
-          {
-            name: "isNative",
-            type: {
-              coption: "u64",
-            },
-          },
-          {
-            name: "delegatedAmount",
-            type: "u64",
-          },
-          {
-            name: "closeAuthority",
-            type: {
-              coption: "publicKey",
-            },
-          },
-        ],
-      },
-    },
-  ],
-};