Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serialization of objects for use in state #129

Open
joe-p opened this issue Mar 10, 2025 · 0 comments
Open

Support serialization of objects for use in state #129

joe-p opened this issue Mar 10, 2025 · 0 comments

Comments

@joe-p
Copy link
Contributor

joe-p commented Mar 10, 2025

Problem

PuyaTS does not currently support native objects in state

export type ListingKey = {
  owner: arc4.Address;
  asset: uint64;
  nonce: uint64;
};

export type ListingValue = {
  deposited: uint64;
  unitaryPrice: uint64;
  bidder: arc4.Address;
  bid: uint64;
  bidUnitaryPrice: uint64;
};

export default class DigitalMarketplace extends arc4.Contract {
  listings = BoxMap<ListingKey, ListingValue>({ keyPrefix: "listings" });

Results in errors such as

contracts/marketplace.algo.ts:300:5 error: Not Supported: Serializing object to bytes
                                            this.listings(key).value = {
                                            ^~~~~~~~~~~~~~~~~~
contracts/marketplace.algo.ts:32:3 error: lib.d.ts::object is not a valid type for storage
                                           listings = BoxMap<ListingKey, ListingValue>({ keyPrefix: "listings" });
                                           ^~~~~~~~
info: Compilation halted due to errors

Solution

Proposal

Automatically handle serialization of native objects in state

Pros and Cons

Easier TEALScript migration and more familiar to TypeScript developers

Dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant