Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

as-chain

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-chain - npm Package Compare versions

Comparing version 0.0.33 to 0.0.34

assembly/binaryextension.ts

2

assembly/index.ts

@@ -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 {

68

assembly/name.ts

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc