File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ pragma solidity ^ 0.8.12 ;
3
+
4
+ import "../samples/HybridAccount.sol " ;
5
+
6
+ contract TestTokenPrice {
7
+ mapping (uint256 => uint256 ) public counters;
8
+ address payable immutable helperAddr;
9
+
10
+ constructor (address payable _helperAddr ) {
11
+ helperAddr = _helperAddr;
12
+ counters[0 ] = 100 ;
13
+ }
14
+
15
+ function fetchPrice (
16
+ string calldata token
17
+ ) public returns (string memory ) {
18
+ HybridAccount ha = HybridAccount (payable (helperAddr));
19
+ string memory price;
20
+
21
+ bytes memory req = abi.encodeWithSignature ("getprice(string) " , token);
22
+ bytes32 userKey = bytes32 (abi.encode (msg .sender ));
23
+ (uint32 error , bytes memory ret ) = ha.CallOffchain (userKey, req);
24
+
25
+ if (error != 0 ) {
26
+ revert (string (ret));
27
+ }
28
+
29
+ (price) = abi.decode (ret, (string ));
30
+ return price;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments