Skip to content

Commit 86c0e4a

Browse files
committed
fix of returning gas
1 parent c32576c commit 86c0e4a

File tree

5 files changed

+106
-54
lines changed

5 files changed

+106
-54
lines changed

contracts/SwapPair/RootSwapPairContract.sol

+28-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ contract RootSwapPairContract is
123123
}(address(this), tip3Deployer, swapPairCodeVersion);
124124

125125
// Storing info about deployed swap pair contracts
126+
bytes tmp;
126127
SwapPairInfo info = SwapPairInfo(
127128
address(this), // root contract
128129
tokenRootContract1, // token root
@@ -134,7 +135,8 @@ contract RootSwapPairContract is
134135
currentTimestamp, // creation timestamp
135136
contractAddress, // address of swap pair
136137
uniqueID, // unique id of swap pair
137-
swapPairCodeVersion // code version of swap pair
138+
swapPairCodeVersion, // code version of swap pair
139+
tmp
138140
);
139141

140142
swapPairDB.add(uniqueID, info);
@@ -159,6 +161,31 @@ contract RootSwapPairContract is
159161

160162
//============Get functions============
161163

164+
/**
165+
* Get all swap pairs
166+
*/
167+
function getAllSwapPairsID() external override view returns (uint256[] ids) {
168+
// uint256 uniqueId;
169+
for((uint256 uniqueId,): swapPairDB) {
170+
ids.push(uniqueId);
171+
}
172+
}
173+
174+
/**
175+
* Check if pair exists
176+
* @param uniqueID unique ID of swap pair
177+
*/
178+
function getPairInfoByID(
179+
uint256 uniqueID
180+
) external view override returns(SwapPairInfo swapPairInfo) {
181+
optional(SwapPairInfo) spi = swapPairDB.fetch(uniqueID);
182+
require(
183+
spi.hasValue(),
184+
RootSwapPairContractErrors.ERROR_PAIR_DOES_NOT_EXIST
185+
);
186+
return spi.get();
187+
}
188+
162189
/**
163190
* Check if pair exists
164191
* @param tokenRootContract1 Address of token root contract

0 commit comments

Comments
 (0)