Skip to content

Commit

Permalink
ts: Remove SPL coders from Anchor package (#2155)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
acheroncrypto authored Nov 17, 2022
1 parent 5c474c6 commit af11599
Show file tree
Hide file tree
Showing 35 changed files with 226 additions and 2,574 deletions.
7 changes: 5 additions & 2 deletions .github/actions/setup-ts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ runs:
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 ../../../
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 ../../
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

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
* 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

### Features
Expand Down
5 changes: 1 addition & 4 deletions tests/custom-coder/Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[programs.localnet]
custom_coder = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w"
native_system = "9NxAd91hhJ3ZBTHytYP894y4ESRKG7n8VbLgdyYGJFLB"
spl_associated_token = "4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh"
spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w"

[registry]
url = "https://anchor.projectserum.com"
Expand All @@ -13,5 +12,3 @@ wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

[features]
4 changes: 2 additions & 2 deletions tests/custom-coder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-coder",
"version": "0.20.0",
"version": "0.25.0",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://github.com/coral-xyz/anchor#readme",
"bugs": {
Expand All @@ -14,7 +14,7 @@
"node": ">=11"
},
"scripts": {
"test": "anchor test"
"test": "anchor test --skip-lint"
},
"dependencies": {
"mocha": "^10.0.0",
Expand Down
20 changes: 0 additions & 20 deletions tests/custom-coder/programs/custom-coder/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/custom-coder/programs/custom-coder/Xargo.toml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/custom-coder/programs/custom-coder/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ default = []
overflow-checks = true

[dependencies]
anchor-lang = { path = "../../../../lang" }
anchor-lang = { path = "../../../../lang" }
30 changes: 3 additions & 27 deletions tests/custom-coder/programs/spl-associated-token/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::*;

declare_id!("4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh");

// See https://solana.stackexchange.com/a/1858/471
#[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 {}
Loading

1 comment on commit af11599

@vercel
Copy link

@vercel vercel bot commented on af11599 Nov 17, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-docs-git-master-200ms.vercel.app
www.anchor-lang.com
anchor-lang.com
anchor-docs-200ms.vercel.app

Please sign in to comment.