diff --git a/README.md b/README.md index fb37d2b6..f138c836 100644 --- a/README.md +++ b/README.md @@ -58,22 +58,18 @@ The first step for using any smart contract is deploying it to the blockchain, or emulator in our case. Do these commands in vscode 1. Start the emulator with the `Run emulator` vscode command. - 2. Open the `NonFungibleToken.cdc` file and the `TopShot.cdc` file. Feel free to read as much as you want to + 2. Open the `NonFungibleToken.cdc` file from the [flow-nft repo](https://github.com/onflow/flow-nft/blob/master/src/contracts/NonFungibleToken.cdc) and the `TopShot.cdc` file. Feel free to read as much as you want to familiarize yourself with the contract - 3. The Marketplace smart contract implements the fungible token interface in `fungible-token.cdc`, so you need - to open that first and click the `deploy contract to account 0x01` button - that appears above the `FlowToken` contract. This will deploy the interface definition and contract - to account 1. - 4. Run the `switch account` command from the vscode comman palette. Switch to account 2. - 5. In `NonFungibleToken.cdc`, click the `deploy contract to account` to deploy to account 2. - 6. Switch to account 3. - 6. In `topshot.cdc`, click the `deploy contract to account` button that appears over the - `TopShot` contract declaration to deploy to account 3. - -This deploys the contract code to account 3. It also runs the contracts + 3. In `NonFungibleToken.cdc`, click the `deploy contract to account` to deploy it. + 4. Switch to a different account + 5. In `TopShot.cdc`, make sure it imports `NonFungibleToken` from the account you deployed it to + 6. click the `deploy contract to account` button that appears over the + `TopShot` contract declaration to deploy it to a new account + +This deploys the contract code. It also runs the contracts `init` function, which initializes the contract storage variables, stores the `Collection` and `Admin` resources -in account storage, and stores references to `Collection`. +in account storage, and creates links to the `Collection`. As you can see, whenever we want to call a function, read a field, or use a type that is defined in a smart contract, we simply import @@ -133,7 +129,9 @@ is a list of events that can be emitted, and what each event means. ## Directory Structure -The directories here are organized into scripts and transactions. +The directories here are organized into contrats, scripts, and transactions. + +Contracts contain the source code for the topshot contracts that are deployed to Flow. Scripts contain read-only transactions to get information about the state of someones Collection or about the state of the TopShot contract. @@ -146,35 +144,13 @@ minting moments, and transfering moments. - `scripts/` : This contains all the read-only Cadence scripts that are used to read information from the smart contract or from a resource in account storage - - `collections/`: Used to read information about a user's Moment collection - - `market/`: Used to read information about the market smart contract and about a user's Moment sales. - - `plays/`: Used to read information related to play data and IDs. - - `sets/`: Used to read various information about set names and IDs - - `test/` : This contains special transactions and scripts that are used - to quickly test the functionality of the smart contracts. They are not all - working now and will be updated to be extensive when the contracts - are updated with the new storage interface changes. - `transactions/` : This directory contains all the state-changing transactions that are associated with the TopShot smart contracts. - - `collections/`: Transactions for a user to interact with their Moment collection - - `market/`: Transactions for users to buy and sell moments using - the market smart contract. - - `plays/`: Transactions for an Admin to add and modify play data and IDs. - - `sets/`: Transactions for an Admin to take all - the actions associated wit sets, like adding plays, minting moments, - locking sets, and more. -### Marketplace -The `topshot_market.cdc` contract allows users to create a marketplace object in their account to sell their moments. - -1. Make sure you have followed the steps to get topshot set up. -2. Deploy `fungible-token.cdc` to account 1 -3. Deploy `NonFungibleToken.cdc` to account 2 and `TopShot.cdc` to account 3. -4. Deploy `MarketTopShot.cdc` to account 4. Feel free to look at the various - fields and functions in the smart contract. +### Marketplace -There currently aren't many example transactions for the market but they will be added soon once we have a better idea of exactly how it will function. +The `MarketTopShot.cdc` contract allows users to create a marketplace object in their account to sell their moments. #### Events for Market-related actions @@ -182,15 +158,15 @@ There currently aren't many example transactions for the market but they will be Emitted when a user lists a moment for sale in their SaleCollection. -- `pub event PriceChanged(id: UInt64, newPrice: UFix64, seller: Address?)` +- `pub event MomentPriceChanged(id: UInt64, newPrice: UFix64, seller: Address?)` Emitted when a user changes the price of their moment. -- `pub event TokenPurchased(id: UInt64, price: UFix64, seller: Address?)` +- `pub event MomentPurchased(id: UInt64, price: UFix64, seller: Address?)` Emitted when a user purchases a moment that is for sale. -- `pub event SaleWithdrawn(id: UInt64, owner: Address?)` +- `pub event MomentWithdrawn(id: UInt64, owner: Address?)` Emitted when a seller withdraws their moment from their SaleCollection diff --git a/src/contracts/MarketTopShot.cdc b/contracts/MarketTopShot.cdc similarity index 100% rename from src/contracts/MarketTopShot.cdc rename to contracts/MarketTopShot.cdc diff --git a/src/contracts/TopShot.cdc b/contracts/TopShot.cdc similarity index 100% rename from src/contracts/TopShot.cdc rename to contracts/TopShot.cdc diff --git a/src/contracts/TopShotShardedCollection.cdc b/contracts/TopShotShardedCollection.cdc similarity index 100% rename from src/contracts/TopShotShardedCollection.cdc rename to contracts/TopShotShardedCollection.cdc diff --git a/src/contracts/TopShotShardedCollectionV1.cdc b/contracts/TopShotShardedCollectionV1.cdc similarity index 100% rename from src/contracts/TopShotShardedCollectionV1.cdc rename to contracts/TopShotShardedCollectionV1.cdc diff --git a/src/contracts/TopShotv1.cdc b/contracts/TopShotv1.cdc similarity index 100% rename from src/contracts/TopShotv1.cdc rename to contracts/TopShotv1.cdc diff --git a/src/contracts/TopshotAdminReceiver.cdc b/contracts/TopshotAdminReceiver.cdc similarity index 100% rename from src/contracts/TopshotAdminReceiver.cdc rename to contracts/TopshotAdminReceiver.cdc diff --git a/contracts/go.mod b/contracts/go.mod deleted file mode 100644 index db9fc04d..00000000 --- a/contracts/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module github.com/dapperlabs/nba-smart-contracts/contracts - -go 1.14 - -require ( - github.com/onflow/flow-ft v0.1.2 // indirect - github.com/onflow/flow-ft/contracts v0.1.3 // indirect - github.com/onflow/flow-go-sdk v0.4.0 - github.com/stretchr/testify v1.5.1 -) diff --git a/contracts/Makefile b/lib/go/contracts/Makefile similarity index 100% rename from contracts/Makefile rename to lib/go/contracts/Makefile diff --git a/contracts/contracts.go b/lib/go/contracts/contracts.go similarity index 94% rename from contracts/contracts.go rename to lib/go/contracts/contracts.go index 04826a41..c6611600 100644 --- a/contracts/contracts.go +++ b/lib/go/contracts/contracts.go @@ -1,11 +1,11 @@ package contracts -//go:generate go run github.com/kevinburke/go-bindata/go-bindata -prefix ../src/contracts -o internal/assets/assets.go -pkg assets -nometadata -nomemcopy ../src/contracts +//go:generate go run github.com/kevinburke/go-bindata/go-bindata -prefix ../../../contracts -o internal/assets/assets.go -pkg assets -nometadata -nomemcopy ../../../contracts import ( "strings" - "github.com/dapperlabs/nba-smart-contracts/contracts/internal/assets" + "github.com/dapperlabs/nba-smart-contracts/lib/go/contracts/internal/assets" ) const ( diff --git a/contracts/contracts_test.go b/lib/go/contracts/contracts_test.go similarity index 95% rename from contracts/contracts_test.go rename to lib/go/contracts/contracts_test.go index 37c8c97a..e115763e 100644 --- a/contracts/contracts_test.go +++ b/lib/go/contracts/contracts_test.go @@ -6,7 +6,7 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/stretchr/testify/assert" - "github.com/dapperlabs/nba-smart-contracts/contracts" + "github.com/dapperlabs/nba-smart-contracts/lib/go/contracts" ) var addrA = flow.HexToAddress("0A") diff --git a/lib/go/contracts/go.mod b/lib/go/contracts/go.mod new file mode 100644 index 00000000..b363adb3 --- /dev/null +++ b/lib/go/contracts/go.mod @@ -0,0 +1,13 @@ +module github.com/dapperlabs/nba-smart-contracts/lib/go/contracts + +go 1.14 + +require ( + github.com/dapperlabs/nba-smart-contracts/contracts v0.1.9 + github.com/onflow/flow-ft v0.1.2 // indirect + github.com/onflow/flow-ft/contracts v0.1.3 // indirect + github.com/onflow/flow-go-sdk v0.4.0 + github.com/stretchr/testify v1.5.1 +) + +replace github.com/dapperlabs/nba-smart-contracts/lib/go/contracts => ../contracts diff --git a/contracts/go.sum b/lib/go/contracts/go.sum similarity index 98% rename from contracts/go.sum rename to lib/go/contracts/go.sum index bba49007..6a155f45 100644 --- a/contracts/go.sum +++ b/lib/go/contracts/go.sum @@ -39,6 +39,9 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/dapperlabs/nba-smart-contracts v0.1.4 h1:DKtQ1olSEdrKI91fJiIKM6DtU/58NXPrkNfATFEIllw= +github.com/dapperlabs/nba-smart-contracts/contracts v0.1.9 h1:4YGqDeEU/pRD/k3q6YlbIUrEyLfxBRnFgp/CDbm3LNE= +github.com/dapperlabs/nba-smart-contracts/contracts v0.1.9/go.mod h1:IfJM8GfN/DiN39E0B8VZE/nlKe/ITUlASFUa1UEWDRY= github.com/dapperlabs/nba-smart-contracts/templates v0.1.6 h1:QPbM2ElXUno5vKabSprwLMimvaWrrzAqwR9j6Gx8UqA= github.com/dapperlabs/nba-smart-contracts/templates v0.1.6/go.mod h1:fnX9SVlV+1pguQZ5wNMP8Tm0aRSkbaP6pv6iOEJdR0c= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/contracts/internal/assets/assets.go b/lib/go/contracts/internal/assets/assets.go similarity index 99% rename from contracts/internal/assets/assets.go rename to lib/go/contracts/internal/assets/assets.go index 47fac2b9..0405a408 100644 --- a/contracts/internal/assets/assets.go +++ b/lib/go/contracts/internal/assets/assets.go @@ -1,11 +1,11 @@ // Code generated by go-bindata. DO NOT EDIT. // sources: -// ../src/contracts/MarketTopShot.cdc (11.083kB) -// ../src/contracts/TopShot.cdc (32.027kB) -// ../src/contracts/TopShotShardedCollection.cdc (6.848kB) -// ../src/contracts/TopShotShardedCollectionV1.cdc (6.371kB) -// ../src/contracts/TopShotv1.cdc (26.334kB) -// ../src/contracts/TopshotAdminReceiver.cdc (952B) +// ../../../contracts/MarketTopShot.cdc (11.083kB) +// ../../../contracts/TopShot.cdc (32.027kB) +// ../../../contracts/TopShotShardedCollection.cdc (6.848kB) +// ../../../contracts/TopShotShardedCollectionV1.cdc (6.371kB) +// ../../../contracts/TopShotv1.cdc (26.334kB) +// ../../../contracts/TopshotAdminReceiver.cdc (952B) package assets diff --git a/events/deposit.go b/lib/go/events/deposit.go similarity index 100% rename from events/deposit.go rename to lib/go/events/deposit.go diff --git a/events/go.mod b/lib/go/events/go.mod similarity index 59% rename from events/go.mod rename to lib/go/events/go.mod index 93d45e12..b7a54a0c 100644 --- a/events/go.mod +++ b/lib/go/events/go.mod @@ -1,4 +1,4 @@ -module github.com/dapperlabs/nba-smart-contracts/events +module github.com/dapperlabs/nba-smart-contracts/lib/go/events go 1.14 diff --git a/events/go.sum b/lib/go/events/go.sum similarity index 100% rename from events/go.sum rename to lib/go/events/go.sum diff --git a/events/moment.go b/lib/go/events/moment.go similarity index 100% rename from events/moment.go rename to lib/go/events/moment.go diff --git a/events/play.go b/lib/go/events/play.go similarity index 100% rename from events/play.go rename to lib/go/events/play.go diff --git a/events/set.go b/lib/go/events/set.go similarity index 100% rename from events/set.go rename to lib/go/events/set.go diff --git a/events/set_play.go b/lib/go/events/set_play.go similarity index 100% rename from events/set_play.go rename to lib/go/events/set_play.go diff --git a/events/withdraw.go b/lib/go/events/withdraw.go similarity index 100% rename from events/withdraw.go rename to lib/go/events/withdraw.go diff --git a/lib/go/templates/Makefile b/lib/go/templates/Makefile new file mode 100644 index 00000000..6cd994a9 --- /dev/null +++ b/lib/go/templates/Makefile @@ -0,0 +1,14 @@ +.PHONY: test +test: + go test ./... + +.PHONY: generate +generate: + go generate + +.PHONY: check-generated +check-generated: + git diff --exit-code + +.PHONY: ci +ci: generate check-generated test \ No newline at end of file diff --git a/templates/data/play_metadata.go b/lib/go/templates/data/play_metadata.go similarity index 100% rename from templates/data/play_metadata.go rename to lib/go/templates/data/play_metadata.go diff --git a/templates/data/set_metadata.go b/lib/go/templates/data/set_metadata.go similarity index 100% rename from templates/data/set_metadata.go rename to lib/go/templates/data/set_metadata.go diff --git a/lib/go/templates/go.mod b/lib/go/templates/go.mod new file mode 100644 index 00000000..f02c2c04 --- /dev/null +++ b/lib/go/templates/go.mod @@ -0,0 +1,20 @@ +module github.com/dapperlabs/nba-smart-contracts/lib/go/templates + +go 1.14 + +require ( + github.com/dapperlabs/nba-smart-contracts/templates v0.1.10 + github.com/ethereum/go-ethereum v1.9.13 // indirect + github.com/kevinburke/go-bindata v3.21.0+incompatible // indirect + github.com/onflow/cadence v0.4.0 // indirect + github.com/onflow/flow-go-sdk v0.4.0 + github.com/pkg/errors v0.9.1 // indirect + github.com/stretchr/testify v1.5.1 + golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 // indirect + golang.org/x/lint v0.0.0-20200130185559-910be7a94367 // indirect + golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect + golang.org/x/tools v0.0.0-20200323144430-8dcfad9e016e // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect +) + +replace github.com/dapperlabs/nba-smart-contracts/lib/go/templates => ../templates diff --git a/templates/go.sum b/lib/go/templates/go.sum similarity index 87% rename from templates/go.sum rename to lib/go/templates/go.sum index 1072106a..638c4a00 100644 --- a/templates/go.sum +++ b/lib/go/templates/go.sum @@ -24,6 +24,7 @@ github.com/antlr/antlr4 v0.0.0-20191217191749-ff67971f8580/go.mod h1:T7PbCXFs94r github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f h1:0cEys61Sr2hUBEXfNV8eyQP01oZuBgoMeHunebPirK8= github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y= github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= +github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/c-bata/go-prompt v0.2.3/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= @@ -36,6 +37,9 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/dapperlabs/nba-smart-contracts v0.1.4 h1:DKtQ1olSEdrKI91fJiIKM6DtU/58NXPrkNfATFEIllw= +github.com/dapperlabs/nba-smart-contracts/templates v0.1.10 h1:JGcIrgbQMaKMGq4nBYbcKyBKcQKLtSxYqt/4BSSDUcU= +github.com/dapperlabs/nba-smart-contracts/templates v0.1.10/go.mod h1:fnX9SVlV+1pguQZ5wNMP8Tm0aRSkbaP6pv6iOEJdR0c= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -43,7 +47,9 @@ github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVz github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -51,6 +57,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.9.9 h1:jnoBvjH8aMH++iH14XmiJdAsnRcmZUM+B5fsnEZBVE0= github.com/ethereum/go-ethereum v1.9.9/go.mod h1:a9TqabFudpDu1nucId+k9S8R9whYaHnGBLKFouA5EAo= +github.com/ethereum/go-ethereum v1.9.13 h1:rOPqjSngvs1VSYH2H+PMPiWt4VEulvNRbFgqiGqJM3E= +github.com/ethereum/go-ethereum v1.9.13/go.mod h1:qwN9d1GLyDh0N7Ab8bMGd0H9knaji2jOBm2RrMGjXls= github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -60,6 +68,7 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.5 h1:AKODKU3pDH1RzZzm6YZu77YWtEAq6uh1rLIAQlay2qc= github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= @@ -82,8 +91,11 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/kevinburke/go-bindata v3.21.0+incompatible h1:baK7hwFJDlAHrOqmE9U3u8tow1Uc5ihN9E/b7djcK2g= +github.com/kevinburke/go-bindata v3.21.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -116,6 +128,8 @@ github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXW github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onflow/cadence v0.4.0-beta1 h1:0f4CMnddT++5OYY53OPFuv5JTb85qDg/nygLV4Bk3Z8= github.com/onflow/cadence v0.4.0-beta1/go.mod h1:gaPtSctdMzT5NAoJgzsRuwUkdgRswVHsRXFNNmCTn3I= +github.com/onflow/cadence v0.4.0 h1:oAKY/HclZZhc5wJgJwdPjWXJuC5IjuuHHVAAq3S7AHI= +github.com/onflow/cadence v0.4.0/go.mod h1:gaPtSctdMzT5NAoJgzsRuwUkdgRswVHsRXFNNmCTn3I= github.com/onflow/flow-go-sdk v0.4.0 h1:ZNEE8HQ6xTyr4+RmlxZ2+U/BjKtQDsAB54I+D8AJpZA= github.com/onflow/flow-go-sdk v0.4.0/go.mod h1:MHn8oQCkBNcl2rXdYSm9VYYK4ogwEpyrdM/XK/czdlM= github.com/onflow/flow/protobuf/go/flow v0.1.5-0.20200601215056-34a11def1d6b/go.mod h1:kRugbzZjwQqvevJhrnnCFMJZNmoSJmxlKt6hTGXZojM= @@ -128,6 +142,8 @@ github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssy github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -168,15 +184,23 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 h1:Q7tZBpemrlsc2I7IyODzhtallWRSm4Q0d09pL6XbQtU= golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= +golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -185,6 +209,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -202,6 +228,8 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -212,7 +240,11 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200323144430-8dcfad9e016e/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -230,6 +262,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190213234257-ec84240a7772/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= +gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200316214253-d7b0ff38cac9/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= @@ -237,6 +270,8 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go new file mode 100644 index 00000000..e45f941c --- /dev/null +++ b/lib/go/templates/internal/assets/assets.go @@ -0,0 +1,298 @@ +// Code generated by go-bindata. DO NOT EDIT. +// sources: +// ../../../scripts/read_currentSeries.cdc (230B) +// ../../../scripts/read_totalSupply.cdc (258B) + +package assets + +import ( + "bytes" + "compress/gzip" + "crypto/sha256" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data, name string) ([]byte, error) { + gz, err := gzip.NewReader(strings.NewReader(data)) + if err != nil { + return nil, fmt.Errorf("read %q: %w", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + + if err != nil { + return nil, fmt.Errorf("read %q: %w", name, err) + } + + clErr := gz.Close() + if clErr != nil { + return nil, clErr + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo + digest [sha256.Size]byte +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _read_currentseriesCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\xcd\x3d\x0e\x83\x30\x0c\x05\xe0\x3d\xa7\x78\x23\x2c\x05\x95\xad\x37\xe8\x0c\x3d\x40\x08\xa6\x44\x22\x4e\xe4\x38\x52\xa5\xaa\x77\xaf\xf8\xe9\x56\x8f\xb6\xdf\xf7\x7c\x48\x51\x14\x43\x4c\xfd\x12\x15\xb3\xc4\x80\xf6\xd5\x76\xc6\x34\x0d\x86\xc5\x67\x64\x27\x3e\x29\x84\xec\x94\xa1\x0b\xc1\x15\x11\x62\x45\x26\xf1\x94\x8f\xc8\xb6\xff\x19\x2e\xb2\x8a\x75\x0a\xcb\x13\x36\x46\x48\x8b\xf0\x16\xb6\x0a\x2e\x61\x24\x81\xc6\xc3\xb2\xeb\x4a\x62\x52\x19\x31\x17\x46\xb0\x9e\xab\xfa\x86\xc7\x9d\xb5\xbb\xe2\x6d\x00\x60\x8d\xcf\xea\xb4\x2f\x67\x77\xbf\x57\xd7\xfb\xf9\xd0\xf1\xf7\xc3\x7c\xcc\x3e\xdf\x00\x00\x00\xff\xff\x77\x22\xd3\x4c\xe6\x00\x00\x00" + +func read_currentseriesCdcBytes() ([]byte, error) { + return bindataRead( + _read_currentseriesCdc, + "read_currentSeries.cdc", + ) +} + +func read_currentseriesCdc() (*asset, error) { + bytes, err := read_currentseriesCdcBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "read_currentSeries.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb7, 0x7d, 0x44, 0xc7, 0xa0, 0x95, 0x92, 0x32, 0xf1, 0x2f, 0xfd, 0xc4, 0xc6, 0xd0, 0x96, 0x25, 0xc3, 0xd, 0x43, 0x2f, 0xb4, 0xb1, 0x9a, 0x20, 0x1e, 0x91, 0x84, 0xec, 0x5, 0xde, 0xac, 0x89}} + return a, nil +} + +var _read_totalsupplyCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\xcd\x3d\x4e\x04\x31\x0c\xc5\xf1\x3e\xa7\x78\xe5\x6e\xc3\xae\x04\xa2\xe0\x06\xd4\x33\x1c\xc0\x93\xf1\x90\x48\x89\x1d\x79\x1c\x04\x42\xdc\x1d\xcd\x07\x1d\x6e\xff\xf2\xef\xe5\xda\xd4\x1c\xa3\xb6\x21\xa9\x63\x31\xad\xb8\x7f\xde\x1f\x43\xb8\xdd\x30\xa6\xbc\x62\x8d\x96\x9b\xc3\x98\xe6\x15\x9e\x18\xb1\x9b\xb1\x38\xa4\xd7\x89\x0d\xba\xa0\x6a\x65\xf1\xad\x92\x23\xd1\x07\x63\x62\x16\xd4\x2c\xce\xf3\x06\xed\xec\xf6\xfb\xb7\x13\x55\xdc\x28\x3a\x48\x66\x18\x7b\x37\x39\xdf\x4f\xd5\xf5\xd8\xa2\x52\xd8\x42\xeb\x13\x96\x2e\xa8\x94\xe5\x72\x7d\xc1\xdb\xab\xf8\xf3\x13\xbe\x03\x00\x14\x7d\xbf\x9c\xee\x83\xab\x53\x19\x7a\x6b\xe5\xeb\xba\xc7\xc3\xc6\x3f\x3d\xfc\x84\xfd\x7e\x03\x00\x00\xff\xff\x0f\x27\xe4\x25\x02\x01\x00\x00" + +func read_totalsupplyCdcBytes() ([]byte, error) { + return bindataRead( + _read_totalsupplyCdc, + "read_totalSupply.cdc", + ) +} + +func read_totalsupplyCdc() (*asset, error) { + bytes, err := read_totalsupplyCdcBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "read_totalSupply.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xba, 0xec, 0x3, 0x79, 0x19, 0x84, 0x56, 0xce, 0x47, 0x9e, 0xcc, 0xa1, 0x36, 0xcd, 0x1, 0xd9, 0xea, 0x75, 0xf4, 0x14, 0x78, 0xc2, 0xf5, 0x7a, 0x17, 0x65, 0x8, 0xc1, 0xb3, 0xa, 0xda, 0x16}} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// AssetString returns the asset contents as a string (instead of a []byte). +func AssetString(name string) (string, error) { + data, err := Asset(name) + return string(data), err +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// MustAssetString is like AssetString but panics when Asset would return an +// error. It simplifies safe initialization of global variables. +func MustAssetString(name string) string { + return string(MustAsset(name)) +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetDigest returns the digest of the file with the given name. It returns an +// error if the asset could not be found or the digest could not be loaded. +func AssetDigest(name string) ([sha256.Size]byte, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err) + } + return a.digest, nil + } + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name) +} + +// Digests returns a map of all known files and their checksums. +func Digests() (map[string][sha256.Size]byte, error) { + mp := make(map[string][sha256.Size]byte, len(_bindata)) + for name := range _bindata { + a, err := _bindata[name]() + if err != nil { + return nil, err + } + mp[name] = a.digest + } + return mp, nil +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "read_currentSeries.cdc": read_currentseriesCdc, + "read_totalSupply.cdc": read_totalsupplyCdc, +} + +// AssetDebug is true if the assets were built with the debug flag enabled. +const AssetDebug = false + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"}, +// AssetDir("data/img") would return []string{"a.png", "b.png"}, +// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + canonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(canonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "read_currentSeries.cdc": &bintree{read_currentseriesCdc, map[string]*bintree{}}, + "read_totalSupply.cdc": &bintree{read_totalsupplyCdc, map[string]*bintree{}}, +}} + +// RestoreAsset restores an asset under the given directory. +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) +} + +// RestoreAssets restores an asset under the given directory recursively. +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + canonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) +} diff --git a/templates/market_templates.go b/lib/go/templates/market_templates.go similarity index 100% rename from templates/market_templates.go rename to lib/go/templates/market_templates.go diff --git a/templates/topshot_admin_templates.go b/lib/go/templates/topshot_admin_templates.go similarity index 97% rename from templates/topshot_admin_templates.go rename to lib/go/templates/topshot_admin_templates.go index b6405191..48986a2d 100644 --- a/templates/topshot_admin_templates.go +++ b/lib/go/templates/topshot_admin_templates.go @@ -1,5 +1,7 @@ package templates +//go:generate go run github.com/kevinburke/go-bindata/go-bindata -prefix ../../../transactions -o internal/assets/assets.go -pkg assets -nometadata -nomemcopy ../../../transactions + import ( "encoding/hex" "encoding/json" @@ -8,7 +10,7 @@ import ( "github.com/onflow/flow-go-sdk" - "github.com/dapperlabs/nba-smart-contracts/templates/data" + "github.com/dapperlabs/nba-smart-contracts/lib/go/templates/data" ) func uint32ToCadenceArr(nums []uint32) []byte { diff --git a/templates/topshot_script_templates.go b/lib/go/templates/topshot_script_templates.go similarity index 98% rename from templates/topshot_script_templates.go rename to lib/go/templates/topshot_script_templates.go index de9989e4..cb09d724 100644 --- a/templates/topshot_script_templates.go +++ b/lib/go/templates/topshot_script_templates.go @@ -1,5 +1,7 @@ package templates +//go:generate go run github.com/kevinburke/go-bindata/go-bindata -prefix ../../../scripts -o internal/assets/assets.go -pkg assets -nometadata -nomemcopy ../../../scripts + import ( "fmt" "strconv" diff --git a/templates/topshot_sharded_collection_templates.go b/lib/go/templates/topshot_sharded_collection_templates.go similarity index 100% rename from templates/topshot_sharded_collection_templates.go rename to lib/go/templates/topshot_sharded_collection_templates.go diff --git a/templates/topshot_user_templates.go b/lib/go/templates/topshot_user_templates.go similarity index 100% rename from templates/topshot_user_templates.go rename to lib/go/templates/topshot_user_templates.go diff --git a/test/Makefile b/lib/go/test/Makefile similarity index 100% rename from test/Makefile rename to lib/go/test/Makefile diff --git a/test/client.go b/lib/go/test/client.go similarity index 100% rename from test/client.go rename to lib/go/test/client.go diff --git a/test/examples.go b/lib/go/test/examples.go similarity index 100% rename from test/examples.go rename to lib/go/test/examples.go diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod new file mode 100644 index 00000000..2cfbcfc6 --- /dev/null +++ b/lib/go/test/go.mod @@ -0,0 +1,19 @@ +module github.com/dapperlabs/nba-smart-contracts/lib/go/test + +go 1.13 + +require ( + github.com/dapperlabs/flow-emulator v0.4.0 + github.com/dapperlabs/nba-smart-contracts/lib/go/contracts v0.0.0-00010101000000-000000000000 + github.com/dapperlabs/nba-smart-contracts/lib/go/templates v0.0.0-00010101000000-000000000000 + github.com/onflow/cadence v0.4.0 + github.com/onflow/flow-ft/contracts v0.1.3 + github.com/onflow/flow-ft/test v0.0.0-20200619173914-64c953134397 + github.com/onflow/flow-go-sdk v0.4.0 + github.com/stretchr/testify v1.5.1 + google.golang.org/grpc v1.28.0 +) + +replace github.com/dapperlabs/nba-smart-contracts/lib/go/templates => ../templates + +replace github.com/dapperlabs/nba-smart-contracts/lib/go/contracts => ../contracts diff --git a/test/go.sum b/lib/go/test/go.sum similarity index 99% rename from test/go.sum rename to lib/go/test/go.sum index 441c8cfe..4a003065 100644 --- a/test/go.sum +++ b/lib/go/test/go.sum @@ -124,6 +124,7 @@ github.com/dapperlabs/nba-smart-contracts/contracts v0.0.0-20200603213557-8eccd6 github.com/dapperlabs/nba-smart-contracts/contracts v0.0.0-20200603213557-8eccd607b75c/go.mod h1:bNDdu+s87Z5k2ntZv2XTkk/qfhmG8H6p47we00HKqdc= github.com/dapperlabs/nba-smart-contracts/contracts v0.1.7 h1:h6MmmFrzWeUxjovZbE3p3Ik4RUU9GSeqjaEViZ4Bsxg= github.com/dapperlabs/nba-smart-contracts/contracts v0.1.7/go.mod h1:bNDdu+s87Z5k2ntZv2XTkk/qfhmG8H6p47we00HKqdc= +github.com/dapperlabs/nba-smart-contracts/contracts v0.1.9/go.mod h1:IfJM8GfN/DiN39E0B8VZE/nlKe/ITUlASFUa1UEWDRY= github.com/dapperlabs/nba-smart-contracts/data v0.0.0-20200603212829-1171ac72a5d7 h1:aubrHbma4sNoKMB1b0TS/YKQQungrErOHPMXpVfPRuw= github.com/dapperlabs/nba-smart-contracts/data v0.0.0-20200603212829-1171ac72a5d7/go.mod h1:YnXE/zaPTfPMhrQg/Gz5S/MrLukeH4gyo0VxmbKWzV4= github.com/dapperlabs/nba-smart-contracts/data v0.0.0-20200603213557-8eccd607b75c h1:cjPmHMuf3kYQAy8+za59QhxVvPXkfpkqadllv1kX9jw= @@ -136,6 +137,7 @@ github.com/dapperlabs/nba-smart-contracts/templates v0.1.6 h1:QPbM2ElXUno5vKabSp github.com/dapperlabs/nba-smart-contracts/templates v0.1.6/go.mod h1:fnX9SVlV+1pguQZ5wNMP8Tm0aRSkbaP6pv6iOEJdR0c= github.com/dapperlabs/nba-smart-contracts/templates v0.1.7-0.20200605142058-1af32287a471 h1:3heezv6cJSuFv7gmPKj8o+By7YWBXrXU6aDoZwWYV7w= github.com/dapperlabs/nba-smart-contracts/templates v0.1.7-0.20200605142058-1af32287a471/go.mod h1:fnX9SVlV+1pguQZ5wNMP8Tm0aRSkbaP6pv6iOEJdR0c= +github.com/dapperlabs/nba-smart-contracts/templates v0.1.10/go.mod h1:fnX9SVlV+1pguQZ5wNMP8Tm0aRSkbaP6pv6iOEJdR0c= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -473,6 +475,7 @@ github.com/onflow/cadence v0.4.0 h1:oAKY/HclZZhc5wJgJwdPjWXJuC5IjuuHHVAAq3S7AHI= github.com/onflow/cadence v0.4.0/go.mod h1:gaPtSctdMzT5NAoJgzsRuwUkdgRswVHsRXFNNmCTn3I= github.com/onflow/cadence v0.4.1-0.20200604185918-21edaa9bfcdd h1:MYPhW5wojW1wlIncBN6Atsi+aC9FPUcCJcURADcmzsk= github.com/onflow/cadence v0.4.1-0.20200604185918-21edaa9bfcdd/go.mod h1:dgj1JPlSDeY6ZSqD/yCW06reFSt+19d/IFgQ1eE8Bfg= +github.com/onflow/flow v0.1.4-0.20200601215056-34a11def1d6b h1:wG1lmGfSIJW4L0ObdHNWHdk2LLXUoHrOU68krvtB//0= github.com/onflow/flow v0.1.4-0.20200601215056-34a11def1d6b/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c= github.com/onflow/flow-ft v0.1.0 h1:VIBn0SPjlMbPxVXqzeKG+Gw0GlZRidmCWzkvRh8at5A= github.com/onflow/flow-ft v0.1.0/go.mod h1:Sh/PKMT0mzGM5Zqb5tL/4wolfQis8KjXNiskkOSWdpU= diff --git a/test/market_test.go b/lib/go/test/market_test.go similarity index 98% rename from test/market_test.go rename to lib/go/test/market_test.go index e0abd034..7e8ebab9 100644 --- a/test/market_test.go +++ b/lib/go/test/market_test.go @@ -6,9 +6,9 @@ import ( fungibleToken "github.com/onflow/flow-ft/contracts" fungibleTokenTemplates "github.com/onflow/flow-ft/test" - "github.com/dapperlabs/nba-smart-contracts/contracts" - "github.com/dapperlabs/nba-smart-contracts/templates" - "github.com/dapperlabs/nba-smart-contracts/templates/data" + "github.com/dapperlabs/nba-smart-contracts/lib/go/contracts" + "github.com/dapperlabs/nba-smart-contracts/lib/go/templates" + "github.com/dapperlabs/nba-smart-contracts/lib/go/templates/data" "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" "github.com/onflow/flow-go-sdk/test" diff --git a/test/topshot_test.go b/lib/go/test/topshot_test.go similarity index 98% rename from test/topshot_test.go rename to lib/go/test/topshot_test.go index 6e6f1195..031f4338 100644 --- a/test/topshot_test.go +++ b/lib/go/test/topshot_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/dapperlabs/nba-smart-contracts/contracts" - "github.com/dapperlabs/nba-smart-contracts/templates" - "github.com/dapperlabs/nba-smart-contracts/templates/data" + "github.com/dapperlabs/nba-smart-contracts/lib/go/contracts" + "github.com/dapperlabs/nba-smart-contracts/lib/go/templates" + "github.com/dapperlabs/nba-smart-contracts/lib/go/templates/data" "github.com/onflow/flow-go-sdk/crypto" "github.com/onflow/flow-go-sdk/test" @@ -355,11 +355,11 @@ func TestMintNFTs(t *testing.T) { // but it upgrades the topshot contract after // and checks if the normal actions are still possible func TestUpgradeTopshot(t *testing.T) { - // b := NewEmulator() - b, err := NewClient("access-001.devnet7.nodes.onflow.org:9000", "d1aa781aaf47d6b8cc8e2510e8e18ab12b7356bee944b84e6dfa578b1bcaac64") - if !assert.NoError(t, err) { - t.Log(err.Error()) - } + b := NewEmulator() + // b, err := NewClient("access-001.devnet7.nodes.onflow.org:9000", "d1aa781aaf47d6b8cc8e2510e8e18ab12b7356bee944b84e6dfa578b1bcaac64") + // if !assert.NoError(t, err) { + // t.Log(err.Error()) + // } accountKeys := test.AccountKeyGenerator() // Should be able to deploy a contract as a new account with no keys. diff --git a/templates/go.mod b/templates/go.mod deleted file mode 100644 index b321d34e..00000000 --- a/templates/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/dapperlabs/nba-smart-contracts/templates - -go 1.13 - -require github.com/onflow/flow-go-sdk v0.4.0 diff --git a/test/go.mod b/test/go.mod deleted file mode 100644 index 6847895f..00000000 --- a/test/go.mod +++ /dev/null @@ -1,19 +0,0 @@ -module github.com/dapperlabs/nba-smart-contracts/test - -go 1.13 - -require ( - github.com/dapperlabs/flow-emulator v0.4.0 - github.com/dapperlabs/nba-smart-contracts/contracts v0.1.7 - github.com/dapperlabs/nba-smart-contracts/templates v0.1.6 - github.com/onflow/cadence v0.4.0 - github.com/onflow/flow-ft/contracts v0.1.3 - github.com/onflow/flow-ft/test v0.0.0-20200619173914-64c953134397 - github.com/onflow/flow-go-sdk v0.4.0 - github.com/stretchr/testify v1.5.1 - google.golang.org/grpc v1.28.0 -) - -replace github.com/dapperlabs/nba-smart-contracts/templates => ../templates - -replace github.com/dapperlabs/nba-smart-contracts/contracts => ../contracts