Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Feb 12, 2024
1 parent 620c5b3 commit 9603216
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions darc-js/src/SDK/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion darc-js/src/SDK/transpiler.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 2 additions & 2 deletions darc-js/src/darcjs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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';
import {run} from './SDK/runtime';

export {
deployDARC,
transpiler,
transpile,
DARC,
InitParam,
darcBinary,
Expand Down
28 changes: 28 additions & 0 deletions darc-js/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion darc-js/tests/expression-test/expression-test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions darc-js/tests/runtime-test/transpileAndRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions darc-js/tests/runtime-test/transpiler-operator-test.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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);
Expand Down

0 comments on commit 9603216

Please sign in to comment.