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

@0xcert/scaffold

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xcert/scaffold - npm Package Compare versions

Comparing version 1.0.0-rc1 to 1.0.0-rc10

.nyc_output/30473ca0-d344-4013-ac66-f824d04c25c5.json

4

CHANGELOG.json

@@ -5,4 +5,4 @@ {

{
"version": "1.0.0-rc1",
"tag": "@0xcert/scaffold_v1.0.0-rc1",
"version": "1.0.0-rc10",
"tag": "@0xcert/scaffold_v1.0.0-rc10",
"date": "Thu, 22 Nov 2018 00:51:03 GMT",

@@ -9,0 +9,0 @@ "comments": {}

@@ -5,3 +5,3 @@ # Change Log - @0xcert/scaffold

## 1.0.0-rc1
## 1.0.0-rc2
Thu, 22 Nov 2018 00:51:03 GMT

@@ -8,0 +8,0 @@

export interface AssetMetadata {
description: string;
image: string;
name: string;
description?: string;
image?: string;
name?: string;
}
export interface ProviderBase {
accountId: string;
}
export declare enum ProviderEvent {
ACCOUNT_CHANGE = "accountChanged",
NETWORK_CHANGE = "networkChanged"
}
export declare enum ProviderIssue {

@@ -5,0 +9,0 @@ GENERAL = 0

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ProviderEvent;
(function (ProviderEvent) {
ProviderEvent["ACCOUNT_CHANGE"] = "accountChanged";
ProviderEvent["NETWORK_CHANGE"] = "networkChanged";
})(ProviderEvent = exports.ProviderEvent || (exports.ProviderEvent = {}));
var ProviderIssue;

@@ -4,0 +9,0 @@ (function (ProviderIssue) {

{
"files": {},
"arguments": "npx nyc npx hayspec test "
"files": {
"packages/0xcert-scaffold/CHANGELOG.json": "ed4edf83e61e2d1360cf51843bcd8f1522a804f6",
"packages/0xcert-scaffold/CHANGELOG.md": "04bf5ffb9485065037fda3292ddef5110d558fe2",
"packages/0xcert-scaffold/README.md": "7bfbd2643bbb937d12c739e2a406f80a4a2651b6",
"packages/0xcert-scaffold/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de",
"packages/0xcert-scaffold/package.json": "1562b1c37da5e3739ad5a43e37dea77947b39d8f",
"packages/0xcert-scaffold/src/assets/metadata.ts": "f42e8c108ed586ffc13f1f0a6f3170e86fb69977",
"packages/0xcert-scaffold/src/core/asset-ledger.ts": "0490d9a5a12d1e0b3284435ae0e9ef40f92c2f51",
"packages/0xcert-scaffold/src/core/mutation.ts": "70cf6a4339e2e99da28fb7d2ab3dcfb88cbcb59c",
"packages/0xcert-scaffold/src/core/order-gateway.ts": "cd23e3d56c268718e07170880c239e98ef7237f7",
"packages/0xcert-scaffold/src/core/provider.ts": "5905b1808e4009b2cb2882fe7f21c5c7ea1e224f",
"packages/0xcert-scaffold/src/core/value-ledger.ts": "e24545dd4528da48859594e27c870d6ec74d219b",
"packages/0xcert-scaffold/src/index.ts": "c49becb92b845c5678dbb1aac124c4ad184e9b1d",
"packages/0xcert-scaffold/src/tests/index.test.ts": "704984a6d673fabaf81d796043ee1eed922a2bb0",
"packages/0xcert-scaffold/tsconfig.json": "99f0fa2e7cf44aa40828236230bc6f15d8648bc6",
"packages/0xcert-scaffold/tslint.json": "c57b3f0cdb7aa74ab2ab02888380f613589cbe66",
"common/config/rush/npm-shrinkwrap.json": "b56bf5d9342bdd909289a88c77e60988dcde36a8"
},
"arguments": "npm run lint && npx nyc npx hayspec test "
}
{
"name": "@0xcert/scaffold",
"version": "1.0.0-rc1",
"version": "1.0.0-rc10",
"description": "Overarching module with types, enums, and interfaces for easier development of interoperable modules.",

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

"lint": "npx tslint 'src/**/*.ts?(x)'",
"test": "npx nyc npx hayspec test"
"test": "npm run lint && npx nyc npx hayspec test"
},

@@ -70,3 +70,3 @@ "hayspec": {

"@hayspec/spec": "^0.8.3",
"@types/node": "^10.12.10",
"@types/node": "^10.12.24",
"nyc": "^13.1.0",

@@ -73,0 +73,0 @@ "ts-node": "^7.0.1",

@@ -8,1 +8,7 @@ <img src="https://github.com/0xcert/framework/raw/master/assets/cover-sub.png" />

This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
# Scaffold Interfaces
These TypeScript interfaces are platform-agnostic base types which are implemented separately in for each provider.
Or in plain English, these are the base data structures in the 0xcert protocol regardless of whether you are using it on a blockchain or MongoDB.

@@ -5,5 +5,17 @@ /**

export interface AssetMetadata {
description: string;
image: string;
name: string;
/**
* A detailed description of an asset.
*/
description?: string;
/**
* A valid URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive.
*/
image?: string;
/**
* A name of an asset.
*/
name?: string;
}

@@ -31,27 +31,153 @@ import { MutationBase } from './mutation';

export interface AssetLedgerBase {
/**
* AssetLedger Id. Address pointing at the smartcontract.
*/
readonly id: string;
/**
* Approves another account so it can transfer the specific asset.
* @param assetId Id of the asset.
* @param accountId Id of the account.
*/
approveAccount(assetId: string, accountId: string | OrderGatewayBase): Promise<MutationBase>;
/**
* Approves an account as an operator (meaning he has full controll of all of your assets).
* @param accountId Account id.
*/
approveOperator(accountId: string | OrderGatewayBase): Promise<MutationBase>;
/**
* Grants abilities of an account.
* @param accountId Id of the account.
* @param abilities List of the abilities.
*/
grantAbilities(accountId: string, abilities: AssetLedgerAbility[]): Promise<MutationBase>;
/**
* Creates a new asset.
* @param recipe Data from which the new asset is created.
*/
createAsset(recipe: AssetLedgerItemRecipe): Promise<MutationBase>;
/**
* Destoys an existing asset (only asset owner can do this).
* @param assetId Id of the asset.
*/
destroyAsset(assetId: string): Promise<MutationBase>;
/**
* Disapproves approved account for a specific asset.
* @param assetId Asset id.
*/
disapproveAccount(assetId: string): Promise<MutationBase>;
/**
* Disapproves an account as an operator.
* @param accountId Account id.
*/
disapproveOperator(accountId: string | OrderGatewayBase): Promise<MutationBase>;
/**
* Disables transfers of asset on the asset ledger.
*/
disableTransfers(): Promise<MutationBase>;
/**
* Enables transfers of asset on the asset ledger.
*/
enableTransfers(): Promise<MutationBase>;
/**
* Gets a list of abilities an account has for this asset ledger.
* @param accountId Account address for wich we want to get abilities.
*/
getAbilities(accountId: string): Promise<AssetLedgerAbility[]>;
/**
* Gets accountId if anyone is approved for this asset.
* @param assetId Id of the asset.
*/
getApprovedAccount(assetId: string): Promise<string>;
/**
* Gets information about the asset(id, uri, imprint).
* @param assetId Id of the asset.
*/
getAsset(assetId: string): Promise<AssetLedgerItem>;
/**
* Gets the asset owner account ID.
* @param assetId Id of the asset.
*/
getAssetAccount(assetId: string): Promise<string>;
/**
* Gets the count of assets an account owns.
* @param accountId Address for which we want asset count.
*/
getBalance(accountId: string): Promise<string>;
/**
* Gets a list of all asset ledger capabilities(options).
*/
getCapabilities(): Promise<AssetLedgerCapability[]>;
/**
* Gets information about the asset ledger (name, symbol, uriBase, schemaId, supply).
*/
getInfo(): Promise<AssetLedgerInfo>;
/**
* Checks if a specific account is approved for a specific asset.
* @param assetId Id of the asset.
* @param accountId Id of the account.
*/
isApprovedAccount(assetId: string, accountId: string | OrderGatewayBase): Promise<boolean>;
/**
* Checks if specific account is the operator for specific account.
* @param accountId Account id.
* @param operatorId Operator account id.
*/
isApprovedOperator(accountId: string, operatorId: string | OrderGatewayBase): Promise<boolean>;
/**
* Checks if transfers on the asset ledger are enabled.
*/
isTransferable(): Promise<boolean>;
/**
* Removes abilities from account.
* @param accountId Id of the account.
* @param abilities List of the abilities.
*/
revokeAbilities(accountId: string, abilities: AssetLedgerAbility[]): Promise<MutationBase>;
/**
* Destroys an existing asset (only someone with asset ledger revoke ability can do this).
* @param assetId If of the asset.
*/
revokeAsset(assetId: string): Promise<MutationBase>;
/**
* Updates asset ledger data.
* @param recipe Data to update asset ledger with.
*/
update(recipe: AssetLedgerUpdateRecipe): Promise<MutationBase>;
/**
* Updates data on an existing asset.
* @param assetId Id of the asset.
* @param recipe Data to update asset with.
*/
updateAsset(assetId: string, recipe: AssetLedgerObjectUpdateRecipe): Promise<MutationBase>;
/**
* Transfers asset to another account.
* @param recipe Data needed for the transfer.
*/
transferAsset(recipe: AssetLedgerTransferRecipe): Promise<MutationBase>;
}

@@ -63,6 +189,28 @@

export interface AssetLedgerDeployRecipe {
/**
* Asset Ledger name.
*/
name: string;
/**
* Asset Ledger symbol/ticker.
*/
symbol: string;
/**
* Uri base for metadata URI-s. At the end of the base the assetId is automatically appended foo each asset.
* Example: https://example.com/id/
* Asset 1 URI will become: https://example.com/id/1
*/
uriBase: string;
/**
* Hashed representation of JSON schema defining this object.
*/
schemaId: string;
/**
* Array representing capabilities.
*/
capabilities?: AssetLedgerCapability[];

@@ -75,4 +223,16 @@ }

export interface AssetLedgerItem {
/**
* Unique asset Id.
*/
id: string;
/**
* Uri poiting to the asset metadata (is automatically generated based on baseUri).
*/
uri: string;
/**
* Merkle tree root of asset proof.
*/
imprint: string;

@@ -85,6 +245,28 @@ }

export interface AssetLedgerInfo {
/**
* Asset Ledger name.
*/
name: string;
/**
* Asset Ledger symbol/ticker.
*/
symbol: string;
/**
* Uri base for metadata URI-s. At the end of the base the assetId is automatically appended foo each asset.
* Example: https://example.com/id/
* Asset 1 URI will become: https://example.com/id/1
*/
uriBase: string;
/**
* Hashed representation of JSON schema defining this object.
*/
schemaId: string;
/**
* Total supply of all assets in this AssetLedger.
*/
supply: string;

@@ -97,4 +279,16 @@ }

export interface AssetLedgerItemRecipe {
/**
* Id(address) of the receiver.
*/
receiverId: string;
/**
* Unique asset Id.
*/
id: string;
/**
* Merkle tree root of asset proof.
*/
imprint: string;

@@ -107,5 +301,21 @@ }

export interface AssetLedgerTransferRecipe {
/**
* Id(address) of the sender.
*/
senderId?: string;
/**
* Id(address) of the receiver.
*/
receiverId: string;
/**
* Unique asset Id.
*/
id: string;
/**
* Additional data that will be sent with mutation to the receiver.
*/
data?: string;

@@ -118,2 +328,6 @@ }

export interface AssetLedgerObjectUpdateRecipe {
/**
* Merkle tree root of asset proof.
*/
imprint: string;

@@ -126,3 +340,9 @@ }

export interface AssetLedgerUpdateRecipe {
/**
* Uri base for metadata URI-s. At the end of the base the assetId is automatically appended foo each asset.
* Example: https://example.com/id/
* Asset 1 URI will become: https://example.com/id/1
*/
uriBase: string;
}

@@ -14,20 +14,68 @@ /**

export interface MutationBase {
/**
* Mutation Id (transaction hash).
*/
id: string;
/**
* Number of confirmations (blocks in blockchain after mutation is accepted) are necessary to mark a mutation complete.
*/
confirmations: number;
/**
* Id(address) of the sender.
*/
senderId: string;
/**
* Id(address) of the receiver.
*/
receiverId: string;
/**
* Checks if mutation in pending.
*/
isPending(): boolean;
/**
* Checks if mutation has reached the required number of confirmation.
*/
isCompleted(): boolean;
/**
* Event emmiter.
*/
emit(event: MutationEvent.CONFIRM, mutation: MutationBase): this;
emit(event: MutationEvent.COMPLETE, mutation: MutationBase): this;
emit(event: MutationEvent.ERROR, error: any): this;
/**
* Attaches on mutation events.
*/
on(event: MutationEvent.CONFIRM, handler: (m: MutationBase) => any): this;
on(event: MutationEvent.COMPLETE, handler: (m: MutationBase) => any): this;
on(event: MutationEvent.ERROR, handler: (e: any, m: MutationBase) => any): this;
/**
* Once handler.
*/
once(event: MutationEvent.CONFIRM, handler: (m: MutationBase) => any): this;
once(event: MutationEvent.COMPLETE, handler: (m: MutationBase) => any): this;
once(event: MutationEvent.ERROR, handler: (e: any, m: MutationBase) => any): this;
/**
* Dettaches from mutation events.
*/
off(event: MutationEvent, handler?: () => any): this;
/**
* Waits until mutation is resolved (mutation reaches the specified number of confirmations).
*/
complete(): Promise<this>;
/**
* Stops listening for confirmations.
*/
forget(): this;
}

@@ -16,5 +16,25 @@ import { MutationBase } from './mutation';

export interface OrderGatewayBase {
/**
* Address of the smart contract that represents this order gateway.
*/
readonly id: string;
/**
* Gets signed claim for an order.
* @param order Order data.
*/
claim(order: Order): Promise<string>;
/**
* Performs an order.
* @param order Order data.
* @param claim Claim data.
*/
perform(order: Order, claim: string): Promise<MutationBase>;
/**
* Cancels an order.
* @param order Order data.
*/
cancel(order: Order): Promise<MutationBase>;

@@ -24,3 +44,3 @@ }

/**
*
* Different order actions.
*/

@@ -34,7 +54,31 @@ export type OrderAction = OrderActionCreateAsset | OrderActionTransferAsset

export interface OrderActionCreateAsset {
/**
* Type od order action.
*/
kind: OrderActionKind.CREATE_ASSET;
/**
* Id (address) of the smart contract that represents the assetLedger.
*/
ledgerId: string;
/**
* Id (address) of the sender.
*/
senderId: string;
/**
* Id (address) of the receiver.
*/
receiverId: string;
/**
* Unique asset Id.
*/
assetId: string;
/**
* Merkle tree root of asset proof.
*/
assetImprint: string;

@@ -47,6 +91,26 @@ }

export interface OrderActionTransferAsset {
/**
* Type od order action.
*/
kind: OrderActionKind.TRANSFER_ASSET;
/**
* Id (address) of the smart contract that represents the assetLedger.
*/
ledgerId: string;
/**
* Id (address) of the sender.
*/
senderId: string;
/**
* Id (address) of the receiver.
*/
receiverId: string;
/**
* Unique asset Id.
*/
assetId: string;

@@ -59,6 +123,26 @@ }

export interface OrderActionTransferValue {
/**
* Type od order action.
*/
kind: OrderActionKind.TRANSFER_VALUE;
/**
* Id (address) of the smart contract that represents the assetLedger.
*/
ledgerId: string;
/**
* Id (address) of the sender.
*/
senderId: string;
/**
* Id (address) of the receiver.
*/
receiverId: string;
/**
* The amount of value(erc20 tokens).
*/
value: string; // TODO BN.js

@@ -71,7 +155,27 @@ }

export class Order {
/**
* Address of the order maker.
*/
public makerId: string;
/**
* Address of the order taker.
*/
public takerId: string;
/**
* Array of actions that will execute in this order.
*/
public actions: OrderAction[];
/**
* Nonce for hash generation - usually current timestamp.
*/
public seed: number;
/**
* Timestamp of order expiration.
*/
public expiration: number;
}
/**
*
* A provider is a connection to a blockchain or other database store.
*/

@@ -9,2 +9,10 @@ export interface ProviderBase {

/**
* Provider events.
*/
export enum ProviderEvent {
ACCOUNT_CHANGE = 'accountChanged',
NETWORK_CHANGE = 'networkChanged',
}
/**
* Error codes.

@@ -20,3 +28,11 @@ */

export class ProviderError extends Error {
/**
* Specific kind of error.
*/
public issue: ProviderIssue;
/**
* Original error report.
*/
public original: any;

@@ -23,0 +39,0 @@

@@ -8,9 +8,51 @@ import { MutationBase } from './mutation';

export interface ValueLedgerBase {
/**
* Value ledger Id. Address pointing at the smartcontract.
*/
readonly id: string;
/**
* Approves another account to operate with a specified amount of value.
* @param accountId Account id.
* @param value Value amount.
*/
approveValue(value: string, accountId: string | OrderGatewayBase): Promise<MutationBase>;
/**
* Disapproves account for operating with your value.
* @param accountId Account id.
*/
disapproveValue(accountId: string | OrderGatewayBase): Promise<MutationBase>;
/**
* Gets the amount of value that another account id approved for.
* @param accountId Account id.
* @param spenderId Account if of the spender.
*/
getApprovedValue(accountId: string, spenderId: string): Promise<String>;
/**
* Gets the amount of value a specific account owns.
* @param accountId Account id.
*/
getBalance(accountId: string): Promise<string>;
/**
* Gets information(name, symbol, total supply, decimals) about the value ledger.
*/
getInfo(): Promise<ValueLedgerInfo>;
/**
* Checks if spender is approved for the specific values.
* @param accountId Account id.
* @param spenderId Account id of spender.
* @param value Value amount we are checking against.
*/
isApprovedValue(value: string, accountId: string | OrderGatewayBase, spenderId: string): Promise<Boolean>;
/**
* Transfer value to another account.
* @param recipe Data needed for the transfer.
*/
transferValue(recipe: ValueLedgerTransferRecipe): Promise<MutationBase>;

@@ -23,5 +65,21 @@ }

export interface ValueLedgerDeployRecipe {
/**
* Value Ledger name.
*/
name: string;
/**
* Value Ledger symbol.
*/
symbol: string;
/**
* Number of decimals the token uses - e.g. 8, means to divide the token amount by 100000000 to get its user representation.
*/
decimals: string;
/**
* Number of total tokens.
*/
supply: string;

@@ -34,5 +92,21 @@ }

export interface ValueLedgerInfo {
/**
* Value Ledger name.
*/
name: string;
/**
* Value Ledger symbol.
*/
symbol: string;
/**
* Number of decimals the token uses - e.g. 8, means to divide the token amount by 100000000 to get its user representation.
*/
decimals: number;
/**
* Number of total tokens.
*/
supply: string;

@@ -45,5 +119,17 @@ }

export interface ValueLedgerTransferRecipe {
/**
* Id (address) of the sender.
*/
senderId?: string;
/**
* Id (address) of the receiver.
*/
receiverId: string;
/**
* The amount of value(erc20 tokens).
*/
value: string;
}

@@ -239,11 +239,2 @@ {

"ban-ts-ignore": true,
"no-console": [
true,
"log",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-debugger": true,

@@ -250,0 +241,0 @@ "no-eval": true,

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