Skip to content

Commit 33e969a

Browse files
authored
Allow-Block list token (#399)
1 parent 55a551e commit 33e969a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4850
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
# Anchor
44+
/anchor/target/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Add files here to ignore them from prettier formatting
2+
/anchor/target/debug
3+
/anchor/target/deploy
4+
/anchor/target/release
5+
/anchor/target/sbf-solana-solana
6+
/anchor/target/test-ledger
7+
/anchor/target/.rustc_info.json
8+
/dist
9+
/coverage
10+
.next
11+
/tmp
12+
package-lock.json
13+
pnpm-lock.yaml
14+
yarn.lock
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "always",
3+
"printWidth": 120,
4+
"semi": false,
5+
"singleQuote": true,
6+
"trailingComma": "all"
7+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AllowBlockList Token
2+
3+
An example of a allow / block list token using token extensions.
4+
5+
## Features
6+
7+
Allows the creation of an allow block list with a list authority.
8+
The allow/block list is then consumed by a transfer-hook.
9+
10+
The list is managed by a single authority and can be used by several token mints. This enables a separation of concerns between token management and allow/block list management, ideal for scenarios where an issuer wants a 3rd party managed allow/block list or wants to share the same list across a group of assets.
11+
12+
Initializes new tokens with several configuration options:
13+
- Permanent delegate
14+
- Allow list
15+
- Block list
16+
- Metadata
17+
- Authorities
18+
19+
The issuer can configure the allow and block list with 3 distinct configurations:
20+
- Force Allow: requires everyone receiving tokens to be explicitly allowed in
21+
- Block: allows everyone to receive tokens unless explicitly blocked
22+
- Threshold Allow: allows everyone to receive tokens unless explicitly blocked up until a given transfer amount threshold. Transfers larger than the threshold require explicitly allow
23+
24+
These configurations are saved in the token mint metadata.
25+
26+
This repo includes a UI to manage the allow/block list based on the `legacy-next-tailwind-basic` template. It also allows creating new token mints on the spot with transfer-hook enabled along with token transfers given that most wallets fail to fetch transfer-hook dependencies on devnet and locally.
27+
28+
## Setup
29+
30+
Install dependencies:
31+
`yarn install`
32+
33+
Compile the program:
34+
`anchor build`
35+
36+
Compile the UI:
37+
`yarn run build`
38+
39+
Serve the UI:
40+
`yarn run dev`
41+
42+
### Local testing
43+
44+
There are a couple scripts to manage the local validator and deployment.
45+
46+
To start the local validator and deploy the program:
47+
`./scripts/start.sh`
48+
49+
To stop the local validator:
50+
`./scripts/stop.sh`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.anchor
2+
.DS_Store
3+
target/debug
4+
target/deploy
5+
target/release
6+
target/sbf-solana-solana
7+
target/test-ledger
8+
target/.rustc_info.json
9+
**/*.rs.bk
10+
node_modules
11+
test-ledger
12+
.yarn
13+
ledger
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.anchor
2+
.DS_Store
3+
target
4+
node_modules
5+
dist
6+
build
7+
test-ledger
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[toolchain]
2+
package_manager = "yarn"
3+
4+
[features]
5+
resolution = true
6+
skip-lint = false
7+
8+
[programs.localnet]
9+
abl-token = "LtkoMwPSKxAE714EY3V1oAEQ5LciqJcRwQQuQnzEhQQ"
10+
11+
[registry]
12+
url = "https://api.apr.dev"
13+
14+
[provider]
15+
cluster = "localnet"
16+
wallet = "~/.config/solana/id.json"
17+
18+
[scripts]
19+
test = "../node_modules/.bin/jest --preset ts-jest"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
resolver = "2"
6+
7+
[profile.release]
8+
overflow-checks = true
9+
lto = "fat"
10+
codegen-units = 1
11+
[profile.release.build-override]
12+
opt-level = 3
13+
incremental = false
14+
codegen-units = 1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[package]
2+
name = "abl-token"
3+
version = "0.1.0"
4+
description = "Created with Anchor"
5+
edition = "2021"
6+
7+
[lib]
8+
crate-type = ["cdylib", "lib"]
9+
name = "abl_token"
10+
11+
[features]
12+
default = []
13+
cpi = ["no-entrypoint"]
14+
no-entrypoint = []
15+
no-idl = []
16+
no-log-ix-name = []
17+
idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
18+
19+
20+
[dependencies]
21+
anchor-lang = { version = "0.31.1", features = ["interface-instructions"] }
22+
anchor-spl = { version = "0.31.1", features = [
23+
"token_2022_extensions",
24+
"token_2022",
25+
] }
26+
27+
28+
spl-tlv-account-resolution = "0.8.1"
29+
spl-transfer-hook-interface = { version = "0.8.2" }
30+
spl-discriminator = "0.3"
31+
32+
[dev-dependencies]
33+
litesvm = "0.6.1"
34+
35+
36+
solana-instruction = "2.2.1"
37+
solana-keypair = "2.2.1"
38+
solana-native-token = "2.2.1"
39+
solana-pubkey = "2.2.1"
40+
solana-signer = "2.2.1"
41+
solana-system-interface = "1.0.0"
42+
solana-transaction = "2.2.1"
43+
solana-message = "2.2.1"
44+
solana-sdk-ids = "2.2.1"
45+
spl-token-2022 = { version = "8.0.1", features = ["no-entrypoint"]}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.bpfel-unknown-unknown.dependencies.std]
2+
features = []

0 commit comments

Comments
 (0)