Skip to content

Commit

Permalink
Merge pull request #33 from algorandfoundation/fix/is-arc4
Browse files Browse the repository at this point in the history
fix: use isArc4 static property to remove explicit version dependency on puya-ts
  • Loading branch information
boblat authored Jan 16, 2025
2 parents d90b5f6 + 10dd99d commit 84fee20
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
41 changes: 33 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"tslib": "^2.6.2"
},
"dependencies": {
"@algorandfoundation/algorand-typescript": "^1.0.0-beta.4",
"@algorandfoundation/puya-ts": "^1.0.0-beta.6",
"@algorandfoundation/algorand-typescript": "^1.0.0-beta.6",
"@algorandfoundation/puya-ts": "^1.0.0-beta.10",
"elliptic": "^6.5.7",
"js-sha256": "^0.11.0",
"js-sha3": "^0.9.3",
Expand Down
11 changes: 9 additions & 2 deletions src/subcontexts/contract-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,20 @@ export class ContractContext {
}

private isArc4<T extends BaseContract>(type: IConstructor<T>): boolean {
// TODO: uncomment the following line once version puya-ts 1.0.0 is released
// return (type as DeliberateAny as typeof BaseContract).isArc4 ?? false

const result = (type as DeliberateAny as typeof BaseContract).isArc4
if (result !== undefined && result !== null) {
return result
}
const proto = Object.getPrototypeOf(type)
if (proto === BaseContract) {
return false
} else if (proto === Contract) {
return true
} else if (proto === Object) {
throw new Error('Cannot create a contract for class as it does not extend Contract or BaseContract')
} else if (proto === null) {
return false
}
return this.isArc4(proto)
}
Expand Down

0 comments on commit 84fee20

Please sign in to comment.