Skip to content

Commit b947137

Browse files
committed
consider unsafe-allow at contract level
1 parent f0acefb commit b947137

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.3.23 (2023-05-04)
4+
5+
- Switch AST resolver to faster implementation.
6+
- Consider unsafe-allow at contract level.
7+
38
## 0.3.22 (2023-04-26)
49

510
- Add `-W` option to skip `WithInit` generation.

src/utils/upgrades-overrides.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ContractDefinition } from 'solidity-ast';
22
import { Node } from 'solidity-ast/node';
3+
import { ASTResolver } from '../ast-resolver';
34
import { getConstructor } from '../solc/ast-utils';
45
import { execall } from '../utils/execall';
56

@@ -17,11 +18,22 @@ const errorKinds = [
1718

1819
type ValidationErrorKind = (typeof errorKinds)[number];
1920

20-
export function hasOverride(node: Node, override: ValidationErrorKind): boolean {
21-
return getOverrides(node).includes(override);
21+
export function hasOverride(node: Node, override: ValidationErrorKind, resolver: ASTResolver): boolean {
22+
return getOverrides(node, resolver).includes(override);
2223
}
2324

24-
export function getOverrides(node: Node): ValidationErrorKind[] {
25+
export function getOverrides(node: Node, resolver: ASTResolver): ValidationErrorKind[] {
26+
const overrides = getOwnOverrides(node);
27+
if ('scope' in node) {
28+
const contract = resolver.resolveContract(node.scope);
29+
if (contract) {
30+
overrides.push(...getOwnOverrides(contract));
31+
}
32+
}
33+
return overrides;
34+
}
35+
36+
function getOwnOverrides(node: Node): ValidationErrorKind[] {
2537
if ('documentation' in node) {
2638
const doc =
2739
typeof node.documentation === 'string' ? node.documentation : node.documentation?.text ?? '';

0 commit comments

Comments
 (0)