From 818ddeb377b7a7c4b4c8c92fcddd81dbd915a86e Mon Sep 17 00:00:00 2001 From: Neha0921 Date: Tue, 10 Aug 2021 15:40:26 +0530 Subject: [PATCH] end point Changes handler added --- src/Library/ss58.php | 28 +++++++++---------- ...{ApiHandler.php => SubstrateInterface.php} | 0 2 files changed, 14 insertions(+), 14 deletions(-) rename src/{ApiHandler.php => SubstrateInterface.php} (100%) diff --git a/src/Library/ss58.php b/src/Library/ss58.php index 37cff3d..d03ef65 100644 --- a/src/Library/ss58.php +++ b/src/Library/ss58.php @@ -19,36 +19,36 @@ public function ss58_decode($address, $valid_address_type = None){ $checksum_prefix = 'SS58PRE'; - $ss58_format = base58.b58decode(address) + $ss58_format = base58.b58decode(address); - if(valid_address_type and ss58_format[0] != valid_address_type){ + if($valid_address_type && $ss58_format[0] != $valid_address_type){ // raise ValueError("Invalid Address type") } # Determine checksum length according to length of address string - if (len(ss58_format) in [3, 4, 6, 10]){ + if (in_array(sizeof($ss58_format) , [3, 4, 6, 10])){ $checksum_length = 1; - }else if (len(ss58_format) in [5, 7, 11, 35]){ + }else if (in_array(sizeof($ss58_format) , [5, 7, 11, 35])){ $checksum_length = 2; - }else if (len(ss58_format) in [8, 12]){ + }else if (in_array(sizeof($ss58_format) ,[8, 12])){ $checksum_length = 3; - }else if (len(ss58_format) in [9, 13]){ - checksum_length = 4 - }else if ( len(ss58_format) in [14]){ + }else if (in_array(sizeof($ss58_format) ,[9, 13])){ + $checksum_length = 4; + }else if ( in_array(sizeof($ss58_format) ,[14])){ $checksum_length = 5; - }else if ( len(ss58_format) in [15]){ + }else if ( in_array(sizeof($ss58_format) ,[15])){ $checksum_length = 6; - }else if ( len(ss58_format) in [16]){ + }else if ( in_array(sizeof($ss58_format) ,[16])){ $checksum_length = 7; - }else if ( len(ss58_format) in [17]){ + }else if ( in_array(sizeof($ss58_format) ,[17])){ $checksum_length = 8; }else{ // raise ValueError("Invalid address length") } - $checksum = blake2b(checksum_prefix + ss58_format[0:-checksum_length]).digest() + $checksum = blake2b($checksum_prefix + $ss58_format[0:-$checksum_length]).digest(); - if (checksum[0:checksum_length] != ss58_format[-checksum_length:]){ + if ($checksum[0:$checksum_length] != $ss58_format[-checksum_length:]){ // raise ValueError("Invalid checksum") } - return ss58_format[1:len(ss58_format)-checksum_length].hex(); + return $ss58_format[1:len($ss58_format)-$checksum_length].hex(); } } diff --git a/src/ApiHandler.php b/src/SubstrateInterface.php similarity index 100% rename from src/ApiHandler.php rename to src/SubstrateInterface.php