Skip to content

Commit

Permalink
module-sdk-go refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicke-lucky committed Jun 29, 2021
1 parent 610f65a commit ef78189
Show file tree
Hide file tree
Showing 46 changed files with 44,342 additions and 0 deletions.
24 changes: 24 additions & 0 deletions module-sdk/random/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package random

import (
"github.com/irisnet/core-sdk-go/common/codec"
"github.com/irisnet/core-sdk-go/common/codec/types"
cryptocodec "github.com/irisnet/core-sdk-go/common/crypto/codec"
sdk "github.com/irisnet/core-sdk-go/types"
)

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgRequestRandom{},
)
}
39 changes: 39 additions & 0 deletions module-sdk/random/export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package random

import sdk "github.com/irisnet/core-sdk-go/types"

// expose Random module api for user
type Client interface {
sdk.Module

RequestRandom(request RequestRandomRequest, basTx sdk.BaseTx) (RequestRandomResp, sdk.ResultTx, sdk.Error)

QueryRandom(ReqId string) (QueryRandomResp, sdk.Error)
QueryRandomRequestQueue(height int64) ([]QueryRandomRequestQueueResp, sdk.Error)
}

type RequestRandomRequest struct {
BlockInterval uint64 `json:"block_interval"`
Oracle bool `json:"oracle"`
ServiceFeeCap sdk.Coins `json:"service_fee_cap"`
}

type RequestRandomResp struct {
Height int64 `json:"height"`
ReqID string `json:"req_id"`
}

type QueryRandomResp struct {
RequestTxHash string `json:"request_tx_hash" yaml:"request_tx_hash"`
Height int64 `json:"height" yaml:"height"`
Value string `json:"value" yaml:"value"`
}

type QueryRandomRequestQueueResp struct {
Height int64 `json:"height" yaml:"height"`
Consumer string `json:"consumer" yaml:"consumer"`
TxHash string `json:"tx_hash" yaml:"tx_hash"`
Oracle bool `json:"oracle" yaml:"oracle"`
ServiceFeeCap sdk.Coins `json:"service_fee_cap" yaml:"service_fee_cap"`
ServiceContextId string `json:"service_context_id" yaml:"service_context_id"`
}
13 changes: 13 additions & 0 deletions module-sdk/random/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module random

go 1.16

require (
github.com/irisnet/core-sdk-go v0.1.0
github.com/gogo/protobuf v1.3.3
)

replace (
github.com/irisnet/core-sdk-go => /Users/nicker/sandbox/bianjie/sdk/irishub-sdk-go/core-sdk
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
)
Loading

0 comments on commit ef78189

Please sign in to comment.