From 5ad5f28fbb2af1ef2bf060e1d783e080149a330a Mon Sep 17 00:00:00 2001 From: John Villar Date: Wed, 23 Oct 2019 22:25:13 -0400 Subject: [PATCH 1/6] Hotfix for satoshi rate divisibility for dispensers --- src/js/components/balances.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/balances.js b/src/js/components/balances.js index dae0bd58c..7101def0a 100644 --- a/src/js/components/balances.js +++ b/src/js/components/balances.js @@ -887,7 +887,7 @@ function CreateDispenserModalViewModel() { self.mainchainrate = ko.observable().extend({ required: true, isValidPositiveQuantity: self, - isValidQtyForDivisibility: self, + //isValidQtyForDivisibility: true, validation: { validator: function(val, self) { return true; From cfe7794c14cb8f678cc9b012675b4a7e30492906 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Fri, 8 Apr 2022 18:03:09 -0400 Subject: [PATCH 2/6] - Fixed window appearing on the main page saying "Just click on the icons to get to the download page" with a list of browsers even having an appropiate browser for the wallet --- src/bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bower.json b/src/bower.json index 95e3f4f68..e7cf60cdd 100644 --- a/src/bower.json +++ b/src/bower.json @@ -17,8 +17,8 @@ "jqBootstrapValidation": "1.3.7", "jqlog": "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jqlog/jqlog-1.3.zip", "keyboard": "1.18.8", - "jReject": "1.0.2", - "jReject-ie11": "https://raw.githubusercontent.com/TurnWheel/jReject/39e310ffb8659488f3d376b721b3a54c89a19d68/js/jquery.reject.js", + "jReject": "1.1.5", + "jReject-ie11": "https://raw.githubusercontent.com/TurnWheel/jReject/8cdb9d6c4f4881c6eff1848643b19cada3b0f81d/js/jquery.reject.js", "jquery.slimscroll": "1.3.1", "jquery-timeago": "1.4.0", "jquery-yql": "https://raw.githubusercontent.com/hail2u/jquery.query-yql/655264551b7962485bcf0d06226e053a6f24629b/jquery.query-yql.js", From a4673aad09cd60f375c977ed3f84493b1dda5f77 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Mon, 18 Apr 2022 19:59:37 -0400 Subject: [PATCH 3/6] - Fixed download url for phantomjs - Nodejs version was upgraded to 14 to prevent CERT_HAS_EXPIRED from knockoutjs --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a7edb62e..aeb48541a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,7 @@ RUN mkdir -p /counterblock_data/asset_img /counterblock_data/asset_img.testnet # Install newest stable nodejs # (the `nodejs` package includes `npm`) RUN apt-get update && apt-get -y remove nodejs npm gyp -RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - +RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - RUN apt-get update && apt-get -y install nodejs # Add transifex auth data if available @@ -74,8 +74,9 @@ ENV TRANSIFEX_PASSWORD ${TRANSIFEX_PASSWORD} RUN if [ -n "$TRANSIFEX_USER" ] && [ -n "$TRANSIFEX_PASSWORD" ]; then echo "$TRANSIFEX_USER:$TRANSIFEX_PASSWORD" > /root/.transifex; fi # Global stuff moved here to speed up build times just for code changes +RUN npm update -g npm RUN npm config set strict-ssl false -ENV PHANTOMJS_CDNURL="http://cnpmjs.org/downloads" +ENV PHANTOMJS_CDNURL="https://bitbucket.org/ariya/phantomjs/downloads" RUN npm install -g bower grunt browserify uglify-es RUN npm install --unsafe-perm -g mocha-phantomjs From cab7dfa8da7cc3f75328f03bfe84c8f1b15cf522 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Tue, 30 Aug 2022 22:48:02 -0400 Subject: [PATCH 4/6] - Added cip03 reset functionality --- src/js/components/asset.js | 14 +++ src/js/components/balances_assets.js | 106 ++++++++++++++++++++++ src/js/components/feed_notifications.js | 4 + src/js/components/feed_pending_actions.js | 9 ++ src/js/pages.init.js | 2 + src/locales/en/translation.json | 8 ++ src/pages/balances.html | 59 ++++++++++++ 7 files changed, 202 insertions(+) diff --git a/src/js/components/asset.js b/src/js/components/asset.js index eb94b610d..b3abb7cdc 100644 --- a/src/js/components/asset.js +++ b/src/js/components/asset.js @@ -48,6 +48,10 @@ function AssetViewModel(props) { return self.owner() == self.ADDRESS; }, self); + self.canBeReset = ko.computed(function() { + return self.isMine() && (self.rawSupply() == self.rawBalance()); + }, self); + self.normalizedBalance = ko.computed(function() { if (self.rawBalance() === null) return null; return normalizeQuantity(self.rawBalance(), self.DIVISIBLE); @@ -61,6 +65,10 @@ function AssetViewModel(props) { return smartFormat(self.normalizedTotalIssued()); }, self); + self.divisibleLabel = ko.computed(function() { + return (self.DIVISIBLE?i18n.t("is_divisible"):i18n.t("is_not_divisible")); + }, self); + self.assetType = ko.computed(function() { if(_.startsWith(self.ASSET, 'A') && !self.ASSET_LONGNAME) { return 'numeric'; @@ -184,6 +192,12 @@ function AssetViewModel(props) { }); }; + self.reset_asset = function() { + assert(self.canBeReset()); + if (!WALLET.canDoTransaction(self.ADDRESS)) return false; + RESET_ASSET_MODAL.show(self.ADDRESS, self.DIVISIBLE, self.SUPPLY, self); + }; + self.changeDescription = function() { if (!WALLET.canDoTransaction(self.ADDRESS)) return false; CHANGE_ASSET_DESCRIPTION_MODAL.show(self.ADDRESS, self); diff --git a/src/js/components/balances_assets.js b/src/js/components/balances_assets.js index f0cc049d0..71610d413 100644 --- a/src/js/components/balances_assets.js +++ b/src/js/components/balances_assets.js @@ -273,6 +273,112 @@ function CreateAssetModalViewModel() { } } +function ResetAssetModalViewModel() { + var self = this; + + self.shown = ko.observable(false); + self.address = ko.observable(''); + self.divisible = ko.observable(); + self.asset = ko.observable(); + + self.totalSupply = ko.observable(); + self.wasDivisible = ko.observable(); + + self.quantity = ko.observable().extend({ + required: true, + isValidPositiveQuantityOrZero: self, + isValidQtyForDivisibility: self + }); + + self.validationModel = ko.validatedObservable({ + quantity: self.quantity + }); + + self.resetForm = function() { + self.divisible(true); + self.quantity(null); + self.validationModel.errors.showAllMessages(false); + self.feeController.reset(); + } + + self.submitForm = function() { + if (!self.validationModel.isValid()) { + self.validationModel.errors.showAllMessages(); + return false; + } + + //data entry is valid...submit to the server + $('#resetAssetModal form').submit(); + } + + self.doAction = function() { + WALLET.doTransactionWithTxHex(self.address(), "create_issuance", self.buildResetAssetTransactionData(), self.feeController.getUnsignedTx(), + + function(txHash, data, endpoint, addressType, armoryUTx) { + self.shown(false); + + var message = i18n.t("you_have_reset", self.asset().ASSET, self.quantity(), (self.divisible()?i18n.t("divisible"):i18n.t("not_divisible"))); + + WALLET.showTransactionCompleteDialog(message + " " + i18n.t(ACTION_PENDING_NOTICE), message, armoryUTx); + } + + + ); + + self.shown(false); + trackEvent('Assets', 'ResetAsset'); + } + + self.buildResetAssetTransactionData = function() { + var quantity = parseFloat(self.quantity()); + var rawQuantity = denormalizeQuantity(quantity, self.divisible()); + + if (rawQuantity > MAX_INT) { + bootbox.alert(i18n.t("issuance_quantity_too_high")); + return false; + } + + return { + source: self.address(), + asset: self.asset().ASSET, + quantity: rawQuantity, + divisible: self.divisible(), + lock: false, + reset: true, + description: self.asset().description(), + transfer_destination: null, + _fee_option: 'custom', + _custom_fee: self.feeController.getCustomFee() + } + } + + self.feeController = CWFeeModelMixin(self, { + action: "create_issuance", + transactionParameters: [self.quantity, self.divisible], + validTransactionCheck: function() { + return self.validationModel.isValid(); + }, + buildTransactionData: self.buildResetAssetTransactionData + }); + + self.show = function(address, divisible, quantity, asset, resetForm) { + if (typeof(resetForm) === 'undefined') resetForm = true; + if (resetForm) self.resetForm(); + self.totalSupply(quantity); + self.wasDivisible(divisible?i18n.t("divisible"):i18n.t("not_divisible")); + + self.address(address); + self.divisible(divisible); + self.asset(asset); + self.quantity(quantity); + self.shown(true); + trackDialogShow('ResetAsset'); + } + + self.hide = function() { + self.shown(false); + } +} function IssueAdditionalAssetModalViewModel() { var self = this; diff --git a/src/js/components/feed_notifications.js b/src/js/components/feed_notifications.js index 49619be71..37ab0f7f9 100644 --- a/src/js/components/feed_notifications.js +++ b/src/js/components/feed_notifications.js @@ -85,6 +85,10 @@ NotificationViewModel.calcText = function(category, message) { desc = i18n.t("notif_token_locked", message['_asset_longname'] || message['asset']); } else if (message['description'] != assetObj.description()) { desc = i18n.t("notif_token_desc_changed", message['_asset_longname'] || message['asset'], assetObj.description(), message['description']); + } else if (message['reset']) { + var newQuantity = message['quantity']; + var newDivisibility = message['divisible']; + desc = i18n.t("notif_token_reset", message['_asset_longname'] || message['asset'], smartFormat(normalizeQuantity(newQuantity, assetObj.DIVISIBLE)), (assetObj.DIVISIBLE?i18n.t("divisible"):i18n.t("not_divisible"))); } else { var additionalQuantity = message['quantity']; if (additionalQuantity) { diff --git a/src/js/components/feed_pending_actions.js b/src/js/components/feed_pending_actions.js index 1e38a945b..e5d50f6f8 100644 --- a/src/js/components/feed_pending_actions.js +++ b/src/js/components/feed_pending_actions.js @@ -64,6 +64,8 @@ PendingActionViewModel.calcText = function(category, data) { desc = i18n.t("pend_or_unconf_issuance", pending, asset_longname || data['asset'], numberWithCommas(normalizeQuantity(data['quantity'], data['divisible']))); } + } else if (data['reset']) { + desc = i18n.t("pend_or_unconf_reset", pending, asset_longname || data['asset'], numberWithCommas(normalizeQuantity(data['quantity'], data['divisible'])), (data['divisible']?i18n.t('divisible'):i18n.t('not_divisible'))); } else { //See if this is a new issuance or not var assetObj = null; @@ -315,6 +317,13 @@ PendingActionFeedViewModel.modifyBalancePendingFlag = function(category, data, f updateUnconfirmedBalance(data['source'], data['asset'], data['quantity'] * -1); updateUnconfirmedBalance(data['destination'], data['asset'], data['quantity']); + } else if (category == 'issuances' && data['reset']) { + addressObj = WALLET.getAddressObj(data['source']); + var assetObj = addressObj.getAssetObj(data['asset']); + if (assetObj && assetObj.isMine()) { + assetObj.issuanceQtyChangePending(flagSetting); + assetObj.balanceChangePending(flagSetting); + } } else if (category == 'issuances' && !data['locked'] && !data['transfer_destination']) { //with this, we don't modify the balanceChangePending flag, but the issuanceQtyChangePending flag instead... addressObj = WALLET.getAddressObj(data['source']); diff --git a/src/js/pages.init.js b/src/js/pages.init.js index 6aefbc5e6..b31bbdd58 100644 --- a/src/js/pages.init.js +++ b/src/js/pages.init.js @@ -151,6 +151,7 @@ function initBalances() { //balances_assets.js window.CREATE_ASSET_MODAL = new CreateAssetModalViewModel(); window.ISSUE_ADDITIONAL_ASSET_MODAL = new IssueAdditionalAssetModalViewModel(); + window.RESET_ASSET_MODAL = new ResetAssetModalViewModel(); window.TRANSFER_ASSET_MODAL = new TransferAssetModalViewModel(); window.CHANGE_ASSET_DESCRIPTION_MODAL = new ChangeAssetDescriptionModalViewModel(); window.PAY_DIVIDEND_MODAL = new PayDividendModalViewModel(); @@ -158,6 +159,7 @@ function initBalances() { ko.applyBindings(CREATE_ASSET_MODAL, document.getElementById("createAssetModal")); ko.applyBindings(ISSUE_ADDITIONAL_ASSET_MODAL, document.getElementById("issueAdditionalAssetModal")); + ko.applyBindings(RESET_ASSET_MODAL, document.getElementById("resetAssetModal")); ko.applyBindings(TRANSFER_ASSET_MODAL, document.getElementById("transferAssetModal")); ko.applyBindings(CHANGE_ASSET_DESCRIPTION_MODAL, document.getElementById("changeAssetDescriptionModal")); ko.applyBindings(PAY_DIVIDEND_MODAL, document.getElementById("payDividendModal")); diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 71c41fcdd..b3dde3602 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -228,6 +228,7 @@ "issuance_exceed_max_quantity": "This issuance would exceed the hard limit for maximum quantity.", "you_will_be_issuing": "You will be issuing %s additional quantity on your token %s.", "you_have_issued": "You have issued %s additional quantity on your token %s.", + "you_have_reset": "You have reset %s with %s supply and now is %s.", "asset_will_be_transfered": "%s will be transferred to %s.", "asset_has_been_transfered": "%s has been transferred to %s.", "same_description_token": "This description is the same as the current description.", @@ -333,6 +334,7 @@ "notif_token_desc_changed": "Token %s had its description changed from %s to %s", "notif_additional_issued": "Additional %s units issued for token %s", "notif_token_issued": "Token %s was issued with an initial quantity of %s units", + "notif_token_reset": "Token %s was reset with a new supply of %s units and now it's %s", "notif_order_buy_active": "Your order to buy %s %s from %s in exchange for %s %s is active", "notif_order_matched": "Order matched between %s (gave %s %s) and %s (gave %s %s)", "notif_order_expired": "Your order ID %s from address %s has expired", @@ -353,6 +355,7 @@ "pend_or_unconf_lock": "%s lock of token %s against additional issuance", "pend_or_unconf_change_desc": "%s change of description for token %s to %s", "pend_or_unconf_issuance_add": "%s issuance of %s additional units for token %s", + "pend_or_unconf_reset": "%s reset of %s to %s supply units and it will be %s", "pend_or_unconf_issuance": "%s creation of token %s with initial quantity of %s units", "pend_or_unconf_broadcast": "%s broadcast:
Text: %s
Value: %s", "pend_or_unconf_bet": "%s %s bet on feed @ %s
Wager: %s XCP, Counterwager: %s XCP", @@ -536,8 +539,10 @@ "show_info": "Show Info", "burn_for_xcp": "Burn for XCP", "issue_additional": "Issue Additional", + "reset_token": "Reset Asset", "transfer_ownership": "Transfer Ownership", "lock_token_issuance": "Lock Token Issuance", + "reset_token_issuance": "Reset Token", "change_token_description": "Change Token Description", "issued": "Issued: %s", "change_address_label": "Change Address Label", @@ -575,6 +580,8 @@ "block_time": "Block Time", "divisible_token": "Divisible token?", "divisible_token_note": "Divisble assets can be subdivided into decimal places.", + "divisible": "divisible", + "not_divisible": "not divisible", "is_locked": "Is locked?", "is_locked_note": "Locked tokens may not have additional unit issued.", "pgp_signature": "PGP Signature", @@ -658,6 +665,7 @@ "pay_holders": "Use this form to pay holders of any token a distribution using XCP or any other token. Note that the full required balance of the token paid out must be present at this same address.

Please NOTE that this action is irreversible!", "address_transfer_ownership": "Enter the Bitcoin address you would like to permanently transfer ownership of this token to. (Be aware that this will not transfer the actual units of this token that you own to this address -- you can do that with a separate Send transaction.)

Please NOTE that this action is irreversible!", "more_token_issue": "How much more of this token would you like to issue? (For divisible tokens, state the quantity as a whole or floating point number, not in satoshis -- e.g. '732.45')

There are currently %s units of this token issued.

Please NOTE that this action is irreversible!", + "reset_token_issue": "Please, enter the new supply and indicate if the token will be divisible or not.

There are currently %s units of this token issued and the token is %s.", "asset_creation_fee_xcp": "Please note that a %s XCP fee will be deducted from your balance upon successful creation.", "change_token_description_p1": "This token's current description is:", "change_token_description_p2": "Enter a new description for your token", diff --git a/src/pages/balances.html b/src/pages/balances.html index bb685d4b9..6cdadd813 100644 --- a/src/pages/balances.html +++ b/src/pages/balances.html @@ -139,6 +139,7 @@

  • +
  • @@ -814,6 +815,64 @@

    + +