Skip to content

Commit

Permalink
feat: more work on the claim feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wm798222 committed Mar 27, 2021
1 parent cf98269 commit c9a2af1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/models/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ class Wallet{
await this.tokenService.completeTransfer(tokens, transfer);
return transfer;

}else{
// TODO: Do I need claim boolean in below cases?
}else{
if(hasControlOverSender){
log.debug("OK, no permission, source under control, now pending it");
const tokensId = [];
Expand All @@ -516,6 +517,7 @@ class Wallet{
state: Transfer.STATE.pending,
parameters: {
tokens: tokensId,
claim: claimBoolean,
},
});
await this.tokenService.pendingTransfer(tokens, transfer);
Expand All @@ -533,6 +535,7 @@ class Wallet{
state: Transfer.STATE.requested,
parameters: {
tokens: tokensId,
claim: claimBoolean,
},
});
await this.tokenService.pendingTransfer(tokens, transfer);
Expand All @@ -547,6 +550,7 @@ class Wallet{
async transferBundle(sender, receiver, bundleSize, claimBoolean){
//check has enough tokens to sender
const tokenCount = await this.tokenService.countTokenByWallet(sender);
// count number of tokens not claimed
const notClaimedTokenCount = await this.tokenService.countNotClaimedTokenByWallet(sender);
// if(tokenCount < bundleSize){
// throw new HttpError(403, `Do not have enough tokens to send`);
Expand Down
3 changes: 3 additions & 0 deletions server/services/TokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ class TokenService{
* Get n tokens from a wallet
*/
async getTokensByBundle(wallet, bundleSize){
//TODO: getByFilter should be able to handle claim boolean
const result = await this.tokenRepository.getByFilter({
wallet_id: wallet.getId(),
transfer_pending: false,
},{
limit: bundleSize,
// add claim
claim: false,
});
return result.map(json => new Token(json, this._session));
}
Expand Down

0 comments on commit c9a2af1

Please sign in to comment.