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

@xyo-network/origin-chain

Package Overview
Dependencies
Maintainers
5
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xyo-network/origin-chain - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

3

dist/@types/index.d.ts
import { IXyoHash } from '@xyo-network/hashing';
import { IXyoSigner, IXyoPublicKey } from '@xyo-network/signing';
import { IXyoBoundWitness } from '@xyo-network/bound-witness';
/**

@@ -9,2 +10,4 @@ * Tracks the state of a particular `XyoNode` in the network. In particular,

export interface IXyoOriginChainRepository {
/** Will create a genesis block if one does not yet exist */
createGenesisBlock(): Promise<IXyoBoundWitness>;
/** Returns the index value that will go into the next block */

@@ -11,0 +14,0 @@ getIndex(): Promise<number>;

2

dist/@types/index.js

@@ -8,3 +8,3 @@ "use strict";

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 21st November 2018 1:37:24 pm
* @Last modified time: Wednesday, 16th January 2019 5:08:32 pm
* @License: All Rights Reserved

@@ -11,0 +11,0 @@ * @Copyright: Copyright XY | The Findables Company

@@ -5,2 +5,3 @@ import { IXyoHash } from '@xyo-network/hashing';

import { XyoBase } from '@xyo-network/base';
import { IXyoBoundWitness } from '@xyo-network/bound-witness';
/**

@@ -27,2 +28,3 @@ * Encapsulates the values that go into an origin-chain managements

getIndex(): Promise<number>;
createGenesisBlock(): Promise<IXyoBoundWitness>;
getPreviousHash(): Promise<IXyoHash | undefined>;

@@ -29,0 +31,0 @@ getNextPublicKey(): Promise<IXyoPublicKey | undefined>;

@@ -8,3 +8,3 @@ "use strict";

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 12th December 2018 10:03:55 am
* @Last modified time: Wednesday, 16th January 2019 5:05:09 pm
* @License: All Rights Reserved

@@ -23,2 +23,5 @@ * @Copyright: Copyright XY | The Findables Company

const base_1 = require("@xyo-network/base");
const bound_witness_1 = require("@xyo-network/bound-witness");
const errors_1 = require("@xyo-network/errors");
const xyo_index_1 = require("./xyo-index");
/**

@@ -54,2 +57,20 @@ * Encapsulates the values that go into an origin-chain managements

}
createGenesisBlock() {
return __awaiter(this, void 0, void 0, function* () {
const currentIndex = yield this.getIndex();
if (currentIndex !== 0) {
throw new errors_1.XyoError(`Could not create Genesis block as one already exists`, errors_1.XyoErrors.CRITICAL);
}
this.logInfo(`Creating genesis block`);
const signers = yield this.getSigners();
const fetter = new bound_witness_1.XyoFetter(new bound_witness_1.XyoKeySet(signers.map(signer => signer.publicKey)), [new xyo_index_1.XyoIndex(0)]);
const signingData = fetter.serialize();
const signatures = yield Promise.all(signers.map(signer => signer.signData(signingData)));
const genesisBlock = new bound_witness_1.XyoBoundWitness([
fetter,
new bound_witness_1.XyoWitness(new bound_witness_1.XyoSignatureSet(signatures), [])
]);
return genesisBlock;
});
}
getPreviousHash() {

@@ -56,0 +77,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -6,3 +6,5 @@ import { IXyoOriginChainRepository } from './@types';

import { IXyoSerializationService } from '@xyo-network/serialization';
export declare class XyoOriginChainLocalStorageRepository implements IXyoOriginChainRepository {
import { XyoBase } from '@xyo-network/base';
import { IXyoBoundWitness } from '@xyo-network/bound-witness';
export declare class XyoOriginChainLocalStorageRepository extends XyoBase implements IXyoOriginChainRepository {
private readonly storageProvider;

@@ -12,2 +14,3 @@ private readonly serializationService;

constructor(storageProvider: IXyoStorageProvider, serializationService: IXyoSerializationService);
createGenesisBlock(): Promise<IXyoBoundWitness>;
getIndex(): Promise<number>;

@@ -14,0 +17,0 @@ getPreviousHash(): Promise<IXyoHash | undefined>;

@@ -8,3 +8,3 @@ "use strict";

* @Last modified by: ryanxyo
* @Last modified time: Monday, 17th December 2018 3:10:41 pm
* @Last modified time: Wednesday, 16th January 2019 5:04:00 pm
* @License: All Rights Reserved

@@ -23,7 +23,14 @@ * @Copyright: Copyright XY | The Findables Company

const xyo_origin_chain_in_memory_repository_1 = require("./xyo-origin-chain-in-memory-repository");
class XyoOriginChainLocalStorageRepository {
const base_1 = require("@xyo-network/base");
class XyoOriginChainLocalStorageRepository extends base_1.XyoBase {
constructor(storageProvider, serializationService) {
super();
this.storageProvider = storageProvider;
this.serializationService = serializationService;
}
createGenesisBlock() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.getOrCreateInMemoryDelegate()).createGenesisBlock();
});
}
getIndex() {

@@ -30,0 +37,0 @@ return __awaiter(this, void 0, void 0, function* () {

{
"name": "@xyo-network/origin-chain",
"version": "0.14.0",
"version": "0.15.0",
"description": "Utilities for managing an origin chain in the xyo network",

@@ -10,10 +10,11 @@ "main": "dist/index.js",

"dependencies": {
"@xyo-network/base": "^0.14.0",
"@xyo-network/bound-witness": "^0.14.0",
"@xyo-network/buffer-utils": "^0.14.0",
"@xyo-network/hashing": "^0.14.0",
"@xyo-network/serialization": "^0.14.0",
"@xyo-network/serialization-schema": "^0.14.0",
"@xyo-network/signing": "^0.14.0",
"@xyo-network/storage": "^0.14.0"
"@xyo-network/base": "^0.15.0",
"@xyo-network/bound-witness": "^0.15.0",
"@xyo-network/buffer-utils": "^0.15.0",
"@xyo-network/errors": "^0.15.0",
"@xyo-network/hashing": "^0.15.0",
"@xyo-network/serialization": "^0.15.0",
"@xyo-network/serialization-schema": "^0.15.0",
"@xyo-network/signing": "^0.15.0",
"@xyo-network/storage": "^0.15.0"
},

@@ -29,3 +30,3 @@ "devDependencies": {

},
"gitHead": "200a705d4116aaaeb6418f174733a4365c97fe2e"
"gitHead": "ac6bdb71c92e79b6faf7dbb748f438c56ea2f3f4"
}

@@ -7,3 +7,3 @@ /*

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 21st November 2018 1:37:24 pm
* @Last modified time: Wednesday, 16th January 2019 5:08:32 pm
* @License: All Rights Reserved

@@ -15,2 +15,3 @@ * @Copyright: Copyright XY | The Findables Company

import { IXyoSigner, IXyoPublicKey } from '@xyo-network/signing'
import { IXyoBoundWitness } from '@xyo-network/bound-witness'

@@ -24,2 +25,6 @@ /**

export interface IXyoOriginChainRepository {
/** Will create a genesis block if one does not yet exist */
createGenesisBlock(): Promise<IXyoBoundWitness>
/** Returns the index value that will go into the next block */

