Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Nov 28, 2023
1 parent fa383e9 commit b593868
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 150 deletions.
4 changes: 0 additions & 4 deletions packages/core-cairo/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { printERC20, defaults as erc20defaults, isAccessControlRequired as erc20
// import { printERC721, defaults as erc721defaults, isAccessControlRequired as erc721IsAccessControlRequired, ERC721Options } from './erc721';
// import { printERC1155, defaults as erc1155defaults, isAccessControlRequired as erc1155IsAccessControlRequired, ERC1155Options } from './erc1155';
// import { printCustom, defaults as customDefaults, isAccessControlRequired as customIsAccessControlRequired, CustomOptions } from './custom';
import { toUint256 } from './utils/uint256';

export interface WizardContractAPI<Options extends CommonOptions> {
/**
Expand Down Expand Up @@ -54,6 +53,3 @@ export const erc20: ERC20 = {
// defaults: customDefaults,
// isAccessControlRequired: customIsAccessControlRequired
// }
export const utils = {
toUint256
}
6 changes: 3 additions & 3 deletions packages/core-cairo/src/build-generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export function buildGeneric(opts: GenericOptions) {
// case 'Custom':
// return buildCustom(opts);

default:
const _: never = opts;
throw new Error('Unknown ERC');
// default:
// const _: never = opts;
// throw new Error('Unknown ERC');
}
}
102 changes: 51 additions & 51 deletions packages/core-cairo/src/contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
import test from 'ava';

import { BaseFunction, ContractBuilder } from './contract';
import { ContractFunction, ContractBuilder } from './contract';
import { printContract } from './print';

test('contract basics', t => {
const Foo = new ContractBuilder();
const Foo = new ContractBuilder("foo");
t.snapshot(printContract(Foo));
});

test('contract with constructor code', t => {
const Foo = new ContractBuilder();
const Foo = new ContractBuilder("foo");
Foo.addConstructorCode('someFunction()');
t.snapshot(printContract(Foo));
});

test('contract with constructor code with semicolon', t => {
const Foo = new ContractBuilder();
const Foo = new ContractBuilder("foo");
Foo.addConstructorCode('someFunction();');
t.snapshot(printContract(Foo));
});

test('contract with function code', t => {
const Foo = new ContractBuilder();
Foo.addFunctionCode('someFunction()', _otherFunction);
t.snapshot(printContract(Foo));
});
// test('contract with function code', t => {
// const Foo = new ContractBuilder("foo");
// Foo.addFunctionCode('someFunction()', _otherFunction);
// t.snapshot(printContract(Foo));
// });

test('contract with function code with semicolon', t => {
const Foo = new ContractBuilder();
Foo.addFunctionCode('someFunction();', _otherFunction);
t.snapshot(printContract(Foo));
});
// test('contract with function code with semicolon', t => {
// const Foo = new ContractBuilder();
// Foo.addFunctionCode('someFunction();', _otherFunction);
// t.snapshot(printContract(Foo));
// });

test('contract with initializer params', t => {
const Foo = new ContractBuilder();
Foo.addComponent(
someModule,
['param1'],
[],
true
);
t.snapshot(printContract(Foo));
});
// test('contract with initializer params', t => {
// const Foo = new ContractBuilder();
// Foo.addComponent(
// someModule,
// ['param1'],
// [],
// true
// );
// t.snapshot(printContract(Foo));
// });

test('contract with library call', t => {
const Foo = new ContractBuilder();
Foo.addComponent(
someModule,
[],
[],
false
);
Foo.addFunction(_libraryFunction);
t.snapshot(printContract(Foo));
});
// test('contract with library call', t => {
// const Foo = new ContractBuilder();
// Foo.addComponent(
// someModule,
// [],
// [],
// false
// );
// Foo.addFunction(_libraryFunction);
// t.snapshot(printContract(Foo));
// });

const someModule = {
name: 'SomeLibrary',
path: 'contracts/some/library',
useNamespace: true
};
// const someModule = {
// name: 'SomeLibrary',
// path: 'contracts/some/library',
// useNamespace: true
// };

const _otherFunction: BaseFunction = {
name: 'otherFunction',
kind: 'external',
args: [],
};
// const _otherFunction: BaseFunction = {
// name: 'otherFunction',
// kind: 'external',
// args: [],
// };

const _libraryFunction: BaseFunction = {
module: someModule,
name: 'libraryFunction',
kind: 'external',
args: [],
};
// const _libraryFunction: BaseFunction = {
// module: someModule,
// name: 'libraryFunction',
// kind: 'external',
// args: [],
// };
1 change: 0 additions & 1 deletion packages/core-cairo/src/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { OptionsError } from './error';
import { defineComponents } from './utils/define-components';
import { defaults as commonDefaults } from './common-options';
import { printContract } from './print';
import { importUint256, NumberTooLarge, toUint256 } from './utils/uint256';
// import { importGetCallerAddress } from './common-functions';

export const defaults: Required<ERC20Options> = {
Expand Down
File renamed without changes.
8 changes: 2 additions & 6 deletions packages/core-cairo/src/generate/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ const blueprint = {
name: ['MyToken'],
symbol: ['MTK'],
burnable: booleans,
snapshots: booleans,
pausable: booleans,
mintable: booleans,
permit: booleans,
votes: booleans,
flashmint: booleans,
safeAllowance: booleans,
premint: ['1'],
access: accessOptions,
upgradeable: upgradeableOptions,
info: infoOptions,
decimals: ['18']
info: infoOptions
};

export function* generateERC20Options(): Generator<Required<ERC20Options>> {
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions packages/core-cairo/src/generate/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from 'path';
import crypto from 'crypto';

import { generateERC20Options } from './erc20';
import { generateERC721Options } from './erc721';
import { generateCustomOptions } from './custom';
// import { generateERC721Options } from './erc721';
// import { generateCustomOptions } from './custom';
import { buildGeneric, GenericOptions } from '../build-generic';
import { printContract } from '../print';
import { OptionsError } from '../error';
Expand All @@ -18,13 +18,13 @@ export function* generateOptions(): Generator<GenericOptions> {
yield { kind: 'ERC20', ...kindOpts };
}

for (const kindOpts of generateERC721Options()) {
yield { kind: 'ERC721', ...kindOpts };
}
// for (const kindOpts of generateERC721Options()) {
// yield { kind: 'ERC721', ...kindOpts };
// }

for (const kindOpts of generateCustomOptions()) {
yield { kind: 'Custom', ...kindOpts };
}
// for (const kindOpts of generateCustomOptions()) {
// yield { kind: 'Custom', ...kindOpts };
// }
}

interface GeneratedContract {
Expand Down Expand Up @@ -62,7 +62,7 @@ function generateContractSubset(subset: Subset): GeneratedContract[] {
if (subset === 'all') {
return contracts;
} else {
const getParents = (c: GeneratedContract) => c.contract.components.map(p => p.module.path);
const getParents = (c: GeneratedContract) => c.contract.components.map(p => p.path);
return [
...findCover(contracts.filter(c => c.options.upgradeable), getParents),
...findCover(contracts.filter(c => !c.options.upgradeable), getParents),
Expand Down
2 changes: 1 addition & 1 deletion packages/core-cairo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export { sanitizeKind } from './kind';

export { contractsVersion, contractsVersionTag } from './utils/version';

export { erc20, utils } from './api';
export { erc20 } from './api';
2 changes: 0 additions & 2 deletions packages/core-cairo/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { getSelfArg } from './common-options';

export function printContract(contract: Contract): string {

console.log('printing contract', contract);

const fns = contract.functions.map(fn => printFunction(fn));

// const hasViews = fns.views.some(l => l.length > 0);
Expand Down
10 changes: 5 additions & 5 deletions packages/core-cairo/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import test from 'ava';

import { generateSources } from './generate/sources';
import type { GenericOptions } from './build-generic';
import { custom, erc20, erc721 } from './api';
import { /*custom,*/ erc20, /*erc721*/ } from './api';

function isAccessControlRequired(opts: GenericOptions) {
switch(opts.kind) {
case 'ERC20':
return erc20.isAccessControlRequired(opts);
case 'ERC721':
return erc721.isAccessControlRequired(opts);
case 'Custom':
return custom.isAccessControlRequired(opts);
// case 'ERC721':
// return erc721.isAccessControlRequired(opts);
// case 'Custom':
// return custom.isAccessControlRequired(opts);
default:
throw new Error("No such kind");
}
Expand Down
32 changes: 0 additions & 32 deletions packages/core-cairo/src/utils/uint256.test.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/core-cairo/src/utils/uint256.ts

This file was deleted.

0 comments on commit b593868

Please sign in to comment.