From b717ded62e9d649464b22d3c2ffce4ce53c1891b Mon Sep 17 00:00:00 2001 From: scc <66scc66@gmail.com> Date: Tue, 25 Jul 2023 11:33:24 +0000 Subject: [PATCH] test: add contract builder test interface, no impl --- .github/workflows/codeql.yml | 8 +++++++- packages/webui/src/ci/contract/builder.ts | 9 +++++++++ .../webui/src/ci/contract/test.contract.ts | 16 ++++++++++++++++ packages/webui/src/ci/contract/test.ts | 10 ++++++++++ packages/webui/src/ci/index.tsx | 18 ++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 packages/webui/src/ci/contract/builder.ts create mode 100644 packages/webui/src/ci/contract/test.contract.ts create mode 100644 packages/webui/src/ci/contract/test.ts diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index dbdd47b..43a3896 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,9 +14,15 @@ name: "CodeQL" on: push: branches: ["master"] + paths-ignore: + - "skboa" + - "node_modules" pull_request: # The branches below must be a subset of the branches above branches: ["master"] + paths-ignore: + - "skboa" + - "node_modules" schedule: - cron: "39 13 * * 0" @@ -32,7 +38,7 @@ jobs: strategy: fail-fast: false matrix: - language: ["javascript", "TypeScript"] + language: ["javascript"] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support diff --git a/packages/webui/src/ci/contract/builder.ts b/packages/webui/src/ci/contract/builder.ts new file mode 100644 index 0000000..f8789d0 --- /dev/null +++ b/packages/webui/src/ci/contract/builder.ts @@ -0,0 +1,9 @@ +import { buildCodeString } from '@trustack/contract_builder'; + +export const buildCode = async (): Promise => { + const codeString = await import('./test.contract.ts?raw'); + // console.log(codeString); + const { code } = await buildCodeString(codeString.default); + + return code; +}; diff --git a/packages/webui/src/ci/contract/test.contract.ts b/packages/webui/src/ci/contract/test.contract.ts new file mode 100644 index 0000000..fa825c1 --- /dev/null +++ b/packages/webui/src/ci/contract/test.contract.ts @@ -0,0 +1,16 @@ +import { BaseContract } from 'skchain'; + +export class TestContract extends BaseContract { + constructor() { + super(); + this.data = { + value: 10000000000000n, + }; + } + + data: { [key: string]: bigint } = {}; + + public getValue = (): bigint => { + return this.data.value; + }; +} diff --git a/packages/webui/src/ci/contract/test.ts b/packages/webui/src/ci/contract/test.ts new file mode 100644 index 0000000..85dcd0a --- /dev/null +++ b/packages/webui/src/ci/contract/test.ts @@ -0,0 +1,10 @@ +import { evalFunction } from 'skchain'; +import { buildCode } from './builder'; + +export const runBuildContractTest = async (): Promise => { + const code = await buildCode(); + // console.log(code); + // evalFunction(``); + // TODO: eval code to test + return true; +}; diff --git a/packages/webui/src/ci/index.tsx b/packages/webui/src/ci/index.tsx index 4688f9a..54818d9 100644 --- a/packages/webui/src/ci/index.tsx +++ b/packages/webui/src/ci/index.tsx @@ -1,11 +1,13 @@ import { Button } from 'antd'; import { useState } from 'react'; +import { runBuildContractTest } from './contract/test'; import { runContractTest, runSkvmTest, runTest } from './run'; export default function CiPage() { const [passed, setPass] = useState(false); const [skvmPassed, setSkvmPass] = useState(false); const [contractPassed, setContractPass] = useState(false); + const [contractBuildPassed, setContractBuildPass] = useState(false); return (
@@ -49,6 +51,22 @@ export default function CiPage() { {contractPassed.toString()}
+ +
+ + + {contractBuildPassed.toString()} + +
); }