Skip to content

Commit

Permalink
Fix minors bug for config merge. Remove error log
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperstrongBE committed Nov 20, 2024
1 parent 6aad6fe commit f321471
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export const ConnectButton = (props: ConnectButtonProps) => {
verifyChainStore(session.auth.actor.toString()).then(res => {
console.log('after connect',res)
if (res) {

if (!storeWallets || !activeNetwork) return;
const mutatedWallet = {...storeWallets};
mutatedWallet[activeNetwork].store = session.auth.actor.toString();
mutatedWallet[activeNetwork].verified = res;

setStoreWallets(mutatedWallet)
}
})
Expand Down
5 changes: 0 additions & 5 deletions includes/api/admin-save-wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ function xprcheckout_register_save_wallet_config_routes()
'validate_callback' => function($param, $request, $key) {
// Ensure the parameter is an array and validate the required keys and their types
if (!is_array($param)) {
error_log('No params');
return false;
}

// Validate testnet configuration
if (isset($param['testnet'])) {
error_log('Have testnet');
if (!is_array($param['testnet']) ||
!isset($param['testnet']['store']) || !is_string($param['testnet']['store']) ||
!isset($param['testnet']['verified']) || !is_bool($param['testnet']['verified'])) {
error_log('Error testnet');
return false;
}
}
Expand All @@ -38,7 +35,6 @@ function xprcheckout_register_save_wallet_config_routes()
if (!is_array($param['mainnet']) ||
!isset($param['mainnet']['store']) || !is_string($param['mainnet']['store']) ||
!isset($param['mainnet']['verified']) || !is_bool($param['mainnet']['verified'])) {
error_log('Error mainnet');
return false;
}
}
Expand Down Expand Up @@ -71,7 +67,6 @@ function admin_only_save_wallet_permission_check($request) {
function handle_save_config_request($request){

$walletsJson = $request->get_param('wallets');
error_log(print_r($walletsJson,1));
$baseResponse = new stdClass();

$serializedWallets = serialize($walletsJson);
Expand Down
7 changes: 3 additions & 4 deletions includes/controllers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public static function GetBaseConfig()
$xprcheckoutGateway = WC()->payment_gateways->payment_gateways()['xprcheckout'];
$rawWallets = $xprcheckoutGateway->get_option('wallets');
$wallets = unserialize($rawWallets);
error_log(print_r($wallets,1));
$activeNetwork = $xprcheckoutGateway->get_option('network');
$store = $wallets[$activeNetwork]['store'];

Expand All @@ -101,7 +100,7 @@ public static function GetBaseConfig()
public static function GetAdminConfig()
{
$xprcheckoutGateway = WC()->payment_gateways->payment_gateways()['xprcheckout'];
$rawWallets = $xprcheckoutGateway->get_option('walletsos');
$rawWallets = $xprcheckoutGateway->get_option('wallets');
$wallets = [
'testnet'=>[
'store'=>'',
Expand All @@ -112,9 +111,9 @@ public static function GetAdminConfig()
'verified'=>false
],
];
if ($rawWallets){
if (!is_null($rawWallets)){
$unserializedWallet = unserialize($rawWallets);
if ($unserializedWallet){
if (!is_null($unserializedWallet)){
$wallets = $unserializedWallet;
}
}
Expand Down

0 comments on commit f321471

Please sign in to comment.