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

primea-objects

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primea-objects - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

.nyc_output/057476a72158e305481006c9c3aeb833.json

51

index.js

@@ -50,2 +50,11 @@ const crypto = require('crypto')

toJSON () {
return `0x${this.toString()}`
}
static fromJSON (arg) {
const { fromHex } = require('./utils')
return new ID(fromHex(arg))
}
encodeCBOR (gen) {

@@ -82,2 +91,27 @@ return gen.write(new cbor.Tagged(TAGS.id, this.id))

toJSON (includeParams = true) {
const json = {
'@FunctionRef': {
actorID: this.actorID.toJSON(),
private: this.identifier[0],
name: this.identifier[1],
gas: this.gas
}
}
if (includeParams) {
json['@FunctionRef'].params = this.params
}
return json
}
static fromJSON (arg) {
const data = arg['@FunctionRef']
return new FunctionRef({
identifier: [data.private, data.name],
actorID: ID.fromJSON(data.actorID),
params: data.params,
gas: data.gas
})
}
/**

@@ -125,2 +159,19 @@ * Creates a copy of the funcRef

toJSON (includeExports = true) {
const json = {
'@ModuleRef': {
id: this.id.toJSON()
}
}
if (includeExports) {
json['@ModuleRef'].exports = this.exports
}
return json
}
static fromJSON (arg) {
const data = arg['@ModuleRef']
return new ModuleRef(data.exports, ID.fromJSON(data.id))
}
encodeCBOR (gen) {

@@ -127,0 +178,0 @@ return gen.write(new cbor.Tagged(TAGS.mod, [this.exports, this.id]))

2

package.json
{
"name": "primea-objects",
"version": "0.0.4",
"version": "0.0.5",
"description": "Object helper classes for Primea's system Objects",

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

@@ -5,2 +5,3 @@ const Buffer = require('safe-buffer').Buffer

const objects = require('../')
const utils = require('../utils')

@@ -68,1 +69,38 @@ tape('system objects', t => {

})
tape('utils', t => {
const id = new objects.ID(Buffer.from([0x1]))
const obj = [
new objects.ModuleRef({'name': ['i32']}, id),
new objects.FunctionRef({
identifier: [false, 'main'],
actorID: id,
params: ['i32'],
gas: 100
}),
Buffer.from([1, 2, 3, 4])
]
const jsonFull = utils.toJSON(obj)
t.deepEquals(JSON.stringify(jsonFull), '[{"@ModuleRef":{"id":"0x01","exports":{"name":["i32"]}}},{"@FunctionRef":{"actorID":"0x01","private":false,"name":"main","gas":100,"params":["i32"]}},"0x01020304"]')
const json = utils.toJSON(obj, false)
t.deepEquals(JSON.stringify(json), '[{"@ModuleRef":{"id":"0x01"}},{"@FunctionRef":{"actorID":"0x01","private":false,"name":"main","gas":100}},"0x01020304"]')
const newObj = [
new objects.ModuleRef(undefined, id),
new objects.FunctionRef({
identifier: [false, 'main'],
actorID: id,
gas: 100
}),
Buffer.from([1, 2, 3, 4])
]
t.deepEquals(utils.fromJSON(json), newObj)
t.deepEquals(utils.fromJSON(jsonFull), obj)
const hashedId01 = utils.actorRefToId([0, 1])
t.deepEquals(hashedId01.id, Buffer.from('0ca311b75efd27e7daf6eec8b51b5c1fe33ff233', 'hex'))
t.end()
})

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

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