Skip to content

Commit

Permalink
fix: funds array for MsgExecuteContract
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Dec 19, 2022
1 parent a53de30 commit 77dcb24
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/sdk-ts/src/core/modules/wasm/msgs/MsgExecuteContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ import { GeneralException } from '@injectivelabs/exceptions'

export declare namespace MsgExecuteContract {
export interface Params {
funds?: {
denom: string
amount: string
}
funds?:
| {
denom: string
amount: string
}
| {
denom: string
amount: string
}[]
sender: string
contractAddress: string
/* Used to provide type safety for execution messages */
Expand Down Expand Up @@ -74,12 +79,20 @@ export default class MsgExecuteContract extends MsgBase<
message.setContract(params.contractAddress)

if (params.funds) {
const funds = new Coin()
const fundsToArray = Array.isArray(params.funds)
? params.funds
: [params.funds]

const funds = fundsToArray.map((coin) => {
const funds = new Coin()

funds.setAmount(coin.amount)
funds.setDenom(coin.denom)

funds.setAmount(params.funds.amount)
funds.setDenom(params.funds.denom)
return funds
})

message.setFundsList([funds])
message.setFundsList(funds)
}

return message
Expand Down

0 comments on commit 77dcb24

Please sign in to comment.