Skip to content

Commit

Permalink
looks about done
Browse files Browse the repository at this point in the history
  • Loading branch information
karnthis committed Dec 2, 2022
1 parent 42ddea1 commit 6036326
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/customBroadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DeliverTxResponse, SigningStargateClient } from '@cosmjs/stargate'
/**
* Jackal Custom Protos
*/
import fileTreeTypes from '@/snackages/tx/custom/fileTree'
import rnsTypes from '@/snackages/tx/custom/rns'
import storageTypes from '@/snackages/tx/custom/storage'

Expand Down Expand Up @@ -35,6 +36,7 @@ export interface IGenBroadcaster {
* The Magic
*/
const masterTypes = [
...Object.values(fileTreeTypes),
...Object.values(rnsTypes),
...Object.values(storageTypes),
...Object.values(bankTypes),
Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { OfflineSigner } from '@cosmjs/proto-signing'
import { genBroadcaster, IGenBroadcaster, TMasterBroadcaster } from '@/customBroadcast'
import IProtoBuilder from '@/interfaces/classes/IProtoBuilder'
import IQueryFileTree from '@/interfaces/classes/IQueryFileTree'
import IQueryJklMint from '@/interfaces/classes/IQueryJklMint'
import IQueryRns from '@/interfaces/classes/IQueryRns'
import IQueryStorage from '@/interfaces/classes/IQueryStorage'
Expand All @@ -10,6 +11,7 @@ import IQueryGov from '@/interfaces/classes/IQueryGov'
import IQueryStaking from '@/interfaces/classes/IQueryStaking'
import {
GrpcWebImpl,
IFileTreeGrpc,
IJklMintGrpc,
IRnsGrpc,
IStorageGrpc,
Expand All @@ -20,6 +22,7 @@ import {
TGrpc
} from '@/interfaces/IGrpcWebImpl'

import QueryFileTree from '@/snackages/query/custom/fileTree'
import QueryJklMint from '@/snackages/query/custom/jklMint'
import QueryRns from '@/snackages/query/custom/rns'
import QueryStorage from '@/snackages/query/custom/storage'
Expand All @@ -28,6 +31,7 @@ import QueryDistribution from '@/snackages/query/static/distribution'
import QueryGov from '@/snackages/query/static/gov'
import QueryStaking from '@/snackages/query/static/staking'

import { ITxFileTree, TxFileTree } from '@/snackages/tx/custom/fileTree'
import { ITxRns, TxRns } from '@/snackages/tx/custom/rns'
import { ITxStorage, TxStorage } from '@/snackages/tx/custom/storage'
import { ITxBank, TxBank } from '@/snackages/tx/static/bank'
Expand Down Expand Up @@ -56,6 +60,7 @@ export default class ProtoBuilder implements IProtoBuilder {
makeAllQuery (): IAllQuery {
return {
/** Custom */
fileTree: this.makeFileTreeQuery(),
jklMint: this.makeJklMintQuery(),
rns: this.makeRnsQuery(),
storage: this.makeStorageQuery(),
Expand All @@ -69,6 +74,7 @@ export default class ProtoBuilder implements IProtoBuilder {
makeAllTx (): IAllTx {
return {
/** Custom */
fileTree: this.makeFileTreeTx(),
jklMint: null,
rns: this.makeRnsTx(),
storage: this.makeStorageTx(),
Expand All @@ -81,6 +87,12 @@ export default class ProtoBuilder implements IProtoBuilder {
}

/** Custom */
makeFileTreeQuery (): IQueryFileTree {
return new QueryFileTree(this.GRpc as IFileTreeGrpc)
}
makeFileTreeTx (): ITxFileTree {
return new TxFileTree()
}
makeJklMintQuery (): IQueryJklMint {
return new QueryJklMint(this.GRpc as IJklMintGrpc)
}
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/IAllQuery.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import IQueryFileTree from '@/interfaces/classes/IQueryFileTree'
import IQueryJklMint from '@/interfaces/classes/IQueryJklMint'
import IQueryRns from '@/interfaces/classes/IQueryRns'
import IQueryStorage from '@/interfaces/classes/IQueryStorage'
Expand All @@ -8,6 +9,7 @@ import IQueryStaking from '@/interfaces/classes/IQueryStaking'

export default interface IAllQuery {
/** Custom */
fileTree: IQueryFileTree,
jklMint: IQueryJklMint,
rns: IQueryRns,
storage: IQueryStorage,
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/IAllTx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ITxFileTree } from '@/snackages/tx/custom/fileTree'
import { ITxRns } from '@/snackages/tx/custom/rns'
import { ITxStorage } from '@/snackages/tx/custom/storage'
import { ITxBank } from '@/snackages/tx/static/bank'
Expand All @@ -7,6 +8,7 @@ import { ITxStaking } from '@/snackages/tx/static/staking'

export default interface IAllTx {
/** Custom */
fileTree: ITxFileTree,
jklMint: null,
rns: ITxRns,
storage: ITxStorage,
Expand Down
14 changes: 7 additions & 7 deletions src/interfaces/IGrpcWebImpl.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { GrpcWebImpl, GrpcWebImpl as IJklMintGrpc } from '@/postgen/canine-chain/jklmint/query'
import { GrpcWebImpl as IRnsGrpc } from '@/postgen/canine-chain/rns/query'
import { GrpcWebImpl as IStorageGrpc } from '@/postgen/canine-chain/storage/query'
import { GrpcWebImpl as IFileTreeGrpc } from '@/postgen/canine_chain/filetree/query'
import { GrpcWebImpl, GrpcWebImpl as IJklMintGrpc } from '@/postgen/canine_chain/jklmint/query'
import { GrpcWebImpl as IRnsGrpc } from '@/postgen/canine_chain/rns/query'
import { GrpcWebImpl as IStorageGrpc } from '@/postgen/canine_chain/storage/query'

import { GrpcWebImpl as IBankGrpc } from '@/postgen/cosmos/bank/v1beta1/query'
import { GrpcWebImpl as IDistributionGrpc } from '@/postgen/cosmos/distribution/v1beta1/query'
import { GrpcWebImpl as IGovGrpc } from '@/postgen/cosmos/gov/v1beta1/query'
import { GrpcWebImpl as IStakingGrpc } from '@/postgen/cosmos/staking/v1beta1/query'

type TGrpc = IJklMintGrpc
type TGrpc = IFileTreeGrpc
| IJklMintGrpc
| IRnsGrpc
| IStorageGrpc
| IBankGrpc
Expand All @@ -19,6 +21,7 @@ export {
GrpcWebImpl,
TGrpc,
/** Custom */
IFileTreeGrpc,
IJklMintGrpc,
IRnsGrpc,
IStorageGrpc,
Expand All @@ -28,6 +31,3 @@ export {
IGovGrpc,
IStakingGrpc
}



11 changes: 7 additions & 4 deletions src/interfaces/classes/IProtoBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { OfflineSigner } from '@cosmjs/proto-signing'
import IQueryRns from '@/interfaces/classes/IQueryRns'
import IQueryFileTree from '@/interfaces/classes/IQueryFileTree'
import IQueryJklMint from '@/interfaces/classes/IQueryJklMint'
import IQueryRns from '@/interfaces/classes/IQueryRns'
import IQueryStorage from '@/interfaces/classes/IQueryStorage'
import IQueryBank from '@/interfaces/classes/IQueryBank'
import IQueryDistribution from '@/interfaces/classes/IQueryDistribution'
import IQueryGov from '@/interfaces/classes/IQueryGov'
import IQueryStaking from '@/interfaces/classes/IQueryStaking'
import { ITxFileTree } from '@/snackages/tx/custom/fileTree'
import { ITxRns } from '@/snackages/tx/custom/rns'
import { ITxStorage } from '@/snackages/tx/custom/storage'
import { ITxBank } from '@/snackages/tx/static/bank'
import { ITxDistribution } from '@/snackages/tx/static/distribution'
import { ITxGov } from '@/snackages/tx/static/gov'
import { ITxStaking } from '@/snackages/tx/static/staking'
import IQueryStorage from '@/interfaces/classes/IQueryStorage'
import { ITxStorage } from '@/snackages/tx/custom/storage'
import IAllQuery from '@/interfaces/IAllQuery'
import IAllTx from '@/interfaces/IAllTx'
import { IGenBroadcaster } from '@/customBroadcast'
Expand All @@ -21,6 +22,8 @@ export default interface IProtoBuilder {
makeMasterBroadcaster (): Promise<IGenBroadcaster>

/** Custom */
makeFileTreeQuery (): IQueryFileTree
makeFileTreeTx (): ITxFileTree
makeJklMintQuery (): IQueryJklMint
makeRnsQuery (): IQueryRns
makeRnsTx (): ITxRns
Expand Down
34 changes: 34 additions & 0 deletions src/interfaces/classes/IQueryFileTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { grpc } from '@improbable-eng/grpc-web'
import {
DeepPartial,
QueryAllFilesRequest,
QueryAllFilesResponse,
QueryAllPubkeysRequest, QueryAllPubkeysResponse,
QueryDecryptRequest,
QueryDecryptResponse,
QueryEncryptRequest,
QueryEncryptResponse,
QueryFileRequest,
QueryFileResponse,
QueryParamsRequest,
QueryParamsResponse,
QueryPubkeyRequest,
QueryPubkeyResponse
} from '@/postgen/canine_chain/filetree/query'

export default interface IQueryFileTree {
/** Parameters queries the parameters of the module. */
queryParams(request: DeepPartial<QueryParamsRequest>, metadata?: grpc.Metadata): Promise<QueryParamsResponse>;
/** Queries a list of Encrypt items. */
queryEncrypt(request: DeepPartial<QueryEncryptRequest>, metadata?: grpc.Metadata): Promise<QueryEncryptResponse>;
/** Queries a list of Decrypt items. */
queryDecrypt(request: DeepPartial<QueryDecryptRequest>, metadata?: grpc.Metadata): Promise<QueryDecryptResponse>;
/** Queries a Files by index. */
queryFiles(request: DeepPartial<QueryFileRequest>, metadata?: grpc.Metadata): Promise<QueryFileResponse>;
/** Queries a list of Files items. */
queryFilesAll(request: DeepPartial<QueryAllFilesRequest>, metadata?: grpc.Metadata): Promise<QueryAllFilesResponse>;
/** Queries a Pubkey by index. */
queryPubkey(request: DeepPartial<QueryPubkeyRequest>, metadata?: grpc.Metadata): Promise<QueryPubkeyResponse>;
/** Queries a list of Pubkey items. */
queryPubkeyAll(request: DeepPartial<QueryAllPubkeysRequest>, metadata?: grpc.Metadata): Promise<QueryAllPubkeysResponse>;
}
52 changes: 52 additions & 0 deletions src/snackages/query/custom/fileTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import IQueryFileTree from '@/interfaces/classes/IQueryFileTree'
import {
DeepPartial,
GrpcWebImpl,
Query,
QueryAllFilesRequest, QueryAllFilesResponse,
QueryAllPubkeysRequest, QueryAllPubkeysResponse,
QueryClientImpl,
QueryDecryptRequest, QueryDecryptResponse,
QueryEncryptRequest, QueryEncryptResponse,
QueryFileRequest, QueryFileResponse,
QueryParamsRequest, QueryParamsResponse,
QueryPubkeyRequest, QueryPubkeyResponse
} from '@/postgen/canine_chain/filetree/query'
import { grpc } from '@improbable-eng/grpc-web'

export default class QueryFileTree implements IQueryFileTree {
private readonly queryClient: Query

constructor (rpc: GrpcWebImpl) {
this.queryClient = new QueryClientImpl(rpc)
}

/** Parameters queries the parameters of the module. */
queryParams(request: DeepPartial<QueryParamsRequest>, metadata?: grpc.Metadata): Promise<QueryParamsResponse> {
return this.queryClient.Params(request, metadata)
}
/** Queries a list of Encrypt items. */
queryEncrypt(request: DeepPartial<QueryEncryptRequest>, metadata?: grpc.Metadata): Promise<QueryEncryptResponse> {
return this.queryClient.Encrypt(request, metadata)
}
/** Queries a list of Decrypt items. */
queryDecrypt(request: DeepPartial<QueryDecryptRequest>, metadata?: grpc.Metadata): Promise<QueryDecryptResponse> {
return this.queryClient.Decrypt(request, metadata)
}
/** Queries a Files by index. */
queryFiles(request: DeepPartial<QueryFileRequest>, metadata?: grpc.Metadata): Promise<QueryFileResponse> {
return this.queryClient.Files(request, metadata)
}
/** Queries a list of Files items. */
queryFilesAll(request: DeepPartial<QueryAllFilesRequest>, metadata?: grpc.Metadata): Promise<QueryAllFilesResponse> {
return this.queryClient.FilesAll(request, metadata)
}
/** Queries a Pubkey by index. */
queryPubkey(request: DeepPartial<QueryPubkeyRequest>, metadata?: grpc.Metadata): Promise<QueryPubkeyResponse> {
return this.queryClient.Pubkey(request, metadata)
}
/** Queries a list of Pubkey items. */
queryPubkeyAll(request: DeepPartial<QueryAllPubkeysRequest>, metadata?: grpc.Metadata): Promise<QueryAllPubkeysResponse> {
return this.queryClient.PubkeyAll(request, metadata)
}
}
81 changes: 81 additions & 0 deletions src/snackages/tx/custom/fileTree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {
MsgAddEditors,
MsgAddViewers,
MsgChangeOwner,
MsgDeleteFile,
MsgMakeRoot,
MsgPostFile,
MsgPostkey,
MsgRemoveEditors,
MsgRemoveViewers,
MsgResetEditors,
MsgResetViewers
} from '@/postgen/canine_chain/filetree/tx'
import { EncodeObject } from '@cosmjs/proto-signing'
import ITypeTuple from '@/interfaces/ITypeTuple'

const fileTreeTypes: ITypeTuple = {
postFile: ['/canine_chain.filetree.MsgPostFile', MsgPostFile],
addViewers: ['/canine_chain.filetree.MsgAddViewers', MsgAddViewers],
postkey: ['/canine_chain.filetree.MsgPostkey', MsgPostkey],
deleteFile: ['/canine_chain.filetree.MsgDeleteFile', MsgDeleteFile],
removeViewers: ['/canine_chain.filetree.MsgRemoveViewers', MsgRemoveViewers],
makeRoot: ['/canine_chain.filetree.MsgMakeRoot', MsgMakeRoot],
addEditors: ['/canine_chain.filetree.MsgAddEditors', MsgAddEditors],
removeEditors: ['/canine_chain.filetree.MsgRemoveEditors', MsgRemoveEditors],
resetEditors: ['/canine_chain.filetree.MsgResetEditors', MsgResetEditors],
resetViewers: ['/canine_chain.filetree.MsgResetViewers', MsgResetViewers],
changeOwner: ['/canine_chain.filetree.MsgChangeOwner', MsgChangeOwner]
}

export default fileTreeTypes

export interface ITxFileTree {
msgPostFile (data: MsgPostFile): EncodeObject
msgAddViewers (data: MsgAddViewers): EncodeObject
msgPostkey (data: MsgPostkey): EncodeObject
msgDeleteFile (data: MsgDeleteFile): EncodeObject
msgRemoveViewers (data: MsgRemoveViewers): EncodeObject
msgMakeRoot (data: MsgMakeRoot): EncodeObject
msgAddEditors (data: MsgAddEditors): EncodeObject
msgRemoveEditors (data: MsgRemoveEditors): EncodeObject
msgResetEditors (data: MsgResetEditors): EncodeObject
msgResetViewers (data: MsgResetViewers): EncodeObject
msgChangeOwner (data: MsgChangeOwner): EncodeObject
}

export class TxFileTree implements ITxFileTree {
msgPostFile (data: MsgPostFile): EncodeObject {
return { typeUrl: fileTreeTypes.postFile[0], value: fileTreeTypes.postFile[1].fromPartial( data ) }
}
msgAddViewers (data: MsgAddViewers): EncodeObject {
return { typeUrl: fileTreeTypes.addViewers[0], value: fileTreeTypes.addViewers[1].fromPartial( data ) }
}
msgPostkey (data: MsgPostkey): EncodeObject {
return { typeUrl: fileTreeTypes.postkey[0], value: fileTreeTypes.postkey[1].fromPartial( data ) }
}
msgDeleteFile (data: MsgDeleteFile): EncodeObject {
return { typeUrl: fileTreeTypes.deleteFile[0], value: fileTreeTypes.deleteFile[1].fromPartial( data ) }
}
msgRemoveViewers (data: MsgRemoveViewers): EncodeObject {
return { typeUrl: fileTreeTypes.removeViewers[0], value: fileTreeTypes.removeViewers[1].fromPartial( data ) }
}
msgMakeRoot (data: MsgMakeRoot): EncodeObject {
return { typeUrl: fileTreeTypes.makeRoot[0], value: fileTreeTypes.makeRoot[1].fromPartial( data ) }
}
msgAddEditors (data: MsgAddEditors): EncodeObject {
return { typeUrl: fileTreeTypes.addEditors[0], value: fileTreeTypes.addEditors[1].fromPartial( data ) }
}
msgRemoveEditors (data: MsgRemoveEditors): EncodeObject {
return { typeUrl: fileTreeTypes.removeEditors[0], value: fileTreeTypes.removeEditors[1].fromPartial( data ) }
}
msgResetEditors (data: MsgResetEditors): EncodeObject {
return { typeUrl: fileTreeTypes.resetEditors[0], value: fileTreeTypes.resetEditors[1].fromPartial( data ) }
}
msgResetViewers (data: MsgResetViewers): EncodeObject {
return { typeUrl: fileTreeTypes.resetViewers[0], value: fileTreeTypes.resetViewers[1].fromPartial( data ) }
}
msgChangeOwner (data: MsgChangeOwner): EncodeObject {
return { typeUrl: fileTreeTypes.changeOwner[0], value: fileTreeTypes.changeOwner[1].fromPartial( data ) }
}
}
22 changes: 11 additions & 11 deletions src/snackages/tx/custom/rns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import { EncodeObject } from '@cosmjs/proto-signing'
import ITypeTuple from '@/interfaces/ITypeTuple'

const rnsTypes: ITypeTuple = {
acceptBid: ['/jackaldao.canine.rns.MsgAcceptBid', MsgAcceptBid],
addRecord: ['/jackaldao.canine.rns.MsgAddRecord', MsgAddRecord],
bid: ['/jackaldao.canine.rns.MsgBid', MsgBid],
buy: ['/jackaldao.canine.rns.MsgBuy', MsgBuy],
cancelBid: ['/jackaldao.canine.rns.MsgCancelBid', MsgCancelBid],
delist: ['/jackaldao.canine.rns.MsgDelist', MsgDelist],
delRecord: ['/jackaldao.canine.rns.MsgDelRecord', MsgDelRecord],
init: ['/jackaldao.canine.rns.MsgInit', MsgInit],
list: ['/jackaldao.canine.rns.MsgList', MsgList],
register: ['/jackaldao.canine.rns.MsgRegister', MsgRegister],
transfer: ['/jackaldao.canine.rns.MsgTransfer', MsgTransfer]
acceptBid: ['/canine_chain.rns.MsgAcceptBid', MsgAcceptBid],
addRecord: ['/canine_chain.rns.MsgAddRecord', MsgAddRecord],
bid: ['/canine_chain.rns.MsgBid', MsgBid],
buy: ['/canine_chain.rns.MsgBuy', MsgBuy],
cancelBid: ['/canine_chain.rns.MsgCancelBid', MsgCancelBid],
delist: ['/canine_chain.rns.MsgDelist', MsgDelist],
delRecord: ['/canine_chain.rns.MsgDelRecord', MsgDelRecord],
init: ['/canine_chain.rns.MsgInit', MsgInit],
list: ['/canine_chain.rns.MsgList', MsgList],
register: ['/canine_chain.rns.MsgRegister', MsgRegister],
transfer: ['/canine_chain.rns.MsgTransfer', MsgTransfer]
}

export default rnsTypes
Expand Down
20 changes: 10 additions & 10 deletions src/snackages/tx/custom/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import { EncodeObject } from '@cosmjs/proto-signing'
import ITypeTuple from '@/interfaces/ITypeTuple'

const storageTypes: ITypeTuple = {
postContract: ['/jackaldao.canine.storage.MsgPostContract', MsgPostContract],
postproof: ['/jackaldao.canine.storage.MsgPostproof', MsgPostproof],
signContract: ['/jackaldao.canine.storage.MsgSignContract', MsgSignContract],
setProviderIP: ['/jackaldao.canine.storage.MsgSetProviderIP', MsgSetProviderIP],
setProviderKeybase: ['/jackaldao.canine.storage.MsgSetProviderKeybase', MsgSetProviderKeybase],
setProviderTotalspace: ['/jackaldao.canine.storage.MsgSetProviderTotalspace', MsgSetProviderTotalspace],
initProvider: ['/jackaldao.canine.storage.MsgInitProvider', MsgInitProvider],
cancelContract: ['/jackaldao.canine.storage.MsgCancelContract', MsgCancelContract],
buyStorage: ['/jackaldao.canine.storage.MsgBuyStorage', MsgBuyStorage],
claimStray: ['/jackaldao.canine.storage.MsgClaimStray', MsgClaimStray]
postContract: ['/canine_chain.storage.MsgPostContract', MsgPostContract],
postproof: ['/canine_chain.storage.MsgPostproof', MsgPostproof],
signContract: ['/canine_chain.storage.MsgSignContract', MsgSignContract],
setProviderIP: ['/canine_chain.storage.MsgSetProviderIP', MsgSetProviderIP],
setProviderKeybase: ['/canine_chain.storage.MsgSetProviderKeybase', MsgSetProviderKeybase],
setProviderTotalspace: ['/canine_chain.storage.MsgSetProviderTotalspace', MsgSetProviderTotalspace],
initProvider: ['/canine_chain.storage.MsgInitProvider', MsgInitProvider],
cancelContract: ['/canine_chain.storage.MsgCancelContract', MsgCancelContract],
buyStorage: ['/canine_chain.storage.MsgBuyStorage', MsgBuyStorage],
claimStray: ['/canine_chain.storage.MsgClaimStray', MsgClaimStray]
}

export default storageTypes
Expand Down

0 comments on commit 6036326

Please sign in to comment.