Skip to content

Commit

Permalink
feat: DNS example
Browse files Browse the repository at this point in the history
Add an example program which stores simple DNS records as compressed
accounts. It consists of the following endpoints:

- create
- update
- delete

Currently it has only Rust SBF tests.

Co-authored-by: Michal Rostecki <vadorovsky@protonmail.com>
  • Loading branch information
Swen and vadorovsky committed Aug 8, 2024
1 parent d2e0e46 commit 4e6241d
Show file tree
Hide file tree
Showing 17 changed files with 723 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/light-system-programs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ jobs:
sub-tests: '[
"cargo test-sbf -p token-escrow -- --test-threads=1"
]'

- program: name-service-test
sub-tests: '[
"cargo test-sbf -p name-service -- --test-threads=1"
]'

steps:
- name: Checkout sources
Expand Down
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ members = [
"programs/system",
"programs/compressed-token",
"programs/registry",
"sdk",
"test-utils",
"utils",
"xtask",
"examples/token-escrow/programs/*",
"examples/name-service/programs/*",
"test-programs/*",
"forester",
"photon-api",
Expand Down

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions examples/name-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
**/*.rs.bk
node_modules
test-ledger
.yarn
8 changes: 8 additions & 0 deletions examples/name-service/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
node_modules
dist
build
test-ledger
18 changes: 18 additions & 0 deletions examples/name-service/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[toolchain]

[features]
seeds = false
skip-lint = false

[programs.localnet]
name_service = "7yucc7fL3JGbyMwg4neUaenNSdySS39hbAk89Ao3t1Hz"

[registry]
url = "https://api.apr.dev"

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

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
1 change: 1 addition & 0 deletions examples/name-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Name Service program example
Empty file added examples/name-service/expand.rs
Empty file.
12 changes: 12 additions & 0 deletions examples/name-service/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("@coral-xyz/anchor");

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

// Add your deploy script here.
};
20 changes: 20 additions & 0 deletions examples/name-service/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"scripts": {
"lint:fix": "prettier \"*/**/*{.js,.ts}\" -w",
"lint": "prettier \"*/**/*{.js,.ts}\" --check",
"test": "cargo test-sbf -p name-service -- --test-threads 1"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^10.0.0",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"typescript": "^4.3.5",
"prettier": "^2.6.2"
}
}
41 changes: 41 additions & 0 deletions examples/name-service/programs/name-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "name-service"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"
rust-version = "1.75.0"
license = "Apache-2.0"

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

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
custom-heap = ["light-heap"]
default = ["custom-heap"]
test-sbf = []
bench-sbf = []

[dependencies]
anchor-lang = { workspace = true, features = ["init-if-needed"] }
borsh = "0.10"
light-compressed-token = { path = "../../../../programs/compressed-token", version = "0.5.0", features = ["cpi"] }
light-system-program = { path = "../../../../programs/system", version = "0.5.0", features = ["cpi"]}
account-compression = { path = "../../../../programs/account-compression", version = "0.5.0", features = ["cpi"] }
light-hasher = { path = "../../../../merkle-tree/hasher", version = "0.3.0" }
light-heap = { path = "../../../../heap", version = "0.3.0", optional = true }
light-macros = { path = "../../../../macros/light", version = "0.5.0" }
light-utils = { path = "../../../../utils", version = "0.3.0" }
light-verifier = { path = "../../../../circuit-lib/verifier", version = "0.3.0" }

[target.'cfg(not(target_os = "solana"))'.dependencies]
solana-sdk = "1.18.11"

[dev-dependencies]
light-test-utils = { path = "../../../../test-utils", version = "0.3.0" }
solana-program-test = "1.18.11"
tokio = "1.36.0"
2 changes: 2 additions & 0 deletions examples/name-service/programs/name-service/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
Empty file.
Loading

0 comments on commit 4e6241d

Please sign in to comment.