Comparing version 0.0.33 to 0.0.34
@@ -13,2 +13,4 @@ export { U128, U256 } from "./bignum"; | ||
export { VariantValue } from "./variant"; | ||
export { Optional } from "./optional"; | ||
export { BinaryExtension } from "./binaryextension"; | ||
@@ -15,0 +17,0 @@ export { |
@@ -72,2 +72,34 @@ import { Decoder, Packer } from "./serializer"; | ||
export function nameToSuffix(name: Name): Name { | ||
let remainingBitsAfterLastActualDot: u32 = 0 | ||
let tmp: u32 = 0 | ||
for (let remainingBits: i32 = 59; remainingBits >= 4; remainingBits -=5) { | ||
// Get characters one-by-one in name in order from left to right (not including the 13th character) | ||
const c = (name.N >> remainingBits) & <u64>(0x1F); | ||
if (!c) { // if this character is a dot | ||
tmp = <u32>(remainingBits) | ||
} else { // if this character is not a dot | ||
remainingBitsAfterLastActualDot = tmp; | ||
} | ||
} | ||
const thirteenthCharacter: u64 = name.N & <u64>(0x0F) | ||
if(thirteenthCharacter) { // if 13th character is not a dot | ||
remainingBitsAfterLastActualDot = tmp; | ||
} | ||
if(remainingBitsAfterLastActualDot == 0) // there is no actual dot in the %name other than potentially leading dots | ||
return new Name(name.N); | ||
// At this point remaining_bits_after_last_actual_dot has to be within the range of 4 to 59 (and restricted to increments of 5). | ||
// Mask for remaining bits corresponding to characters after last actual dot, except for 4 least significant bits (corresponds to 13th character). | ||
const mask: u64 = (<u64>(1) << remainingBitsAfterLastActualDot) - 16; | ||
const shift: u32 = 64 - remainingBitsAfterLastActualDot; | ||
const nameValue = ((name.N & mask) << shift) + (thirteenthCharacter << (shift-1)) | ||
return new Name(nameValue) | ||
} | ||
export class Name implements Packer { | ||
@@ -92,2 +124,6 @@ N: u64; | ||
suffix(): Name { | ||
return nameToSuffix(this) | ||
} | ||
pack(): u8[] { | ||
@@ -138,34 +174,2 @@ let ret = new Array<u8>(8); | ||
} | ||
} | ||
export function nameToSuffix(name: Name): Name { | ||
let remainingBitsAfterLastActualDot: u32 = 0 | ||
let tmp: u32 = 0 | ||
for (let remainingBits: i32 = 59; remainingBits >= 4; remainingBits -=5) { | ||
// Get characters one-by-one in name in order from left to right (not including the 13th character) | ||
const c = (name.N >> remainingBits) & <u64>(0x1F); | ||
if (!c) { // if this character is a dot | ||
tmp = <u32>(remainingBits) | ||
} else { // if this character is not a dot | ||
remainingBitsAfterLastActualDot = tmp; | ||
} | ||
} | ||
const thirteenthCharacter: u64 = name.N & <u64>(0x0F) | ||
if(thirteenthCharacter) { // if 13th character is not a dot | ||
remainingBitsAfterLastActualDot = tmp; | ||
} | ||
if(remainingBitsAfterLastActualDot == 0) // there is no actual dot in the %name other than potentially leading dots | ||
return new Name(name.N); | ||
// At this point remaining_bits_after_last_actual_dot has to be within the range of 4 to 59 (and restricted to increments of 5). | ||
// Mask for remaining bits corresponding to characters after last actual dot, except for 4 least significant bits (corresponds to 13th character). | ||
const mask: u64 = (<u64>(1) << remainingBitsAfterLastActualDot) - 16; | ||
const shift: u32 = 64 - remainingBitsAfterLastActualDot; | ||
const nameValue = ((name.N & mask) << shift) + (thirteenthCharacter << (shift-1)) | ||
return new Name(nameValue) | ||
} |
{ | ||
"name": "as-chain", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"description": "chain module for assemblyscript", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1313501
35
3474