-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jer/fast-break' of github.com:dapperlabs/nba-smart-cont…
…racts into jer/fast-break
- Loading branch information
Showing
51 changed files
with
3,685 additions
and
2,109 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -1 +1 @@ | ||
* @joshuahannan | ||
*.cdc @dapperlabs/flow-smart-contracts |
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
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.idea | ||
flow.json | ||
flow.json | ||
/imports | ||
.vscode |
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
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
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
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
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
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
module github.com/dapperlabs/nba-smart-contracts/lib/go/contracts | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/kevinburke/go-bindata v3.22.0+incompatible | ||
github.com/stretchr/testify v1.7.1 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/rogpeppe/go-internal v1.8.0 // indirect | ||
github.com/stretchr/testify v1.7.1 | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
|
||
) | ||
|
||
replace github.com/dapperlabs/nba-smart-contracts/lib/go/contracts => ../contracts |
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
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,55 @@ | ||
package events | ||
|
||
import ( | ||
"fmt" | ||
"github.com/onflow/cadence" | ||
jsoncdc "github.com/onflow/cadence/encoding/json" | ||
) | ||
|
||
var ( | ||
MomentLocked = "TopShotLocking.MomentLocked" | ||
) | ||
|
||
type MomentLockedEvent interface { | ||
FlowID() uint64 | ||
Duration() cadence.UFix64 | ||
ExpiryTimestamp() cadence.UFix64 | ||
} | ||
|
||
type momentLockedEvent cadence.Event | ||
|
||
func (evt momentLockedEvent) FlowID() uint64 { | ||
return uint64(evt.Fields[0].(cadence.UInt64)) | ||
} | ||
|
||
func (evt momentLockedEvent) Duration() cadence.UFix64 { | ||
return evt.Fields[1].(cadence.UFix64) | ||
} | ||
|
||
func (evt momentLockedEvent) ExpiryTimestamp() cadence.UFix64 { | ||
return evt.Fields[2].(cadence.UFix64) | ||
} | ||
|
||
func (evt momentLockedEvent) validate() error { | ||
if evt.EventType.QualifiedIdentifier != MomentLocked { | ||
return fmt.Errorf("error validating event: event is not a valid moment locked event, expected type %s, got %s", | ||
MomentLocked, evt.EventType.QualifiedIdentifier) | ||
} | ||
return nil | ||
} | ||
|
||
var _ MomentLockedEvent = (*momentLockedEvent)(nil) | ||
|
||
func DecodeMomentLockedEvent(b []byte) (MomentLockedEvent, error) { | ||
value, err := jsoncdc.Decode(nil, b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
event := momentLockedEvent(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.