-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from algorandfoundation/feat/extract-op-nuances
feat: Improve devex of `op.extract` by supporting 'extract to end' be…
- Loading branch information
Showing
17 changed files
with
15,188 additions
and
33 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { uint64 } from '@algorandfoundation/algorand-typescript' | ||
import { assert, BaseContract, Bytes } from '@algorandfoundation/algorand-typescript' | ||
import { extract } from '@algorandfoundation/algorand-typescript/op' | ||
|
||
export class ExtractBytesAlgo extends BaseContract { | ||
approvalProgram(): boolean { | ||
this.test(2, 0) | ||
return true | ||
} | ||
|
||
private test(two: uint64, zero: uint64) { | ||
assert(two === 2, 'Param two should be 2') | ||
assert(zero === 0, 'Param zero should be 0') | ||
const b = Bytes('abcdefg') | ||
assert(extract(b, 2) === Bytes('cdefg')) | ||
assert(extract(b, two) === Bytes('cdefg')) | ||
|
||
assert(extract(b, 2, 2) === Bytes('cd')) | ||
assert(extract(b, two, two) === Bytes('cd')) | ||
|
||
assert(extract(b, two, zero) === Bytes('')) | ||
} | ||
} |
Oops, something went wrong.