Skip to content

Commit

Permalink
fix create account with cw20 fund
Browse files Browse the repository at this point in the history
  • Loading branch information
dev8723 committed Jun 21, 2023
1 parent fbdf46c commit 0908ebf
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,29 @@ export class WarpSdk {
}

public async createAccount(sender: string, funds?: warp_controller.Fund[]): Promise<TxInfo> {
const txPayload = TxBuilder.new()
.execute<Extract<warp_controller.ExecuteMsg, { create_account: {} }>>(sender, this.controllerContract, {
const txPayload = TxBuilder.new().execute<Extract<warp_controller.ExecuteMsg, { create_account: {} }>>(
sender,
this.controllerContract,
{
create_account: {
funds,
},
})
.build();

return this.wallet.tx(txPayload);
}
);
funds
.filter((fund) => Object.keys(fund).includes('cw20'))
.forEach((fund) => {
txPayload.execute(sender, fund['cw20'].contract_addr, {
increase_allowance: {
spender: this.controllerContract,
amount: fund['cw20'].amount,
expires: {
never: {},
},
},
});
});
return this.wallet.tx(txPayload.build());
}

public async withdrawAssets(sender: string, msg: warp_account.WithdrawAssetsMsg): Promise<TxInfo> {
Expand Down

0 comments on commit 0908ebf

Please sign in to comment.