@@ -26,0 +31,0 @@ getIndex(): Promise<number>

@@ -7,3 +7,3 @@ /*

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 12th December 2018 10:03:55 am
* @Last modified time: Wednesday, 16th January 2019 5:05:09 pm
* @License: All Rights Reserved

@@ -17,2 +17,5 @@ * @Copyright: Copyright XY | The Findables Company

import { XyoBase } from '@xyo-network/base'
import { IXyoBoundWitness, XyoKeySet, XyoFetter, XyoBoundWitness, XyoWitness, XyoSignatureSet } from '@xyo-network/bound-witness'
import { XyoError, XyoErrors } from '@xyo-network/errors'
import { XyoIndex } from './xyo-index'

@@ -59,2 +62,27 @@ /**

public async createGenesisBlock(): Promise<IXyoBoundWitness> {
const currentIndex = await this.getIndex()
if (currentIndex !== 0) {
throw new XyoError(`Could not create Genesis block as one already exists`, XyoErrors.CRITICAL)
}
this.logInfo(`Creating genesis block`)
const signers = await this.getSigners()
const fetter = new XyoFetter(
new XyoKeySet(signers.map(signer => signer.publicKey)),
[new XyoIndex(0)]
)
const signingData = fetter.serialize()
const signatures = await Promise.all(signers.map(signer => signer.signData(signingData)))
const genesisBlock = new XyoBoundWitness([
fetter,
new XyoWitness(new XyoSignatureSet(signatures), [])
])
return genesisBlock
}
public async getPreviousHash(): Promise<IXyoHash | undefined> {

@@ -61,0 +89,0 @@ return this.previousHash

@@ -7,3 +7,3 @@ /*

* @Last modified by: ryanxyo
* @Last modified time: Monday, 17th December 2018 3:10:41 pm
* @Last modified time: Wednesday, 16th January 2019 5:04:00 pm
* @License: All Rights Reserved

@@ -19,6 +19,7 @@ * @Copyright: Copyright XY | The Findables Company

import { IXyoSerializationService } from '@xyo-network/serialization'
import { XyoPreviousHash } from './xyo-previous-hash'
import { XyoNextPublicKey } from './xyo-next-public-key'
import { XyoBase } from '@xyo-network/base'
import { IXyoBoundWitness } from '@xyo-network/bound-witness'
export class XyoOriginChainLocalStorageRepository implements IXyoOriginChainRepository {
export class XyoOriginChainLocalStorageRepository extends XyoBase implements IXyoOriginChainRepository {

@@ -30,4 +31,10 @@ private inMemoryDelegate: XyoOriginChainStateInMemoryRepository | undefined

private readonly serializationService: IXyoSerializationService
) {}
) {
super()
}
public async createGenesisBlock(): Promise<IXyoBoundWitness> {
return (await this.getOrCreateInMemoryDelegate()).createGenesisBlock()
}
public async getIndex() {

@@ -34,0 +41,0 @@ return (await this.getOrCreateInMemoryDelegate()).getIndex()

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