Enable Threshold (1-of-N) Support in HTS Precompile - #1069
Conversation
✅ Deploy Preview for hedera-hips ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
3b7917b to
cdef1c5
Compare
|
Hi @mgarbs , it seems to me we solved all the pending issues. From my PoV we can proceed. |
|
From a technical point of view, I do not think this can be accommodated without system contract versioning as you would be potentially breaking existing contracts because of the need to redefine the |
|
I totally agree with @lukelee-sl, this is a great candidate for the contract versioning initiative. |
|
I agree that this is a good fit for the new contract versioning initiative. @lukelee-sl I don't think we need to make an explicit reference to this detail in the HIP, especially if the new process is going to be the new norm, but just in case, feel free to suggest some changes. @stoyanov-st Yes, we need to make as many details explicit as possible, but they can be just an example and the real struct can be defined later. The guidelines for a HIP are to make explicit any changes that affect the operation of the network, including interfaces. In this case, if we maintain compatibility with old contracts, as we will now do with the versioning system, we can more easily skip all the details on the Solidity side, but it's good to have them as an initial idea and as a reference for developers reading the HIPs in the future. If there are major changes during development, we can always update the HIP with the correct interfaces, but if there are major changes, we will need to do a new HIP release. |
Signed-off-by: Michael Garber <michael.garber@swirldslabs.com>
556c886 to
2e4a81d
Compare
|
After carefully reviewing this HIP, the smart contracts team has agreed on several discussion topics that need to be addressed for the clarity and understanding of this feature. Those are:
Considering the impact that this proposal is going to make, we need to be careful and also be able to foresee most of the implications that it is going to produce. |
Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
6ed5e2e to
57778dd
Compare
| <script src="{{ '/assets/js/hipstable.js' | relative_url }}"></script> | ||
| <script src="{{ '/assets/js/filter.js' | relative_url }}"></script> | ||
| <script src="{{ '/assets/js/pr-integration.js' | relative_url }}"></script> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script> |
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this problem, replace the no-op .replace(/'/g, "'") and .replace(/"/g, '"') calls with replacements that actually target unicode smart quotes, substituting them with regular ASCII single ' and double " quotes, respectively. Specifically:
- Change the patterns to match the unicode smart quotes:
‘(U+2018) and’(U+2019) for single quotes, and“(U+201C) and”(U+201D) for double quotes. - Replace them with the ASCII equivalents (
'and"). - Remove the unnecessary no-op replacements.
All changes should be made in the block of code that does the replacements (lines 45–56 in scripts/validateHIP.js). No new imports or dependencies are required.
| @@ -45,15 +45,12 @@ | ||
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| // Replace smart single quotes to ASCII single quote | ||
| .replace(/[\u2018\u2019]/g, "'") | ||
| // Replace smart double quotes to ASCII double quote | ||
| .replace(/[\u201C\u201D]/g, '"') | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this issue, update all redundant .replace(/'/g, "'") and .replace(/"/g, '"') calls to actually target the typographic/smart quote Unicode characters commonly found in documents, replacing them with plain ASCII equivalents. Specifically:
- Replace left/right single quotes (
‘is U+2018,’is U+2019) with' - Replace left/right double quotes (
“is U+201C,”is U+201D) with"
This should be done in the replacement block for lines 44-56 inscripts/validateHIP.js.
No new imports or dependencies are needed.
| @@ -45,15 +45,10 @@ | ||
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/[\u2018\u2019]/g, "'") // left/right single quotes to ASCII | ||
| .replace(/[\u201C\u201D]/g, '"') // left/right double quotes to ASCII | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
The fix requires identifying the intended problematic characters (smart quotes), and replacing them with correct ASCII equivalents. Specifically:
- Lines like
.replace(/"/g, '"')should target the Unicode smart quotes, for example, replacing U+201C (\u201C) and U+201D (\u201D) with". - Instead of
.replace(/"/g, '"'), use.replace(/\u201C/g, '"')and.replace(/\u201D/g, '"'). - Clean up redundant replacements of
'as well, if applicable (so-called "smart" single quotes U+2018/U+2019). - Only modify the
draftHipclean-up chain inscripts/validateHIP.js(lines 45–56). - No new imports required.
- No change to overall functionality, only correct the character replacement.
| @@ -45,15 +45,15 @@ | ||
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/\u2018/g, "'") // left single quote | ||
| .replace(/\u2019/g, "'") // right single quote | ||
| .replace(/\u201C/g, '"') // left double quote | ||
| .replace(/\u201D/g, '"') // right double quote | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
| // .replace(/'/g, "'") // another type of smart quote (u2019), handled above | ||
| // .replace(/"/g, '"') // another type of smart quote (u201C), handled above | ||
| // .replace(/"/g, '"'); // another type of smart quote (u201D), handled above | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the problem, the code should replace specific Unicode quote characters (such as left/right smart quotes) with their ASCII equivalents (' and "), rather than replacing the ASCII quote with itself. The affected region is lines 48–56 in scripts/validateHIP.js. Specifically, the code should use the corresponding Unicode code points for smart quotes — e.g., replace ‘/’ with ', and “/” with " — not generic ASCII quotes.
To implement these changes, update the relevant .replace() calls to properly match and convert Unicode smart quotes to ASCII quotes. No additional imports or custom methods are required; all replacements can be done using JS regular expressions.
| @@ -45,15 +45,15 @@ | ||
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/[\u2018]/g, "'") // left single quotation mark (‘) to ASCII single quote | ||
| .replace(/[\u2019]/g, "'") // right single quotation mark (’) to ASCII single quote | ||
| .replace(/[\u201C]/g, '"') // left double quotation mark (“) to ASCII double quote | ||
| .replace(/[\u201D]/g, '"') // right double quotation mark (”) to ASCII double quote | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
| // removed duplicate smart quote replaces since they're now handled above | ||
| // removed duplicate smart quote replaces since they're now handled above | ||
| // removed duplicate smart quote replaces since they're now handled above | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
| .replace(/"/g, '"') // right double quote | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix the problem, locate the .replace(/'/g, "'") on line 54, which is intended to convert smart single quotes (such as U+2019) to ASCII apostrophes. Change the regular expression so it matches the correct Unicode code point(s) for smart quotes—for example, \u2019 (right single quotation mark), \u2018 (left single quotation mark), and possibly others—then replace them with the simple ASCII apostrophe ('). No additional imports are needed as this uses JavaScript's built-in string and regex support. Only change the code on or near line 54 for this correction.
| @@ -51,7 +51,7 @@ | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/[\u2018\u2019]/g, "'") // left/right single quotation marks to apostrophe | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
|
|
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To properly standardize double quotes in the HIP text, we should replace all forms of "smart quotes" with the standard ASCII double quote character ("). This means explicitly targeting Unicode characters such as “ (LEFT DOUBLE QUOTATION MARK, U+201C) and ” (RIGHT DOUBLE QUOTATION MARK, U+201D). Lines 50, 51, 55, and 56 currently use /"/g, which matches only the ASCII double quote, but they should use /[“”]/g to replace these Unicode types. Thus, in file scripts/validateHIP.js, lines 50, 51, 55, and 56 should match these Unicode smart quotes and replace with ".
No external dependency is needed; only native JavaScript regex.
| @@ -47,13 +47,13 @@ | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/“/g, '"') // left double quote U+201C | ||
| .replace(/”/g, '"') // right double quote U+201D | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
| .replace(/“/g, '"') // another type of smart quote (redundant, left quote) | ||
| .replace(/”/g, '"'); // another type of smart quote (redundant, right quote) | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
General fix:
Remove or correct the .replace lines where the code attempts to replace a substring with itself (/"/g, '"') for both single and double quotes. Instead, the code should explicitly match and replace smart/curly quotes (such as “, ”, ‘, ’) with the ASCII equivalents. This will ensure that all variants of smart quotes are handled correctly for JSON and downstream processing.
Specifics:
- On lines 48–56, correct the regexes so that all Unicode smart quotes are matched, and are replaced with ASCII
'or"as appropriate. - Remove all lines that simply
.replace(/'/g, "'")or.replace(/"/g, '"')unless they're meant to revert something that was previously mapped incorrectly (which seems not to be the intent here). - Add correct regex replacements for smart quote characters:
- Single quotes:
‘(U+2018),’(U+2019) - Double quotes:
“(U+201C),”(U+201D)
- Single quotes:
Implementation details:
Edit line 45–56 in scripts/validateHIP.js to:
- Replace
.replace(/‘|’/g, "'") // smart single quotes - Replace
.replace(/“|”/g, '"') // smart double quotes - Remove any duplicate or no-op replacements.
No new imports are necessary.
| @@ -45,15 +45,10 @@ | ||
| draftHip = draftHip | ||
| .replace(/—/g, '-') // em dash to hyphen | ||
| .replace(/–/g, '-') // en dash to hyphen | ||
| .replace(/'/g, "'") // left single quote | ||
| .replace(/'/g, "'") // right single quote | ||
| .replace(/"/g, '"') // left double quote | ||
| .replace(/"/g, '"') // right double quote | ||
| .replace(/[‘’]/g, "'") // smart single quotes U+2018, U+2019 to ASCII | ||
| .replace(/[“”]/g, '"') // smart double quotes U+201C, U+201D to ASCII | ||
| .replace(/…/g, '...') // ellipsis | ||
| .replace(/[\u2028\u2029]/g, '\n') // line/paragraph separators | ||
| .replace(/'/g, "'") // another type of smart quote (u2019) | ||
| .replace(/"/g, '"') // another type of smart quote (u201C) | ||
| .replace(/"/g, '"'); // another type of smart quote (u201D) | ||
| .replace(/[\u2028\u2029]/g, '\n'); // line/paragraph separators | ||
|
|
||
| // Check if API key is available | ||
| if (!API_KEY) { |
57778dd to
6ed5e2e
Compare
Enable Threshold Keys Support in HTS updateTokenKeys Precompile
This update adds support for using threshold keyswithin the
updateTokenKeysHTS precompile function, allowing developers to set token keys with multiple signatories directly in smart contracts. While complex keys are supported in the SDK, this enhancement allows on-chain token management with multi-signature and threshold-controlled permissions, expanding flexibility for applications requiring decentralized control over token keys.