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.31 to 0.0.32

55

assembly/dbi64.ts
import * as env from "./env";
import {printString} from "./debug";
import {Packer} from "./serializer";
import { printString } from "./debug";
import { Packer } from "./serializer";
import { check } from "./system";

@@ -13,9 +14,7 @@ export function say_hello(): void {

export const UNKNOWN_PRIMARY_KEY: u64 = 0xffffffffffffffff
export class PrimaryIterator<T extends PrimaryValue> {
db: DBI64<T>;
i: i32;
validPrimary: bool
_value: T | null;
_primary: u64;

@@ -25,34 +24,29 @@ constructor(

i: i32,
_primary: u64,
primary: u64,
validPrimary: bool
) {
this.db = db;
this.i = i;
this._value = null;
this._primary = _primary;
this._primary = primary;
this.validPrimary = validPrimary
}
get primary(): u64 {
if (!this.isOk()) {
return 0;
}
check(this.isOk(), "get primary: invalid iterator")
if (this._primary != UNKNOWN_PRIMARY_KEY) {
if (this.validPrimary) {
return this._primary;
}
let value = this.value;
let value = this.getValue();
this._primary = value!.getPrimaryValue();
this.validPrimary = true;
return this._primary;
}
get value(): T | null {
if (this._value) {
return this._value;
}
getValue(): T | null {
if (!this.isOk()) {
return null;
}
this._value = this.db.getEx(this.i)
return this._value;
return this.db.getEx(this.i)
}

@@ -80,3 +74,3 @@

let i = env.db_store_i64(this.scope, this.table, payer, id, data_ptr, data.length );
return new PrimaryIterator<T>(this, i, id);
return new PrimaryIterator<T>(this, i, id, true);
}

@@ -98,3 +92,6 @@

get(iterator: PrimaryIterator<T>): T | null {
return iterator.value;
if (!iterator.isOk()) {
return null;
}
return this.getEx(iterator.i);
}

@@ -119,3 +116,3 @@

let itNext = env.db_next_i64(iterator.i, primary_ptr);
return new PrimaryIterator(this, itNext, load<u64>(primary_ptr));
return new PrimaryIterator(this, itNext, load<u64>(primary_ptr), true);
}

@@ -127,3 +124,3 @@

let itNext = env.db_previous_i64(iterator.i, primary_ptr);
return new PrimaryIterator(this, itNext, load<u64>(primary_ptr));
return new PrimaryIterator(this, itNext, load<u64>(primary_ptr), true);
}

@@ -135,5 +132,5 @@

if (i >= 0) {
return new PrimaryIterator(this, i, id);
return new PrimaryIterator(this, i, id, true);
}
return new PrimaryIterator(this, i, id);
return new PrimaryIterator(this, i, 0, false);
}

@@ -144,3 +141,3 @@

let i = env.db_lowerbound_i64(this.code, this.scope, this.table, id);
return new PrimaryIterator(this, i, UNKNOWN_PRIMARY_KEY);
return new PrimaryIterator(this, i, 0, false);
}

@@ -151,3 +148,3 @@

let i = env.db_upperbound_i64(this.code, this.scope, this.table, id);
return new PrimaryIterator(this, i, UNKNOWN_PRIMARY_KEY);
return new PrimaryIterator(this, i, 0, false);
}

@@ -158,5 +155,5 @@

let i = env.db_end_i64(this.code, this.scope, this.table);
return new PrimaryIterator(this, i, UNKNOWN_PRIMARY_KEY);
return new PrimaryIterator(this, i, 0, false);
}
}

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

export { DBI64, PrimaryIterator, UNKNOWN_PRIMARY_KEY } from "./dbi64";
export { DBI64, PrimaryIterator } from "./dbi64";
export { IDX64 } from "./idx64";

@@ -9,0 +9,0 @@ export { IDXF64 } from "./idxf64";

import { IDXDB, SecondaryValue, SecondaryIterator } from "./idxdb";
import { DBI64, PrimaryIterator, PrimaryValue, UNKNOWN_PRIMARY_KEY } from "./dbi64";
import { DBI64, PrimaryIterator, PrimaryValue } from "./dbi64";
import { Name } from "./name";

@@ -54,7 +54,2 @@ import { check } from "./system";

check(primary == it.primary, "primary key can't be changed during update!");
//update value in iterator
if (changetype<usize>(it.value) != changetype<usize>(value)) {
it.value!.unpack(value.pack());
}
this.db.update(it, payer.N, value);

@@ -61,0 +56,0 @@ for (let i=0; i<this.idxdbs.length; i++) {

@@ -24,3 +24,3 @@ import { MultiIndex, MultiIndexValue } from "./mi";

if (it.isOk()) {
return it.value;
return it.getValue();
}

@@ -34,3 +34,3 @@ return null;

if (it.isOk()) {
return it.value!;
return it.getValue()!;
}

@@ -37,0 +37,0 @@ return instantiate<T>();

{
"name": "as-chain",
"version": "0.0.31",
"version": "0.0.32",
"description": "chain module for assemblyscript",

@@ -5,0 +5,0 @@ "main": "js/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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