Skip to content

Commit

Permalink
Update handling of boxes & fix asset params
Browse files Browse the repository at this point in the history
  • Loading branch information
fergalwalsh committed Apr 25, 2024
1 parent da3f0aa commit 81af0c1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions algojig/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,15 @@ def update_global_state(self, app_id, state_delta):
self.global_states[app_id].update(state_delta)

def set_box(self, app_id, key, value):
if type(value) is not bytearray:
value = bytearray(value)
if app_id not in self.boxes:
self.boxes[app_id] = {}
self.boxes[app_id][key] = value
if key in self.boxes[app_id]:
# use slicing to mutate the existing object
self.boxes[app_id][key][:] = value[:]
else:
self.boxes[app_id][key] = value

def set_auth_addr(self, address, auth_addr):
self.accounts[address]['auth_addr'] = auth_addr
Expand Down Expand Up @@ -283,10 +289,10 @@ def write_accounts(self):
'e': asset.get('name', b''),
'f': asset.get('url', b''),
'g': asset.get('metadata_hash', b''),
'h': asset.get('manager', None),
'i': asset.get('reserve', None),
'j': asset.get('freeze', None),
'k': asset.get('clawback', None),
'h': decode_address(asset['manager']) if 'manager' in asset else None,
'i': decode_address(asset['reserve']) if 'reserve' in asset else None,
'j': decode_address(asset['freeze']) if 'freeze' in asset else None,
'k': decode_address(asset['clawback']) if 'clawback' in asset else None,
"y": AssetResourceFlag.CREATOR_AND_HOLDER if (b[0] or b[1]) else AssetResourceFlag.CREATOR,
})
q = 'INSERT INTO resources (addrid, aidx, data) VALUES (?, ?, ?)'
Expand Down

0 comments on commit 81af0c1

Please sign in to comment.