-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test sample for multiple stargate client
- Loading branch information
1 parent
4494d2d
commit 3621b12
Showing
630 changed files
with
312,241 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
__fixtures__/v-next/outputcombinedclient/akash-cosmos-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { GeneratedType, Registry, OfflineSigner } from "@cosmjs/proto-signing"; | ||
import { defaultRegistryTypes, AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; | ||
import { HttpEndpoint } from "@cosmjs/tendermint-rpc"; | ||
import { createRpcClient } from "../outputinstantrpc/extern"; | ||
import { DeliverTxResponse, EncodeObject, StdFee, TxRpc, SigningClientParams } from "./types"; | ||
import * as cosmosGroupV1TxAmino from "./cosmos/group/v1/tx.amino"; | ||
import * as cosmosNftV1beta1TxAmino from "./cosmos/nft/v1beta1/tx.amino"; | ||
import * as akashAuditV1beta1AuditAmino from "./akash/audit/v1beta1/audit.amino"; | ||
import * as akashAuditV1beta2AuditAmino from "./akash/audit/v1beta2/audit.amino"; | ||
import * as cosmosGroupV1TxRegistry from "./cosmos/group/v1/tx.registry"; | ||
import * as cosmosNftV1beta1TxRegistry from "./cosmos/nft/v1beta1/tx.registry"; | ||
import * as akashAuditV1beta1AuditRegistry from "./akash/audit/v1beta1/audit.registry"; | ||
import * as akashAuditV1beta2AuditRegistry from "./akash/audit/v1beta2/audit.registry"; | ||
|
||
|
||
export const combinedAminoConverters = { | ||
...cosmosGroupV1TxAmino.AminoConverter, | ||
...cosmosNftV1beta1TxAmino.AminoConverter, | ||
...akashAuditV1beta1AuditAmino.AminoConverter, | ||
...akashAuditV1beta2AuditAmino.AminoConverter, | ||
}; | ||
|
||
export const combinedProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [ | ||
...cosmosGroupV1TxRegistry.registry, | ||
...cosmosNftV1beta1TxRegistry.registry, | ||
...akashAuditV1beta1AuditRegistry.registry, | ||
...akashAuditV1beta2AuditRegistry.registry, | ||
]; | ||
|
||
export const getAkashCosmosSigningClientOptions = ({ | ||
defaultTypes = defaultRegistryTypes | ||
}: { | ||
defaultTypes?: ReadonlyArray<[string, GeneratedType]>; | ||
} = {}): { | ||
registry: Registry; | ||
aminoTypes: AminoTypes; | ||
} => { | ||
const registry = new Registry([ | ||
...defaultTypes, | ||
...combinedProtoRegistry, | ||
]); | ||
const aminoTypes = new AminoTypes({ | ||
...combinedAminoConverters, | ||
}); | ||
return { | ||
registry, | ||
aminoTypes | ||
} | ||
} | ||
|
||
export const getSigningAkashCosmosClient = async ({ | ||
rpcEndpoint, | ||
signer, | ||
defaultTypes = defaultRegistryTypes | ||
}: { | ||
rpcEndpoint: string | HttpEndpoint; | ||
signer: OfflineSigner; | ||
defaultTypes?: ReadonlyArray<[string, GeneratedType]>; | ||
}) => { | ||
const { | ||
registry, | ||
aminoTypes | ||
} = getAkashCosmosSigningClientOptions({ | ||
defaultTypes | ||
}); | ||
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { | ||
registry: (registry as any), | ||
aminoTypes | ||
}); | ||
return client; | ||
}; | ||
|
||
export const getSigningAkashCosmosTxRpc = async ({ | ||
rpcEndpoint, | ||
signer | ||
}: SigningClientParams) => { | ||
let txRpc = (await createRpcClient(rpcEndpoint) as TxRpc); | ||
const signingClient = await getSigningAkashCosmosClient({ | ||
rpcEndpoint, | ||
signer | ||
}); | ||
txRpc.signAndBroadcast = (signerAddress: string, messages: EncodeObject[], fee: number | StdFee | "auto", memo?: string) => { | ||
return (signingClient.signAndBroadcast(signerAddress, messages, fee, memo) as Promise<DeliverTxResponse>); | ||
}; | ||
return txRpc; | ||
}; |
81 changes: 81 additions & 0 deletions
81
__fixtures__/v-next/outputcombinedclient/akash/audit/v1beta1/audit.amino.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* eslint-disable */ | ||
import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute"; | ||
import { AminoMsg } from "@cosmjs/amino"; | ||
import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit"; | ||
export interface MsgSignProviderAttributesAminoType extends AminoMsg { | ||
type: "akash/audit/testonly-sign-provider-attributes"; | ||
value: { | ||
owner: string; | ||
auditor: string; | ||
attributes: { | ||
key: string; | ||
value: string; | ||
}[]; | ||
}; | ||
} | ||
export interface MsgDeleteProviderAttributesAminoType extends AminoMsg { | ||
type: "akash/audit/testonly-delete-provider-attributes"; | ||
value: { | ||
owner: string; | ||
auditor: string; | ||
keys: string[]; | ||
}; | ||
} | ||
export const AminoConverter = { | ||
"/akash.audit.v1beta1.MsgSignProviderAttributes": { | ||
aminoType: "akash/audit/testonly-sign-provider-attributes", | ||
toAmino: ({ | ||
owner, | ||
auditor, | ||
attributes | ||
}: MsgSignProviderAttributes): MsgSignProviderAttributesAminoType["value"] => { | ||
return { | ||
owner, | ||
auditor, | ||
attributes: attributes.map(el0 => ({ | ||
key: el0.key, | ||
value: el0.value | ||
})) | ||
}; | ||
}, | ||
fromAmino: ({ | ||
owner, | ||
auditor, | ||
attributes | ||
}: MsgSignProviderAttributesAminoType["value"]): MsgSignProviderAttributes => { | ||
return { | ||
owner, | ||
auditor, | ||
attributes: attributes.map?.(el0 => ({ | ||
key: el0.key, | ||
value: el0.value | ||
})) | ||
}; | ||
} | ||
}, | ||
"/akash.audit.v1beta1.MsgDeleteProviderAttributes": { | ||
aminoType: "akash/audit/testonly-delete-provider-attributes", | ||
toAmino: ({ | ||
owner, | ||
auditor, | ||
keys | ||
}: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAminoType["value"] => { | ||
return { | ||
owner, | ||
auditor, | ||
keys | ||
}; | ||
}, | ||
fromAmino: ({ | ||
owner, | ||
auditor, | ||
keys | ||
}: MsgDeleteProviderAttributesAminoType["value"]): MsgDeleteProviderAttributes => { | ||
return { | ||
owner, | ||
auditor, | ||
keys | ||
}; | ||
} | ||
} | ||
}; |
82 changes: 82 additions & 0 deletions
82
__fixtures__/v-next/outputcombinedclient/akash/audit/v1beta1/audit.registry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute"; | ||
import { TelescopeGeneratedType } from "../../../types"; | ||
import { Registry } from "@cosmjs/proto-signing"; | ||
import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit"; | ||
export const registry: ReadonlyArray<[string, TelescopeGeneratedType<any, any, any>]> = [["/akash.audit.v1beta1.MsgSignProviderAttributes", MsgSignProviderAttributes], ["/akash.audit.v1beta1.MsgDeleteProviderAttributes", MsgDeleteProviderAttributes]]; | ||
export const load = (protoRegistry: Registry) => { | ||
registry.forEach(([typeUrl, mod]) => { | ||
protoRegistry.register(typeUrl, mod); | ||
}); | ||
}; | ||
export const MessageComposer = { | ||
encoded: { | ||
signProviderAttributes(value: MsgSignProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", | ||
value: MsgSignProviderAttributes.encode(value).finish() | ||
}; | ||
}, | ||
deleteProviderAttributes(value: MsgDeleteProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", | ||
value: MsgDeleteProviderAttributes.encode(value).finish() | ||
}; | ||
} | ||
}, | ||
withTypeUrl: { | ||
signProviderAttributes(value: MsgSignProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", | ||
value | ||
}; | ||
}, | ||
deleteProviderAttributes(value: MsgDeleteProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", | ||
value | ||
}; | ||
} | ||
}, | ||
toJSON: { | ||
signProviderAttributes(value: MsgSignProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", | ||
value: MsgSignProviderAttributes.toJSON(value) | ||
}; | ||
}, | ||
deleteProviderAttributes(value: MsgDeleteProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", | ||
value: MsgDeleteProviderAttributes.toJSON(value) | ||
}; | ||
} | ||
}, | ||
fromJSON: { | ||
signProviderAttributes(value: any) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", | ||
value: MsgSignProviderAttributes.fromJSON(value) | ||
}; | ||
}, | ||
deleteProviderAttributes(value: any) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", | ||
value: MsgDeleteProviderAttributes.fromJSON(value) | ||
}; | ||
} | ||
}, | ||
fromPartial: { | ||
signProviderAttributes(value: MsgSignProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", | ||
value: MsgSignProviderAttributes.fromPartial(value) | ||
}; | ||
}, | ||
deleteProviderAttributes(value: MsgDeleteProviderAttributes) { | ||
return { | ||
typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", | ||
value: MsgDeleteProviderAttributes.fromPartial(value) | ||
}; | ||
} | ||
} | ||
}; |
36 changes: 36 additions & 0 deletions
36
__fixtures__/v-next/outputcombinedclient/akash/audit/v1beta1/audit.rpc.msg.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute"; | ||
import { DeliverTxResponse, StdFee, TxRpc } from "../../../types"; | ||
import { BinaryReader } from "../../../binary"; | ||
import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgSignProviderAttributesResponse, MsgSignProviderAttributesResponseSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType, MsgDeleteProviderAttributesResponse, MsgDeleteProviderAttributesResponseSDKType } from "./audit"; | ||
/** Msg defines the provider Msg service */ | ||
export interface Msg { | ||
/** SignProviderAttributes defines a method that signs provider attributes */ | ||
signProviderAttributes(signerAddress: string, message: MsgSignProviderAttributes, fee: number | StdFee | "auto", memo?: string): Promise<DeliverTxResponse>; | ||
/** DeleteProviderAttributes defines a method that deletes provider attributes */ | ||
deleteProviderAttributes(signerAddress: string, message: MsgDeleteProviderAttributes, fee: number | StdFee | "auto", memo?: string): Promise<DeliverTxResponse>; | ||
} | ||
export class MsgClientImpl implements Msg { | ||
private readonly rpc: TxRpc; | ||
constructor(rpc: TxRpc) { | ||
this.rpc = rpc; | ||
} | ||
/* SignProviderAttributes defines a method that signs provider attributes */ | ||
signProviderAttributes = async (signerAddress: string, message: MsgSignProviderAttributes, fee: number | StdFee | "auto" = "auto", memo: string = ""): Promise<DeliverTxResponse> => { | ||
const data = [{ | ||
typeUrl: MsgSignProviderAttributes.typeUrl, | ||
value: message | ||
}]; | ||
return this.rpc.signAndBroadcast!(signerAddress, data, fee, memo); | ||
}; | ||
/* DeleteProviderAttributes defines a method that deletes provider attributes */ | ||
deleteProviderAttributes = async (signerAddress: string, message: MsgDeleteProviderAttributes, fee: number | StdFee | "auto" = "auto", memo: string = ""): Promise<DeliverTxResponse> => { | ||
const data = [{ | ||
typeUrl: MsgDeleteProviderAttributes.typeUrl, | ||
value: message | ||
}]; | ||
return this.rpc.signAndBroadcast!(signerAddress, data, fee, memo); | ||
}; | ||
} | ||
export const createClientImpl = (rpc: TxRpc) => { | ||
return new MsgClientImpl(rpc); | ||
}; |
Oops, something went wrong.