Skip to content

Instantly share code, notes, and snippets.

@jelilat
Created April 20, 2022 09:08
Show Gist options
  • Save jelilat/f73d241bfcf22d892a55658240f18b08 to your computer and use it in GitHub Desktop.
Save jelilat/f73d241bfcf22d892a55658240f18b08 to your computer and use it in GitHub Desktop.
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