Skip to content

Commit

Permalink
Merge pull request #7 from BitCannaGlobal/v1.0.14
Browse files Browse the repository at this point in the history
Push to v1.0.14
  • Loading branch information
atmoner authored Dec 16, 2022
2 parents fbbb2a4 + 9233944 commit 1462727
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
6 changes: 5 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://commerce.bitcanna.io
Tags: payments, cryptocurrency, blockchain
Requires at least: 3.0.1
Tested up to: 6.1.1
Stable tag: 1.0.13
Stable tag: 1.0.14
Requires PHP: 7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -37,6 +37,10 @@ For our FAQ we'd like to refer you to our [documentation website](https://docs.b
5. After just a couple seconds, the payment will be performed and you can view your transaction.

== Changelog ==
= 1.0.13 =
* Add failover on RPC/LCD
* Fix bech32 admin confirmation

= 1.0.13 =
* Add keplr/ledger compatibility
* Fix check balance keplr
Expand Down
16 changes: 13 additions & 3 deletions admin/partials/cosmos-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
</fieldset>
<input id="checkDisclamer" name="checkDisclamer" type="hidden" value="true">
<?php submit_button("Confirm"); ?>

</form>
</div>
</div>
Expand Down Expand Up @@ -97,7 +98,7 @@
<td><input required="required" type="text" id="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $value ); ?>" value="<?php echo esc_attr( $configCosmosAddr[$value] ); ?>" size="50" />
<div id="goodAddr_<?php echo esc_attr( $value ); ?>" style="display: none; color:green;">This is a valid address.</div>
<div id="badAddr_<?php echo esc_attr( $value ); ?>" style="display: none; color:red;">This is an invalid address. Please double-check.</div>
<div id="badAddrPrefix_<?php echo esc_attr( $value ); ?>" style="display: none; color:red;">Bad address prefiix</div>
<div id="badAddrPrefix_<?php echo esc_attr( $value ); ?>" style="display: none; color:red;">This address does not belong to this chain. Please update to the right address.</div>
</td>
<td>
<button id="target" value="<?php echo esc_attr( $value ); ?>" name="get_chain" class="button button-primary" type="button">
Expand All @@ -115,8 +116,10 @@
<input type="hidden" name="update_address" value="true">
<div id="resultAddr"></div>
</table>

<?php submit_button(); ?>
<button type="submit" class="button button-primary" id="sendConfig" name="mymod_pc_form" >
<i class="process-icon-save"></i> Save Changes
</button>


</form>
</div>
Expand Down Expand Up @@ -152,17 +155,20 @@
$("#goodAddr_"+element.name).show();
$("#badAddr_"+element.name).hide();
$("#badAddrPrefix_"+element.name).hide();
$('#sendConfig').prop('disabled', false);
} else {
$("#goodAddr_"+element.name).hide();
$("#badAddr_"+element.name).hide();
$("#badAddrPrefix_"+element.name).show();
$('#sendConfig').prop('disabled', true);
}

} catch (error) {
console.error(error);
$("#goodAddr_"+element.name).hide();
$("#badAddrPrefix_"+element.name).hide();
$("#badAddr_"+element.name).show();
$('#sendConfig').prop('disabled', true);
}
});
});
Expand All @@ -183,6 +189,10 @@
const offlineSigner = window.keplr.getOfflineSigner(chainId)
const accounts = await offlineSigner.getAccounts()
$( '#' + foundChain.name ).val(accounts[0].address)
$("#goodAddr_"+foundChain.name).show();
$("#badAddr_"+foundChain.name).hide();
$("#badAddrPrefix_"+foundChain.name).hide();
$('#sendConfig').prop('disabled', false);
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions cosmos-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: Cosmos Pay
* Plugin URI: https://twitter.com/bitcannaglobal
* Description: Easily accept cryptocurrency payments on your WordPress site. Enable multiple currencies from the interconnected Cosmos ecosystem.
* Version: 1.0.13
* Version: 1.0.14
* Author: BitCanna
* Author URI: https://commerce.bitcanna.io
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.13' );
define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.14' );



Expand Down
2 changes: 1 addition & 1 deletion public/js/bundle.js

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions public/js/bundle.js.source/src/initsend.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
} = require('@cosmjs/stargate')
const axios = require('axios')

exports.sendByChain = async function(getChainId, recipient, amount, orderId, memo, $) {
exports.sendByChain = async function(getChainId, recipient, amount, orderId, memo, isLogged, $) {
//console.log(initConfig.default)
let foundChain = initConfig.default.find(element => element.name === getChainId);
//console.log(foundChain)
Expand All @@ -29,8 +29,17 @@ exports.sendByChain = async function(getChainId, recipient, amount, orderId, mem
const offlineSigner = await window.getOfflineSignerAuto(chainId);
const accounts = await offlineSigner.getAccounts();

// Failover RPC
let finalRpc = ''
try {
let failOver = await axios.get(foundChain.rpcURL)
finalRpc = foundChain.rpcURL
} catch (e) {
finalRpc = foundChain.rpcRegistryURL
}

const client = await SigningStargateClient.connectWithSigner(
foundChain.rpcURL,
finalRpc,
offlineSigner
)

Expand All @@ -48,27 +57,21 @@ exports.sendByChain = async function(getChainId, recipient, amount, orderId, mem

try {
const result = await client.sendTokens(accounts[0].address, recipient, [amountFinal], fee, memo)
assertIsBroadcastTxSuccess(result)
//console.log(result)
if (result.code !== undefined && result.code !== 0) {
alert("Failed to send tx: " + result.log || result.rawLog);
} else {
$("#spinner").hide('slow');
$("#AcceptedTx").show();
//alert("Succeed to send tx");
$("#returnResult").html( result.transactionHash );
//console.log(order_id);

// var returnUrl = '/index.php?fc=module&module=cosmospay&controller=validation&check&tx_hash='+result.transactionHash

var returnUrl = '/api-cosmos/?tx_hash='+result.transactionHash+'&order_id='+orderId

axios.get(returnUrl)
.then(function (response) {
console.log(response);
$("#returnResultStore").html( response.data.message );
$("#sendForm").hide();
$("#viewFinalTx").show();

$("#viewFinalTx").show();
$("#checkAdresse").show();
$("#waitingcheckAdresse").hide();
$("#checkAdresse").css("color", "#31BF91");
Expand All @@ -82,10 +85,14 @@ exports.sendByChain = async function(getChainId, recipient, amount, orderId, mem
$("#finalUrlTx").attr("href", "https://www.mintscan.io/" + foundChain.mintscanId + "/txs/"+result.transactionHash)
$("#viewFinalTx").show(1000);
$("#timer").hide();

if (isLogged === 'true') {
setTimeout(function() {
window.location.href = "/my-account/view-order/" + orderId + "/";
}, 5000);
}
})
.catch(function (error) {
// console.log(error);
console.log(error);
});
}
} catch (e) {
Expand Down

0 comments on commit 1462727

Please sign in to comment.