Skip to content

Commit

Permalink
Add guards for unhandled new contract kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
immrsd committed Jan 9, 2025
1 parent 17645fd commit f823667
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/core-cairo/src/generate/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ function generateContractSubset(subset: Subset, kind?: Kind): GeneratedContract[
case 'Governor':
case 'Custom':
return c.options.upgradeable === isUpgradeable;
default:
const _: never = c.options;
throw new Error('Unknown kind');
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions packages/core-cairo/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { generateSources, writeGeneratedSources } from './generate/sources';
import type { GenericOptions, KindedOptions } from './build-generic';
import { custom, erc20, erc721, erc1155 } from './api';


interface Context {
generatedSourcesPath: string
}
Expand Down Expand Up @@ -67,8 +66,8 @@ test('is access control required', async t => {
case 'Account':
case 'Governor':
case 'Vesting':
// These contracts have no acess control
return
// These contracts have no access control option
break;
case 'ERC20':
case 'ERC721':
case 'ERC1155':
Expand All @@ -80,6 +79,10 @@ test('is access control required', async t => {
t.notRegex(contract.source, regexOwnable, JSON.stringify(contract.options));
}
}
break;
default:
const _: never = contract.options;
throw new Error('Unknown kind');
}
}
});

0 comments on commit f823667

Please sign in to comment.