Created
April 20, 2022 09:08
-
-
Save jelilat/f73d241bfcf22d892a55658240f18b08 to your computer and use it in GitHub Desktop.
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
package keeper | |
import ( | |
"context" | |
"github.com/cosmonaut/gofundme/x/gofundme/types" | |
sdk "github.com/cosmos/cosmos-sdk/types" | |
) | |
func (k msgServer) CreateGofundme(goCtx context.Context, msg *types.MsgCreateGofundme) (*types.MsgCreateGofundmeResponse, error) { | |
ctx := sdk.UnwrapSDKContext(goCtx) | |
// Start a gofundme with the following user inputs | |
var gofundme = types.Gofundme{ | |
Creator: msg.Creator, | |
Goal: msg.Goal, | |
Start: msg.Start, | |
End: msg.End, | |
Claim: false, | |
} | |
//Allow users to set their gofundme campaign start date to be current time | |
if gofundme.Start == "now" { | |
gofundme.Start = ctx.BlockTime().Format("2006–01–02T15:04:05.000000000") | |
} | |
// Add the gofundme to the keeper | |
k.AppendGofundme(ctx, gofundme) | |
return &types.MsgCreateGofundmeResponse{}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment