-
Notifications
You must be signed in to change notification settings - Fork 518
Afrz: ASA Global Freeze #6298
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
base: master
Are you sure you want to change the base?
Afrz: ASA Global Freeze #6298
Changes from 13 commits
e5725b8
d837ec2
d6a6e25
436d2c2
849f2d4
c4ea51a
1d1044d
e0954a4
7232431
7d41877
3e7d594
a4716ea
f8db258
4f19688
3af7cc0
e11abe8
b82ceae
d1bf5b1
7e6911a
20c3770
f121e8b
292a68f
592554d
d8f4bf5
78593ec
6cdd2b1
b5c5d5d
980bed3
09be117
f0d8ea7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,9 +33,10 @@ import ( | |||||
| // AssetHolding converts between basics.AssetHolding and model.AssetHolding | ||||||
| func AssetHolding(ah basics.AssetHolding, ai basics.AssetIndex) model.AssetHolding { | ||||||
| return model.AssetHolding{ | ||||||
| Amount: ah.Amount, | ||||||
| AssetID: uint64(ai), | ||||||
| IsFrozen: ah.Frozen, | ||||||
| Amount: ah.Amount, | ||||||
| AssetID: uint64(ai), | ||||||
| IsFrozen: ah.Frozen, | ||||||
| LastFreezeChange: ah.LastFreezeChange, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -255,6 +256,10 @@ func AccountToAccountData(a *model.Account) (basics.AccountData, error) { | |||||
| if ca.Params.DefaultFrozen != nil { | ||||||
| defaultFrozen = *ca.Params.DefaultFrozen | ||||||
| } | ||||||
| var lastGlobalFreeze uint64 | ||||||
| if ca.Params.LastGlobalFreeze != nil { | ||||||
| lastGlobalFreeze = *ca.Params.LastGlobalFreeze | ||||||
| } | ||||||
| var url string | ||||||
| if ca.Params.Url != nil { | ||||||
| url = *ca.Params.Url | ||||||
|
|
@@ -269,17 +274,18 @@ func AccountToAccountData(a *model.Account) (basics.AccountData, error) { | |||||
| } | ||||||
|
|
||||||
| assetParams[basics.AssetIndex(ca.Index)] = basics.AssetParams{ | ||||||
| Total: ca.Params.Total, | ||||||
| Decimals: uint32(ca.Params.Decimals), | ||||||
| DefaultFrozen: defaultFrozen, | ||||||
| UnitName: unitName, | ||||||
| AssetName: name, | ||||||
| URL: url, | ||||||
| MetadataHash: metadataHash, | ||||||
| Manager: manager, | ||||||
| Reserve: reserve, | ||||||
| Freeze: freeze, | ||||||
| Clawback: clawback, | ||||||
| Total: ca.Params.Total, | ||||||
| Decimals: uint32(ca.Params.Decimals), | ||||||
| DefaultFrozen: defaultFrozen, | ||||||
| LastGlobalFreeze: lastGlobalFreeze, | ||||||
| UnitName: unitName, | ||||||
| AssetName: name, | ||||||
| URL: url, | ||||||
| MetadataHash: metadataHash, | ||||||
| Manager: manager, | ||||||
| Reserve: reserve, | ||||||
| Freeze: freeze, | ||||||
| Clawback: clawback, | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -288,8 +294,9 @@ func AccountToAccountData(a *model.Account) (basics.AccountData, error) { | |||||
| assets = make(map[basics.AssetIndex]basics.AssetHolding, len(*a.Assets)) | ||||||
| for _, h := range *a.Assets { | ||||||
| assets[basics.AssetIndex(h.AssetID)] = basics.AssetHolding{ | ||||||
| Amount: h.Amount, | ||||||
| Frozen: h.IsFrozen, | ||||||
| Amount: h.Amount, | ||||||
| Frozen: h.IsFrozen, | ||||||
| LastFreezeChange: h.LastFreezeChange, | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -483,21 +490,23 @@ func AppLocalState(state basics.AppLocalState, appIdx basics.AppIndex) model.App | |||||
| // AssetParamsToAsset converts basics.AssetParams to model.Asset | ||||||
| func AssetParamsToAsset(creator string, idx basics.AssetIndex, params *basics.AssetParams) model.Asset { | ||||||
| frozen := params.DefaultFrozen | ||||||
| lastGlobalFreeze := params.LastGlobalFreeze | ||||||
| assetParams := model.AssetParams{ | ||||||
| Creator: creator, | ||||||
| Total: params.Total, | ||||||
| Decimals: uint64(params.Decimals), | ||||||
| DefaultFrozen: &frozen, | ||||||
| Name: omitEmpty(printableUTF8OrEmpty(params.AssetName)), | ||||||
| NameB64: sliceOrNil([]byte(params.AssetName)), | ||||||
| UnitName: omitEmpty(printableUTF8OrEmpty(params.UnitName)), | ||||||
| UnitNameB64: sliceOrNil([]byte(params.UnitName)), | ||||||
| Url: omitEmpty(printableUTF8OrEmpty(params.URL)), | ||||||
| UrlB64: sliceOrNil([]byte(params.URL)), | ||||||
| Clawback: addrOrNil(params.Clawback), | ||||||
| Freeze: addrOrNil(params.Freeze), | ||||||
| Manager: addrOrNil(params.Manager), | ||||||
| Reserve: addrOrNil(params.Reserve), | ||||||
| Creator: creator, | ||||||
| Total: params.Total, | ||||||
| Decimals: uint64(params.Decimals), | ||||||
| DefaultFrozen: &frozen, | ||||||
| LastGlobalFreeze: &lastGlobalFreeze, | ||||||
|
||||||
| LastGlobalFreeze: &lastGlobalFreeze, | |
| LastGlobalFreeze: omitEmpty(params.LastGlobalFreeze), |
I think DefaultFrozen: omitEmpty(params.DefaultFrozen) would also be an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, if you change DefaultFrozen: omitEmpty(params.DefaultFrozen) then the false is not omitted from the response. I don't understand why. It should be setting the value to nil when false, which I expect to get omitted. Anyway, don't do that.
But, assuming it has the behavior we want, it would still be nice to use omitEmpty on params.LastGlobalFreeze.
We'll need to extend rest-assets-endpoint.sh to have e2e tests of the new stuff either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies that we're not "lying" to REST APIs like we're doing to AVM code. We don't set
assetHolding.IsFrozenwhen the asset is globally frozen? I think we probably should, I don't see a good reason to treat them differently.We could add
assetHolding.IsLocallyFrozen, just as from AVM.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API now returns booleans, abstracting away the uint64 txncounter values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I forgot to mention, when retrieving an account it only includes their local frozen state. I would have to lookup all asset params for every asset they hold to change their frozen state with respect to the LastGlobalFreeze.