Skip to content

Commit c6c2b41

Browse files
authored
Merge pull request #24 from Terran-One/feat/DeleteFunds
Supported deletion of funds by adding delete functionality to bank module.
2 parents 50c15d7 + f25ea74 commit c6c2b41

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terran-one/cw-simulate",
3-
"version": "2.6.1",
3+
"version": "2.6.2",
44
"description": "Mock blockchain environment for simulating CosmWasm interactions",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/modules/bank.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,19 @@ describe('BankModule', () => {
180180
],
181181
});
182182
});
183+
it('handle delete', () => {
184+
// Arrange
185+
const bank = chain.bank;
186+
bank.setBalance('alice', [{denom: 'foo', amount: '1000'}]);
187+
bank.setBalance('bob', [{denom: 'fizz', amount: '900'}]);
188+
189+
// Act
190+
bank.deleteBalance('bob');
191+
192+
// Assert
193+
expect(bank.getBalance('alice')).toBeDefined();
194+
expect(bank.getBalances()).toEqual(Map([
195+
['alice', [{denom: 'foo', amount: '1000'}]]
196+
]));
197+
});
183198
});

src/modules/bank.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ export class BankModule {
120120
public getBalances() {
121121
return (this.chain.store.getIn(['bank', 'balances'], Map([])) as Map<string, Coin[]>);
122122
}
123+
124+
public deleteBalance(address:string) {
125+
this.chain.store = this.chain.store.deleteIn( ['bank', 'balances', address]);
126+
127+
}
123128

124129
public async handleMsg(
125130
sender: string,

0 commit comments

Comments
 (0)