Skip to content

Commit

Permalink
fix: algopy.LocalState.get now works with account keyword argument
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-makerx committed Jan 16, 2025
1 parent a06b254 commit 0722493
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 143 deletions.
3 changes: 2 additions & 1 deletion examples/local_state/local_state_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def get_guaranteed_data(self, for_account: Account) -> Bytes:

@subroutine
def get_data_with_default(self, for_account: Account, default: Bytes) -> Bytes:
return self.local.get(for_account, default)
# offset contract use arguments without kwarg
return self.local.get(account=for_account, default=default)

@subroutine
def get_data_or_assert(self, for_account: Account) -> Bytes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sources": [
"../local_state_contract.py"
],
"mappings": ";;;;;;;;;;;;;;;;AAoBW;;AAAX;;;AACmB;;AACR;;AAAA;AAAA;;AAAA;;;AAAA;AAAiD;AAAjD;AAAA;;;AACQ;;AACR;;AAAX;;;AACmB;;AAEF;;;AAAT;;AACG;;AAAoB;AAApB;AAAX;;;AACe;;AAAU;;;;;;;;;;;;;;;;;;;;;AAAV;AAAf;;;AAC6C;;AAyB5B;AAAA;AAAA;AAAA;AAAA;AAEF;AAAA;AA2BJ;;AAAA;AA3B4C;AA2B5C;AAAA;AAAA;AA3BI;AAAP;AAgCG;;AAAA;AA9BoC;AA8BpC;AAAA;;AA9BH;AAmCG;AAAA;AAlCkC;AAkClC;AAAA;AAlCI;;AAAA;AAAP;AA9BQ;AAQG;;AAPF;;AAAU;;;;;;;;;;;;;;;;;;;;AAAV;AAAjB;;;AAC4C;;AAqCnB;AAAA;AAAA;AACjB;AAtCQ;;;;AACC;;AAAU;;;;;;;;;;;;;AAAV;AAAjB;;;AACiC;;AA6CrB;AAAJ;AA5CY;;;;;;;;;AAAJ;;;;AAEO;;AAEV;;AAAoB;;AAApB;AAAb;;;AACe;;AAAU;;;;;;;;;;AAAV;AAAf;;;AAC8B;;AAkCtB;AAlCkC;;;AAkClC;AA7BW;;AAJF;;AAAU;;;;;;;;;;;;;;;;;;;;;;;AAAV;AAAjB;;;AAC2D;;;AAAZ;;AAsBhC;AAAA;AAAA;AAAA;AAtBC;;;;AAEO;;AAGJ;",
"mappings": ";;;;;;;;;;;;;;;;AAoBW;;AAAX;;;AACmB;;AACR;;AAAA;AAAA;;AAAA;;;AAAA;AAAiD;AAAjD;AAAA;;;AACQ;;AACR;;AAAX;;;AACmB;;AAEF;;;AAAT;;AACG;;AAAoB;AAApB;AAAX;;;AACe;;AAAU;;;;;;;;;;;;;;;;;;;;;AAAV;AAAf;;;AAC6C;;AAyB5B;AAAA;AAAA;AAAA;AAAA;AAEF;AAAA;AA4BJ;;AAAA;AA5B4C;AA4B5C;AAAA;AAAA;AA5BI;AAAP;AAiCG;;AAAA;AA/BoC;AA+BpC;AAAA;;AA/BH;AAoCG;AAAA;AAnCkC;AAmClC;AAAA;AAnCI;;AAAA;AAAP;AA9BQ;AAQG;;AAPF;;AAAU;;;;;;;;;;;;;;;;;;;;AAAV;AAAjB;;;AAC4C;;AAsCnB;AAAA;AAAA;AACjB;AAvCQ;;;;AACC;;AAAU;;;;;;;;;;;;;AAAV;AAAjB;;;AACiC;;AA8CrB;AAAJ;AA7CY;;;;;;;;;AAAJ;;;;AAEO;;AAEV;;AAAoB;;AAApB;AAAb;;;AACe;;AAAU;;;;;;;;;;AAAV;AAAf;;;AAC8B;;AAmCtB;AAnCkC;;;AAmClC;AA9BW;;AAJF;;AAAU;;;;;;;;;;;;;;;;;;;;;;;AAAV;AAAjB;;;AAC2D;;;AAAZ;;AAuBhC;AAAA;AAAA;AAAA;AAvBC;;;;AAEO;;AAGJ;",
"op_pc_offset": 0,
"pc_events": {
"1": {
Expand Down
27 changes: 14 additions & 13 deletions examples/local_state/out/LocalStateContract.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ main_after_if_else@10:
// assert result.length == get_local_state_length(self.local, for_account)
dup
len
// local_state/local_state_contract.py:85
// local_state/local_state_contract.py:86
// return state[account].length
dig 2
intc_0 // 0
// local_state/local_state_contract.py:57-58
// # this just tests local state proxy can be passed around
// assert result.length == get_local_state_length(self.local, for_account)
bytec_0 // "local"
// local_state/local_state_contract.py:85
// local_state/local_state_contract.py:86
// return state[account].length
app_local_get_ex
assert // check LocalState exists for account
Expand All @@ -92,30 +92,30 @@ main_after_if_else@10:
// assert result.length == get_local_state_length(self.local, for_account)
==
assert
// local_state/local_state_contract.py:90
// local_state/local_state_contract.py:91
// return account in LocalState(Bytes, key=key)
dig 1
intc_0 // 0
// local_state/local_state_contract.py:59-60
// # tests for dynamic key
// assert local_bytes_exists(for_account, Bytes(b"local"))
bytec_0 // 0x6c6f63616c
// local_state/local_state_contract.py:90
// local_state/local_state_contract.py:91
// return account in LocalState(Bytes, key=key)
app_local_get_ex
bury 1
// local_state/local_state_contract.py:59-60
// # tests for dynamic key
// assert local_bytes_exists(for_account, Bytes(b"local"))
assert
// local_state/local_state_contract.py:95
// local_state/local_state_contract.py:96
// return LocalState(Bytes, key=key)[account]
swap
intc_0 // 0
// local_state/local_state_contract.py:61
// assert read_local_bytes(for_account, String("local")) == result
bytec_0 // "local"
// local_state/local_state_contract.py:95
// local_state/local_state_contract.py:96
// return LocalState(Bytes, key=key)[account]
app_local_get_ex
assert // check LocalState exists for account
Expand Down Expand Up @@ -144,12 +144,12 @@ main_else_body@13:
// local_state/local_state_contract.py:33
// log(self.get_data_or_assert(Txn.sender))
txn Sender
// local_state/local_state_contract.py:70
// local_state/local_state_contract.py:71
// result, exists = self.local.maybe(for_account)
intc_0 // 0
bytec_0 // "local"
app_local_get_ex
// local_state/local_state_contract.py:71
// local_state/local_state_contract.py:72
// assert exists, "no data for account"
assert // no data for account
// local_state/local_state_contract.py:33
Expand All @@ -167,7 +167,7 @@ main_else_body@15:
// local_state/local_state_contract.py:35
// self.delete_data(Txn.sender)
txn Sender
// local_state/local_state_contract.py:80
// local_state/local_state_contract.py:81
// del self.local[for_account]
bytec_0 // "local"
app_local_del
Expand Down Expand Up @@ -199,13 +199,13 @@ main_else_body@21:
// local_state/local_state_contract.py:42
// self.set_data(Txn.sender, Txn.application_args(1))
txn Sender
// local_state/local_state_contract.py:76
// local_state/local_state_contract.py:77
// self.local[for_account] = value
bytec_0 // "local"
// local_state/local_state_contract.py:42
// self.set_data(Txn.sender, Txn.application_args(1))
txna ApplicationArgs 1
// local_state/local_state_contract.py:76
// local_state/local_state_contract.py:77
// self.local[for_account] = value
app_local_put

Expand All @@ -226,8 +226,9 @@ main_else_body@24:
// log(self.get_data_with_default(Txn.sender, Txn.application_args(1)))
txna ApplicationArgs 1
txn Sender
// local_state/local_state_contract.py:66
// return self.local.get(for_account, default)
// local_state/local_state_contract.py:66-67
// # offset contract use arguments without kwarg
// return self.local.get(account=for_account, default=default)
intc_0 // 0
bytec_0 // "local"
app_local_get_ex
Expand Down

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ main_if_body@12:
// assert result.length == get_local_state_length(self.local, for_account)
l-load-copy result#0 0 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,result#0 (copy)
len (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1
// local_state/local_state_contract.py:85
// local_state/local_state_contract.py:86
// return state[account].length
l-load-copy for_account#0 2 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,for_account#0 (copy)
int 0 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,for_account#0 (copy),0
// local_state/local_state_contract.py:58
// assert result.length == get_local_state_length(self.local, for_account)
byte "local" (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,for_account#0 (copy),0,"local"
// local_state/local_state_contract.py:85
// local_state/local_state_contract.py:86
// return state[account].length
app_local_get_ex (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,maybe_value%0#0,maybe_exists%0#0
assert // check LocalState exists for account (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,maybe_value%0#0
Expand All @@ -105,14 +105,14 @@ main_if_body@12:
l-load tmp%0#4 1 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%0#1,tmp%0#4
== (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,tmp%2#1
assert (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0
// local_state/local_state_contract.py:90
// local_state/local_state_contract.py:91
// return account in LocalState(Bytes, key=key)
l-load-copy for_account#0 1 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,for_account#0 (copy)
int 0 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,for_account#0 (copy),0
// local_state/local_state_contract.py:60
// assert local_bytes_exists(for_account, Bytes(b"local"))
byte 0x6c6f63616c (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,for_account#0 (copy),0,0x6c6f63616c
// local_state/local_state_contract.py:90
// local_state/local_state_contract.py:91
// return account in LocalState(Bytes, key=key)
app_local_get_ex (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,maybe_value%0#0,maybe_exists%0#0
l-store maybe_exists%0#0 1 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,maybe_exists%0#0,maybe_value%0#0
Expand All @@ -121,14 +121,14 @@ main_if_body@12:
// assert local_bytes_exists(for_account, Bytes(b"local"))
l-load maybe_exists%0#0 0 (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0,maybe_exists%0#0
assert (𝕗) method#0,awst_tmp%0#0 | for_account#0,result#0
// local_state/local_state_contract.py:95
// local_state/local_state_contract.py:96
// return LocalState(Bytes, key=key)[account]
l-load for_account#0 1 (𝕗) method#0,awst_tmp%0#0 | result#0,for_account#0
int 0 (𝕗) method#0,awst_tmp%0#0 | result#0,for_account#0,0
// local_state/local_state_contract.py:61
// assert read_local_bytes(for_account, String("local")) == result
byte "local" (𝕗) method#0,awst_tmp%0#0 | result#0,for_account#0,0,"local"
// local_state/local_state_contract.py:95
// local_state/local_state_contract.py:96
// return LocalState(Bytes, key=key)[account]
app_local_get_ex (𝕗) method#0,awst_tmp%0#0 | result#0,maybe_value%0#0,maybe_exists%0#0
assert // check LocalState exists for account (𝕗) method#0,awst_tmp%0#0 | result#0,maybe_value%0#0
Expand Down Expand Up @@ -156,12 +156,12 @@ main_if_body@14:
// local_state/local_state_contract.py:33
// log(self.get_data_or_assert(Txn.sender))
txn Sender (𝕗) method#0,awst_tmp%0#0 | for_account#0
// local_state/local_state_contract.py:70
// local_state/local_state_contract.py:71
// result, exists = self.local.maybe(for_account)
int 0 (𝕗) method#0,awst_tmp%0#0 | for_account#0,0
byte "local" (𝕗) method#0,awst_tmp%0#0 | for_account#0,0,"local"
app_local_get_ex (𝕗) method#0,awst_tmp%0#0 | result#0,exists#0
// local_state/local_state_contract.py:71
// local_state/local_state_contract.py:72
// assert exists, "no data for account"
assert // no data for account (𝕗) method#0,awst_tmp%0#0 | result#0
// local_state/local_state_contract.py:33
Expand All @@ -182,7 +182,7 @@ main_if_body@16:
// local_state/local_state_contract.py:35
// self.delete_data(Txn.sender)
txn Sender (𝕗) method#0,awst_tmp%0#0 | for_account#0
// local_state/local_state_contract.py:80
// local_state/local_state_contract.py:81
// del self.local[for_account]
byte "local" (𝕗) method#0,awst_tmp%0#0 | for_account#0,"local"
app_local_del (𝕗) method#0,awst_tmp%0#0 |
Expand Down Expand Up @@ -227,7 +227,7 @@ main_if_body@23:
// self.set_data(Txn.sender, Txn.application_args(1))
txn Sender (𝕗) method#0,awst_tmp%0#0 | for_account#0
txna ApplicationArgs 1 (𝕗) method#0,awst_tmp%0#0 | for_account#0,value#0
// local_state/local_state_contract.py:76
// local_state/local_state_contract.py:77
// self.local[for_account] = value
l-load for_account#0 1 (𝕗) method#0,awst_tmp%0#0 | value#0,for_account#0
byte "local" (𝕗) method#0,awst_tmp%0#0 | value#0,for_account#0,"local"
Expand All @@ -248,8 +248,8 @@ main_if_body@25:
// log(self.get_data_with_default(Txn.sender, Txn.application_args(1)))
txn Sender (𝕗) method#0,awst_tmp%0#0 | for_account#0
txna ApplicationArgs 1 (𝕗) method#0,awst_tmp%0#0 | for_account#0,default#0
// local_state/local_state_contract.py:66
// return self.local.get(for_account, default)
// local_state/local_state_contract.py:67
// return self.local.get(account=for_account, default=default)
l-load for_account#0 1 (𝕗) method#0,awst_tmp%0#0 | default#0,for_account#0
int 0 (𝕗) method#0,awst_tmp%0#0 | default#0,for_account#0,0
byte "local" (𝕗) method#0,awst_tmp%0#0 | default#0,for_account#0,0,"local"
Expand Down
Loading

0 comments on commit 0722493

Please sign in to comment.