Skip to content

Commit

Permalink
Add download option for upgradeable Foundry package (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Mar 20, 2024
1 parent d33453b commit a594e07
Show file tree
Hide file tree
Showing 5 changed files with 834 additions and 84 deletions.
26 changes: 22 additions & 4 deletions packages/core/src/zip-foundry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ test.serial('erc20 full', async t => {
await runTest(c, t, opts);
});

test.serial('erc721 basic', async t => {
const opts: GenericOptions = { kind: 'ERC721', name: 'My Token', symbol: 'MTK'};
test.serial('erc20 uups, roles', async t => {
const opts: GenericOptions = { kind: 'ERC20', name: 'My Token', symbol: 'MTK', upgradeable: 'uups', access: 'roles' };
const c = buildERC20(opts);
await runTest(c, t, opts);
});

test.serial('erc721 uups, ownable', async t => {
const opts: GenericOptions = { kind: 'ERC721', name: 'My Token', symbol: 'MTK', upgradeable: 'uups', access: 'ownable' };
const c = buildERC721(opts);
await runTest(c, t, opts);
});
Expand All @@ -61,12 +67,24 @@ test.serial('erc1155 basic', async t => {
await runTest(c, t, opts);
});

test.serial('erc1155 transparent, ownable', async t => {
const opts: GenericOptions = { kind: 'ERC1155', name: 'My Token', uri: 'https://myuri/{id}', upgradeable: 'transparent', access: 'ownable' };
const c = buildERC1155(opts);
await runTest(c, t, opts);
});

test.serial('custom basic', async t => {
const opts: GenericOptions = { kind: 'Custom', name: 'My Contract' };
const c = buildCustom(opts);
await runTest(c, t, opts);
});

test.serial('custom transparent, managed', async t => {
const opts: GenericOptions = { kind: 'Custom', name: 'My Contract', upgradeable: 'transparent', access: 'managed' };
const c = buildCustom(opts);
await runTest(c, t, opts);
});

async function runTest(c: Contract, t: ExecutionContext<Context>, opts: GenericOptions) {
const zip = await zipFoundry(c, opts);

Expand Down Expand Up @@ -105,8 +123,8 @@ async function extractAndRunPackage(zip: JSZip, c: Contract, t: ExecutionContext

const setGitUser = 'git init && git config user.email "test@test.test" && git config user.name "Test"';
const setup = 'bash setup.sh';
const test = 'forge test';
const script = `forge script script/${c.name}.s.sol`;
const test = 'forge test' + (c.upgradeable ? ' --force' : '');
const script = `forge script script/${c.name}.s.sol` + (c.upgradeable ? ' --force' : '');

const exec = (cmd: string) => util.promisify(child.exec)(cmd, { env: { ...process.env, NO_COLOR: '' } });

Expand Down
Loading

0 comments on commit a594e07

Please sign in to comment.