Skip to content

Commit cc763fb

Browse files
Merge pull request #78 from smartcontractkit/NONEVM-2203-Add-jetton-func-import-as-dependency-of-.-contracts-nix-shell
[NONEVM-2203] Fetch jetton wallet and minter func implementation in nix shell
2 parents 3af9447 + 38963d8 commit cc763fb

File tree

4 files changed

+46
-39
lines changed

4 files changed

+46
-39
lines changed

.github/workflows/contracts-build.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ jobs:
1919
with:
2020
nix_path: nixpkgs=channel:nixos-unstable
2121

22-
- name: Fetch and build Jetton contracts
23-
run: |
24-
nix build .#contracts-jetton-func
25-
2622
- name: Run build
2723
run: |
2824
pushd contracts

contracts/default.nix

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,29 @@
66

77
# source yarn.lock at the root of the repo
88
yarnLock = ../yarn.lock;
9-
in {
10-
# Output a set of specifc shells
11-
devShells = {
12-
contracts = pkgs.callPackage ./shell.nix {inherit pkgs;};
13-
};
9+
10+
# Define packages first
11+
packages = rec {
12+
# Official TON Jetton contract in FunC
13+
contracts-jetton-func = pkgs.buildNpmPackage (finalAttrs: rec {
14+
pname = "contracts-jetton-func";
15+
16+
src = pkgs.fetchgit {
17+
url = "https://github.com/ton-blockchain/jetton-contract.git";
18+
rev = "3d24b419f2ce49c09abf6b8703998187fe358ec9"; # jetton-1.2, Jun 7, 2025
19+
hash = "sha256-jel0z/DsndlpnWuUhm4vzoacM/zboLCIqcPmPqBsDgU=";
20+
};
21+
version = (builtins.fromJSON (builtins.readFile "${src}/package.json")).version;
22+
23+
npmDepsHash = "sha256-EZtvTf19MjSKTWNir6pcP9XHwUIpE4ILSlhS+cQD/7w=";
24+
25+
meta = with pkgs.lib; {
26+
description = "Reference implementation of Jetton (fungible token) smart contract for TON.";
27+
license = licenses.mit;
28+
changelog = "https://github.com/ton-blockchain/jetton-contract/releases/tag/jetton-1.2";
29+
};
30+
});
1431

15-
# Output a set of specifc packages
16-
packages = {
1732
# Chainlink contract pkgs
1833
contracts = pkgs.stdenv.mkDerivation (finalAttrs: {
1934
inherit (package-info) version;
@@ -40,32 +55,24 @@ in {
4055
nodejs_24
4156
];
4257

58+
buildInputs = [
59+
contracts-jetton-func
60+
];
61+
4362
meta = with pkgs.lib; {
4463
inherit (package-info) description;
4564
license = licenses.mit;
4665
# TODO: update to contracts project-specific tag
4766
changelog = "https://github.com/smartcontractkit/chainlink-ton/releases/tag/v${version}";
4867
};
4968
});
50-
51-
# Official TON Jetton contract in FunC
52-
contracts-jetton-func = pkgs.buildNpmPackage (finalAttrs: rec {
53-
pname = "contracts-jetton-func";
54-
55-
src = pkgs.fetchgit {
56-
url = "https://github.com/ton-blockchain/jetton-contract.git";
57-
rev = "3d24b419f2ce49c09abf6b8703998187fe358ec9"; # jetton-1.2, Jun 7, 2025
58-
hash = "sha256-jel0z/DsndlpnWuUhm4vzoacM/zboLCIqcPmPqBsDgU=";
59-
};
60-
version = (builtins.fromJSON (builtins.readFile "${src}/package.json")).version;
61-
62-
npmDepsHash = "sha256-EZtvTf19MjSKTWNir6pcP9XHwUIpE4ILSlhS+cQD/7w=";
63-
64-
meta = with pkgs.lib; {
65-
description = "Reference implementation of Jetton (fungible token) smart contract for TON.";
66-
license = licenses.mit;
67-
changelog = "https://github.com/ton-blockchain/jetton-contract/releases/tag/jetton-1.2";
68-
};
69-
});
7069
};
70+
in {
71+
# Output a set of specifc shells
72+
devShells = {
73+
contracts = pkgs.callPackage ./shell.nix {inherit pkgs; jetton-contracts = packages.contracts-jetton-func;};
74+
};
75+
76+
# Output a set of specifc packages
77+
inherit packages;
7178
}

contracts/shell.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
stdenv,
33
pkgs,
44
lib,
5+
jetton-contracts,
56
}:
67
pkgs.mkShell {
78
buildInputs = with pkgs; [
@@ -21,4 +22,10 @@ pkgs.mkShell {
2122
git
2223
jq
2324
];
25+
26+
shellHook = ''
27+
export PATH_CONTRACTS_JETTON="${jetton-contracts}/lib/node_modules/jetton/build/"
28+
29+
echo "Jetton contracts located here: $PATH_CONTRACTS_JETTON"
30+
'';
2431
}

contracts/tests/Jetton.spec.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import { sha256 } from '@ton/crypto'
77
import { resolve } from 'path'
88
import { readFileSync } from 'fs'
99
import { execSync } from 'child_process'
10+
import { env } from 'process'
1011

1112
const ONCHAIN_CONTENT_PREFIX = 0x00
1213
const OFFCHAIN_CONTENT_PREFIX = 0x01
1314

15+
const PATH_CONTRACTS_JETTON = env.PATH_CONTRACTS_JETTON
16+
1417
const jettonDataURI = 'smartcontract.com'
1518

1619
describe('Send and Receive Jettons', () => {
@@ -462,10 +465,7 @@ function findGitRoot(): string {
462465
}
463466

464467
async function JettonMinterCode(): Promise<Cell> {
465-
const compiledPath = resolve(
466-
findGitRoot(),
467-
'result/lib/node_modules/jetton/build/JettonMinter.compiled.json',
468-
)
468+
const compiledPath = `${PATH_CONTRACTS_JETTON}/JettonMinter.compiled.json`
469469
const compiled = JSON.parse(readFileSync(compiledPath, 'utf8'))
470470
const hex = compiled.hex
471471
if (!hex) {
@@ -478,10 +478,7 @@ async function JettonMinterCode(): Promise<Cell> {
478478
}
479479

480480
async function JettonWalletCode(): Promise<Cell> {
481-
const compiledPath = resolve(
482-
findGitRoot(),
483-
'result/lib/node_modules/jetton/build/JettonWallet.compiled.json',
484-
)
481+
const compiledPath = `${PATH_CONTRACTS_JETTON}/JettonWallet.compiled.json`
485482
const compiled = JSON.parse(readFileSync(compiledPath, 'utf8'))
486483
const hex = compiled.hex
487484
if (!hex) {

0 commit comments

Comments
 (0)