@ -1,4 +1,5 @@
import { strict as assert } from 'assert' ;
import { strict as assert } from 'assert' ;
import nock from 'nock' ;
import {
import {
KOVAN _CHAIN _ID ,
KOVAN _CHAIN _ID ,
MAINNET _CHAIN _ID ,
MAINNET _CHAIN _ID ,
@ -8,52 +9,68 @@ import {
import { TRANSAK _API _KEY } from '../constants/on-ramp' ;
import { TRANSAK _API _KEY } from '../constants/on-ramp' ;
import getBuyEthUrl from './buy-eth-url' ;
import getBuyEthUrl from './buy-eth-url' ;
const WYRE _ACCOUNT _ID = 'AC-7AG3W4XH4N2' ;
const ETH _ADDRESS = '0x0dcd5d886577d5581b0c524242ef2ee70be3e7bc' ;
const MAINNET = {
chainId : MAINNET _CHAIN _ID ,
amount : 5 ,
address : ETH _ADDRESS ,
} ;
const ROPSTEN = {
chainId : ROPSTEN _CHAIN _ID ,
} ;
const RINKEBY = {
chainId : RINKEBY _CHAIN _ID ,
} ;
const KOVAN = {
chainId : KOVAN _CHAIN _ID ,
} ;
describe ( 'buy-eth-url' , function ( ) {
describe ( 'buy-eth-url' , function ( ) {
const mainnet = {
it ( 'returns Wyre url with an ETH address for Ethereum mainnet' , async function ( ) {
chainId : MAINNET _CHAIN _ID ,
nock ( 'https://api.metaswap.codefi.network' )
amount : 5 ,
. get ( ` /fiatOnRampUrl?serviceName=wyre&destinationAddress= ${ ETH _ADDRESS } ` )
address : '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' ,
. reply ( 200 , {
} ;
url : ` https://pay.sendwyre.com/purchase?accountId= ${ WYRE _ACCOUNT _ID } &utm_campaign= ${ WYRE _ACCOUNT _ID } &destCurrency=ETH&utm_medium=widget&paymentMethod=debit-card&reservation=MLZVUF8FMXZUMARJC23B&dest=ethereum%3A ${ ETH _ADDRESS } &utm_source=checkout ` ,
const ropsten = {
} ) ;
chainId : ROPSTEN _CHAIN _ID ,
const wyreUrl = await getBuyEthUrl ( MAINNET ) ;
} ;
assert . equal (
const rinkeby = {
wyreUrl ,
chainId : RINKEBY _CHAIN _ID ,
` https://pay.sendwyre.com/purchase?accountId= ${ WYRE _ACCOUNT _ID } &utm_campaign= ${ WYRE _ACCOUNT _ID } &destCurrency=ETH&utm_medium=widget&paymentMethod=debit-card&reservation=MLZVUF8FMXZUMARJC23B&dest=ethereum%3A ${ ETH _ADDRESS } &utm_source=checkout ` ,
} ;
) ;
const kovan = {
nock . cleanAll ( ) ;
chainId : KOVAN _CHAIN _ID ,
} ) ;
} ;
it ( 'returns a fallback Wyre url if /orders/reserve API call fails' , async function ( ) {
it ( 'returns Wyre url with an ETH address for Ethereum mainnet' , function ( ) {
const wyreUrl = await getBuyEthUrl ( MAINNET ) ;
const wyreUrl = getBuyEthUrl ( mainnet ) ;
assert . equal (
assert . equal (
wyreUrl ,
wyreUrl ,
'https://pay.sendwyre.com/purchase?dest=ethereum:0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc&destCurrency=ETH&accountId=AC-7AG3W4XH4N2&paymentMethod=debit-card' ,
` https://pay.sendwyre.com/purchase?dest=ethereum: ${ ETH _ADDRESS } &destCurrency=ETH&accountId= ${ WYRE _ACCOUNT _ID } &paymentMethod=debit-card ` ,
) ;
) ;
} ) ;
} ) ;
it ( 'returns Transak url with an ETH address for Ethereum mainnet' , function ( ) {
it ( 'returns Transak url with an ETH address for Ethereum mainnet' , async function ( ) {
const transakUrl = getBuyEthUrl ( { ... mainnet , service : 'transak' } ) ;
const transakUrl = await getBuyEthUrl ( { ... MAINNET , service : 'transak' } ) ;
assert . equal (
assert . equal (
transakUrl ,
transakUrl ,
` https://global.transak.com/?apiKey= ${ TRANSAK _API _KEY } &hostURL=https%3A%2F%2Fmetamask.io&defaultCryptoCurrency=ETH&walletAddress=0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc ` ,
` https://global.transak.com/?apiKey= ${ TRANSAK _API _KEY } &hostURL=https%3A%2F%2Fmetamask.io&defaultCryptoCurrency=ETH&walletAddress= ${ ETH _ADDRESS } ` ,
) ;
) ;
} ) ;
} ) ;
it ( 'returns metamask ropsten faucet for network 3' , function ( ) {
it ( 'returns metamask ropsten faucet for network 3' , async function ( ) {
const ropstenUrl = getBuyEthUrl ( ropsten ) ;
const ropstenUrl = await getBuyEthUrl ( ROPSTEN ) ;
assert . equal ( ropstenUrl , 'https://faucet.metamask.io/' ) ;
assert . equal ( ropstenUrl , 'https://faucet.metamask.io/' ) ;
} ) ;
} ) ;
it ( 'returns rinkeby dapp for network 4' , function ( ) {
it ( 'returns rinkeby dapp for network 4' , async function ( ) {
const rinkebyUrl = getBuyEthUrl ( rinkeby ) ;
const rinkebyUrl = await getBuyEthUrl ( RINKEBY ) ;
assert . equal ( rinkebyUrl , 'https://www.rinkeby.io/' ) ;
assert . equal ( rinkebyUrl , 'https://www.rinkeby.io/' ) ;
} ) ;
} ) ;
it ( 'returns kovan github test faucet for network 42' , function ( ) {
it ( 'returns kovan github test faucet for network 42' , async function ( ) {
const kovanUrl = getBuyEthUrl ( kovan ) ;
const kovanUrl = await getBuyEthUrl ( KOVAN ) ;
assert . equal ( kovanUrl , 'https://github.com/kovan-testnet/faucet' ) ;
assert . equal ( kovanUrl , 'https://github.com/kovan-testnet/faucet' ) ;
} ) ;
} ) ;
} ) ;
} ) ;