Skip to content

Commit

Permalink
fix: add claim boolean column to transaction table, update yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
wm798222 committed Apr 19, 2021
1 parent 6b43e88 commit f1bf00d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

var dbm;
var type;
var seed;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = function(db) {
return db.addColumn('transaction', 'claim', { type: 'boolean' })
};

exports.down = function(db) {
return db.removeColumn('transaction', 'claim');
};

exports._meta = {
"version": 1
};
4 changes: 3 additions & 1 deletion docs/api/spec/treetracker-token-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ paths:
tags:
- Transfers
summary: 'Move, request, and send tokens between wallets'
description: 'Move, request, and send tokens between wallets (by name or id) as allowed by trust relationships. Transfer can be created/requested either using an explicit list of token ids or by specifying a bundle of tokens using tags and a count of tokens to attempt to transfer. The originator of the request (currently logged in wallet) is used by the server code to compute who the originating wallet is for this request, whether the request is a credit, debut, or managed transfer, and if appropriate trust relationships exist to automatically execute or if it must be stored as a request until approval'
description: 'Move, request, and send tokens between wallets (by name or id) as allowed by trust relationships. Transfer can be created/requested either using an explicit list of token ids or by specifying a bundle of tokens using tags and a count of tokens to attempt to transfer. The originator of the request (currently logged in wallet) is used by the server code to compute who the originating wallet is for this request, whether the request is a credit, debut, or managed transfer, and if appropriate trust relationships exist to automatically execute or if it must be stored as a request until approval. A claim boolean is entered to specify if the tokens are transferrable. Claimed tokens cannot participate in further transfers after they are received.'
parameters:
- $ref: '#/components/parameters/treetrackerApiKeyParam'
- $ref: '#/components/parameters/contentTypeJsonHeader'
Expand All @@ -199,13 +199,15 @@ paths:
- e533653e-2dbf-48cd-940a-a87e5a393158
sender_wallet: zaven4
receiver_wallet: 2
claim: false
Bundle:
value:
bundle:
bundle_size: 100
matching_all_tags:
- pine
- Tanzania
claim: false
required: true
responses:
'201':
Expand Down
4 changes: 2 additions & 2 deletions server/models/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ class Wallet{

const tokensId = [];
for(let token of tokens){
// check if the tokens you want to transfer is claimed, i.e. not trasfferable
// check if the tokens you want to transfer is claimed, i.e. not transferrable
if (token['_JSON']['claim'] == true) {
console.log("token is claimed, cannot be transfered");
let uuid = token['_id'];
Expand All @@ -497,7 +497,7 @@ class Wallet{
claim: claimBoolean,
});
log.debug("now, deal with tokens");
await this.tokenService.completeTransfer(tokens, transfer);
await this.tokenService.completeTransfer(tokens, transfer, claimBoolean);
return transfer;

// TODO: Do I need claim boolean in below cases?
Expand Down

0 comments on commit f1bf00d

Please sign in to comment.