Skip to content
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

Fix/iap #619

Merged
merged 3 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27189,67 +27189,6 @@ paths:
additionalProperties: {}
tags:
- Query
'/Pylons-tech/pylons/pylons/get_recipe_history/{cookbook_id}/{recipe_id}':
get:
summary: Queries a list of GetRecipeHistory items.
operationId: PylonstechPylonsPylonsGetRecipeHistory
responses:
'200':
description: A successful response.
schema:
type: object
properties:
History:
type: array
items:
type: object
properties:
item_id:
type: string
cookbook_id:
type: string
recipe_id:
type: string
sender:
type: string
sender_name:
type: string
receiver:
type: string
amount:
type: string
created_at:
type: string
format: int64
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: cookbook_id
in: path
required: true
type: string
- name: recipe_id
in: path
required: true
type: string
tags:
- Query
'/pylons/account/address/{address}':
get:
summary: Queries a list of getAccountByAddress items.
Expand Down Expand Up @@ -28294,6 +28233,67 @@ paths:
type: boolean
tags:
- Query
'/pylons/get_recipe_history/{cookbook_id}/{recipe_id}':
get:
summary: Queries a list of GetRecipeHistory items.
operationId: PylonstechPylonsPylonsGetRecipeHistory
responses:
'200':
description: A successful response.
schema:
type: object
properties:
History:
type: array
items:
type: object
properties:
item_id:
type: string
cookbook_id:
type: string
recipe_id:
type: string
sender:
type: string
sender_name:
type: string
receiver:
type: string
amount:
type: string
created_at:
type: string
format: int64
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: cookbook_id
in: path
required: true
type: string
- name: recipe_id
in: path
required: true
type: string
tags:
- Query
/pylons/get_stripe_refund:
get:
summary: Queries a list of GetStripeRefund items.
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ require (
require github.com/golang/glog v1.0.0 // indirect

require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
Expand Down Expand Up @@ -498,6 +499,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 h1:BGNSrTRW4rwfhJiFwvwF4XQ0Y72Jj9YEgxVrtovbD5o=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3/go.mod h1:VHn7KgNsRriXa4mcgtkpR00OXyQY6g67JWMvn+R27A4=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
Expand Down
2 changes: 1 addition & 1 deletion proto/pylons/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ service Query {

// Queries a list of GetRecipeHistory items.
rpc GetRecipeHistory(QueryGetRecipeHistoryRequest) returns (QueryGetRecipeHistoryResponse) {
option (google.api.http).get = "/Pylons-tech/pylons/pylons/get_recipe_history/{cookbook_id}/{recipe_id}";
option (google.api.http).get = "/pylons/get_recipe_history/{cookbook_id}/{recipe_id}";
}

// Queries a list of GetStripeRefund items.
Expand Down
4 changes: 3 additions & 1 deletion x/pylons/keeper/msg_get_tx_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"encoding/json"
"math"
"net/http"
"sort"
"strconv"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
q "github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/types/tx"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
)
Expand Down Expand Up @@ -117,7 +119,7 @@ func GetTxHistory(ctx client.Context, address, denom string, limit, offset int64
func QueryHistoryCosmos(txService tx.ServiceServer, query string) (history *tx.GetTxsEventResponse, err error) {
history, err = txService.GetTxsEvent(context.Background(), &tx.GetTxsEventRequest{Events: []string{
query,
}})
}, Pagination: &q.PageRequest{Limit: math.MaxInt}})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/pylons/keeper/msg_server_apple_iap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (k msgServer) AppleIap(goCtx context.Context, msg *types.MsgAppleIap) (*typ
}

if k.HasAppleIAPOrder(ctx, receipt.PurchaseID) {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "the Apple IAP order ID is already being used")
return nil, sdkerrors.Wrap(types.ErrReceiptAlreadyUsed, "the Apple IAP order ID is already being used")
}

