contracts-wizard icon indicating copy to clipboard operation
contracts-wizard copied to clipboard

Add Cairo API for a general contract

Open ericglau opened this issue 3 years ago • 1 comments

Related to https://github.com/OpenZeppelin/contracts-wizard/issues/110 and https://github.com/OpenZeppelin/contracts-wizard/issues/82

Requested for https://github.com/onlydustxyz/generator-starknet/issues/28

Proposed API

New function:

function printGeneral(opts?: GeneralOptions): string

With the following interfaces:

interface GeneralOptions {
  name: string;
  access?: 'ownable' | false;
  upgradeable?: boolean;
  info?: {
    license?: string;
  };
  storageVars?: StorageVariable[];
}

interface StorageVariable {
  name: string;
  type: 'felt' | 'Uint256';
  view?: boolean;
  setInConstructor?: boolean;
}

Open questions

  • Feedback welcome on function or option names
  • Should the storage variables support arguments or multiple values? (this would increase complexity when posing the questions in the user interface (whether console or GUI))

ericglau avatar May 19 '22 18:05 ericglau

Related to #110, #112.

frangio avatar May 20 '22 21:05 frangio

This is supported through the custom contract type in the API.

Handling of custom storage variables is not included since storage variables are generic to the Cairo language, whereas Wizard is intended to help with usage of libraries.

ericglau avatar Sep 07 '22 14:09 ericglau