Skip to content

Commit

Permalink
Merge pull request #4 from twilson63/main
Browse files Browse the repository at this point in the history
Created some unit and arlocal tests for createOrder
  • Loading branch information
t8 committed Jan 11, 2023
2 parents a9b48fc + c5ac771 commit bf2c947
Show file tree
Hide file tree
Showing 10 changed files with 6,522 additions and 36 deletions.
9 changes: 7 additions & 2 deletions package.json
Expand Up @@ -20,12 +20,17 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "node ./build.js",
"fmt": "prettier --write ."
"fmt": "prettier --write .",
"test": "vitest",
"coverage": "vitest run --coverage"
},
"devDependencies": {
"arlocal": "^1.1.58",
"esbuild": "^0.14.51",
"npm-dts": "^1.3.12",
"prettier": "^2.7.1"
"prettier": "^2.7.1",
"vitest": "^0.24.3",
"warp-contracts": "^1.2.13"
},
"dependencies": {
"arweave": "^1.11.4",
Expand Down
5 changes: 3 additions & 2 deletions src/modules/createOrder.ts
Expand Up @@ -36,7 +36,7 @@ export const CreateOrder = async (

ContractAssert(
usedPair[0] === SmartWeave.contract.id ||
usedPair[1] === SmartWeave.contract.id,
usedPair[1] === SmartWeave.contract.id,
"One of the two contracts in the pair isn't the current contract."
);

Expand Down Expand Up @@ -175,7 +175,6 @@ export const CreateOrder = async (
},
sortedOrderbook
);

// Update orderbook accordingly
state.pairs[pairIndex].orders = orderbook;

Expand All @@ -193,6 +192,7 @@ export const CreateOrder = async (
.reduce((a, b) => a + b, 0) /
matches.map(({ qty: volume }) => volume).reduce((a, b) => a + b, 0);


// update the latest price data
state.pairs[pairIndex].priceData = {
dominantToken,
Expand Down Expand Up @@ -252,6 +252,7 @@ export const CreateOrder = async (
// if the match function throws an error, refund the transfer
await refundTransfer();


// return state with the refund foreign call
// and the error message
return {
Expand Down

0 comments on commit bf2c947

Please sign in to comment.