Skip to content

Commit 84fee20

Browse files
authored
Merge pull request #33 from algorandfoundation/fix/is-arc4
fix: use isArc4 static property to remove explicit version dependency on puya-ts
2 parents d90b5f6 + 10dd99d commit 84fee20

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

package-lock.json

Lines changed: 33 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"tslib": "^2.6.2"
6464
},
6565
"dependencies": {
66-
"@algorandfoundation/algorand-typescript": "^1.0.0-beta.4",
67-
"@algorandfoundation/puya-ts": "^1.0.0-beta.6",
66+
"@algorandfoundation/algorand-typescript": "^1.0.0-beta.6",
67+
"@algorandfoundation/puya-ts": "^1.0.0-beta.10",
6868
"elliptic": "^6.5.7",
6969
"js-sha256": "^0.11.0",
7070
"js-sha3": "^0.9.3",

src/subcontexts/contract-context.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +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+
161+
const result = (type as DeliberateAny as typeof BaseContract).isArc4
162+
if (result !== undefined && result !== null) {
163+
return result
164+
}
158165
const proto = Object.getPrototypeOf(type)
159166
if (proto === BaseContract) {
160167
return false
161168
} else if (proto === Contract) {
162169
return true
163-
} else if (proto === Object) {
164-
throw new Error('Cannot create a contract for class as it does not extend Contract or BaseContract')
170+
} else if (proto === null) {
171+
return false
165172
}
166173
return this.isArc4(proto)
167174
}

0 commit comments

Comments
 (0)