Skip to content

remove NFT stuff#560

Merged
dessaya merged 12 commits intodevelopfrom
remove-nft-stuff
Apr 4, 2025
Merged

remove NFT stuff#560
dessaya merged 12 commits intodevelopfrom
remove-nft-stuff

Conversation

@dessaya
Copy link
Copy Markdown
Contributor

@dessaya dessaya commented Mar 26, 2025

No description provided.

@dessaya dessaya force-pushed the remove-nft-stuff branch from e3e7df4 to ffdb58f Compare April 3, 2025 16:53
@dessaya dessaya requested a review from lmoe April 3, 2025 16:55

type GetBalanceRequest struct {
Owner *iotago.Address
CoinType iotago.ObjectType // optional
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this ObjectType removed?

Wouldn't it make sense to keep a specific type for CoinTypes coming from the API, just to indicate it properly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the old type ObjectType = string with a more strict ObjectType struct {s string} to avoid subtle bugs where the string contains an invalid or non-canonical format.

Here I just replaced the argument type with string, so it keeps the functionality. I didn't remove it.

return err
}
// use ShortString to save space
e.WriteString(rt.ShortString())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the beginning of our first Alpha we had an issue that we stored CoinTypes as ShortString but compared them with FullName Type strings, which caused several problems in the accounting contract. I'm not sure what the actual solution was. If we do a length agnostic check, or if we always use short/full length strings.

Just want to point out that we should validate this carefully, so we don't sometimes store full and short length types, or compare them incorrectly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why I defined other related types as struct {s string} instead of just string. For now let's keep it like this (if the tests pass) and when we get time to refactor properly let's unify the types and make sure this bug cannot happen.

ObjectID: &data.ObjectID,
Options: &iotajsonrpc.IotaObjectDataOptions{ShowContent: true},
})
// for coins the "field name" is of type 0x1::ascii::String
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the case for only coins and nothing else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the key of the coins in the assets bag is the cointype converted to string, and for objects the key is the object ID.

🤷‍♂️

argB := iotago.Argument{NestedResult: &iotago.NestedResult{Cmd: *argBorrow.Result, Result: 1}}

for coinType, coinBalance := range assets.Coins {
for _, coinType := range slices.Sorted(slices.Values(maps.Keys(assets.Coins))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to sort the coins here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to make sure that the resulting PTB is deterministic.
Probably it's not needed, but I'm not sure.

Module: iscmove.AssetsBagModuleName,
Function: "take_asset",
TypeArguments: []iotago.TypeTag{assetsBag.Objects[id].TypeTag()},
Arguments: []iotago.Argument{argAssetsBag, ptb.MustPure(id)},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the object is deposit and withdraw in the same PTB, then ptb.MustPure(id) may cause error, because the same id will show up more than once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, should I replace it with ptb.MustForceSeparatePure ?

@dessaya dessaya merged commit 7c31ef1 into develop Apr 4, 2025
3 of 4 checks passed
@dessaya dessaya deleted the remove-nft-stuff branch April 4, 2025 11:27
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

Successfully merging this pull request may close these issues.

3 participants