Skip to content

Commit

Permalink
ts: Coder as interface and SPL token coder (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante authored Jan 10, 2022
1 parent 9df69cd commit 84e0852
Show file tree
Hide file tree
Showing 41 changed files with 2,625 additions and 126 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ incremented for features.

* lang: Allow repr overrides for zero copy accounts ([#1273](https://github.com/project-serum/anchor/pull/1273)).

### Breaking

* ts: `Coder` is now an interface and the existing class has been renamed to `BorshCoder`. This change allows the generation of Anchor clients for non anchor programs ([#1259](https://github.com/project-serum/anchor/pull/1259/files)).

## [0.20.0] - 2022-01-06

### Fixes
Expand Down
13 changes: 13 additions & 0 deletions tests/custom-coder/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[programs.localnet]
custom_coder = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w"

[registry]
url = "https://anchor.projectserum.com"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
4 changes: 4 additions & 0 deletions tests/custom-coder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[workspace]
members = [
"programs/*"
]
12 changes: 12 additions & 0 deletions tests/custom-coder/migrations/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Migrations are an early feature. Currently, they're nothing more than this
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@project-serum/anchor");

module.exports = async function (provider) {
// Configure client to use the provider.
anchor.setProvider(provider);

// Add your deploy script here.
};
19 changes: 19 additions & 0 deletions tests/custom-coder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "custom-coder",
"version": "0.20.0",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://github.com/project-serum/anchor#readme",
"bugs": {
"url": "https://github.com/project-serum/anchor/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/project-serum/anchor.git"
},
"engines": {
"node": ">=11"
},
"scripts": {
"test": "anchor test"
}
}
19 changes: 19 additions & 0 deletions tests/custom-coder/programs/custom-coder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "custom-coder"
version = "0.1.0"
description = "Created with Anchor"
edition = "2018"

[lib]
crate-type = ["cdylib", "lib"]
name = "custom_coder"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.20.0"
2 changes: 2 additions & 0 deletions tests/custom-coder/programs/custom-coder/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
14 changes: 14 additions & 0 deletions tests/custom-coder/programs/custom-coder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod custom_coder {
use super::*;
pub fn initialize(_ctx: Context<Initialize>, a: Option<u8>) -> ProgramResult {
Ok(())
}
}

#[derive(Accounts)]
pub struct Initialize {}
19 changes: 19 additions & 0 deletions tests/custom-coder/programs/spl-token/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "spl-token"
version = "0.1.0"
description = "Created with Anchor"
edition = "2018"

[lib]
crate-type = ["cdylib", "lib"]
name = "spl_token"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.20.0"
2 changes: 2 additions & 0 deletions tests/custom-coder/programs/spl-token/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
Loading

0 comments on commit 84e0852

Please sign in to comment.