Skip to content

Commit

Permalink
Merge pull request #398 from pranavkparti/transfers-post-fix
Browse files Browse the repository at this point in the history
Created transfer returns token_count
  • Loading branch information
Kpoke committed Aug 21, 2023
2 parents c360847 + 1e41d78 commit 6678ac8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions server/handlers/transferHandler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ describe('transferRouter', () => {
result: {
id: tokenId,
state: TransferEnums.STATE.completed,
parameters: {
bundle: {
bundleSize: 1,
},
},
},
status: 201,
});
Expand All @@ -128,6 +133,12 @@ describe('transferRouter', () => {
expect(res.body).eql({
id: tokenId,
state: TransferEnums.STATE.completed,
parameters: {
bundle: {
bundleSize: 1,
},
},
token_count: 1
});
expect(
initiateTranferStub.calledOnceWithExactly(
Expand All @@ -151,6 +162,11 @@ describe('transferRouter', () => {
result: {
id: tokenId,
state: TransferEnums.STATE.completed,
parameters: {
bundle: {
bundleSize: 1,
},
},
},
status: 202,
});
Expand All @@ -168,6 +184,12 @@ describe('transferRouter', () => {
expect(res.body).eql({
id: tokenId,
state: TransferEnums.STATE.completed,
parameters: {
bundle: {
bundleSize: 1,
},
},
token_count: 1
});
expect(
initiateTranferStub.calledOnceWithExactly(
Expand Down
8 changes: 7 additions & 1 deletion server/handlers/transferHandler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ const transferPost = async (req, res) => {
req.wallet_id,
);

res.status(status).send(result);
const modifiedTransfer = {
...result,
token_count:
+result.parameters?.bundle?.bundleSize || +result.parameters?.tokens?.length,
}

res.status(status).send(modifiedTransfer);
};

const transferIdAcceptPost = async (req, res) => {
Expand Down

0 comments on commit 6678ac8

Please sign in to comment.