Skip to content

Commit 777faa0

Browse files
authored
Merge pull request #34 from algorandfoundation/fix/is-arc4
fix: throw error if the param being passed to ctx.contract.create function is not detected to be a contract
2 parents 84fee20 + 3793c4f commit 777faa0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/subcontexts/contract-context.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,20 @@ export class ContractContext {
155155
}
156156

157157
private isArc4<T extends BaseContract>(type: IConstructor<T>): boolean {
158-
// TODO: uncomment the following line once version puya-ts 1.0.0 is released
159-
// return (type as DeliberateAny as typeof BaseContract).isArc4 ?? false
160-
161158
const result = (type as DeliberateAny as typeof BaseContract).isArc4
162159
if (result !== undefined && result !== null) {
163160
return result
164161
}
162+
// TODO: uncomment the following line once version puya-ts 1.0.0 is released and delete the rest of the function
163+
// throw new internal.errors.CodeError('Cannot create a contract for class as it does not extend Contract or BaseContract')
164+
165165
const proto = Object.getPrototypeOf(type)
166166
if (proto === BaseContract) {
167167
return false
168168
} else if (proto === Contract) {
169169
return true
170-
} else if (proto === null) {
171-
return false
170+
} else if (proto === Object || proto === null) {
171+
throw new internal.errors.CodeError('Cannot create a contract for class as it does not extend Contract or BaseContract')
172172
}
173173
return this.isArc4(proto)
174174
}

0 commit comments

Comments
 (0)