Skip to content

Commit 0d0cd01

Browse files
committed
first release
0 parents  commit 0d0cd01

31 files changed

+6442
-0
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
WALLET_MNEMONIC="mnemonic words..."
2+
WALLET_VERSION="v4" # "v1r1" | "v1r2" | "v1r3" | "v2r1" | "v2r2" | "v3r1" | "v3r2" | "v4" | "v5r1"
3+
TONCENTER_ENDPOINT="https://testnet.toncenter.com/api/v2/"
4+
TONCENTER_TYPE="testnet"
5+
TONCENTER_VERSION="v2"
6+
TONCENTER_KEY="see https://t.me/toncenter"

.github/workflows/qa.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: qa
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- '.github/**'
12+
- 'contracts/**'
13+
- 'scripts/**'
14+
- 'tests/**'
15+
- 'wrappers/**'
16+
- 'jest.config.ts'
17+
- 'package.json'
18+
- 'pnpm-lock.yaml'
19+
- 'tsconfig.json'
20+
21+
jobs:
22+
qa:
23+
runs-on: ubuntu-latest
24+
permissions: write-all
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: ever-guild/tvm-action@v1
28+
with:
29+
args: tlbc -v -t -q contracts/SampleBench.tlb
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: 9
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
cache: 'pnpm'
37+
cache-dependency-path: '**/pnpm-lock.yaml'
38+
- run: |
39+
pnpm install
40+
pnpm lint
41+
pnpm build-all
42+
pnpm test

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
node_modules
2+
temp
3+
build
4+
dist
5+
.DS_Store
6+
7+
# VS Code
8+
.vscode/*
9+
.history/
10+
*.vsix
11+
12+
# IDEA files
13+
.idea
14+
15+
# VIM
16+
Session.vim
17+
.vim/
18+
19+
# Other private editor folders
20+
.nvim/
21+
.emacs/
22+
.helix/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

LICENSE

Lines changed: 662 additions & 0 deletions
Large diffs are not rendered by default.

blueprint.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'dotenv/config'
2+
import { Config } from '@ton/blueprint';
3+
4+
export const config: Config = {
5+
network: {
6+
endpoint: process.env.TONCENTER_ENDPOINT ?? 'https://toncenter.com/api/v3/jsonRPC',
7+
// @ts-ignore
8+
type: process.env.TONCENTER_TYPE ?? 'testnet',
9+
// @ts-ignore
10+
version: process.env.TONCENTER_VERSION ?? 'v3',
11+
key: process.env.TONCENTER_KEY,
12+
},
13+
};
14+
15+

changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Change Log
2+
3+
All notable changes to the Sample Blueprint project will be documented in this file
4+
5+
## [1.0.0] - 2025-??-??
6+
7+
- [ ] ???
8+
- [ ] ???
9+
- [ ] ???
10+
- [ ] ???
11+
- [ ] ???
12+
- [ ] ???

contracts/SampleBench.fc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "lib/SampleBench.auto.fc";
2+
#include "lib/stdlib.fc";
3+
4+
;; recv_internal is the main function of the contract
5+
;; and is called when it receives a message from other contracts
6+
() recv_internal(cell msg, slice body) impure {
7+
;; ignore all empty messages
8+
if (body.slice_empty?()) {
9+
return ();
10+
}
11+
slice cs = msg.begin_parse();
12+
int flags = cs~load_uint(4);
13+
;; ignore all bounced messages
14+
if (flags & 1) {
15+
return ();
16+
}
17+
;; here we populate the storage variables
18+
load_state();
19+
;; by convention, the first 32 bits of incoming message is the op
20+
int op = body~load_op();
21+
;; by convention, the next 64 bits contain the "query id", although this is not always the case
22+
body~skip_query_id();
23+
;; actiom message procesed
24+
int change = body~load_change();
25+
if (op == OP_INCR) {
26+
counter += change;
27+
save_state();
28+
return ();
29+
} elseif (op == OP_DECR) {
30+
counter -= change;
31+
save_state();
32+
return ();
33+
}
34+
;; if the message contains an op that is not known to this contract, we throw
35+
throw(0xffff);
36+
}

contracts/SampleBench.tact

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
message(0x49533468) Incr {
2+
queryId: Int as uint64;
3+
change: Int as uint8;
4+
}
5+
6+
message(0x0ee52db3) Decr {
7+
queryId: Int as uint64;
8+
change: Int as uint8;
9+
}
10+
11+
struct State {
12+
id: Int as uint32;
13+
counter: Int as int32;
14+
}
15+
16+
contract SampleBench(id: Int as uint32, counter: Int as int32) {
17+
// Empty receiver for the deployment, which expects the `null` message body
18+
receive() { }
19+
20+
receive(msg: Incr) {
21+
self.counter += msg.change;
22+
}
23+
24+
receive(msg: Decr) {
25+
self.counter -= msg.change;
26+
}
27+
28+
get fun state(): State {
29+
return State {
30+
id: self.id,
31+
counter: self.counter,
32+
};
33+
}
34+
}

contracts/SampleBench.tlb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
_ id:uint32 counter:int32 = State;
2+
3+
action_incr#49533468 queryId:uint64 change:uint8 = IncrAction;
4+
action_decr#0ee52db3 queryId:uint64 change:uint8 = DecrAction;
5+
_ _:IncrAction = Action;
6+
_ _:DecrAction = Action;
7+
8+
// (crc16('state') & 0xffff) | 0x10000
9+
get_state#12f15 result:State = GetState;
10+
_ _:GetState = Gertter;
11+
12+
// tlbc -qvvv contracts/SampleBench.tlb 2>&1 | tee build/SampleBench.txt
13+
// tlbc -o build/SampleBench -n SampleBench -z contracts/SampleBench.tlb
14+
// npx @ton-community/tlb-codegen -o wrappers/SampleBench.schema.ts contracts/SampleBench.tlb
15+
16+
// experemental
17+
// npx @ton-community/tlb-codegen -o contracts/lib/SampleBench.auto.fc contracts/SampleBench.tlb
18+
// npx @ton-community/tlb-codegen -o contracts/lib/SampleBench.auto.tolk contracts/SampleBench.tlb

0 commit comments

Comments
 (0)