Skip to content

Commit 9753fa9

Browse files
author
tilo-14
committed
Add escrow, fundraiser, AMM, and minter with SPL/T22/Light interop
- Escrow: peer-to-peer token swap (make_offer, take_offer) - Fundraiser: time-gated fundraising with refunds - Token-swap: constant-product AMM with liquidity pools - Light-token-minter: create light-mints with metadata - All programs tested across 5 token configs (SPL, T22, Light, LightSpl, LightT22) - CI aligned with upstream Photon indexer rev
1 parent 46f677a commit 9753fa9

77 files changed

Lines changed: 16397 additions & 58 deletions

Some content is hidden

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

.github/actions/setup/action.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
name: Setup Environment
2-
description: Setup Rust, Solana CLI, and Light CLI for testing
2+
description: Setup Rust, Solana CLI, and optionally Node.js for testing
33

44
inputs:
5+
example:
6+
description: "Example directory path (used for Rust workspace caching)"
7+
required: false
8+
default: ""
9+
node-version:
10+
description: "Node.js version to install (optional, empty = minimal Node for Light CLI only)"
11+
required: false
12+
default: ""
513
solana-cli-version:
614
description: "Solana CLI version"
715
required: false
8-
default: "2.1.21"
16+
default: "2.3.11"
917
rust-toolchain:
1018
description: "Rust toolchain version"
1119
required: false
12-
default: "1.85.0"
20+
default: "1.90.0"
1321
light-cli-version:
1422
description: "Light CLI version"
1523
required: false
1624
default: "alpha"
25+
photon-indexer:
26+
description: "Install Photon indexer (required for TypeScript tests)"
27+
required: false
28+
default: "false"
1729

1830
runs:
1931
using: composite
@@ -22,18 +34,19 @@ runs:
2234
uses: actions-rust-lang/setup-rust-toolchain@v1
2335
with:
2436
toolchain: ${{ inputs.rust-toolchain }}
25-
cache: false
37+
cache-workspaces: ${{ inputs.example || '.' }}
2638

27-
- name: Setup Node.js (for Light CLI)
39+
- name: Setup Node.js
40+
if: inputs.node-version != ''
2841
uses: actions/setup-node@v4
2942
with:
30-
node-version: "22"
43+
node-version: ${{ inputs.node-version }}
3144

32-
- name: Cache npm global packages
33-
uses: actions/cache@v4
45+
- name: Setup Node.js (for Light CLI)
46+
if: inputs.node-version == ''
47+
uses: actions/setup-node@v4
3448
with:
35-
path: ~/.npm
36-
key: npm-${{ runner.os }}-light-cli-${{ inputs.light-cli-version }}
49+
node-version: "22"
3750

3851
- name: Cache Solana CLI tools
3952
uses: actions/cache@v4
@@ -53,6 +66,21 @@ runs:
5366
shell: bash
5467
run: npm install -g @lightprotocol/zk-compression-cli@${{ inputs.light-cli-version }}
5568

69+
- name: Cache Photon indexer
70+
if: inputs.photon-indexer == 'true'
71+
id: cache-photon
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.cargo/bin/photon
75+
key: photon-${{ runner.os }}-ac7df6c388db847b7693a7a1cb766a7c9d7809b5
76+
77+
- name: Install Photon indexer
78+
if: inputs.photon-indexer == 'true' && steps.cache-photon.outputs.cache-hit != 'true'
79+
shell: bash
80+
env:
81+
RUSTFLAGS: "-A dead-code"
82+
run: cargo install --git https://github.com/lightprotocol/photon.git --rev ac7df6c388db847b7693a7a1cb766a7c9d7809b5 --locked --force
83+
5684
- name: Generate keypair
5785
shell: bash
5886
run: solana-keygen new --no-bip39-passphrase
@@ -64,4 +92,3 @@ runs:
6492
cargo --version
6593
solana --version
6694
light --version
67-

.github/workflows/rust-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
SOLANA_CLI_VERSION: "2.3.11"
18+
RUST_TOOLCHAIN: "1.90.0"
19+
20+
jobs:
21+
test-rust:
22+
name: ${{ matrix.package }}
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
package:
28+
- escrow
29+
- fundraiser
30+
- light-token-minter
31+
- swap_example
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup environment
36+
uses: ./.github/actions/setup
37+
with:
38+
example: programs/anchor
39+
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
40+
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
41+
42+
- name: Test
43+
working-directory: programs/anchor
44+
run: cargo test-sbf -p ${{ matrix.package }}

