@hyperbridge/core 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,6 +18,7 @@ import {DispatchPost, DispatchPostResponse, DispatchGet, IDispatcher} from "../i
|
|
|
18
18
|
import {IApp, IncomingPostRequest, IncomingPostResponse, IncomingGetResponse} from "../interfaces/IApp.sol";
|
|
19
19
|
|
|
20
20
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
21
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* @dev Uniswap interface for estimating fees in the native token
|
|
@@ -35,6 +36,8 @@ interface IUniswapV2Router02 {
|
|
|
35
36
|
* host authorization, and cross-chain message handling. Extend this contract to build your Hyperbridge application.
|
|
36
37
|
*/
|
|
37
38
|
abstract contract HyperApp is IApp {
|
|
39
|
+
using SafeERC20 for IERC20;
|
|
40
|
+
|
|
38
41
|
/**
|
|
39
42
|
* @dev Call was not expected
|
|
40
43
|
*/
|
|
@@ -136,8 +139,8 @@ abstract contract HyperApp is IApp {
|
|
|
136
139
|
address hostAddr = host();
|
|
137
140
|
address feeToken = IDispatcher(hostAddr).feeToken();
|
|
138
141
|
uint256 fee = quote(request);
|
|
139
|
-
if (payer != address(this)) IERC20(feeToken).
|
|
140
|
-
IERC20(feeToken).
|
|
142
|
+
if (payer != address(this)) IERC20(feeToken).safeTransferFrom(payer, address(this), fee);
|
|
143
|
+
IERC20(feeToken).forceApprove(hostAddr, fee);
|
|
141
144
|
IDispatcher(hostAddr).dispatch(request);
|
|
142
145
|
}
|
|
143
146
|
|
|
@@ -152,8 +155,8 @@ abstract contract HyperApp is IApp {
|
|
|
152
155
|
address hostAddr = host();
|
|
153
156
|
address feeToken = IDispatcher(hostAddr).feeToken();
|
|
154
157
|
uint256 fee = quote(response);
|
|
155
|
-
if (payer != address(this)) IERC20(feeToken).
|
|
156
|
-
IERC20(feeToken).
|
|
158
|
+
if (payer != address(this)) IERC20(feeToken).safeTransferFrom(payer, address(this), fee);
|
|
159
|
+
IERC20(feeToken).forceApprove(hostAddr, fee);
|
|
157
160
|
IDispatcher(hostAddr).dispatch(response);
|
|
158
161
|
}
|
|
159
162
|
|
|
@@ -168,8 +171,8 @@ abstract contract HyperApp is IApp {
|
|
|
168
171
|
address hostAddr = host();
|
|
169
172
|
address feeToken = IDispatcher(hostAddr).feeToken();
|
|
170
173
|
uint256 fee = quote(request);
|
|
171
|
-
if (payer != address(this)) IERC20(feeToken).
|
|
172
|
-
IERC20(feeToken).
|
|
174
|
+
if (payer != address(this)) IERC20(feeToken).safeTransferFrom(payer, address(this), fee);
|
|
175
|
+
IERC20(feeToken).forceApprove(hostAddr, fee);
|
|
173
176
|
IDispatcher(hostAddr).dispatch(request);
|
|
174
177
|
}
|
|
175
178
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperbridge/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Hyperbridge Solidity SDK for dispatching & receiving cross-chain messages",
|
|
5
5
|
"author": "Polytope Labs <hello@polytope.technology>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"bridges"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@openzeppelin/contracts": "^5.4.0",
|
|
33
34
|
"@polytope-labs/solidity-merkle-trees": "^0.3.3",
|
|
34
|
-
"openzeppelin-solidity": "^4.8.1",
|
|
35
35
|
"prettier": "^3.3.3",
|
|
36
36
|
"prettier-plugin-solidity": "^1.3.1"
|
|
37
37
|
},
|