Remove unnecessary address prefix from createStakingAminoConverters
This commit is contained in:
@@ -45,7 +45,7 @@ describe("AminoTypes", () => {
|
||||
|
||||
it("can override type with Amino type collision", () => {
|
||||
const types = new AminoTypes({
|
||||
...createStakingAminoConverters("cosmos"),
|
||||
...createStakingAminoConverters(),
|
||||
"/cosmos.staking.otherVersion456.MsgDelegate": {
|
||||
aminoType: "cosmos-sdk/MsgDelegate",
|
||||
toAmino: (m: MsgDelegate): { readonly foo: string } => ({
|
||||
|
||||
@@ -41,7 +41,7 @@ describe("AminoTypes", () => {
|
||||
validatorDstAddress: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
amount: coin(1234, "ucosm"),
|
||||
};
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters("cosmos"));
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters());
|
||||
const aminoMsg = aminoTypes.toAmino({
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
||||
value: msg,
|
||||
@@ -87,7 +87,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
value: coin(1234, "ucosm"),
|
||||
};
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters("cosmos"));
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters());
|
||||
const aminoMsg = aminoTypes.toAmino({
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator",
|
||||
value: msg,
|
||||
@@ -126,7 +126,7 @@ describe("AminoTypes", () => {
|
||||
validatorAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
amount: coin(1234, "ucosm"),
|
||||
};
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters("cosmos"));
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters());
|
||||
const aminoMsg = aminoTypes.toAmino({
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
|
||||
value: msg,
|
||||
@@ -155,7 +155,7 @@ describe("AminoTypes", () => {
|
||||
minSelfDelegation: "123",
|
||||
validatorAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
};
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters("cosmos"));
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters());
|
||||
const aminoMsg = aminoTypes.toAmino({
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator",
|
||||
value: msg,
|
||||
@@ -184,7 +184,7 @@ describe("AminoTypes", () => {
|
||||
validatorAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
amount: coin(1234, "ucosm"),
|
||||
};
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters("cosmos"));
|
||||
const aminoTypes = new AminoTypes(createStakingAminoConverters());
|
||||
const aminoMsg = aminoTypes.toAmino({
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate",
|
||||
value: msg,
|
||||
@@ -212,7 +212,7 @@ describe("AminoTypes", () => {
|
||||
amount: coin(1234, "ucosm"),
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes(createStakingAminoConverters("cosmos")).fromAmino(aminoMsg);
|
||||
const msg = new AminoTypes(createStakingAminoConverters()).fromAmino(aminoMsg);
|
||||
const expectedValue: MsgBeginRedelegate = {
|
||||
delegatorAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
validatorSrcAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
@@ -251,7 +251,7 @@ describe("AminoTypes", () => {
|
||||
value: coin(1234, "ucosm"),
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes(createStakingAminoConverters("cosmos")).fromAmino(aminoMsg);
|
||||
const msg = new AminoTypes(createStakingAminoConverters()).fromAmino(aminoMsg);
|
||||
const expectedValue: MsgCreateValidator = {
|
||||
description: {
|
||||
moniker: "validator",
|
||||
@@ -295,7 +295,7 @@ describe("AminoTypes", () => {
|
||||
amount: coin(1234, "ucosm"),
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes(createStakingAminoConverters("cosmos")).fromAmino(aminoMsg);
|
||||
const msg = new AminoTypes(createStakingAminoConverters()).fromAmino(aminoMsg);
|
||||
const expectedValue: MsgDelegate = {
|
||||
delegatorAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
validatorAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
@@ -323,7 +323,7 @@ describe("AminoTypes", () => {
|
||||
validator_address: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes(createStakingAminoConverters("cosmos")).fromAmino(aminoMsg);
|
||||
const msg = new AminoTypes(createStakingAminoConverters()).fromAmino(aminoMsg);
|
||||
const expectedValue: MsgEditValidator = {
|
||||
description: {
|
||||
moniker: "validator",
|
||||
@@ -351,7 +351,7 @@ describe("AminoTypes", () => {
|
||||
amount: coin(1234, "ucosm"),
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes(createStakingAminoConverters("cosmos")).fromAmino(aminoMsg);
|
||||
const msg = new AminoTypes(createStakingAminoConverters()).fromAmino(aminoMsg);
|
||||
const expectedValue: MsgUndelegate = {
|
||||
delegatorAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
validatorAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
|
||||
@@ -143,9 +143,7 @@ export function isAminoMsgUndelegate(msg: AminoMsg): msg is AminoMsgUndelegate {
|
||||
return msg.type === "cosmos-sdk/MsgUndelegate";
|
||||
}
|
||||
|
||||
export function createStakingAminoConverters(
|
||||
_prefix: string,
|
||||
): Record<string, AminoConverter | "not_supported_by_chain"> {
|
||||
export function createStakingAminoConverters(): Record<string, AminoConverter | "not_supported_by_chain"> {
|
||||
return {
|
||||
"/cosmos.staking.v1beta1.MsgBeginRedelegate": {
|
||||
aminoType: "cosmos-sdk/MsgBeginRedelegate",
|
||||
|
||||
@@ -87,19 +87,18 @@ export interface PrivateSigningStargateClient {
|
||||
export interface SigningStargateClientOptions extends StargateClientOptions {
|
||||
readonly registry?: Registry;
|
||||
readonly aminoTypes?: AminoTypes;
|
||||
readonly prefix?: string;
|
||||
readonly broadcastTimeoutMs?: number;
|
||||
readonly broadcastPollIntervalMs?: number;
|
||||
readonly gasPrice?: GasPrice;
|
||||
}
|
||||
|
||||
function createDefaultTypes(prefix: string): AminoConverters {
|
||||
function createDefaultTypes(): AminoConverters {
|
||||
return {
|
||||
...createAuthzAminoConverters(),
|
||||
...createBankAminoConverters(),
|
||||
...createDistributionAminoConverters(),
|
||||
...createGovAminoConverters(),
|
||||
...createStakingAminoConverters(prefix),
|
||||
...createStakingAminoConverters(),
|
||||
...createIbcAminoConverters(),
|
||||
...createFeegrantAminoConverters(),
|
||||
...createVestingAminoConverters(),
|
||||
@@ -146,10 +145,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
options: SigningStargateClientOptions,
|
||||
) {
|
||||
super(tmClient, options);
|
||||
// TODO: do we really want to set a default here? Ideally we could get it from the signer such that users only have to set it once.
|
||||
const prefix = options.prefix ?? "cosmos";
|
||||
const { registry = createDefaultRegistry(), aminoTypes = new AminoTypes(createDefaultTypes(prefix)) } =
|
||||
options;
|
||||
const { registry = createDefaultRegistry(), aminoTypes = new AminoTypes(createDefaultTypes()) } = options;
|
||||
this.registry = registry;
|
||||
this.aminoTypes = aminoTypes;
|
||||
this.signer = signer;
|
||||
|
||||
Reference in New Issue
Block a user