diff --git a/app/handler/google.go b/app/handler/google.go index 604f71e..8fcab25 100644 --- a/app/handler/google.go +++ b/app/handler/google.go @@ -28,7 +28,7 @@ type GoogleApp struct { // eg. https://us-central1-m3o-apis.cloudfunctions.net/ address string // max number of apps per user - limit int + limit int // custom domain for apps domain string // the service account for the app @@ -143,12 +143,12 @@ func New() *GoogleApp { log.Info(string(outp)) return &GoogleApp{ - domain: domain, - project: project, - address: address, - limit: limit, + domain: domain, + project: project, + address: address, + limit: limit, identity: identity, - App: new(App), + App: new(App), } } diff --git a/function/handler/google.go b/function/handler/google.go index 0007a50..1249db2 100644 --- a/function/handler/google.go +++ b/function/handler/google.go @@ -26,7 +26,7 @@ type GoogleFunction struct { // eg. https://us-central1-m3o-apis.cloudfunctions.net/ address string // max functions deployed - limit int + limit int // function identity identity string } @@ -126,9 +126,9 @@ func NewFunction() *GoogleFunction { } log.Info(string(outp)) return &GoogleFunction{ - project: project, - address: address, - limit: limit, + project: project, + address: address, + limit: limit, identity: identity, } } diff --git a/go.mod b/go.mod index 1926448..6f9e1f9 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e - github.com/micro/micro/v3 v3.8.0 + github.com/micro/micro/v3 v3.8.1-0.20211216122745-2e7245423520 github.com/miekg/dns v1.1.31 // indirect github.com/minio/minio-go/v7 v7.0.16 github.com/o1egl/govatar v0.3.0 diff --git a/go.sum b/go.sum index bf00b92..0aba582 100644 --- a/go.sum +++ b/go.sum @@ -495,6 +495,8 @@ github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4f github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/micro/micro/v3 v3.8.0 h1:RTH2835RJ4/aqLZGMjGCIf7HroCmYlJh2KRHHuSL/AE= github.com/micro/micro/v3 v3.8.0/go.mod h1:gjFa8T2ouD6BvorPTVPXLWtrRJwSKT5KxUNuu23Kkts= +github.com/micro/micro/v3 v3.8.1-0.20211216122745-2e7245423520 h1:LtErHRofRQf5damrjb5AkpvmklaIhx3anLJ9sN4fMrI= +github.com/micro/micro/v3 v3.8.1-0.20211216122745-2e7245423520/go.mod h1:gjFa8T2ouD6BvorPTVPXLWtrRJwSKT5KxUNuu23Kkts= github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo= diff --git a/joke/generate.go b/joke/generate.go index 96f431a..7d9db91 100644 --- a/joke/generate.go +++ b/joke/generate.go @@ -1,2 +1,3 @@ package main + //go:generate make proto diff --git a/movie/generate.go b/movie/generate.go index 96f431a..7d9db91 100644 --- a/movie/generate.go +++ b/movie/generate.go @@ -1,2 +1,3 @@ package main + //go:generate make proto diff --git a/nft/domain/opensea.go b/nft/domain/opensea.go index 1296c49..ef30563 100644 --- a/nft/domain/opensea.go +++ b/nft/domain/opensea.go @@ -9,58 +9,58 @@ type CollectionsResponse struct { } type Asset struct { - Id int32 `json:"id"` - TokenId string `json:"token_id"` - Sales int32 `json:"num_sales"` - ImageUrl string `json:"image_url"` - Name string `json:"name"` - Description string `json:"description"` - Permalink string `json:"permalink"` - Contract *Contract `json:"asset_contract"` - Collection *Collection `json:"collection"` - Creator *User `json:"creator"` - Owner *User `json:"owner"` - LastSale *Sale `json:"last_sale,omitempty"` - Presale bool `json:"is_presale"` - ListingDate string `json:"listing_date,omitempty"` + Id int32 `json:"id"` + TokenId string `json:"token_id"` + Sales int32 `json:"num_sales"` + ImageUrl string `json:"image_url"` + Name string `json:"name"` + Description string `json:"description"` + Permalink string `json:"permalink"` + Contract *Contract `json:"asset_contract"` + Collection *Collection `json:"collection"` + Creator *User `json:"creator"` + Owner *User `json:"owner"` + LastSale *Sale `json:"last_sale,omitempty"` + Presale bool `json:"is_presale"` + ListingDate string `json:"listing_date,omitempty"` } type Contract struct { - // name of contract - Name string `json:"name,omitempty"` - // ethereum address - Address string `json:"address,omitempty"` - // type of contract e.g "semi-fungible" - Type string `json:"asset_contract_type,omitempty"` - // timestamp of creation - CreatedAt string `json:"created_date,omitempty"` - // owner id - Owner int32 `json:"owner,omitempty"` - // aka "ERC1155" - Schema string `json:"schema_name,omitempty"` - // related symbol - Symbol string `json:"symbol,omitempty"` - // description of contract - Description string `json:"description,omitempty"` - // payout address - PayoutAddress string `json:"payout_address,omitempty"` - // seller fees - SellerFees string `json:"seller_fees_basis_points,omitempty"` + // name of contract + Name string `json:"name,omitempty"` + // ethereum address + Address string `json:"address,omitempty"` + // type of contract e.g "semi-fungible" + Type string `json:"asset_contract_type,omitempty"` + // timestamp of creation + CreatedAt string `json:"created_date,omitempty"` + // owner id + Owner int32 `json:"owner,omitempty"` + // aka "ERC1155" + Schema string `json:"schema_name,omitempty"` + // related symbol + Symbol string `json:"symbol,omitempty"` + // description of contract + Description string `json:"description,omitempty"` + // payout address + PayoutAddress string `json:"payout_address,omitempty"` + // seller fees + SellerFees string `json:"seller_fees_basis_points,omitempty"` } type Collection struct { - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - Slug string `json:"slug,omitempty"` - ImageUrl string `json:"image_url,omitempty"` - CreatedAt string `json:"created_date,omitempty"` - PayoutAddress string `json:"payout_address,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Slug string `json:"slug,omitempty"` + ImageUrl string `json:"image_url,omitempty"` + CreatedAt string `json:"created_date,omitempty"` + PayoutAddress string `json:"payout_address,omitempty"` } type User struct { - User *Username `json:"user"` - ProfileUrl string `json:"profile_img_url,omitempty"` - Address string `json:"address,omitempty"` + User *Username `json:"user"` + ProfileUrl string `json:"profile_img_url,omitempty"` + Address string `json:"address,omitempty"` } type Username struct { @@ -68,40 +68,39 @@ type Username struct { } type SaleAsset struct { - TokenId string `json:"token_id"` + TokenId string `json:"token_id"` Decimals int32 `json:"decimals"` } type Sale struct { - Asset *SaleAsset `json:"asset"` - EventType string `json:"event_type,omitempty"` - EventTimestamp string `json:"event_timestamp,omitempty"` - TotalPrice string `json:"total_price,omitempty"` - Quantity string `json:"quantity,omitempty"` - CreatedAt string `json:"created_date,omitempty"` - Transaction *Transaction `json:"transaction,omitempty"` - PaymentToken *Token `json:"payment_token,omitempty"` + Asset *SaleAsset `json:"asset"` + EventType string `json:"event_type,omitempty"` + EventTimestamp string `json:"event_timestamp,omitempty"` + TotalPrice string `json:"total_price,omitempty"` + Quantity string `json:"quantity,omitempty"` + CreatedAt string `json:"created_date,omitempty"` + Transaction *Transaction `json:"transaction,omitempty"` + PaymentToken *Token `json:"payment_token,omitempty"` } type Transaction struct { - Id int32 `json:"id,omitempty"` - Timestamp string `json:"timestamp,omitempty"` - BlockHash string `json:"block_hash,omitempty"` - BlockNumber string `json:"block_number,omitempty"` - FromAccount *User `json:"from_account,omitempty"` - ToAccount *User `json:"to_account,omitempty"` - TransactionHash string `json:"transaction_hash,omitempty"` - TransactionIndex string `json:"transaction_index,omitempty"` + Id int32 `json:"id,omitempty"` + Timestamp string `json:"timestamp,omitempty"` + BlockHash string `json:"block_hash,omitempty"` + BlockNumber string `json:"block_number,omitempty"` + FromAccount *User `json:"from_account,omitempty"` + ToAccount *User `json:"to_account,omitempty"` + TransactionHash string `json:"transaction_hash,omitempty"` + TransactionIndex string `json:"transaction_index,omitempty"` } type Token struct { - Id int32 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Symbol string `json:"symbol,omitempty"` - Address string `json:"address,omitempty"` - ImageUrl string `json:"image_url,omitempty"` - Decimals int32 `json:"decimals,omitempty"` - EthPrice string `json:"eth_price,omitempty"` - UsdPrice string `json:"usd_price,omitempty"` + Id int32 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Symbol string `json:"symbol,omitempty"` + Address string `json:"address,omitempty"` + ImageUrl string `json:"image_url,omitempty"` + Decimals int32 `json:"decimals,omitempty"` + EthPrice string `json:"eth_price,omitempty"` + UsdPrice string `json:"usd_price,omitempty"` } - diff --git a/nft/generate.go b/nft/generate.go index 96f431a..7d9db91 100644 --- a/nft/generate.go +++ b/nft/generate.go @@ -1,2 +1,3 @@ package main + //go:generate make proto diff --git a/nft/handler/nft.go b/nft/handler/nft.go index 15f615c..c30e8db 100644 --- a/nft/handler/nft.go +++ b/nft/handler/nft.go @@ -3,13 +3,11 @@ package handler import ( "context" - pb "github.com/micro/services/nft/proto" ) type Nft struct{} - func (n *Nft) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.AssetsResponse) error { return nil } diff --git a/nft/handler/opensea.go b/nft/handler/opensea.go index 41dc31d..aac0204 100644 --- a/nft/handler/opensea.go +++ b/nft/handler/opensea.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - "github.com/micro/services/pkg/api" - "github.com/micro/services/nft/domain" "github.com/micro/micro/v3/service/config" - "github.com/micro/micro/v3/service/logger" "github.com/micro/micro/v3/service/errors" + "github.com/micro/micro/v3/service/logger" + "github.com/micro/services/nft/domain" pb "github.com/micro/services/nft/proto" + "github.com/micro/services/pkg/api" ) // OpenSea handler @@ -23,24 +23,23 @@ var ( openseaURL = "https://api.opensea.io/api/v1" ) - func New() *OpenSea { - v, err := config.Get("nft.key") - if err != nil { - logger.Fatal("nft.key config not found: %v", err) - } + v, err := config.Get("nft.key") + if err != nil { + logger.Fatal("nft.key config not found: %v", err) + } - key := v.String("") - if len(key) == 0 { - logger.Fatal("nft.key config not found") - } + key := v.String("") + if len(key) == 0 { + logger.Fatal("nft.key config not found") + } // set the api key api.SetKey("X-API-KEY", key) - return &OpenSea { + return &OpenSea{ apiKey: key, - Nft: new(Nft), + Nft: new(Nft), } } @@ -83,7 +82,7 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass var resp domain.AssetsResponse - if err := api.Get(uri + params, &resp); err != nil { + if err := api.Get(uri+params, &resp); err != nil { return errors.InternalServerError("nft.assets", "failed to get assets: %v", err) } @@ -117,7 +116,7 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass if asset.LastSale.Transaction == nil { asset.LastSale.Transaction = &domain.Transaction{ FromAccount: &domain.User{User: new(domain.Username)}, - ToAccount: &domain.User{User: new(domain.Username)}, + ToAccount: &domain.User{User: new(domain.Username)}, } } if asset.LastSale.Transaction.FromAccount == nil { @@ -137,36 +136,36 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass } lastSale = &pb.Sale{ - AssetTokenId: asset.LastSale.Asset.TokenId, - AssetDecimals: asset.LastSale.Asset.Decimals, - EventType: asset.LastSale.EventType, + AssetTokenId: asset.LastSale.Asset.TokenId, + AssetDecimals: asset.LastSale.Asset.Decimals, + EventType: asset.LastSale.EventType, EventTimestamp: asset.LastSale.EventTimestamp, - TotalPrice: asset.LastSale.TotalPrice, - Quantity: asset.LastSale.Quantity, - CreatedAt: asset.LastSale.CreatedAt, + TotalPrice: asset.LastSale.TotalPrice, + Quantity: asset.LastSale.Quantity, + CreatedAt: asset.LastSale.CreatedAt, Transaction: &pb.Transaction{ - Id: asset.LastSale.Transaction.Id, - Timestamp: asset.LastSale.Transaction.Timestamp, - BlockHash: asset.LastSale.Transaction.BlockHash, + Id: asset.LastSale.Transaction.Id, + Timestamp: asset.LastSale.Transaction.Timestamp, + BlockHash: asset.LastSale.Transaction.BlockHash, BlockNumber: asset.LastSale.Transaction.BlockNumber, FromAccount: &pb.User{ - Username: asset.LastSale.Transaction.FromAccount.User.Username, + Username: asset.LastSale.Transaction.FromAccount.User.Username, ProfileUrl: asset.LastSale.Transaction.FromAccount.ProfileUrl, - Address: asset.LastSale.Transaction.FromAccount.Address, + Address: asset.LastSale.Transaction.FromAccount.Address, }, ToAccount: &pb.User{ - Username: asset.LastSale.Transaction.ToAccount.User.Username, + Username: asset.LastSale.Transaction.ToAccount.User.Username, ProfileUrl: asset.LastSale.Transaction.ToAccount.ProfileUrl, - Address: asset.LastSale.Transaction.ToAccount.Address, + Address: asset.LastSale.Transaction.ToAccount.Address, }, - TransactionHash: asset.LastSale.Transaction.TransactionHash, + TransactionHash: asset.LastSale.Transaction.TransactionHash, TransactionIndex: asset.LastSale.Transaction.TransactionIndex, }, PaymentToken: &pb.Token{ - Id: asset.LastSale.PaymentToken.Id, - Name: asset.LastSale.PaymentToken.Name, - Symbol: asset.LastSale.PaymentToken.Symbol, - Address: asset.LastSale.PaymentToken.Address, + Id: asset.LastSale.PaymentToken.Id, + Name: asset.LastSale.PaymentToken.Name, + Symbol: asset.LastSale.PaymentToken.Symbol, + Address: asset.LastSale.PaymentToken.Address, ImageUrl: asset.LastSale.PaymentToken.ImageUrl, Decimals: asset.LastSale.PaymentToken.Decimals, EthPrice: asset.LastSale.PaymentToken.EthPrice, @@ -176,45 +175,45 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass } rsp.Assets = append(rsp.Assets, &pb.Asset{ - Name: asset.Name, + Name: asset.Name, Description: asset.Description, - Id: asset.Id, - TokenId: asset.TokenId, - ImageUrl: asset.ImageUrl, - Sales: asset.Sales, - Permalink: asset.Permalink, + Id: asset.Id, + TokenId: asset.TokenId, + ImageUrl: asset.ImageUrl, + Sales: asset.Sales, + Permalink: asset.Permalink, Contract: &pb.Contract{ - Name: asset.Contract.Name, - Description: asset.Contract.Description, - Address: asset.Contract.Address, - Type: asset.Contract.Type, - CreatedAt: asset.Contract.CreatedAt, - Owner: asset.Contract.Owner, - Schema: asset.Contract.Schema, - Symbol: asset.Contract.Symbol, + Name: asset.Contract.Name, + Description: asset.Contract.Description, + Address: asset.Contract.Address, + Type: asset.Contract.Type, + CreatedAt: asset.Contract.CreatedAt, + Owner: asset.Contract.Owner, + Schema: asset.Contract.Schema, + Symbol: asset.Contract.Symbol, PayoutAddress: asset.Contract.PayoutAddress, - SellerFees: asset.Contract.SellerFees, + SellerFees: asset.Contract.SellerFees, }, Collection: &pb.Collection{ - Name: asset.Collection.Name, - Description: asset.Collection.Description, - Slug: asset.Collection.Slug, - ImageUrl: asset.Collection.ImageUrl, - CreatedAt: asset.Collection.CreatedAt, + Name: asset.Collection.Name, + Description: asset.Collection.Description, + Slug: asset.Collection.Slug, + ImageUrl: asset.Collection.ImageUrl, + CreatedAt: asset.Collection.CreatedAt, PayoutAddress: asset.Collection.PayoutAddress, }, Owner: &pb.User{ - Username: asset.Owner.User.Username, + Username: asset.Owner.User.Username, ProfileUrl: asset.Owner.ProfileUrl, - Address: asset.Owner.Address, + Address: asset.Owner.Address, }, Creator: &pb.User{ - Username: asset.Creator.User.Username, + Username: asset.Creator.User.Username, ProfileUrl: asset.Creator.ProfileUrl, - Address: asset.Creator.Address, + Address: asset.Creator.Address, }, - LastSale: lastSale, - Presale: asset.Presale, + LastSale: lastSale, + Presale: asset.Presale, ListingDate: asset.ListingDate, }) } @@ -241,25 +240,24 @@ func (o *OpenSea) Collections(ctx context.Context, req *pb.CollectionsRequest, r offset = req.Offset } - params += fmt.Sprintf("limit=%d&offset=%d",limit, offset) + params += fmt.Sprintf("limit=%d&offset=%d", limit, offset) var resp domain.CollectionsResponse - if err := api.Get(uri + params, &resp); err != nil { + if err := api.Get(uri+params, &resp); err != nil { return errors.InternalServerError("nft.collections", "failed to get collections: %v", err) } for _, collection := range resp.Collections { rsp.Collections = append(rsp.Collections, &pb.Collection{ - Name: collection.Name, - Description: collection.Description, - Slug: collection.Slug, - ImageUrl: collection.ImageUrl, - CreatedAt: collection.CreatedAt, + Name: collection.Name, + Description: collection.Description, + Slug: collection.Slug, + ImageUrl: collection.ImageUrl, + CreatedAt: collection.CreatedAt, PayoutAddress: collection.PayoutAddress, }) } return nil } - diff --git a/nft/main.go b/nft/main.go index 7abe2cd..bec35a2 100644 --- a/nft/main.go +++ b/nft/main.go @@ -1,10 +1,10 @@ package main import ( - "github.com/micro/services/nft/handler" - pb "github.com/micro/services/nft/proto" "github.com/micro/micro/v3/service" "github.com/micro/micro/v3/service/logger" + "github.com/micro/services/nft/handler" + pb "github.com/micro/services/nft/proto" ) func main() { diff --git a/search/generate.go b/search/generate.go index 96f431a..7d9db91 100644 --- a/search/generate.go +++ b/search/generate.go @@ -1,2 +1,3 @@ package main + //go:generate make proto diff --git a/search/handler/search.go b/search/handler/search.go index 908a2cc..38f0d45 100644 --- a/search/handler/search.go +++ b/search/handler/search.go @@ -5,9 +5,8 @@ import ( "sync" "time" - - "github.com/micro/services/pkg/tenant" "github.com/micro/micro/v3/service/store" + "github.com/micro/services/pkg/tenant" pb "github.com/micro/services/search/proto" ) @@ -20,8 +19,8 @@ var ( ) type Vote struct { - Id string `json:"id"` - Message string `json:"message"` + Id string `json:"id"` + Message string `json:"message"` VotedAt time.Time `json:"voted_at"` } @@ -34,8 +33,8 @@ func (n *Search) Vote(ctx context.Context, req *pb.VoteRequest, rsp *pb.VoteResp id = "micro" } - rec := store.NewRecord(voteKey + id, &Vote{ - Id: id, + rec := store.NewRecord(voteKey+id, &Vote{ + Id: id, Message: req.Message, VotedAt: time.Now(), }) @@ -47,4 +46,3 @@ func (n *Search) Vote(ctx context.Context, req *pb.VoteRequest, rsp *pb.VoteResp return nil } - diff --git a/search/main.go b/search/main.go index da5949e..589127b 100644 --- a/search/main.go +++ b/search/main.go @@ -1,10 +1,10 @@ package main import ( - "github.com/micro/services/search/handler" - pb "github.com/micro/services/search/proto" "github.com/micro/micro/v3/service" "github.com/micro/micro/v3/service/logger" + "github.com/micro/services/search/handler" + pb "github.com/micro/services/search/proto" ) func main() { diff --git a/translate/handler/translate.go b/translate/handler/translate.go index a287b91..a3eb41b 100644 --- a/translate/handler/translate.go +++ b/translate/handler/translate.go @@ -3,8 +3,8 @@ package handler import ( "context" - me "github.com/micro/micro/v3/service/errors" "github.com/micro/micro/v3/service/config" + me "github.com/micro/micro/v3/service/errors" "github.com/micro/micro/v3/service/logger" "github.com/pkg/errors" "golang.org/x/text/language" @@ -17,7 +17,7 @@ import ( type translation struct { ApiKey string - Limit int + Limit int } func NewTranslation() *translation { @@ -39,7 +39,7 @@ func NewTranslation() *translation { return &translation{ ApiKey: key, - Limit: limit, + Limit: limit, } } diff --git a/youtube/handler/youtube.go b/youtube/handler/youtube.go index e817df0..6f06cce 100644 --- a/youtube/handler/youtube.go +++ b/youtube/handler/youtube.go @@ -50,7 +50,7 @@ func (y *Youtube) Embed(ctx context.Context, req *pb.EmbedRequest, rsp *pb.Embed } } - rsp.LongUrl = "https://www.youtube.com/watch?v="+id + rsp.LongUrl = "https://www.youtube.com/watch?v=" + id rsp.ShortUrl = "https://youtu.be/" + id rsp.EmbedUrl = "https://www.youtube.com/embed/" + id rsp.HtmlScript = ``