Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for getJettonData getWalletData getMaxPunishment #7

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: [],
rules: {},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
settings: {},
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
temp
build
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"printWidth": 120,
"tabWidth": 4,
"semi": false,
"singleQuote": true,
"bracketSpacing": true,
"semi": true
"trailingComma": "all"
}
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: build_graphviz graphs clean

UID=$(shell id -u)
GID=$(shell id -g)

GRAPHVIZ_DOCKER_IMG=contract/graphviz:latest

build_graphviz:
@docker build -t $(GRAPHVIZ_DOCKER_IMG) -f docker/graphviz.Dockerfile .

graphs:
@docker run --rm --user $(UID):$(GID) -v $(PWD)/graphs:/data $(GRAPHVIZ_DOCKER_IMG)

clean:
@rm -r graphs/img
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ There are 3 roles in the governance of the protocol:
- Deploy: `yarn blueprint run`
- Test: `yarn test`

### Graphs

Requirements:

1. [Docker](https://docs.docker.com/get-docker/)
2. make

How to generate:

1. `make build_graphviz`
2. `make graphs`

## License

MIT
[MIT](./LICENSE)
2 changes: 1 addition & 1 deletion contracts/imports/stdlib.fc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ slice begin_parse(cell c) asm "CTOS";
;;; Preloads the first reference from the slice.
cell preload_ref(slice s) asm "PLDREF";

{- Functions below are commented because are implemented on compilator level for optimisation -}
{- Functions below are commented because are implemented on compilator level for optimisation -}

;;; Loads a signed [len]-bit integer from a slice [s].
;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX";
Expand Down
2 changes: 1 addition & 1 deletion contracts/imports/utils.fc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int max_recommended_punishment_for_validator_misbehaviour(int stake) inline_ref
, cs~load_uint(16), cs~load_uint(16)
, cs~load_uint(16)
, cs~load_uint(16), cs~load_uint(16), cs~load_uint(16)
);
);

;; https://github.com/ton-blockchain/ton/blob/master/lite-client/lite-client.cpp#L3721
int fine = default_flat_fine;
Expand Down
11 changes: 10 additions & 1 deletion contracts/treasury.fc
Original file line number Diff line number Diff line change
Expand Up @@ -1370,14 +1370,24 @@ builder pack_participation
}

() upgrade_data(slice src, int query_id, slice s) impure method_id {
;; Add code for upgrading date here.

;; This is just a template, and will only run after upgrade_code.
;; If data is upgraded, remember to reset this code,
;; so that the next upgrade won't change data by mistake.

;; Do not change the following code.
load_data();
unpack_extension();

throw_unless(err::access_denied, equal_slice_bits(src, governor));

builder excess = begin_cell()
.store_uint(op::gas_excess, 32)
.store_uint(query_id, 64);
send_msg(false, src.to_builder(), null(), excess, 0, send::remaining_value + send::ignore_errors);

throw(0);
}

() upgrade_code(slice src, slice s) impure inline {
Expand All @@ -1392,7 +1402,6 @@ builder pack_participation
set_code(new_code);
set_c3(new_code.begin_parse().bless());
upgrade_data(src, query_id, s);
throw(0);
}

() withdraw_surplus(int msg_ton, slice src, slice s) impure inline {
Expand Down
14 changes: 14 additions & 0 deletions custom-matchers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export {}

declare global {
namespace jest {
interface AsymmetricMatchers {
toBeBetween(a: bigint | string, b: bigint | string): void
toBeTonValue(v: bigint | string): void
}
interface Matchers<R> {
toBeBetween(a: bigint | string, b: bigint | string): R
toBeTonValue(v: bigint | string): R
}
}
}
10 changes: 10 additions & 0 deletions docker/graphviz.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:3.18

RUN apk add --no-cache graphviz ttf-dejavu && \
chmod -R a+rw /var/cache/fontconfig

COPY docker/graphviz.sh /dot/graphviz.sh

WORKDIR /data

ENTRYPOINT ["/dot/graphviz.sh"]
11 changes: 11 additions & 0 deletions docker/graphviz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

if [ ! -d "img" ]; then
mkdir img
fi

for file in *.dot
do
echo "Generating image from $file"
dot -Tsvg $file -o img/${file%.*}.svg
done
91 changes: 91 additions & 0 deletions graphs/img/00-legend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions graphs/img/01-deposit-coins.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading