1
+ import { Solana } from "@renproject/chains" ;
1
2
import { getERC20Instance } from "@renproject/chains-ethereum/src/contracts" ;
2
3
import BigNumber from "bignumber.js" ;
3
4
import chai from "chai" ;
@@ -7,12 +8,14 @@ import {
7
8
Arbitrum ,
8
9
Avalanche ,
9
10
BinanceSmartChain ,
11
+ Catalog ,
10
12
Ethereum ,
13
+ EthereumBaseChain ,
11
14
EVMParam ,
15
+ Goerli ,
12
16
Polygon ,
13
17
} from "packages/chains/chains-ethereum/src" ;
14
18
import { Filecoin } from "packages/chains/chains-filecoin/src" ;
15
- import { Solana } from "packages/chains/chains-solana/src" ;
16
19
import { Terra } from "packages/chains/chains-terra/src" ;
17
20
import RenJS from "packages/ren/src" ;
18
21
import { GatewayParams } from "packages/ren/src/params" ;
@@ -436,36 +439,143 @@ describe("Gateway", () => {
436
439
await defaultGatewayHandler ( await renJS . gateway ( gatewayParams ) ) ;
437
440
} ) . timeout ( 100000000000 ) ;
438
441
439
- it ( "DAI/fromBinanceSmartChain " , async ( ) => {
442
+ it ( "USDT/toCatalog " , async ( ) => {
440
443
const network = RenNetwork . Testnet ;
441
444
442
- const asset = Ethereum . assets . DAI ;
443
- const from = initializeChain ( BinanceSmartChain , network ) ;
444
- const to = initializeChain ( Ethereum , network ) ;
445
+ const from = initializeChain ( Goerli , network ) ;
446
+ const catalog = initializeChain ( Catalog , network ) ;
447
+ const bsc = initializeChain ( BinanceSmartChain , network ) ;
448
+ const polygon = initializeChain ( Polygon , network ) ;
449
+ const renJS = new RenJS ( network ) . withChains (
450
+ from ,
451
+ catalog ,
452
+ bsc ,
453
+ polygon ,
454
+ ) ;
455
+ console . log ( await from . signer ! . getAddress ( ) ) ;
445
456
446
- const renJS = new RenJS ( network ) . withChains ( from , to ) ;
457
+ console . log (
458
+ Goerli . assets . USDT ,
459
+ ( await from . getBalance ( Goerli . assets . USDT ) )
460
+ . shiftedBy ( - ( await from . assetDecimals ( Goerli . assets . USDT ) ) )
461
+ . toFixed ( ) ,
462
+ ) ;
463
+ console . log (
464
+ Goerli . assets . DAI ,
465
+ ( await from . getBalance ( Goerli . assets . DAI ) )
466
+ . shiftedBy ( - ( await from . assetDecimals ( Goerli . assets . DAI ) ) )
467
+ . toFixed ( ) ,
468
+ ) ;
469
+ console . log (
470
+ Goerli . assets . USDC ,
471
+ ( await from . getBalance ( Goerli . assets . USDC ) )
472
+ . shiftedBy ( - ( await from . assetDecimals ( Goerli . assets . USDC ) ) )
473
+ . toFixed ( ) ,
474
+ ) ;
447
475
448
- const gatewayParams = {
449
- asset,
450
- from : from . Account ( { amount : 0.5 , convertUnit : true } ) ,
451
- to : to . Address ( "0x797522fb74d42bb9fbf6b76dea24d01a538d5d66" ) ,
452
- } ;
476
+ const options : Array < [ string , EthereumBaseChain ] > = [
477
+ // [Goerli.assets.USDT, catalog],
478
+ // [Goerli.assets.USDC, catalog],
479
+ // [Goerli.assets.DAI, catalog],
480
+ [ Goerli . assets . USDT , bsc ] ,
481
+ [ Goerli . assets . USDC , bsc ] ,
482
+ [ Goerli . assets . DAI , bsc ] ,
483
+ [ Goerli . assets . USDT , polygon ] ,
484
+ [ Goerli . assets . USDC , polygon ] ,
485
+ [ Goerli . assets . DAI , polygon ] ,
486
+ ] ;
487
+
488
+ for ( const [ asset , to ] of options ) {
489
+ // const asset = Ethereum.assets.USDT;
490
+ const decimals = await from . assetDecimals ( asset ) ;
491
+
492
+ const amount = 100.2 ;
493
+
494
+ const gatewayParams = {
495
+ asset,
496
+ from : from . Account ( { amount, convertUnit : true } ) ,
497
+ to : to . Address ( "0x5eb99e19183728404AaeBc8eEF47C085dBE86F54" ) ,
498
+ } ;
453
499
454
- await defaultGatewayHandler ( await renJS . gateway ( gatewayParams ) ) ;
500
+ await defaultGatewayHandler (
501
+ await renJS . gateway ( gatewayParams ) ,
502
+ new BigNumber ( amount ) . shiftedBy ( decimals ) ,
503
+ ) ;
504
+
505
+ console . log (
506
+ asset ,
507
+ "on" ,
508
+ to . chain ,
509
+ (
510
+ await to . getBalance (
511
+ asset ,
512
+ "0x5eb99e19183728404AaeBc8eEF47C085dBE86F54" ,
513
+ )
514
+ )
515
+ . shiftedBy ( - ( await to . assetDecimals ( asset ) ) )
516
+ . toFixed ( ) ,
517
+ ) ;
518
+ }
455
519
} ) . timeout ( 100000000000 ) ;
456
520
457
- it ( "BTC/fromEthereum " , async ( ) => {
521
+ it ( "BTC/to catalog chains " , async ( ) => {
458
522
const network = RenNetwork . Testnet ;
459
523
460
- const asset = Bitcoin . assets . BTC ;
461
- const from = initializeChain ( Ethereum , network ) ;
462
- const to = initializeChain ( Solana , network ) ;
524
+ const from = initializeChain ( Bitcoin , network ) ;
525
+ const asset = from . assets . BTC ;
526
+ const catalog = initializeChain ( Catalog , network ) ;
527
+ const bsc = initializeChain ( BinanceSmartChain , network ) ;
528
+ const polygon = initializeChain ( Polygon , network ) ;
529
+ const ethereum = initializeChain ( Ethereum , network ) ;
530
+ const renJS = new RenJS ( network ) . withChains (
531
+ from ,
532
+ catalog ,
533
+ bsc ,
534
+ polygon ,
535
+ ethereum ,
536
+ ) ;
537
+
538
+ const options : EthereumBaseChain [ ] = [ catalog , bsc , polygon , ethereum ] ;
539
+
540
+ for ( const to of options ) {
541
+ // const asset = Ethereum.assets.USDT;
542
+
543
+ const gatewayParams = {
544
+ asset,
545
+ from : from . GatewayAddress ( ) ,
546
+ to : to . Address ( "0x5eb99e19183728404AaeBc8eEF47C085dBE86F54" ) ,
547
+ } ;
548
+
549
+ await defaultGatewayHandler ( await renJS . gateway ( gatewayParams ) ) ;
550
+
551
+ console . log (
552
+ asset ,
553
+ "on" ,
554
+ to . chain ,
555
+ (
556
+ await to . getBalance (
557
+ asset ,
558
+ "0x5eb99e19183728404AaeBc8eEF47C085dBE86F54" ,
559
+ )
560
+ )
561
+ . shiftedBy ( - ( await to . assetDecimals ( asset ) ) )
562
+ . toFixed ( ) ,
563
+ ) ;
564
+ }
565
+ } ) . timeout ( 100000000000 ) ;
566
+
567
+ it . only ( "REN/toSolana" , async ( ) => {
568
+ const network = RenNetwork . Testnet ;
569
+
570
+ const asset = Ethereum . assets . REN ;
571
+ const from = initializeChain ( Solana , network ) ;
572
+ const to = initializeChain ( Ethereum , network ) ;
463
573
464
574
const renJS = new RenJS ( network ) . withChains ( from , to ) ;
465
575
466
576
const gatewayParams : GatewayParams = {
467
577
asset,
468
- from : from . Account ( { amount : 1 , convertUnit : true } ) ,
578
+ from : from . Account ( { amount : 95 , convertUnit : true } ) ,
469
579
to : to . Account ( ) ,
470
580
} ;
471
581
0 commit comments