Skip to content

Commit

Permalink
Merge pull request #24 from Terran-One/feat/DeleteFunds
Browse files Browse the repository at this point in the history
Supported deletion of funds by adding delete functionality to bank module.
  • Loading branch information
dabralyogesh authored Nov 29, 2022
2 parents 50c15d7 + f25ea74 commit c6c2b41
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@terran-one/cw-simulate",
"version": "2.6.1",
"version": "2.6.2",
"description": "Mock blockchain environment for simulating CosmWasm interactions",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
15 changes: 15 additions & 0 deletions src/modules/bank.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,19 @@ describe('BankModule', () => {
],
});
});
it('handle delete', () => {
// Arrange
const bank = chain.bank;
bank.setBalance('alice', [{denom: 'foo', amount: '1000'}]);
bank.setBalance('bob', [{denom: 'fizz', amount: '900'}]);

// Act
bank.deleteBalance('bob');

// Assert
expect(bank.getBalance('alice')).toBeDefined();
expect(bank.getBalances()).toEqual(Map([
['alice', [{denom: 'foo', amount: '1000'}]]
]));
});
});
5 changes: 5 additions & 0 deletions src/modules/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ export class BankModule {
public getBalances() {
return (this.chain.store.getIn(['bank', 'balances'], Map([])) as Map<string, Coin[]>);
}

public deleteBalance(address:string) {
this.chain.store = this.chain.store.deleteIn( ['bank', 'balances', address]);

}

public async handleMsg(
sender: string,
Expand Down

0 comments on commit c6c2b41

Please sign in to comment.