@@ -41,7 +41,7 @@ public void SwapIntent(
41
41
BigInteger amount ,
42
42
String toToken ,
43
43
BigInteger toAmount ,
44
- String data ) {
44
+ byte [] data ) {
45
45
}
46
46
47
47
@ EventLog (indexed = 2 )
@@ -247,19 +247,44 @@ public void tokenFallback(Address _from, BigInteger _value, byte[] _data) {
247
247
248
248
// string(address of depositer) -> string (deposits token address) -> amountof
249
249
// token
250
- String depositor = json .get ("depositor" ).asString ();
251
- String token = json .get ("token" ).asString ();
252
- BigInteger amount = new BigInteger (json .get ("amount" ).asString ());
253
-
254
- deposit .at (depositor ).set (token , amount );
255
- SwapOrder swapOrder = SwapOrder
256
- .fromBytes (hexStringToByteArray (json .get ("swapOrderDataBytes" ).asString ()));
250
+ // String depositor = json.get("depositor").asString();
251
+ // String token = json.get("token").asString();
252
+ // BigInteger amount = new BigInteger(json.get("amount").asString());
253
+ String type = json .get ("type" ).asString ();
254
+ // deposit.at(depositor).set(token, amount);
255
+ if (type .equals ("swap" )) {
256
+ SwapOrder swapOrder = SwapOrder
257
+ .fromBytes (hexStringToByteArray (json .get ("swapOrderDataBytes" ).asString ()));
258
+ deposit .at (swapOrder .creator ).set (swapOrder .token , swapOrder .amount );
259
+
260
+ // Context.require(amount.equals(swapOrder.amount), "Token amount must be
261
+ // equal");
262
+ // Context.require(swapOrder.getToken() != null, "Token can't be null");
263
+ Context .require (Context .getCaller ().toString ().equals (extractAddress (swapOrder .getCreator ())),
264
+ "Creator must be sender" );
265
+ _swap (swapOrder );
266
+ } else {
267
+ SwapOrder swapOrder = SwapOrder
268
+ .fromBytes (hexStringToByteArray (json .get ("swapOrderDataBytes" ).asString ()));
269
+
270
+ SwapOrderData swapOrderData = new SwapOrderData ();
271
+ swapOrderData .id = swapOrder .id ;
272
+ swapOrderData .emitter = swapOrder .emitter ;
273
+ swapOrderData .srcNID = swapOrder .srcNID ;
274
+ swapOrderData .dstNID = swapOrder .dstNID ;
275
+ swapOrderData .creator = swapOrder .creator ;
276
+ swapOrderData .destinationAddress = swapOrder .destinationAddress ;
277
+ swapOrderData .token = swapOrder .token ;
278
+ swapOrderData .amount = swapOrder .amount ;
279
+ swapOrderData .toToken = swapOrder .toToken ;
280
+ swapOrderData .toAmount = swapOrder .toAmount ;
281
+ swapOrderData .data = swapOrder .data ;
282
+
283
+ String solver = json .get ("solver" ).asString ();
284
+ fill (swapOrderData , solver );
285
+ }
286
+ ;
257
287
258
- Context .require (amount .equals (swapOrder .amount ), "Token amount must be equal" );
259
- Context .require (swapOrder .getToken () != null , "Token can't be null" );
260
- Context .require (Context .getCaller ().toString ().equals (extractAddress (swapOrder .getCreator ())),
261
- "Creator must be sender" );
262
- _swap (swapOrder );
263
288
}
264
289
265
290
@ External
0 commit comments