.github/workflows/typescript-tests.yml

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
SOLANA_CLI_VERSION: "2.1.21"
17+
SOLANA_CLI_VERSION: "2.3.11"
18+
RUST_TOOLCHAIN: "1.90.0"
1819
NODE_VERSION: "22"
1920

2021
jobs:
@@ -24,48 +25,13 @@ jobs:
2425
steps:
2526
- uses: actions/checkout@v4
2627

27-
- name: Setup Node.js
28-
uses: actions/setup-node@v4
28+
- name: Setup environment
29+
uses: ./.github/actions/setup
2930
with:
3031
node-version: ${{ env.NODE_VERSION }}
31-
32-
- name: Cache Solana CLI tools
33-
uses: actions/cache@v4
34-
with:
35-
path: |
36-
~/.cache/solana/
37-
~/.local/share/solana/
38-
key: solana-cli-${{ runner.os }}-${{ env.SOLANA_CLI_VERSION }}
39-
40-
- name: Install Solana CLI tools
41-
run: |
42-
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_CLI_VERSION }}/install)"
43-
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
44-
45-
- name: Install Light CLI
46-
run: npm install -g @lightprotocol/zk-compression-cli@alpha
47-
48-
- name: Install Rust (for Photon)
49-
uses: actions-rust-lang/setup-rust-toolchain@v1
50-
with:
51-
toolchain: stable
52-
cache: false
53-
54-
- name: Cache Photon indexer
55-
id: cache-photon
56-
uses: actions/cache@v4
57-
with:
58-
path: ~/.cargo/bin/photon
59-
key: photon-${{ runner.os }}-1a785036de52896b68d06413e3b0231122d6aa4a
60-
61-
- name: Install Photon indexer
62-
if: steps.cache-photon.outputs.cache-hit != 'true'
63-
run: cargo install --git https://github.com/lightprotocol/photon.git --rev 1a785036de52896b68d06413e3b0231122d6aa4a --locked
64-
env:
65-
RUSTFLAGS: "-A dead-code"
66-
67-
- name: Generate keypair
68-
run: solana-keygen new --no-bip39-passphrase
32+
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
33+
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
34+
photon-indexer: "true"
6935

7036
- name: Install dependencies
7137
working-directory: typescript-client

.gitignore

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# Dependencies
12
**/node_modules/
23
**/dist/
4+
5+
# Environment and secrets
36
**/.env
7+
**/.env.*
8+
**/*-keypair.json
9+
**/id.json
10+
11+
# Build artifacts
12+
**/target
13+
**/.anchor
14+
15+
# Test artifacts
16+
**/test-ledger
17+
18+
# Lock files
419
**/pnpm-lock.yaml
520
**/package-lock.json
21+
22+
# Backups
623
**/*.json.bak
7-
**/test-ledger
8-
**/target
24+
25+
# Project-specific
926
cli/accounts/
27+
bugs.md

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ TypeScript examples for light-token-sdk.
3636

3737
## Documentation
3838

39-
Learn more [about to Light-Token here](https://www.zkcompression.com/light-token/welcome).
39+
Learn more [about Light-Token here](https://www.zkcompression.com/light-token/welcome).

programs/anchor/Anchor.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[toolchain]
2+
3+
[features]
4+
resolution = true
5+
skip-lint = false
6+
7+
[workspace]
8+
members = [
9+
"escrow",
10+
"fundraiser",
11+
"light-token-minter",
12+
"token-swap",
13+
]
14+
15+
[programs.localnet]
16+
escrow = "FKJs6rp6TXJtxzLiPtdYhqa9ExRuBXG2zwh4fda6WATN"
17+
fundraiser = "Eoiuq1dXvHxh6dLx3wh9gj8kSAUpga11krTrbfF5XYsC"
18+
light_token_minter = "3EPJBoxM8Evtv3Wk7R2mSWsrSzUD7WSKAaYugLgpCitV"
19+
swap_example = "AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn"
20+
counter = "PDAm7XVHEkBvzBYDh8qF3z8NxnYQzPjGQJKcHVmMZpT"
21+
22+
[registry]
23+
url = "https://api.apr.dev"
24+
25+
[provider]
26+
cluster = "localnet"
27+
wallet = "~/.config/solana/id.json"
28+
29+
[scripts]
30+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

0 commit comments

Comments
 (0)