Skip to content

Commit

Permalink
Add project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
EmelyanenkoK committed May 18, 2023
1 parent 11c0388 commit b986efa
Show file tree
Hide file tree
Showing 14 changed files with 5,597 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
temp
build
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "contracts/jetton_dao"]
path = contracts/jetton_dao
url = https://github.com/EmelyanenkoK/jetton_dao
[submodule "contracts/awaited_minter"]
path = contracts/awaited_minter
url = https://github.com/1IxI1/share-distributor-contract/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"bracketSpacing": true,
"semi": true
}
1 change: 1 addition & 0 deletions contracts/awaited_minter
Submodule awaited_minter added at 33dad4
1 change: 1 addition & 0 deletions contracts/jetton_dao
Submodule jetton_dao added at 69c8be
8 changes: 8 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
};

export default config;
5,449 changes: 5,449 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "liquid_staking",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"test": "jest"
},
"devDependencies": {
"@ton-community/blueprint": "^0.9.0",
"@ton-community/sandbox": "^0.10.0",
"@ton-community/test-utils": "^0.2.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.5",
"jest": "^29.5.0",
"prettier": "^2.8.6",
"ton": "^13.4.1",
"ton-core": "^0.49.0",
"ton-crypto": "^3.2.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
13 changes: 13 additions & 0 deletions scripts/deployPool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { toNano } from 'ton-core';
import { Pool } from '../wrappers/Pool';
import { compile, NetworkProvider } from '@ton-community/blueprint';

export async function run(provider: NetworkProvider) {
const pool = provider.open(Pool.createFromConfig({}, await compile('Pool')));

await pool.sendDeploy(provider.sender(), toNano('0.05'));

await provider.waitForDeploy(pool.address);

// run methods on `pool`
}
38 changes: 38 additions & 0 deletions tests/Pool.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Blockchain, SandboxContract } from '@ton-community/sandbox';
import { Cell, toNano } from 'ton-core';
import { Pool } from '../wrappers/Pool';
import '@ton-community/test-utils';
import { compile } from '@ton-community/blueprint';

describe('Pool', () => {
let code: Cell;

beforeAll(async () => {
code = await compile('Pool');
});

let blockchain: Blockchain;
let pool: SandboxContract<Pool>;

beforeEach(async () => {
blockchain = await Blockchain.create();

pool = blockchain.openContract(Pool.createFromConfig({}, code));

const deployer = await blockchain.treasury('deployer');

const deployResult = await pool.sendDeploy(deployer.getSender(), toNano('0.05'));

expect(deployResult.transactions).toHaveTransaction({
from: deployer.address,
to: pool.address,
deploy: true,
success: true,
});
});

it('should deploy', async () => {
// the check is done inside beforeEach
// blockchain and pool are ready to use
});
});
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2020",
"outDir": "dist",
"module": "commonjs",
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
6 changes: 6 additions & 0 deletions wrappers/Pool.compile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CompilerConfig } from '@ton-community/blueprint';

export const compile: CompilerConfig = {
lang: 'func',
targets: ['contracts/pool.func'],
};
29 changes: 29 additions & 0 deletions wrappers/Pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core';

export type PoolConfig = {};

export function poolConfigToCell(config: PoolConfig): Cell {
return beginCell().endCell();
}

export class Pool implements Contract {
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}

static createFromAddress(address: Address) {
return new Pool(address);
}

static createFromConfig(config: PoolConfig, code: Cell, workchain = 0) {
const data = poolConfigToCell(config);
const init = { code, data };
return new Pool(contractAddress(workchain, init), init);
}

async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
await provider.internal(via, {
value,
sendMode: SendMode.PAY_GAS_SEPARATELY,
body: beginCell().endCell(),
});
}
}

0 comments on commit b986efa

Please sign in to comment.