Skip to content

Commit

Permalink
Merge branch 'plugin-dev-planning'
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Dec 23, 2023
2 parents af6a878 + 77f903f commit f657bd2
Show file tree
Hide file tree
Showing 13 changed files with 1,528 additions and 1,447 deletions.
2 changes: 2 additions & 0 deletions darc-js/src/SDK/includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { objectMethod } from "@babel/types";

export let operationList: OperationStruct[] = [];

export let programNotes: string = "";

export function batch_mint_tokens(addressArray: string[], amountArray: bigint[], tokenClass: bigint[]) {
let operation = op_batch_mint_tokens(addressArray, amountArray, tokenClass);
operationList.push(operation);
Expand Down
3 changes: 2 additions & 1 deletion darc-js/src/SDK/opcodes/op_batch_create_token_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export function op_batch_create_token_class(
votingWeightArray,
dividendWeightArray
],
ADDRESS_2DARRAY: []
ADDRESS_2DARRAY: [],
BYTES: []
}
};
return operation;
Expand Down
3 changes: 2 additions & 1 deletion darc-js/src/SDK/opcodes/op_batch_mint_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function op_batch_mint_tokens(addressArray: string[], tokenClass: bigint[
],
ADDRESS_2DARRAY: [
addressArray
]
],
BYTES: []
}
};

Expand Down
8 changes: 5 additions & 3 deletions darc-js/src/SDK/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as DARC from "../DARC/DARC";
* @param targetDARCAddress The address of the DARC contract to be used
* @returns nothing
*/
export async function run(code:string, wallet:ethers.Wallet, targetDARCAddress:string, darcVersion: DARC.DARC_VERSION = DARC.DARC_VERSION.Test) {
export async function run(code:string, wallet:ethers.Wallet, targetDARCAddress:string, darcVersion: DARC.DARC_VERSION = DARC.DARC_VERSION.Latest) {
let include = '';
for (const key in instructions) {
include += `let ${key} = instructions.${key};\n`;
Expand All @@ -31,18 +31,20 @@ export async function run(code:string, wallet:ethers.Wallet, targetDARCAddress:s
// create the program
const program:ProgramStruct = {
programOperatorAddress: operatorAddress,
operations: resultList
operations: resultList,
notes: ""
};

// create the attached DARC
const attachedDARC = new DARC.DARC({
address: targetDARCAddress,
version: DARC.DARC_VERSION.Test,
version: darcVersion,
wallet: wallet,
});

await attachedDARC.entrance(program);

// after execution, clear the operation list
instructions.operationList.length = 0;
instructions.programNotes.replace(instructions.programNotes, '');
}
17 changes: 14 additions & 3 deletions darc-js/src/SDK/struct/basicTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import type {

type PromiseOrValue<T> = T | Promise<T>;


export type VotingRuleStruct = {
votingTokenClassList: PromiseOrValue<BigNumberish>[];
approvalThresholdPercentage: PromiseOrValue<BigNumberish>;
votingDurationInSeconds: PromiseOrValue<BigNumberish>;
executionPendingDurationInSeconds: PromiseOrValue<BigNumberish>;
isEnabled: PromiseOrValue<boolean>;
note: PromiseOrValue<string>;
notes: PromiseOrValue<string>;
bIsAbsoluteMajority: PromiseOrValue<boolean>;
};

Expand All @@ -38,7 +39,7 @@ export type VotingRuleStructOutput = [
votingDurationInSeconds: BigNumber;
executionPendingDurationInSeconds: BigNumber;
isEnabled: boolean;
note: string;
notes: string;
bIsAbsoluteMajority: boolean;
};

Expand Down Expand Up @@ -133,6 +134,7 @@ export type ParamStruct = {
PARAMETER_ARRAY: PromiseOrValue<BigNumberish>[];
UINT256_2DARRAY: PromiseOrValue<BigNumberish>[][];
ADDRESS_2DARRAY: PromiseOrValue<string>[][];
BYTES: PromiseOrValue<BytesLike>;
};

export type ParamStructOutput = [
Expand All @@ -144,7 +146,8 @@ export type ParamStructOutput = [
PluginStructOutput[],
number[],
BigNumber[][],
string[][]
string[][],
string
] & {
UINT256_ARRAY: BigNumber[];
ADDRESS_ARRAY: string[];
Expand All @@ -155,6 +158,7 @@ export type ParamStructOutput = [
PARAMETER_ARRAY: number[];
UINT256_2DARRAY: BigNumber[][];
ADDRESS_2DARRAY: string[][];
BYTES: string;
};

export type OperationStruct = {
Expand All @@ -172,4 +176,11 @@ export type OperationStructOutput = [string, number, ParamStructOutput] & {
export type ProgramStruct = {
programOperatorAddress: PromiseOrValue<string>;
operations: OperationStruct[];
notes: PromiseOrValue<string>;
};

export type ProgramStructOutput = [string, OperationStructOutput[], string] & {
programOperatorAddress: string;
operations: OperationStructOutput[];
notes: string;
};
Loading

0 comments on commit f657bd2

Please sign in to comment.