Skip to content

Commit

Permalink
fix: eip712 typing order
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Aug 22, 2022
1 parent 68d4734 commit 10e4b6d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-ts/src/core/MsgBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export abstract class MsgBase<
}

public toEip712Types(): Map<string, TypedDataField[]> {
return objectKeysToEip712Types(this.toAmino())
return objectKeysToEip712Types(this.toAmino() as Record<string, any>)
}

public toEip712(): {
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/core/bank/msgs/MsgSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ export default class MsgSend extends MsgBase<
}

public toAmino(): MsgSend.Amino {
const { params } = this
const proto = this.toProto()
const message = {
...snakeCaseKeys(proto.toObject()),
amount: [{ ...snakeCaseKeys(params.amount) }],
amount: proto
.getAmountList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

// @ts-ignore
Expand Down
1 change: 0 additions & 1 deletion packages/sdk-ts/src/core/eip712.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export const objectKeysToEip712Types = (
) => {
const output = new Map<string, TypedDataField[]>()
const types = new Array<TypedDataField>()
// const sortedProperties = Object.keys(object).sort()

for (const property in object) {
if (property === '@type' || property === 'type') {
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/core/gov/msgs/MsgDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ export default class MsgDeposit extends MsgBase<
}

public toAmino(): MsgDeposit.Amino {
const { params } = this
const proto = this.toProto()
const message = {
...snakeCaseKeys(proto.toObject()),
amount: [{ ...snakeCaseKeys(params.amount) }],
amount: proto
.getAmountList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class MsgSubmitProposalExpiryFuturesMarketLaunch extends MsgBase<

public toAmino(): MsgSubmitProposalExpiryFuturesMarketLaunch.Amino {
const { params } = this
const proto = this.toProto()
const content = this.getContent()
const proposalType =
'/injective.exchange.v1beta1.ExpiryFuturesMarketLaunchProposal'
Expand All @@ -108,7 +109,9 @@ export default class MsgSubmitProposalExpiryFuturesMarketLaunch extends MsgBase<
content: {
...content.toObject(),
},
initial_deposit: [{ ...snakeCaseKeys(params.deposit) }],
initial_deposit: proto
.getInitialDepositList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

const messageWithProposalType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class MsgSubmitProposalPerpetualMarketLaunch extends MsgBase<

public toAmino(): MsgSubmitProposalPerpetualMarketLaunch.Amino {
const { params } = this
const proto = this.toProto()
const content = this.getContent()
const proposalType =
'/injective.exchange.v1beta1.PerpetualMarketLaunchProposal'
Expand All @@ -107,7 +108,9 @@ export default class MsgSubmitProposalPerpetualMarketLaunch extends MsgBase<
content: {
...content.toObject(),
},
initial_deposit: [{ ...snakeCaseKeys(params.deposit) }],
initial_deposit: proto
.getInitialDepositList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

const messageWithProposalType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class MsgSubmitProposalSpotMarketLaunch extends MsgBase<

public toAmino(): MsgSubmitProposalSpotMarketLaunch.Amino {
const { params } = this
const proto = this.toProto()
const content = this.getContent()
const proposalType = '/injective.exchange.v1beta1.SpotMarketLaunchProposal'

Expand All @@ -99,7 +100,9 @@ export default class MsgSubmitProposalSpotMarketLaunch extends MsgBase<
content: {
...content.toObject(),
},
initial_deposit: [{ ...snakeCaseKeys(params.deposit) }],
initial_deposit: proto
.getInitialDepositList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

const messageWithProposalType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default class MsgSubmitProposalSpotMarketParamUpdate extends MsgBase<

public toAmino(): MsgSubmitProposalSpotMarketParamUpdate.Amino {
const { params } = this
const proto = this.toProto()
const content = this.getContent()
const proposalType =
'/injective.exchange.v1beta1.SpotMarketParamUpdateProposal'
Expand All @@ -102,7 +103,9 @@ export default class MsgSubmitProposalSpotMarketParamUpdate extends MsgBase<
content: {
...content.toObject(),
},
initial_deposit: [{ ...snakeCaseKeys(params.deposit) }],
initial_deposit: proto
.getInitialDepositList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

const messageWithProposalType = {
Expand Down
5 changes: 4 additions & 1 deletion packages/sdk-ts/src/core/gov/msgs/MsgSubmitTextProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default class MsgSubmitTextProposal extends MsgBase<

public toAmino(): MsgSubmitTextProposal.Amino {
const { params } = this
const proto = this.toProto()
const content = this.getContent()
const proposalType = '/cosmos.gov.v1beta1.TextProposal'

Expand All @@ -88,7 +89,9 @@ export default class MsgSubmitTextProposal extends MsgBase<
content: {
...content.toObject(),
},
initial_deposit: [{ ...snakeCaseKeys(params.deposit) }],
initial_deposit: proto
.getInitialDepositList()
.map((amount) => snakeCaseKeys(amount.toObject())),
}

const messageWithProposalType = {
Expand Down
1 change: 0 additions & 1 deletion packages/sdk-ui-ts/src/core/clients/MsgBroadcastClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class MsgBroadcastClient {
try {
const txResponse = await prepareTx()
const signature = await signTx(txResponse.getData())
// console.log(txResponse.getData(), signature)

const promise = transactionApi.broadcastTxRequest({
signature,
Expand Down

0 comments on commit 10e4b6d

Please sign in to comment.