New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aldea/core

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aldea/core - npm Package Compare versions

Comparing version 0.7.0 to 0.7.2

6

CHANGELOG.md
# @aldea/core
## 0.7.2
### Patch Changes
- 50b769f: Added support for native aldea BigInt
## 0.7.0

@@ -4,0 +10,0 @@

2

dist/abi/query.js

@@ -29,3 +29,3 @@ import { CodeKind, MethodKind, } from "./types.js";

const methods = parents.flatMap(p => p.methods).concat(node.methods);
return { ...node, fields, methods };
return { ...node, extends: 'Jig', fields, methods };
}

@@ -32,0 +32,0 @@ getFunction() {

@@ -5,3 +5,3 @@ import { CodeKind, } from './abi/types.js';

import { BufReader, BufWriter, Pointer, ref, } from './internal.js';
import { strToBytes, bytesToStr } from './support/util.js';
import { strToBytes, bytesToStr, bytesToBn, bnToShortestBytes } from './support/util.js';
/**

@@ -318,2 +318,17 @@ * BCS implementation for Aldea builtins and types as defined in an ABI.

});
this.registerType('BigInt', {
assert: (val) => assert(typeof val === 'bigint', `bigint expected. recieved: ${val}`),
decode: (reader) => {
const isNeg = reader.readBool();
const bytes = reader.readBytes();
const bigInt = bytesToBn(bytes);
return isNeg ? bigInt * -1n : bigInt;
},
encode: (writer, val) => {
const isNeg = val < 0n;
const buf = bnToShortestBytes(val);
writer.writeBool(isNeg);
writer.writeBytes(buf);
},
});
this.registerType('string', {

@@ -320,0 +335,0 @@ assert: (val) => assert(typeof val === 'string', `string expected. recieved: ${val}`),

@@ -11,2 +11,3 @@ import { randomBytes } from '@noble/hashes/utils';

export declare function bnToBytes(num: bigint, len?: number): Uint8Array;
export declare function bnToShortestBytes(num: bigint): Uint8Array;
/**

@@ -13,0 +14,0 @@ * Decodes the given Uint8Array as a little-endian bigint.

@@ -22,2 +22,11 @@ import { etc } from '@noble/ed25519';

}
export function bnToShortestBytes(num) {
const nums = [];
let next = num > 0n ? num : -num;
while (next > 0) {
nums.push(Number(next % 256n));
next = next >> 8n;
}
return new Uint8Array(nums);
}
/**

@@ -24,0 +33,0 @@ * Decodes the given Uint8Array as a little-endian bigint.

{
"name": "@aldea/core",
"description": "Core Aldea data structures and cryptographic functions.",
"version": "0.7.0",
"version": "0.7.2",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "type": "module",

@@ -49,3 +49,3 @@ import {

const methods = parents.flatMap(p => p.methods).concat(node.methods)
return { ...node, fields, methods }
return { ...node, extends: 'Jig', fields, methods }
}

@@ -52,0 +52,0 @@

import {
Abi,
ClassNode,
CodeDef,
CodeKind,
FieldNode,
FunctionNode, InterfaceNode,
FunctionNode,
MethodNode,

@@ -12,3 +11,3 @@ TypeNode,

import { AbiQuery, isClass, isClassLike, isFunctionLike, isInterface } from './abi/query.js'
import { AbiQuery, isClassLike, isFunctionLike } from './abi/query.js'
import { AbiSchema, PkgSchema } from './bcs/schemas.js'

@@ -24,3 +23,3 @@

import { strToBytes, bytesToStr } from './support/util.js'
import {strToBytes, bytesToStr, bytesToBn, bnToShortestBytes} from './support/util.js'

@@ -389,2 +388,18 @@ /**

this.registerType<bigint>('BigInt', {
assert: (val) => assert(typeof val === 'bigint', `bigint expected. recieved: ${val}`),
decode: (reader) => {
const isNeg = reader.readBool()
const bytes = reader.readBytes()
const bigInt = bytesToBn(bytes)
return isNeg ? bigInt * -1n : bigInt
},
encode: (writer, val) => {
const isNeg = val < 0n;
const buf = bnToShortestBytes(val)
writer.writeBool(isNeg)
writer.writeBytes(buf)
},
})
this.registerType<string>('string', {

@@ -391,0 +406,0 @@ assert: (val) => assert(typeof val === 'string', `string expected. recieved: ${val}`),

@@ -24,2 +24,12 @@ import { etc } from '@noble/ed25519'

export function bnToShortestBytes(num: bigint): Uint8Array {
const nums: number[] = []
let next = num > 0n ? num : -num
while (next > 0) {
nums.push(Number(next % 256n))
next = next >> 8n
}
return new Uint8Array(nums)
}
/**

@@ -26,0 +36,0 @@ * Decodes the given Uint8Array as a little-endian bigint.

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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