-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add remix #163
Merged
jrkhan
merged 25 commits into
dapperlabs:feature/add-subeditions
from
dapperlabs:feat/add-remix
Oct 27, 2022
Merged
Add remix #163
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e2a65c4
add remix to contracts
anatoly256 d2c0c2c
add remix to transactions
anatoly256 0b57345
add remix to lib
anatoly256 2db2330
fix misprints
anatoly256 8eb6e28
add function to get moment's subedition
anatoly256 e256ec1
fix tests
anatoly256 a7c0307
fix tests
anatoly256 b3b30f7
refactor subEdition contract
anatoly256 41ba825
add subEdition tests
anatoly256 657413b
add new function to create subEdition resource
anatoly256 1b424e7
add documentation
anatoly256 959fc59
refactor SubeditionAdmin
anatoly256 cfbfb6d
add comments/transactions/tests
anatoly256 fb19870
add events
anatoly256 9452a2d
Revert spacings
anatoly256 c0aa841
Merge branch 'master' into feat/add-remix
anatoly256 247a860
Fix comments
anatoly256 5144246
use test abstractions in subedition_test.go
anatoly256 4cbdd70
fix comments
anatoly256 9e0735c
fix comments
anatoly256 7947542
add comment to SubeditionAdminStoragePath()
anatoly256 ab6f9c3
add subeditionId to MomentMinted event
anatoly256 71beb97
change SubeditionCreated event/add length check to MintMoment event
anatoly256 6472f17
change subeditionID to subeditionId
anatoly256 48ba382
Merge branch 'master' into feat/add-remix
anatoly256 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package events | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/onflow/cadence" | ||
jsoncdc "github.com/onflow/cadence/encoding/json" | ||
) | ||
|
||
var ( | ||
EventSubeditionCreated = "TopShot.SubeditionCreated" | ||
) | ||
|
||
type SubeditionCreatedEvent interface { | ||
Id() uint32 | ||
Name() string | ||
MetaData() map[interface{}]interface{} | ||
} | ||
|
||
type subeditionCreatedEvent cadence.Event | ||
|
||
func (evt subeditionCreatedEvent) Id() uint32 { | ||
return evt.Fields[0].(cadence.UInt32).ToGoValue().(uint32) | ||
} | ||
|
||
func (evt subeditionCreatedEvent) Name() string { | ||
return evt.Fields[1].(cadence.String).ToGoValue().(string) | ||
} | ||
|
||
func (evt subeditionCreatedEvent) MetaData() map[interface{}]interface{} { | ||
return evt.Fields[2].(cadence.Dictionary).ToGoValue().(map[interface{}]interface{}) | ||
} | ||
|
||
func (evt subeditionCreatedEvent) validate() error { | ||
if evt.EventType.QualifiedIdentifier != EventSubeditionCreated { | ||
return fmt.Errorf("error validating event: event is not a valid subedition created event, expected type %s, got %s", | ||
EventSubeditionCreated, evt.EventType.QualifiedIdentifier) | ||
} | ||
return nil | ||
} | ||
|
||
func DecodeSubeditionCreatedEvent(b []byte) (SubeditionCreatedEvent, error) { | ||
value, err := jsoncdc.Decode(nil, b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
event := subeditionCreatedEvent(value.(cadence.Event)) | ||
if err := event.validate(); err != nil { | ||
return nil, fmt.Errorf("error decoding event: %w", err) | ||
} | ||
return event, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package events | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/onflow/cadence" | ||
jsoncdc "github.com/onflow/cadence/encoding/json" | ||
) | ||
|
||
var ( | ||
EventSubeditionAddedToMoment = "TopShot.SubeditionAddedToMoment" | ||
) | ||
|
||
type SubeditionAddedToMomentEvent interface { | ||
MomentID() uint64 | ||
SubeditionID() uint32 | ||
} | ||
|
||
type subeditionAddedToMomentEvent cadence.Event | ||
|
||
func (evt subeditionAddedToMomentEvent) MomentID() uint64 { | ||
return evt.Fields[0].(cadence.UInt64).ToGoValue().(uint64) | ||
} | ||
|
||
func (evt subeditionAddedToMomentEvent) SubeditionID() uint32 { | ||
return evt.Fields[1].(cadence.UInt32).ToGoValue().(uint32) | ||
} | ||
|
||
func (evt subeditionAddedToMomentEvent) validate() error { | ||
if evt.EventType.QualifiedIdentifier != EventSubeditionAddedToMoment { | ||
return fmt.Errorf("error validating event: event is not a valid subedition added to moment event, expected type %s, got %s", | ||
EventSubeditionAddedToMoment, evt.EventType.QualifiedIdentifier) | ||
} | ||
return nil | ||
} | ||
|
||
func DecodeSubeditionAddedToMomentEvent(b []byte) (SubeditionAddedToMomentEvent, error) { | ||
value, err := jsoncdc.Decode(nil, b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
event := subeditionAddedToMomentEvent(value.(cadence.Event)) | ||
if err := event.validate(); err != nil { | ||
return nil, fmt.Errorf("error decoding event: %w", err) | ||
} | ||
return event, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It isn't clear to me what the ID represents, considering you use
subeditionID
in the next event. Does it represent the subedition ID? Shouldn't we also have the play and set IDs in the event?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.
Agree with consistent/more specific name for id.
In the current iteration, the subedition is intended to be reused across many sets/plays. (This will make it much easier to search for all 'diamond' moments if they share an id) -> so subedition created event will not have a set/play as the subedition itself does not have a set/play.
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.