streampay

package
v2.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 15 Imported by: 3

README

Streampay

Streampay module is used to create stream payments on cosmos-sdk based chains

Anyone can create a stream payment to a recipient address with a specified amount with type of stream and end time. receiver can claim the amount after the end time or can claim streamed amount at anytime if payment type is continuous or periodic.

Types of steam payments:

  1. Continuous
  2. Delayed
  3. Periodic

Continuous Stream Payment Amount will be streamed continuously based on time and can be claimed at any time. Delayed Stream Payment Amount can be claimed only at the end of end time (works as scheduled payment) Periodic Stream Payment Amount will be streamed according to stream periods

Cancellable Stream Payments streampay module supports cancellable streaming payments also cancellable streams can be cancelled before it's endtime if stream is in progress remaining amount will be returned to stream payment creator

Stream Payment

message StreamPayment {
  string id = 1;
  string sender = 2;
  string recipient = 3;
  cosmos.base.v1beta1.Coin total_amount = 4 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin",
    (gogoproto.moretags) = "yaml:\"total_amount\""
  ];
  StreamType stream_type = 5 [(gogoproto.moretags) = "yaml:\"stream_type\""];
  repeated Period periods = 6 [(gogoproto.nullable) = true];
  bool cancellable = 7;
  google.protobuf.Timestamp start_time = 8 [
    (gogoproto.nullable) = false,
    (gogoproto.stdtime) = true,
    (gogoproto.moretags) = "yaml:\"start_time\""
  ];
  google.protobuf.Timestamp end_time = 9 [
    (gogoproto.nullable) = false,
    (gogoproto.stdtime) = true,
    (gogoproto.moretags) = "yaml:\"end_time\""
  ];
  cosmos.base.v1beta1.Coin streamed_amount = 10 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin",
    (gogoproto.moretags) = "yaml:\"streamed_amount\""
  ];
  google.protobuf.Timestamp last_claimed_at = 11 [
    (gogoproto.nullable) = false,
    (gogoproto.stdtime) = true,
    (gogoproto.moretags) = "yaml:\"last_claimed_at\""
  ];
  StreamStatus status = 12;
}

State

The state of the module is expressed by following fields:

  • 1.StreamPayments: list of stream payments
  • 2.Params: streampay module params
message GenesisState {
  repeated StreamPayment stream_payments      = 1 [(gogoproto.nullable) = false];
  uint64                 next_stream_payment_number = 2;
  Params params                 = 3 [(gogoproto.nullable) = false];
}

Messages

Stream Send

MsgStreamSend can be submitted by any account to create a stream payment

message MsgStreamSend {
  string sender = 1;
  string recipient = 2;
  cosmos.base.v1beta1.Coin amount = 3 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
  ];
  google.protobuf.Duration duration = 4 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];
  StreamType stream_type = 5 [(gogoproto.moretags) = "yaml:\"stream_type\""];
  repeated Period periods = 6 [(gogoproto.nullable) = true];
  bool cancellable = 7;
}
Stop Stream / Cancel Stream

MsgStopStream can be submitted by stream-payment creator to stop the stream payment.

message MsgStopStream {
  string stream_id = 1 [(gogoproto.moretags) = "yaml:\"stream_id\""];
  string sender = 2;
}
Claim Streamed Amount

MsgClaimStreamedAmount can be submitted by claimer to claim amount from stream payment.

message MsgClaimStreamedAmount {
  string stream_id = 1 [(gogoproto.moretags) = "yaml:\"stream_id\""];
  string claimer = 2;
}

Queries

service Query {
  rpc StreamingPayments(QueryStreamPaymentsRequest) returns (QueryStreamPaymentsResponse) {
    option (google.api.http).get = "/omniflix/streampay/v1/streaming-payments";
  }
  rpc StreamingPayment(QueryStreamPaymentRequest) returns (QueryStreamPaymentResponse) {
    option (google.api.http).get = "/omniflix/streampay/v1/streaming-payments/{id}";
  }
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/omniflix/streampay/v1/params";
  }
}

CLI Transactions

Stream Send

Continuous payment

 streampayd tx streampay stream-send [recipient] [amount] \
 --end-time <end-timestamp> \
 --chain-id <chain-id> \
 --from <sender> \
 --fees <fees>

Delayed payment:

streampayd tx streampay stream-send [recipient] [amount] \
--end-time <end-timestamp> \
--delayed \
--chain-id <chain-id> \
--from <sender> \
--fees <fees>

Periodic payment:

streampayd tx streampay stream-send [recipient] [amount] \
--end-time <end-timestamp> \
--stream-periods-file <stream-periods-file> \
--chain-id <chain-id> \
--from <sender> \
--fees <fees>
Stop Stream
streampayd tx streampay stop-stream [stream-id] --chain-id <chain-id> --from <sender> --fees <fees>
Claim Streamed Amount
streampayd tx streampay claim [stream-id] --chain-id <chain-id> --from <sender> --fees <fees>

CLI Queries

  1. Query all streaming payments
streampayd q streampay stream-payments
  1. Query stream payment by it's id
streampayd q streampay stream-payment [stream-payment-id]
  1. Query streampay module params
streampayd q streampay params

Documentation

Index

Constants

View Source
const ConsensusVersion = 2

ConsensusVersion defines the current x/marketplace module consensus version.

Variables

This section is empty.

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

ExportGenesis returns the capability module's exported genesis.

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)

InitGenesis initializes the capability module's state from a provided genesis state.

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements the AppModule interface for the capability module.

func NewAppModule

func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

BeginBlock executes all ABCI BeginBlock logic respective to the capability module.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements ConsensusVersion.

func (AppModule) EndBlock

EndBlock executes all ABCI EndBlock logic respective to the capability module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs the capability module's genesis initialization It returns no validator updates.

func (AppModule) Name

func (am AppModule) Name() string

Name returns the capability module's name.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the capability module's query routing key.

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants registers the capability module's invariants.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers a GRPC query service to respond to the module-specific GRPC queries.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

AppModuleBasic implements the AppModuleBasic interface for the capability module.

func NewAppModuleBasic

func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns the capability module's default genesis state.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns the capability module's root query command.

func (AppModuleBasic) GetTxCmd

func (a AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns the capability module's root tx command.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the capability module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.

func (AppModuleBasic) RegisterInterfaces

func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router)

RegisterRESTRoutes registers the capability module's REST service handlers.

func (AppModuleBasic) ValidateGenesis

ValidateGenesis performs genesis state validation for the capability module.

Directories

Path Synopsis
client
cli
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL