From 96032161748e8500a1019e3399d8959fa030e2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=8B=E5=85=9A=20Lidang?= Date: Sun, 11 Feb 2024 20:27:12 -0600 Subject: [PATCH] update --- darc-js/src/SDK/runtime.ts | 4 +-- darc-js/src/SDK/transpiler.ts | 2 +- darc-js/src/darcjs.ts | 4 +-- darc-js/src/sdk.ts | 28 +++++++++++++++++++ .../tests/expression-test/expression-test.ts | 2 +- darc-js/tests/runtime-test/transpileAndRun.ts | 4 +-- .../runtime-test/transpiler-operator-test.ts | 4 +-- 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/darc-js/src/SDK/runtime.ts b/darc-js/src/SDK/runtime.ts index 863c898..1058ea8 100644 --- a/darc-js/src/SDK/runtime.ts +++ b/darc-js/src/SDK/runtime.ts @@ -2,7 +2,7 @@ import * as instructions from "./includes"; import { ethers, Contract } from 'ethers'; import { OperationStruct, OperationStructOutput, ProgramStruct } from "../types/basicTypes"; import * as DARC from "../DARC/DARC"; -import { transpiler } from "./transpiler"; +import { transpile } from "./transpiler"; /** @@ -65,7 +65,7 @@ export async function transpileAndRun( darcVersion: DARC.DARC_VERSION = DARC.DARC_VERSION.Latest, delegateToAddress?:string ) { - const compiledCode = transpiler(code); + const compiledCode = transpile(code); if (delegateToAddress) { await run(compiledCode, wallet, targetDARCAddress, darcVersion, delegateToAddress); } diff --git a/darc-js/src/SDK/transpiler.ts b/darc-js/src/SDK/transpiler.ts index 51bdd49..00e56ab 100644 --- a/darc-js/src/SDK/transpiler.ts +++ b/darc-js/src/SDK/transpiler.ts @@ -1,4 +1,4 @@ -export function transpiler(sourceCode: string): string { +export function transpile(sourceCode: string): string { // compile the source code with babel standalone const babel = require('@babel/standalone'); diff --git a/darc-js/src/darcjs.ts b/darc-js/src/darcjs.ts index 293f398..7a00689 100644 --- a/darc-js/src/darcjs.ts +++ b/darc-js/src/darcjs.ts @@ -1,5 +1,5 @@ import {deployDARC} from './deployDARC/deployDARC'; -import { transpiler } from './SDK/transpiler'; +import { transpile } from './SDK/transpiler'; import { DARC, InitParam } from './DARC/DARC'; import { darcBinary, DARCBinaryStruct, DARC_VERSION } from './darcBinary/darcBinary'; import { ethers } from 'ethers'; @@ -7,7 +7,7 @@ import {run} from './SDK/runtime'; export { deployDARC, - transpiler, + transpile, DARC, InitParam, darcBinary, diff --git a/darc-js/src/sdk.ts b/darc-js/src/sdk.ts index 7260a09..df7e27e 100644 --- a/darc-js/src/sdk.ts +++ b/darc-js/src/sdk.ts @@ -1,3 +1,27 @@ +/** + * Below are core darcjs + */ +import {deployDARC} from './deployDARC/deployDARC'; +import { transpile } from './SDK/transpiler'; +import { InitParam } from './DARC/DARC'; +import { darcBinary, DARCBinaryStruct, DARC_VERSION } from './darcBinary/darcBinary'; + +export { + deployDARC, + transpile, + DARC, + InitParam, + darcBinary, + DARCBinaryStruct, + DARC_VERSION, + ethers, +}; + +/** + * Below are core interpreter functions for the By-law Script + */ +export { transpileAndRun } from "./SDK/runtime"; + /** * Below are all necessary functions for the SDK. */ @@ -261,6 +285,10 @@ export function upgrade_to_the_latest(): OperationStruct { return operation; } + +/** + * Below are all condition nodes for composing plugins + */ export { batch_op_size_greater_than, batch_op_size_less_than, diff --git a/darc-js/tests/expression-test/expression-test.ts b/darc-js/tests/expression-test/expression-test.ts index 5570fe6..59bb14c 100644 --- a/darc-js/tests/expression-test/expression-test.ts +++ b/darc-js/tests/expression-test/expression-test.ts @@ -1,5 +1,5 @@ import {executeOperationList, operator_address_equals} from "../../src/sdk"; -import {run, deployDARC, DARC_VERSION} from '../../src/darcjs'; +import { deployDARC, DARC_VERSION} from '../../src/darcjs'; import { ethers, BigNumber } from 'ethers'; import * as DARC from '../../src/DARC/DARC'; import 'mocha'; diff --git a/darc-js/tests/runtime-test/transpileAndRun.ts b/darc-js/tests/runtime-test/transpileAndRun.ts index ae77a38..71c4c00 100644 --- a/darc-js/tests/runtime-test/transpileAndRun.ts +++ b/darc-js/tests/runtime-test/transpileAndRun.ts @@ -7,7 +7,7 @@ import { expect } from 'chai'; import { batch_add_and_enable_plugins, batch_mint_tokens, batch_create_token_classes } from "../../src/sdk"; import {or, node, and, expression} from "../../src/SDK/Node"; import { transpileAndRun } from "../../src/SDK/runtime"; -import { transpiler } from "../../src/darcjs"; +import { transpile } from "../../src/darcjs"; const programOperatorAddress = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"; @@ -36,7 +36,7 @@ function toBigIntArray(array: number[]): bigint[] { return bigIntArray; } -describe('transpiler and execution test', () => { +describe('transpile and execution test', () => { it ('should run the by-law script with expression node, logical operation node generated successfully', async () => { const darc_contract_address = await deployDARC(DARC_VERSION.Latest, signer); diff --git a/darc-js/tests/runtime-test/transpiler-operator-test.ts b/darc-js/tests/runtime-test/transpiler-operator-test.ts index 0d0e4f6..7e8371a 100644 --- a/darc-js/tests/runtime-test/transpiler-operator-test.ts +++ b/darc-js/tests/runtime-test/transpiler-operator-test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import 'mocha'; -import { transpiler } from '../../src/SDK/transpiler'; +import { transpile } from '../../src/SDK/transpiler'; import { Node } from '@babel/types'; describe('Operator Test', @@ -16,7 +16,7 @@ describe('Operator Test', `; - const transpiled_result = transpiler(code); + const transpiled_result = transpile(code); console.log(transpiled_result); expect(true).to.equal(true);