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.17 to 0.0.19

assembly/variant.ts

26

assembly/asset.ts

@@ -194,2 +194,18 @@ import { check } from "./system";

static fromString(assetStr: string): Asset {
const splitAsset = assetStr.split(' ')
const amountStr = splitAsset[0]
const symbolCodeStr = splitAsset[1]
const splitAmount = amountStr.split('.')
const precision = splitAmount.length == 1 ? 0 : splitAmount[1].length;
const rawAmount = I64.parseInt(`${splitAmount[0]}${splitAmount[1]}`, 10)
const symbol = new Symbol(symbolCodeStr, <u8>(precision))
const asset = new Asset(rawAmount, symbol)
check(asset.isValid(), "invalid asset");
return asset
}
isAmountWithinRange(): bool {

@@ -204,8 +220,8 @@ return -MAX_AMOUNT <= this.amount && this.amount <= MAX_AMOUNT;

toString(): string {
let precision = <i32>(this.symbol.value & 0xFF);
let div = 10;
for (let i=0; i<precision; i++) {
div *= 10;
const precision = this.symbol.precision();
let rawAmount = this.amount.toString().padStart(precision + 1, '0')
if (precision > 0) {
rawAmount = rawAmount.slice(0, rawAmount.length - precision) + "." + rawAmount.slice(rawAmount.length - precision, rawAmount.length)
}
return (this.amount/div).toString() + '.' + (this.amount%div).toString().padStart(precision, '0') + " " + this.symbol.getSymbolString();
return rawAmount + " " + this.symbol.getSymbolString()
}

@@ -212,0 +228,0 @@

5

assembly/helpers.ts

@@ -54,3 +54,3 @@ import { PermissionLevel, Action } from "./action"

export class Table implements MultiIndexValue {
export class MockPacker implements MultiIndexValue {
pack(): u8[] {

@@ -91,1 +91,4 @@ check(false, "not implemented");

}
export class Table extends MockPacker {}
export class InlineAction extends Table {}

@@ -16,4 +16,2 @@ import {IDXDB, SecondaryValue, SecondaryType, SecondaryIterator, SecondaryReturnValue} from "./idxdb";

store(id: u64, value: Float128, payer: u64): SecondaryIterator {
check(value.type == SecondaryType.F128, "idx_long_double: bad type");
check(value.value.length == 2, "idx_long_double: bad value");
let secondary_ptr = value.data.dataStart;

@@ -33,6 +31,4 @@ let it = env.db_idx_long_double_store(this.scope, this.table, payer, id, secondary_ptr);

update(iterator: SecondaryIterator, secondary: Float128, payer: u64): void {
check(secondary.type == SecondaryType.F128, "idx_long_double: bad value");
check(secondary.data.length == 2, "idx_long_double: bad value");
let secondary_ptr = secondary.value.dataStart;
env.db_idx_long_double_update(iterator, payer, secondary_ptr);
let secondary_ptr = secondary.data.dataStart;
env.db_idx_long_double_update(iterator.i, payer, secondary_ptr);
}

@@ -39,0 +35,0 @@

@@ -12,2 +12,3 @@ export { U128, U256 } from "./bignum";

export { IDX256 } from "./idx256";
export { VariantValue } from "./variant";

@@ -62,3 +63,3 @@ export {

export {Contract, ActionWrapper, Table} from "./helpers"
export {Contract, ActionWrapper, Table, InlineAction} from "./helpers"

@@ -117,3 +118,2 @@ export {

export * from "./serializer";
export { Utils } from "./utils";
export * from "./decorator";
export { Utils } from "./utils";

@@ -348,4 +348,3 @@ import { check } from "./system";

setTimePoint(t: TimePoint): void {
const microSinceEpoch = t.timeSinceEpoch().count();
const msecSinceEpoch = microSinceEpoch / 1000;
const msecSinceEpoch = t.msSinceEpoch();
this.slot = <u32>((msecSinceEpoch - BlockTimestamp.blockTimestampEpoch) / BlockTimestamp.blockIntervalMs)

@@ -352,0 +351,0 @@ }

{
"name": "as-chain",
"version": "0.0.17",
"version": "0.0.19",
"description": "chain module for assemblyscript",
"main": "js/index.js",
"types": "assembly/index.ts",
"types": "./types.d.ts",
"author": "learnforpractice <learnforpractice@gmail.com>",

@@ -8,0 +8,0 @@ "license": "MIT",

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