Skip to content

Commit

Permalink
0.11: Unrestricted tuples (#39)
Browse files Browse the repository at this point in the history
* array refactor WIP

* fix dynamicArrayElements WIP

* tuple refactor WIP

* working returnDynamicArrayFromTuple WIP

* replace err() with throw Error()

* extractDynamicTupleElement WIP

* tuple refactor WIP

* tuples: string -> bytes, custom types WIP

* support encoding strings in tuples WIP

* fix extractDynamicTupleElement WIP

* fix tuple string updates WIP

* fix objects and custom tuple types WIP

* fix static arrays of dynamic types WIP

* working non-nested tests WIP

* remove processStaticArrayElement WIP

* update_dynamic_tuple_element subroutine WIP

* reduce update_dynamic_tuple_element scratch usage WIP

* update_dynamic_head subroutine

* all tests passing

* fix dynamic array element access in tuples

* updateDynamicArrayInMiddleOfTuple

* update example clients

* add algokit to ci

* 0.11
  • Loading branch information
joe-p authored Apr 29, 2023
1 parent 09f1faa commit e10968e
Show file tree
Hide file tree
Showing 24 changed files with 12,813 additions and 8,749 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Run sandbox
run: git clone https://github.com/algorand/sandbox && ./sandbox/sandbox up -v dev
- name: Run algokit localnet
run: pipx install algokit && algokit localnet start

- name: Install modules
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion examples/arc75/arc75_client.ts

Large diffs are not rendered by default.

169 changes: 113 additions & 56 deletions examples/arc75/artifacts/ARC75.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,45 @@ addAppToWhiteList:

// examples/arc75/arc75.algo.ts:37
// whitelist: Whitelist = { account: this.txn.sender, boxIndex: boxIndex, arc: arc }
byte 0x
dup
store 0 // tuple head
store 1 // tuple tail
byte 0x0024
store 2 // head offset
load 0 // tuple head
txn Sender
concat
store 0 // tuple head
load 0 // tuple head
frame_dig -2 // boxIndex: uint16
concat
store 11 // static elements
byte 0x0024 // head end
store 8 // dynamic head
int 36
store 9 // dynamic head offset
byte 0x
store 10 // dynamic elements
store 0 // tuple head
load 0 // tuple head
load 2 // head offset
concat
store 0 // tuple head
frame_dig -1 // arc: bytes
dup
len
itob
extract 6 2
swap
concat
load 10 // dynamic elements
dup
len
load 2 // head offset
btoi
+
itob
extract 6 2
store 2 // head offset
load 1 // tuple tail
swap
concat
store 10 // dynamic elements
load 11 // static elements
load 8 // dynamic head
load 10 // dynamic elements
concat
store 1 // tuple tail
load 0 // tuple head
load 1 // tuple tail
concat
frame_bury -6 // whitelist: Whitelist

Expand Down Expand Up @@ -189,9 +203,10 @@ addAppToWhiteList:
if0_else:
// examples/arc75/arc75.algo.ts:42
// newWhitelist: uint64[] = [appID]
byte 0x0001
frame_dig -3 // appID: uint64
itob
byte 0x0001
swap
concat
frame_bury -7 // newWhitelist: uint64[]

Expand Down Expand Up @@ -245,31 +260,45 @@ setAppWhitelist:

// examples/arc75/arc75.algo.ts:59
// whitelist: Whitelist = { account: this.txn.sender, boxIndex: boxIndex, arc: arc }
byte 0x
dup
store 0 // tuple head
store 1 // tuple tail
byte 0x0024
store 2 // head offset
load 0 // tuple head
txn Sender
concat
store 0 // tuple head
load 0 // tuple head
frame_dig -2 // boxIndex: uint16
concat
store 11 // static elements
byte 0x0024 // head end
store 8 // dynamic head
int 36
store 9 // dynamic head offset
byte 0x
store 10 // dynamic elements
store 0 // tuple head
load 0 // tuple head
load 2 // head offset
concat
store 0 // tuple head
frame_dig -1 // arc: bytes
dup
len
itob
extract 6 2
swap
concat
load 10 // dynamic elements
dup
len
load 2 // head offset
btoi
+
itob
extract 6 2
store 2 // head offset
load 1 // tuple tail
swap
concat
store 10 // dynamic elements
load 11 // static elements
load 8 // dynamic head
load 10 // dynamic elements
concat
store 1 // tuple tail
load 0 // tuple head
load 1 // tuple tail
concat
frame_bury -5 // whitelist: Whitelist

Expand Down Expand Up @@ -350,31 +379,45 @@ deleteWhitelist:

// examples/arc75/arc75.algo.ts:81
// whitelist: Whitelist = { account: this.txn.sender, boxIndex: boxIndex, arc: arc }
byte 0x
dup
store 0 // tuple head
store 1 // tuple tail
byte 0x0024
store 2 // head offset
load 0 // tuple head
txn Sender
concat
store 0 // tuple head
load 0 // tuple head
frame_dig -2 // boxIndex: uint16
concat
store 11 // static elements
byte 0x0024 // head end
store 8 // dynamic head
int 36
store 9 // dynamic head offset
byte 0x
store 10 // dynamic elements
store 0 // tuple head
load 0 // tuple head
load 2 // head offset
concat
store 0 // tuple head
frame_dig -1 // arc: bytes
dup
len
itob
extract 6 2
swap
concat
load 10 // dynamic elements
dup
len
load 2 // head offset
btoi
+
itob
extract 6 2
store 2 // head offset
load 1 // tuple tail
swap
concat
store 10 // dynamic elements
load 11 // static elements
load 8 // dynamic head
load 10 // dynamic elements
concat
store 1 // tuple tail
load 0 // tuple head
load 1 // tuple tail
concat
frame_bury -4 // whitelist: Whitelist

Expand Down Expand Up @@ -425,31 +468,45 @@ deleteAppFromWhitelist:

// examples/arc75/arc75.algo.ts:98
// whitelist: Whitelist = { account: this.txn.sender, boxIndex: boxIndex, arc: arc }
byte 0x
dup
store 0 // tuple head
store 1 // tuple tail
byte 0x0024
store 2 // head offset
load 0 // tuple head
txn Sender
concat
store 0 // tuple head
load 0 // tuple head
frame_dig -2 // boxIndex: uint16
concat
store 11 // static elements
byte 0x0024 // head end
store 8 // dynamic head
int 36
store 9 // dynamic head offset
byte 0x
store 10 // dynamic elements
store 0 // tuple head
load 0 // tuple head
load 2 // head offset
concat
store 0 // tuple head
frame_dig -1 // arc: bytes
dup
len
itob
extract 6 2
swap
concat
load 10 // dynamic elements
dup
len
load 2 // head offset
btoi
+
itob
extract 6 2
store 2 // head offset
load 1 // tuple tail
swap
concat
store 10 // dynamic elements
load 11 // static elements
load 8 // dynamic head
load 10 // dynamic elements
concat
store 1 // tuple tail
load 0 // tuple head
load 1 // tuple tail
concat
frame_bury -6 // whitelist: Whitelist

Expand Down Expand Up @@ -521,10 +578,10 @@ deleteAppFromWhitelist:
// assert(spliced[0] === appID)
frame_dig -7 // spliced: uint64[]
int 0
int 8
*
int 8 // element length
* // element offset
int 2
+
+ // add two for length
int 8
extract3
btoi
Expand Down
2 changes: 1 addition & 1 deletion examples/arc75/artifacts/ARC75.json

Large diffs are not rendered by default.

Loading

0 comments on commit e10968e

Please sign in to comment.