var coinIssuer types.CoinIssuer
Expand Down
8 changes: 4 additions & 4 deletions x/pylons/keeper/msg_server_apple_iap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (suite *IntegrationTestSuite) TestMsgServerappleInAppPurchaseGetCoins() {
ProductID: "pylons_10",
PurchaseID: "2000000086523782",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(10))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(10000000))),
},
{
// valid recipet 2 35 coins

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix comment "valid recipe 2 35 coins"

Expand All @@ -61,7 +61,7 @@ func (suite *IntegrationTestSuite) TestMsgServerappleInAppPurchaseGetCoins() {
ProductID: "pylons_35",
PurchaseID: "2000000086528808",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(45))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(45000000))),
},
{
// valid recipet 3 60 coins

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix comment "valid recipe 3 60 coins"

Expand All @@ -72,7 +72,7 @@ func (suite *IntegrationTestSuite) TestMsgServerappleInAppPurchaseGetCoins() {
ProductID: "pylons_60",
PurchaseID: "2000000086529484",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(105))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(105000000))),
},
{
// invalid product id is embedded within the receipt data
Expand All @@ -83,7 +83,7 @@ func (suite *IntegrationTestSuite) TestMsgServerappleInAppPurchaseGetCoins() {
ProductID: "pylons_60",
PurchaseID: "2000000086529484",
},
err: sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "the Apple IAP order ID is already being used"),
err: sdkerrors.Wrap(types.ErrReceiptAlreadyUsed, "the Apple IAP order ID is already being used"),
},
} {
tc := tc
Expand Down
2 changes: 1 addition & 1 deletion x/pylons/keeper/msg_server_google_iap_get_coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (k msgServer) GoogleInAppPurchaseGetCoins(goCtx context.Context, msg *types
ctx := sdk.UnwrapSDKContext(goCtx)

if k.HasGoogleIAPOrder(ctx, msg.PurchaseToken) {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "the Google IAP order ID is already being used")
return nil, sdkerrors.Wrap(types.ErrReceiptAlreadyUsed, "the Google IAP order ID is already being used")
}

// find matching package from list of coin issuers
Expand Down
8 changes: 4 additions & 4 deletions x/pylons/keeper/msg_server_google_iap_get_coins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (suite *IntegrationTestSuite) TestMsgServerGoogleInAppPurchaseGetCoins() {
ReceiptDataBase64: "eyJvcmRlcklkIjoiR1BBLjMzOTYtNjQwNy00NDUyLTYyMDIwIiwicGFja2FnZU5hbWUiOiJ0ZWNoLnB5bG9ucy53YWxsZXQiLCJwcm9kdWN0SWQiOiJweWxvbnNfMTAiLCJwdXJjaGFzZVRpbWUiOjE2NTU5MDEzMTY5NDEsInB1cmNoYXNlU3RhdGUiOjAsInB1cmNoYXNlVG9rZW4iOiJoZm9vY2Jsam9nZ21kZWlla2ZvbGJpbWUuQU8tSjFPd0Jyc3J3TFNnZ3ZNU1ZMSlI2d2wxeGF4Q1FDRjBNNW9ON3ZpRUVldjVHRVJMOGEwR04zdDh6MVpQcGROcnE4dHBnelpDTTNJZ2NQNXYya2FiRWxObHRzYmg2R0EiLCJhY2tub3dsZWRnZWQiOmZhbHNlfQ==",
Signature: "LZXvpQwMzGPUnPx06ueOhHDT8INhvxo+YYpqNK17pv1JoU5efoQk7/nHiNvMIHUaX9n0DRF0+Cg/VhZw70zvb4n+18jqRRyKBj/wHt8VSJEco1cHmnwh15OE4FY49YINidBERCBo01xD6qhuMnh7ZB0CwWRBSrDLHKuk4Y9Qybhn72/MtVeMCs+4aK1iWi7iJ9ABfHFbbomFDkOSQvxwAboPcg7VfiZMXS2K67dxWK6YaSQVc21zLtABgigiAqg6mRKiG5d2BdHSXo5qh13f/py2fj6CRf+b9lcVDM0cDGXcsBkPME/OUWQNyqd2tFMlcZn6SwOR7suuzzoB4A8rHg==",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(10))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(10000000))),
},
{
desc: "Valid2",
Expand All @@ -69,7 +69,7 @@ func (suite *IntegrationTestSuite) TestMsgServerGoogleInAppPurchaseGetCoins() {
ReceiptDataBase64: "eyJvcmRlcklkIjoiR1BBLjMzODYtMjU3MC00NDY4LTQ3MTY0IiwicGFja2FnZU5hbWUiOiJ0ZWNoLnB5bG9ucy53YWxsZXQiLCJwcm9kdWN0SWQiOiJweWxvbnNfMzUiLCJwdXJjaGFzZVRpbWUiOjE2NTU5MDEzNjk3NTUsInB1cmNoYXNlU3RhdGUiOjAsInB1cmNoYXNlVG9rZW4iOiJuZmlwZnBqYWNoYmZkb2xwaWtoaGJpZWEuQU8tSjFPeDEyNWRHMzI1MGphWGxiZHJWem4wQ2ZOdHlsMUE1MWQ2ZjdJM29xQkhBUXc3TjNZS1VsWWhWRGM4SEVZVGFMQ3pZUnBWcEI4TmpxVlpVUzNrXzZKMEF0LWotM3ciLCJhY2tub3dsZWRnZWQiOmZhbHNlfQ==",
Signature: "kj8+9dVWtJbCtT92KhrXiXpq6oDfSu+yq+eOGjsiX856vS4ZD0JptbV0aB75NV2vIfbmsMcWafuLip64c78akqPxCwXTCH1eNcJxzHdsUumYt7y7BrdsrDc7PwDTloV9+Qe2ReRVUQISD4a+J7fGiQTVHkAbVvUoRAtShojByJHxqgMIx2/WGqtY+tDwlyqMtc44JlK+zrEn+1n93/v6ZS9X1Nv+I9HYWMhdxMXaJ+POnxH7hz/2LzKWlyoi82L/RBouOVzGpVfqiqyap0hiVxmQPP6K+vNBSiUgreNpMD+2qlslOHDugORgjqHf1eLs4hrBO99iDjYMWX5g+Bz0bQ==",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(45))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(45000000))),
},
{
desc: "Valid3",
Expand All @@ -80,7 +80,7 @@ func (suite *IntegrationTestSuite) TestMsgServerGoogleInAppPurchaseGetCoins() {
ReceiptDataBase64: "eyJvcmRlcklkIjoiR1BBLjMzMTgtMjc2MS0zODk1LTI5NDcwIiwicGFja2FnZU5hbWUiOiJ0ZWNoLnB5bG9ucy53YWxsZXQiLCJwcm9kdWN0SWQiOiJweWxvbnNfNjAiLCJwdXJjaGFzZVRpbWUiOjE2NTU5MDEzODY4MjAsInB1cmNoYXNlU3RhdGUiOjAsInB1cmNoYXNlVG9rZW4iOiJtY25wa25vamtwY2lnZWdib21jaGlraW4uQU8tSjFPeUZlZ1kxRkRlTkE5S3psWWVFbU9Jd2tYaUFYZWhmVnlsb3F2YjhUWGYyV21vYnIxdzhlbWNjQUtuamV6XzllNk5DMWk0Q0txN0tuVGxQa2tTa2xkVnI4QzFjMWciLCJhY2tub3dsZWRnZWQiOmZhbHNlfQ==",
Signature: "FREfEWfRXaNzRCgD6MLAaKpc1kZ2FbNVfeXLazKoxpY4tHFo1VsmEqCPdsYymCZys0yehWczPaQJMkB5YwGgwPSKGtWKgwP68gG6SsO21f5SKqcLjvuWyShspifDNjJ7vNy+XPwfjd6PWwYQWVNogr2dC8dN433X+1guY+FExeT0UwbgY8SedsaxRT2nOH2ONLDVx/rR0+kNie13bg/AUZzRkFKYKtUuUQtXq3F1CyDGg/ARgut0EFNJVaW6nrK9as2/7l6V3/+16iDP3dknk7sL9y+VpgfwFrGwQKX23DR33qepjhh7uY67DjxST7Ci4AoALkYdRJ7/TRyDXKe8xw==",
},
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(105))),
balance: sdk.NewCoins(sdk.NewCoin(types.PylonsCoinDenom, sdk.NewInt(105000000))),
},
{
// re-using IAP from Valid1
Expand All @@ -92,7 +92,7 @@ func (suite *IntegrationTestSuite) TestMsgServerGoogleInAppPurchaseGetCoins() {
ReceiptDataBase64: "eyJvcmRlcklkIjoiR1BBLjMzMTgtMjc2MS0zODk1LTI5NDcwIiwicGFja2FnZU5hbWUiOiJ0ZWNoLnB5bG9ucy53YWxsZXQiLCJwcm9kdWN0SWQiOiJweWxvbnNfNjAiLCJwdXJjaGFzZVRpbWUiOjE2NTU5MDEzODY4MjAsInB1cmNoYXNlU3RhdGUiOjAsInB1cmNoYXNlVG9rZW4iOiJtY25wa25vamtwY2lnZWdib21jaGlraW4uQU8tSjFPeUZlZ1kxRkRlTkE5S3psWWVFbU9Jd2tYaUFYZWhmVnlsb3F2YjhUWGYyV21vYnIxdzhlbWNjQUtuamV6XzllNk5DMWk0Q0txN0tuVGxQa2tTa2xkVnI4QzFjMWciLCJhY2tub3dsZWRnZWQiOmZhbHNlfQ==",
Signature: "FREfEWfRXaNzRCgD6MLAaKpc1kZ2FbNVfeXLazKoxpY4tHFo1VsmEqCPdsYymCZys0yehWczPaQJMkB5YwGgwPSKGtWKgwP68gG6SsO21f5SKqcLjvuWyShspifDNjJ7vNy+XPwfjd6PWwYQWVNogr2dC8dN433X+1guY+FExeT0UwbgY8SedsaxRT2nOH2ONLDVx/rR0+kNie13bg/AUZzRkFKYKtUuUQtXq3F1CyDGg/ARgut0EFNJVaW6nrK9as2/7l6V3/+16iDP3dknk7sL9y+VpgfwFrGwQKX23DR33qepjhh7uY67DjxST7Ci4AoALkYdRJ7/TRyDXKe8xw==",
},
err: sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "the Google IAP order ID is already being used"),
err: sdkerrors.Wrap(types.ErrReceiptAlreadyUsed, "the Google IAP order ID is already being used"),
},
} {
tc := tc
Expand Down
1 change: 1 addition & 0 deletions x/pylons/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ var (
ErrInvalidPendingExecution = sdkerrors.Register(ModuleName, 1103, "completing execution would create an inconsistent state")
ErrDuplicateUsername = sdkerrors.Register(ModuleName, 1104, "username already taken by another account")
ErrItemLocked = sdkerrors.Register(ModuleName, 1105, "item locked")
ErrReceiptAlreadyUsed = sdkerrors.Register(ModuleName, 1106, "receipt already used")
)
6 changes: 3 additions & 3 deletions x/pylons/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ var (
{
CoinDenom: PylonsCoinDenom,
Packages: []GoogleInAppPurchasePackage{
{PackageName: "tech.pylons.wallet", ProductId: "pylons_10", Amount: sdk.NewInt(10)},
{PackageName: "tech.pylons.wallet", ProductId: "pylons_35", Amount: sdk.NewInt(35)},
{PackageName: "tech.pylons.wallet", ProductId: "pylons_60", Amount: sdk.NewInt(60)},
{PackageName: "tech.pylons.wallet", ProductId: "pylons_10", Amount: sdk.NewInt(10000000)},
{PackageName: "tech.pylons.wallet", ProductId: "pylons_35", Amount: sdk.NewInt(35000000)},
{PackageName: "tech.pylons.wallet", ProductId: "pylons_60", Amount: sdk.NewInt(60000000)},
},
GoogleInAppPurchasePubKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuMzgsJOZzyZvmOG8T9baGxDR/DWx6dgku7UdDfc6aGKthPGYouOa4KvLGEuNd+YTilwtEEryi3mmYAtl8MNtiAQCiry7HjdRNle8lLUHSKwBLVCswY3WGEAuW+5mo/V6X0klS8se65fIqCv2x/SKjtTZvKO/Oe3uehREMY1b8uWLrD5roubXzmaLsFGIRi5wdg8UWRe639LCNb2ghD2Uw0svBTJqn/ymsPmCfVjmCNNRDxfxzlA8O4EEKCK1qOdwIejMAfFMrN87u+0HTQbCKQ/xUQrR6fUhWT2mqttBGhi1NmTNBlUDyXYU+7ILbfJUVqQcKNDbFQd+xv9wBnXAhwIDAQAB",
EntityName: "Pylons_Inc",
Expand Down
Loading