diff --git a/src/customBroadcast.ts b/src/customBroadcast.ts index f4868ae..2e975b6 100644 --- a/src/customBroadcast.ts +++ b/src/customBroadcast.ts @@ -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' @@ -35,6 +36,7 @@ export interface IGenBroadcaster { * The Magic */ const masterTypes = [ + ...Object.values(fileTreeTypes), ...Object.values(rnsTypes), ...Object.values(storageTypes), ...Object.values(bankTypes), diff --git a/src/index.ts b/src/index.ts index 41dcecf..aa43f72 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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' @@ -10,6 +11,7 @@ import IQueryGov from '@/interfaces/classes/IQueryGov' import IQueryStaking from '@/interfaces/classes/IQueryStaking' import { GrpcWebImpl, + IFileTreeGrpc, IJklMintGrpc, IRnsGrpc, IStorageGrpc, @@ -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' @@ -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' @@ -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(), @@ -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(), @@ -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) } diff --git a/src/interfaces/IAllQuery.ts b/src/interfaces/IAllQuery.ts index 1080585..fa250ca 100644 --- a/src/interfaces/IAllQuery.ts +++ b/src/interfaces/IAllQuery.ts @@ -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' @@ -8,6 +9,7 @@ import IQueryStaking from '@/interfaces/classes/IQueryStaking' export default interface IAllQuery { /** Custom */ + fileTree: IQueryFileTree, jklMint: IQueryJklMint, rns: IQueryRns, storage: IQueryStorage, diff --git a/src/interfaces/IAllTx.ts b/src/interfaces/IAllTx.ts index 67364de..39d49d1 100644 --- a/src/interfaces/IAllTx.ts +++ b/src/interfaces/IAllTx.ts @@ -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' @@ -7,6 +8,7 @@ import { ITxStaking } from '@/snackages/tx/static/staking' export default interface IAllTx { /** Custom */ + fileTree: ITxFileTree, jklMint: null, rns: ITxRns, storage: ITxStorage, diff --git a/src/interfaces/IGrpcWebImpl.ts b/src/interfaces/IGrpcWebImpl.ts index 55eab31..48b2d9a 100644 --- a/src/interfaces/IGrpcWebImpl.ts +++ b/src/interfaces/IGrpcWebImpl.ts @@ -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 @@ -19,6 +21,7 @@ export { GrpcWebImpl, TGrpc, /** Custom */ + IFileTreeGrpc, IJklMintGrpc, IRnsGrpc, IStorageGrpc, @@ -28,6 +31,3 @@ export { IGovGrpc, IStakingGrpc } - - - diff --git a/src/interfaces/classes/IProtoBuilder.ts b/src/interfaces/classes/IProtoBuilder.ts index 8900f5b..e95b1e3 100644 --- a/src/interfaces/classes/IProtoBuilder.ts +++ b/src/interfaces/classes/IProtoBuilder.ts @@ -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' @@ -21,6 +22,8 @@ export default interface IProtoBuilder { makeMasterBroadcaster (): Promise /** Custom */ + makeFileTreeQuery (): IQueryFileTree + makeFileTreeTx (): ITxFileTree makeJklMintQuery (): IQueryJklMint makeRnsQuery (): IQueryRns makeRnsTx (): ITxRns diff --git a/src/interfaces/classes/IQueryFileTree.ts b/src/interfaces/classes/IQueryFileTree.ts new file mode 100644 index 0000000..c0ea602 --- /dev/null +++ b/src/interfaces/classes/IQueryFileTree.ts @@ -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, metadata?: grpc.Metadata): Promise; + /** Queries a list of Encrypt items. */ + queryEncrypt(request: DeepPartial, metadata?: grpc.Metadata): Promise; + /** Queries a list of Decrypt items. */ + queryDecrypt(request: DeepPartial, metadata?: grpc.Metadata): Promise; + /** Queries a Files by index. */ + queryFiles(request: DeepPartial, metadata?: grpc.Metadata): Promise; + /** Queries a list of Files items. */ + queryFilesAll(request: DeepPartial, metadata?: grpc.Metadata): Promise; + /** Queries a Pubkey by index. */ + queryPubkey(request: DeepPartial, metadata?: grpc.Metadata): Promise; + /** Queries a list of Pubkey items. */ + queryPubkeyAll(request: DeepPartial, metadata?: grpc.Metadata): Promise; +} diff --git a/src/snackages/query/custom/fileTree.ts b/src/snackages/query/custom/fileTree.ts new file mode 100644 index 0000000..3d3d346 --- /dev/null +++ b/src/snackages/query/custom/fileTree.ts @@ -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, metadata?: grpc.Metadata): Promise { + return this.queryClient.Params(request, metadata) + } + /** Queries a list of Encrypt items. */ + queryEncrypt(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.Encrypt(request, metadata) + } + /** Queries a list of Decrypt items. */ + queryDecrypt(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.Decrypt(request, metadata) + } + /** Queries a Files by index. */ + queryFiles(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.Files(request, metadata) + } + /** Queries a list of Files items. */ + queryFilesAll(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.FilesAll(request, metadata) + } + /** Queries a Pubkey by index. */ + queryPubkey(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.Pubkey(request, metadata) + } + /** Queries a list of Pubkey items. */ + queryPubkeyAll(request: DeepPartial, metadata?: grpc.Metadata): Promise { + return this.queryClient.PubkeyAll(request, metadata) + } +} diff --git a/src/snackages/tx/custom/fileTree.ts b/src/snackages/tx/custom/fileTree.ts new file mode 100644 index 0000000..e0863bd --- /dev/null +++ b/src/snackages/tx/custom/fileTree.ts @@ -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 ) } + } +} diff --git a/src/snackages/tx/custom/rns.ts b/src/snackages/tx/custom/rns.ts index 653a00e..aaec174 100644 --- a/src/snackages/tx/custom/rns.ts +++ b/src/snackages/tx/custom/rns.ts @@ -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 diff --git a/src/snackages/tx/custom/storage.ts b/src/snackages/tx/custom/storage.ts index 64eb36a..156525d 100644 --- a/src/snackages/tx/custom/storage.ts +++ b/src/snackages/tx/custom/storage.ts @@ -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