Add:Pxiel Contract , tests and readme#6
Add:Pxiel Contract , tests and readme#6D45putspin wants to merge 5 commits intoHathorNetwork:masterfrom
Conversation
|
Can you please add a PR description with high-level functionality of the blueprint? |
blueprints/pxiel/__pycache__/tests_pxiel.cpython-312-pytest-9.0.2.pyc
Outdated
Show resolved
Hide resolved
| @public(allow_deposit=True) | ||
| def paint(self, ctx: Context, x: int, y: int, color: str) -> None: | ||
|
|
||
| action = ctx.get_single_action(HATHOR_TOKEN_UID) |
There was a problem hiding this comment.
Note: get_single_action gets a single action for the passed token, in this case HTR. This doesn't mean there aren't more actions for other tokens, which I think wasn't the intention here. Same for the other methods that use it.
There was a problem hiding this comment.
This is only informational. Changing it is not required for approval.
There was a problem hiding this comment.
Sorry could you elaborate more on this? We only use Htr
We should Let owner set the token ? is that what you mean?
There was a problem hiding this comment.
No, sorry for not being clear. What I meant is, the get_single_action method only checks that a single action exists for the token passed in its argument. So action = ctx.get_single_action(HATHOR_TOKEN_UID) asserts that there's only one action for HTR.
However, this doesn't mean there aren't other actions for other tokens in the transaction. For example, in you paint method, the user could deposit 1 HTR and 1 hUSDC, and it would success. The hUSDC balance would be added to the contract, but would be ignored by your code.
What you probably meant to do (I think), was to also assert that there's a single action across all tokens, and that it is HTR, so your code should be:
| action = ctx.get_single_action(HATHOR_TOKEN_UID) | |
| action = ctx.get_single_action(HATHOR_TOKEN_UID) | |
| assert len(ctx.actions) == 1, 'expected only one token' |
Let me know if you find this confusing, so we can take it into account in the documentation and future improvements to the API.
There was a problem hiding this comment.
oh, ok i got it , yeah probably better to add it to avoid user misuse
There was a problem hiding this comment.
You would also have to do it on the paint_batch and withdraw methods
done |
Co-authored-by: Gabriel Levcovitz <g.levcovitz@gmail.com>
|
The blueprint This approval DOES NOT include any review of the blueprint's business logic, correctness, or security. Hathor does not perform such assessments. Full responsibility for the blueprint's behavior and any resulting consequences rests solely with its author. |
Canvas Management
Customizable Grid: The canvas size and the per-pixel fee are defined at initialization.
Persistent State: Stores the color, owner, and timestamp of every painted pixel.
Batch Painting: Supports painting multiple pixels in a single transaction (up to 32) to optimize network fees and user experience.
Economy & Ownership
Fee Collection: Every "paint" action requires a deposit of HTR. These fees accumulate within the contract.
Admin Withdrawal: The blueprint owner (the address that initialized the contract) can withdraw the collected fees at any time.
Strict Validation: Includes checks for coordinate bounds, valid hex color formats (#RRGGBB), and sufficient fee deposits.