@@ -498,6 +498,9 @@ async function fetchDataUnionMainnetAddress(
498498
499499function getDataUnionMainnetAddress ( client : StreamrClient , dataUnionName : string , deployerAddress : EthereumAddress ) {
500500 const { factoryMainnetAddress } = client . options
501+ if ( ! factoryMainnetAddress ) {
502+ throw new Error ( 'StreamrClient has no factoryMainnetAddress configuration.' )
503+ }
501504 // NOTE! this must be updated when DU sidechain smartcontract changes: keccak256(CloneLib.cloneBytecode(data_union_mainnet_template));
502505 const codeHash = '0x50a78bac973bdccfc8415d7d9cfd62898b8f7cf6e9b3a15e7d75c0cb820529eb'
503506 const salt = keccak256 ( defaultAbiCoder . encode ( [ 'string' , 'address' ] , [ dataUnionName , deployerAddress ] ) )
@@ -521,6 +524,9 @@ async function fetchDataUnionSidechainAddress(client: StreamrClient, duMainnetAd
521524
522525function getDataUnionSidechainAddress ( client : StreamrClient , mainnetAddress : EthereumAddress ) {
523526 const { factorySidechainAddress } = client . options
527+ if ( ! factorySidechainAddress ) {
528+ throw new Error ( 'StreamrClient has no factorySidechainAddress configuration.' )
529+ }
524530 // NOTE! this must be updated when DU sidechain smartcontract changes: keccak256(CloneLib.cloneBytecode(data_union_sidechain_template))
525531 const codeHash = '0x040cf686e25c97f74a23a4bf01c29dd77e260c4b694f5611017ce9713f58de83'
526532 return getCreate2Address ( factorySidechainAddress , hexZeroPad ( mainnetAddress , 32 ) , codeHash )
@@ -941,9 +947,14 @@ export class DataUnionEndpoints {
941947 * Get token balance in "wei" (10^-18 parts) for given address
942948 */
943949 async getTokenBalance ( address : string ) : Promise < BigNumber > {
944- const a = getAddress ( address )
950+ const { tokenAddress } = this . client . options
951+ if ( ! tokenAddress ) {
952+ throw new Error ( 'StreamrClient has no tokenAddress configuration.' )
953+ }
954+ const addr = getAddress ( address )
945955 const provider = this . client . ethereum . getMainnetProvider ( )
946- const token = new Contract ( this . client . options . tokenAddress , [ {
956+
957+ const token = new Contract ( tokenAddress , [ {
947958 name : 'balanceOf' ,
948959 inputs : [ { type : 'address' } ] ,
949960 outputs : [ { type : 'uint256' } ] ,
@@ -952,7 +963,7 @@ export class DataUnionEndpoints {
952963 stateMutability : 'view' ,
953964 type : 'function'
954965 } ] , provider )
955- return token . balanceOf ( a )
966+ return token . balanceOf ( addr )
956967 }
957968
958969 /**
0 commit comments