Skip to content

feat: new constructor with browser support #314

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

Merged
merged 7 commits into from
Jan 5, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ jobs:
- name: Compile all
run: bun compile-all

- name: Web test
run: bunx playwright install && bun web-test

Binary file modified bun.lockb
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@
"run-itxns": "bun examples/itxns/demo.ts",
"run-examples": "conc \"bun run-merkle\" \"bun run-tuple_in_box\" \"bun run-itxns\"",
"run-simple": "bun examples/simple/index.ts",
"webpack-smoketest": "webpack --config tests/web/webpack.config.js",
"web-test": "webpack --config tests/web/webpack.config.js && bun playwright test --config tests/web/playwright.config.ts",
"pre-commit": "conc \"bun lint\" \"bun test\" \"bun test examples/\" \"bun run-examples\" \"bun webpack-smoketest\" \"bun scripts/compile_all_smoketest.ts\"",
"compile-all": "bun scripts/compile_all.ts"
},
"dependencies": {
"@algorandfoundation/algokit-utils": "5.0.1",
"@microsoft/tsdoc": "^0.14.2",
"@playwright/test": "^1.40.1",
"argparse": "^2.0.1",
"dotenv": "^16.3.1",
"js-sha512": "^0.8.0",
Expand All @@ -69,6 +70,7 @@
"@algorandfoundation/algokit-client-generator": "v2.3.1-beta.1",
"@jest/globals": "^29.5.0",
"@types/argparse": "^2.0.11",
"@types/express": "^4.17.21",
"@types/node": "^18.11.9",
"@types/node-fetch": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.44.0",
Expand All @@ -80,6 +82,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^5.0.1",
"express": "^4.18.2",
"glob": "^10.3.10",
"jest": "^29.5.0",
"path-browserify": "^1.0.1",
Expand Down
11 changes: 9 additions & 2 deletions scripts/compile_all.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { globSync } from 'glob';
import fs, { readFileSync } from 'fs';
import fs from 'fs';
import path from 'path';
import { Project } from 'ts-morph';
import { Compiler } from '../src/lib';
Expand All @@ -25,7 +25,14 @@ async function main() {
if (file.includes('compile_errors')) return;
const isExample = file.includes('examples/');
const project = isExample ? EXAMPLES_PROJECT : TESTS_PROJECT;
const compilers = Compiler.compileAll(readFileSync(file, 'utf-8'), project, { filename: file });

const options = {
cwd: process.cwd(),
project,
srcPath: file,
};

const compilers = Compiler.compileAll(options);

let dir = path.join(__dirname, '..', 'tests', 'contracts', 'artifacts');

Expand Down
28 changes: 14 additions & 14 deletions src/bin/tealscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,16 @@ import * as fs from 'fs';
import { ArgumentParser } from 'argparse';
import ts from 'typescript';
import { Project } from 'ts-morph';
import Compiler, { CompilerOptions } from '../lib/compiler';
import Compiler from '../lib/compiler';

import 'dotenv/config';
import { VERSION } from '../version';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
async function processFile(filename: string, parsed: any) {
const content = fs.readFileSync(filename, 'utf-8');

// Output dir for artifacts
const dir = parsed.output;

const options = {
filename,
algodPort: process.env.ALGOD_PORT ? Number(process.env.ALGOD_PORT) : undefined,
algodServer: process.env.ALGOD_SERVER,
algodToken: process.env.ALGOD_TOKEN,
disableWarnings: parsed.disable_warnings as boolean,
disableOverflowChecks: parsed.unsafe_disable_overflow_checks as boolean,
disableTypeScript: parsed.unsafe_disable_typescript as boolean,
} as CompilerOptions;

const tsConfigFilePath = path.join(process.cwd(), ts.findConfigFile(filename, ts.sys.fileExists, 'tsconfig.json')!);

const project = new Project({
Expand All @@ -41,7 +29,19 @@ async function processFile(filename: string, parsed: any) {
project.compilerOptions.set({ experimentalDecorators: true });
}

const compilers = Compiler.compileAll(content, project, options);
const options = {
algodPort: process.env.ALGOD_PORT ? Number(process.env.ALGOD_PORT) : undefined,
algodServer: process.env.ALGOD_SERVER,
algodToken: process.env.ALGOD_TOKEN,
disableWarnings: parsed.disable_warnings as boolean,
disableOverflowChecks: parsed.unsafe_disable_overflow_checks as boolean,
disableTypeScript: parsed.unsafe_disable_typescript as boolean,
srcPath: filename,
project,
cwd: process.cwd(),
};

const compilers = Compiler.compileAll(options);

compilers.forEach(async (compilerPromise) => {
const compiler = await compilerPromise;
Expand Down
Loading