Socket
Socket
Sign inDemoInstall

@neo-one/smart-contract

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neo-one/smart-contract - npm Package Compare versions

Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6

4

package.json
{
"name": "@neo-one/smart-contract",
"version": "1.0.0-alpha.5",
"version": "1.0.0-alpha.6",
"keywords": [

@@ -30,3 +30,3 @@ "neo",

"engines": {
"node": ">=8.9.0"
"node": ">=10.4.1"
},

@@ -33,0 +33,0 @@ "publishConfig": {

@@ -52,124 +52,36 @@ declare global {

function syscall(name: 'Neo.Runtime.CheckWitness', witness: Buffer): boolean;
function syscall(
name: 'Neo.Runtime.Notify',
...args: Array<Buffer | number | string | boolean>
): void;
function syscall(name: 'Neo.Runtime.Notify', ...args: Array<Buffer | number | string | boolean>): void;
function syscall(name: 'Neo.Runtime.Log', value: string): void;
function syscall(name: 'Neo.Runtime.GetTime'): number;
function syscall(
name: 'Neo.Runtime.Serialize',
value: SerializableValue,
): Buffer;
function syscall(
name: 'Neo.Runtime.Deserialize',
value: Buffer,
): SerializableValue;
function syscall(name: 'Neo.Runtime.Serialize', value: SerializableValue): Buffer;
function syscall(name: 'Neo.Runtime.Deserialize', value: Buffer): SerializableValue;
function syscall(name: 'Neo.Blockchain.GetHeight'): number;
function syscall(
name: 'Neo.Blockchain.GetHeader',
hashOrIndex: Buffer | number,
): HeaderBase;
function syscall(
name: 'Neo.Blockchain.GetBlock',
hashOrIndex: Buffer | number,
): BlockBase;
function syscall(
name: 'Neo.Blockchain.GetTransaction',
hash: Buffer,
): TransactionBase;
function syscall(
name: 'Neo.Blockchain.GetAccount',
hash: Buffer,
): AccountBase;
function syscall(name: 'Neo.Blockchain.GetHeader', hashOrIndex: Buffer | number): HeaderBase;
function syscall(name: 'Neo.Blockchain.GetBlock', hashOrIndex: Buffer | number): BlockBase;
function syscall(name: 'Neo.Blockchain.GetTransaction', hash: Buffer): TransactionBase;
function syscall(name: 'Neo.Blockchain.GetAccount', hash: Buffer): AccountBase;
function syscall(name: 'Neo.Blockchain.GetValidators'): Array<Buffer>;
function syscall(name: 'Neo.Blockchain.GetAsset', hash: Buffer): AssetBase;
function syscall(
name: 'Neo.Blockchain.GetContract',
hash: Buffer,
): ContractBase;
function syscall(
name: 'Neo.Header.GetHash',
blockOrHeader: BlockBase | HeaderBase,
): Buffer;
function syscall(
name: 'Neo.Header.GetVersion',
blockOrHeader: BlockBase | HeaderBase,
): number;
function syscall(
name: 'Neo.Header.GetPrevHash',
blockOrHeader: BlockBase | HeaderBase,
): Buffer;
function syscall(
name: 'Neo.Header.GetIndex',
blockOrHeader: BlockBase | HeaderBase,
): number;
function syscall(
name: 'Neo.Header.GetMerkleRoot',
blockOrHeader: BlockBase | HeaderBase,
): Buffer;
function syscall(
name: 'Neo.Header.GetTimestamp',
blockOrHeader: BlockBase | HeaderBase,
): number;
function syscall(
name: 'Neo.Header.GetConsensusData',
blockOrHeader: BlockBase | HeaderBase,
): number;
function syscall(
name: 'Neo.Header.GetNextConsensus',
blockOrHeader: BlockBase | HeaderBase,
): Buffer;
function syscall(
name: 'Neo.Block.GetTransactionCount',
block: BlockBase,
): number;
function syscall(
name: 'Neo.Block.GetTransactions',
block: BlockBase,
): Array<TransactionBase>;
function syscall(
name: 'Neo.Block.GetTransaction',
block: BlockBase,
index: number,
): TransactionBase;
function syscall(
name: 'Neo.Transaction.GetHash',
transaction: TransactionBase,
): Buffer;
function syscall(
name: 'Neo.Transaction.GetType',
transaction: TransactionBase,
): number;
function syscall(
name: 'Neo.Transaction.GetAttributes',
transaction: TransactionBase,
): Array<AttributeBase>;
function syscall(
name: 'Neo.Transaction.GetInputs',
transaction: TransactionBase,
): Array<InputBase>;
function syscall(
name: 'Neo.Transaction.GetOutputs',
transaction: TransactionBase,
): Array<OutputBase>;
function syscall(
name: 'Neo.Transaction.GetReferences',
transaction: TransactionBase,
): Array<OutputBase>;
function syscall(
name: 'Neo.Transaction.GetUnspentCoins',
transaction: TransactionBase,
): Array<OutputBase>;
function syscall(
name: 'Neo.InvocationTransaction.GetScript',
transaction: TransactionBase,
): Buffer;
function syscall(
name: 'Neo.Attribute.GetUsage',
attribute: AttributeBase,
): number;
function syscall(
name: 'Neo.Attribute.GetData',
attribute: AttributeBase,
): Buffer;
function syscall(name: 'Neo.Blockchain.GetContract', hash: Buffer): ContractBase;
function syscall(name: 'Neo.Header.GetHash', blockOrHeader: BlockBase | HeaderBase): Buffer;
function syscall(name: 'Neo.Header.GetVersion', blockOrHeader: BlockBase | HeaderBase): number;
function syscall(name: 'Neo.Header.GetPrevHash', blockOrHeader: BlockBase | HeaderBase): Buffer;
function syscall(name: 'Neo.Header.GetIndex', blockOrHeader: BlockBase | HeaderBase): number;
function syscall(name: 'Neo.Header.GetMerkleRoot', blockOrHeader: BlockBase | HeaderBase): Buffer;
function syscall(name: 'Neo.Header.GetTimestamp', blockOrHeader: BlockBase | HeaderBase): number;
function syscall(name: 'Neo.Header.GetConsensusData', blockOrHeader: BlockBase | HeaderBase): number;
function syscall(name: 'Neo.Header.GetNextConsensus', blockOrHeader: BlockBase | HeaderBase): Buffer;
function syscall(name: 'Neo.Block.GetTransactionCount', block: BlockBase): number;
function syscall(name: 'Neo.Block.GetTransactions', block: BlockBase): Array<TransactionBase>;
function syscall(name: 'Neo.Block.GetTransaction', block: BlockBase, index: number): TransactionBase;
function syscall(name: 'Neo.Transaction.GetHash', transaction: TransactionBase): Buffer;
function syscall(name: 'Neo.Transaction.GetType', transaction: TransactionBase): number;
function syscall(name: 'Neo.Transaction.GetAttributes', transaction: TransactionBase): Array<AttributeBase>;
function syscall(name: 'Neo.Transaction.GetInputs', transaction: TransactionBase): Array<InputBase>;
function syscall(name: 'Neo.Transaction.GetOutputs', transaction: TransactionBase): Array<OutputBase>;
function syscall(name: 'Neo.Transaction.GetReferences', transaction: TransactionBase): Array<OutputBase>;
function syscall(name: 'Neo.Transaction.GetUnspentCoins', transaction: TransactionBase): Array<OutputBase>;
function syscall(name: 'Neo.InvocationTransaction.GetScript', transaction: TransactionBase): Buffer;
function syscall(name: 'Neo.Attribute.GetUsage', attribute: AttributeBase): number;
function syscall(name: 'Neo.Attribute.GetData', attribute: AttributeBase): Buffer;
function syscall(name: 'Neo.Input.GetHash', input: InputBase): Buffer;

@@ -179,19 +91,6 @@ function syscall(name: 'Neo.Input.GetIndex', input: InputBase): number;

function syscall(name: 'Neo.Output.GetValue', output: OutputBase): number;
function syscall(
name: 'Neo.Output.GetScriptHash',
output: OutputBase,
): Buffer;
function syscall(
name: 'Neo.Account.GetScriptHash',
account: AccountBase,
): Buffer;
function syscall(
name: 'Neo.Account.GetVotes',
account: AccountBase,
): Array<Buffer>;
function syscall(
name: 'Neo.Account.GetBalance',
account: AccountBase,
assetHash: Buffer,
): number;
function syscall(name: 'Neo.Output.GetScriptHash', output: OutputBase): Buffer;
function syscall(name: 'Neo.Account.GetScriptHash', account: AccountBase): Buffer;
function syscall(name: 'Neo.Account.GetVotes', account: AccountBase): Array<Buffer>;
function syscall(name: 'Neo.Account.GetBalance', account: AccountBase, assetHash: Buffer): number;
function syscall(name: 'Neo.Asset.GetAssetId', asset: AssetBase): Buffer;

@@ -205,39 +104,12 @@ function syscall(name: 'Neo.Asset.GetAssetType', asset: AssetBase): number;

function syscall(name: 'Neo.Asset.GetIssuer', asset: AssetBase): Buffer;
function syscall(
name: 'Neo.Contract.GetScript',
contract: ContractBase,
): Buffer;
function syscall(name: 'Neo.Contract.GetScript', contract: ContractBase): Buffer;
function syscall(name: 'Neo.Storage.GetContext'): StorageContextBase;
function syscall(name: 'Neo.Storage.Get', context: StorageContextBase, key: Buffer | string): SerializableValue;
function syscall(name: 'Neo.Storage.Find', context: StorageContextBase, prefix: Buffer | string): StorageIteratorBase;
function syscall(name: 'Neo.Iterator.Next', iterator: StorageIteratorBase): boolean;
function syscall(name: 'Neo.Iterator.Key', iterator: StorageIteratorBase): Buffer | string;
function syscall(name: 'Neo.Iterator.Value', iterator: StorageIteratorBase): Buffer | number | string | boolean;
function syscall(name: 'Neo.Account.SetVotes', account: AccountBase, votes: Array<Buffer>): void;
function syscall(name: 'Neo.Validator.Register', publicKey: Buffer): ValidatorBase;
function syscall(
name: 'Neo.Storage.Get',
context: StorageContextBase,
key: Buffer | string,
): SerializableValue;
function syscall(
name: 'Neo.Storage.Find',
context: StorageContextBase,
prefix: Buffer | string,
): StorageIteratorBase;
function syscall(
name: 'Neo.Iterator.Next',
iterator: StorageIteratorBase,
): boolean;
function syscall(
name: 'Neo.Iterator.Key',
iterator: StorageIteratorBase,
): Buffer | string;
function syscall(
name: 'Neo.Iterator.Value',
iterator: StorageIteratorBase,
): Buffer | number | string | boolean;
function syscall(
name: 'Neo.Account.SetVotes',
account: AccountBase,
votes: Array<Buffer>,
): void;
function syscall(
name: 'Neo.Validator.Register',
publicKey: Buffer,
): ValidatorBase;
function syscall(
name: 'Neo.Asset.Create',

@@ -252,8 +124,4 @@ assetType: number,

): AssetBase;
function syscall(name: 'Neo.Asset.Renew', asset: AssetBase, years: number): number;
function syscall(
name: 'Neo.Asset.Renew',
asset: AssetBase,
years: number,
): number;
function syscall(
name: 'Neo.Contract.Create',

@@ -282,6 +150,3 @@ script: Buffer,

): ContractBase;
function syscall(
name: 'Neo.Contract.GetStorageContext',
contract: ContractBase,
): StorageContextBase;
function syscall(name: 'Neo.Contract.GetStorageContext', contract: ContractBase): StorageContextBase;
function syscall(name: 'Neo.Contract.Destroy'): void;

@@ -294,19 +159,8 @@ function syscall(

): void;
function syscall(
name: 'Neo.Storage.Delete',
context: StorageContextBase,
key: Buffer | string,
): void;
function syscall(
name: 'System.ExecutionEngine.GetScriptContainer',
): TransactionBase;
function syscall(
name: 'System.ExecutionEngine.GetExecutingScriptHash',
): Buffer;
function syscall(name: 'Neo.Storage.Delete', context: StorageContextBase, key: Buffer | string): void;
function syscall(name: 'System.ExecutionEngine.GetScriptContainer'): TransactionBase;
function syscall(name: 'System.ExecutionEngine.GetExecutingScriptHash'): Buffer;
function syscall(name: 'System.ExecutionEngine.GetCallingScriptHash'): Buffer;
function syscall(name: 'System.ExecutionEngine.GetEntryScriptHash'): Buffer;
function syscall(
name: 'Neo.Runtime.Return',
value: Buffer | number | string | boolean,
): void;
function syscall(name: 'Neo.Runtime.Return', value: Buffer | number | string | boolean): void;
function syscall(name: 'Neo.Runtime.GetArgument', idx: number): any;

@@ -313,0 +167,0 @@ }

@@ -0,1 +1,2 @@

// tslint:disable readonly-array no-object-mutation no-unused
export type Address = Buffer;

@@ -6,3 +7,3 @@ export type Hash256 = Buffer;

export interface FixedTag<T extends number> {
__decimals: T;
readonly __decimals: T;
}

@@ -14,3 +15,3 @@ export type Fixed<T extends number> = number | (number & FixedTag<T>);

export abstract class SmartContract {
constructor(public readonly owner: Address) {}
public constructor(public readonly owner: Address) {}

@@ -22,7 +23,4 @@ protected get address(): Address {

export class MapStorage<
K extends SerializableValue,
V extends SerializableValue
> {
constructor(private readonly prefix?: Buffer) {}
export class MapStorage<K extends SerializableValue, V extends SerializableValue> {
public constructor(private readonly prefix?: Buffer) {}

@@ -33,3 +31,3 @@ public get(keyIn: K): V | null {

syscall('Neo.Storage.GetContext'),
this.prefix == null
this.prefix === undefined
? syscall('Neo.Runtime.Serialize', keyIn)

@@ -44,3 +42,3 @@ : Buffer.concat([this.prefix, syscall('Neo.Runtime.Serialize', keyIn)]),

syscall('Neo.Storage.GetContext'),
this.prefix == null
this.prefix === undefined
? syscall('Neo.Runtime.Serialize', keyIn)

@@ -54,3 +52,3 @@ : Buffer.concat([this.prefix, syscall('Neo.Runtime.Serialize', keyIn)]),

export class SetStorage<K extends SerializableValue> {
constructor(private readonly prefix?: Buffer) {}
public constructor(private readonly prefix?: Buffer) {}

@@ -62,7 +60,5 @@ public has(keyIn: K): boolean {

syscall('Neo.Storage.GetContext'),
this.prefix == null
this.prefix === undefined
? syscall('Neo.Runtime.Serialize', keyIn)
: Buffer.concat(
[this.prefix, syscall('Neo.Runtime.Serialize', keyIn)],
),
: Buffer.concat([this.prefix, syscall('Neo.Runtime.Serialize', keyIn)]),
) === true

@@ -76,3 +72,3 @@ );

syscall('Neo.Storage.GetContext'),
this.prefix == null
this.prefix === undefined
? syscall('Neo.Runtime.Serialize', keyIn)

@@ -86,3 +82,3 @@ : Buffer.concat([this.prefix, syscall('Neo.Runtime.Serialize', keyIn)]),

export class Output {
constructor(private readonly output: OutputBase) {}
public constructor(private readonly output: OutputBase) {}

@@ -103,3 +99,3 @@ public get address(): Address {

export class Input {
constructor(private readonly input: InputBase) {}
public constructor(private readonly input: InputBase) {}

@@ -156,3 +152,3 @@ public get hash(): Hash256 {

export class Attribute {
constructor(private readonly attribute: AttributeBase) {}
public constructor(private readonly attribute: AttributeBase) {}

@@ -182,3 +178,3 @@ public get usage(): AttributeUsage {

constructor(transaction: TransactionBase) {
public constructor(transaction: TransactionBase) {
this.transaction = transaction;

@@ -192,36 +188,23 @@ }

public get type(): TransactionType {
return syscall(
'Neo.Transaction.GetType',
this.transaction,
) as TransactionType;
return syscall('Neo.Transaction.GetType', this.transaction) as TransactionType;
}
public get attributes(): Attribute[] {
return syscall('Neo.Transaction.GetAttributes', this.transaction).map(
(attribute) => new Attribute(attribute),
);
return syscall('Neo.Transaction.GetAttributes', this.transaction).map((attribute) => new Attribute(attribute));
}
public get outputs(): Output[] {
return syscall('Neo.Transaction.GetOutputs', this.transaction).map(
(output) => new Output(output),
);
return syscall('Neo.Transaction.GetOutputs', this.transaction).map((output) => new Output(output));
}
public get inputs(): Input[] {
return syscall('Neo.Transaction.GetInputs', this.transaction).map(
(input) => new Input(input),
);
return syscall('Neo.Transaction.GetInputs', this.transaction).map((input) => new Input(input));
}
public get references(): Output[] {
return syscall('Neo.Transaction.GetReferences', this.transaction).map(
(output) => new Output(output),
);
return syscall('Neo.Transaction.GetReferences', this.transaction).map((output) => new Output(output));
}
public get unspentOutputs(): Output[] {
return syscall('Neo.Transaction.GetUnspentCoins', this.transaction).map(
(output) => new Output(output),
);
return syscall('Neo.Transaction.GetUnspentCoins', this.transaction).map((output) => new Output(output));
}

@@ -235,3 +218,3 @@

export abstract class BaseBlock<T extends HeaderBase | BlockBase> {
constructor(protected readonly block: T) {}
public constructor(protected readonly block: T) {}

@@ -278,11 +261,7 @@ public get hash(): Hash256 {

public get transactions(): Transaction[] {
return syscall('Neo.Block.GetTransactions', this.block).map(
(transaction) => new Transaction(transaction),
);
return syscall('Neo.Block.GetTransactions', this.block).map((transaction) => new Transaction(transaction));
}
public getTransaction(index: Integer): Transaction {
return new Transaction(
syscall('Neo.Block.GetTransaction', this.block, index),
);
return new Transaction(syscall('Neo.Block.GetTransaction', this.block, index));
}

@@ -292,3 +271,3 @@ }

export class Account {
constructor(private readonly account: AccountBase) {}
public constructor(private readonly account: AccountBase) {}

@@ -323,3 +302,3 @@ public get hash(): Address {

export class Asset {
constructor(private readonly asset: AssetBase) {}
public constructor(private readonly asset: AssetBase) {}

@@ -360,3 +339,3 @@ public get hash(): Hash256 {

export class Contract extends Account {
constructor(private readonly contract: ContractBase, account: AccountBase) {
public constructor(private readonly contract: ContractBase, account: AccountBase) {
super(account);

@@ -413,20 +392,11 @@ }

export function getContract(address: Address): Contract {
return new Contract(
syscall('Neo.Blockchain.GetContract', address),
syscall('Neo.Blockchain.GetAccount', address),
);
return new Contract(syscall('Neo.Blockchain.GetContract', address), syscall('Neo.Blockchain.GetAccount', address));
}
export function verify(
target: any,
propertyKey: string,
descriptor: PropertyDescriptor,
): void {
// tslint:disable-next-line no-any
export function verify(target: any, propertyKey: string, descriptor: PropertyDescriptor): void {
throw new Error('This should be transpiled.');
}
export function constant(
target: any,
propertyKey: string,
descriptor: PropertyDescriptor,
): void {
// tslint:disable-next-line no-any
export function constant(target: any, propertyKey: string, descriptor: PropertyDescriptor): void {
throw new Error('This should be transpiled.');

@@ -436,6 +406,3 @@ }

export function createEventHandler(name: string): () => void;
export function createEventHandler<A0>(
name: string,
arg0Name: string,
): (arg0: A0) => void;
export function createEventHandler<A0>(name: string, arg0Name: string): (arg0: A0) => void;
export function createEventHandler<A0, A1>(

@@ -454,6 +421,7 @@ name: string,

name: string,
// tslint:disable-next-line
// tslint:disable-next-line no-any
...args: any[]
): (...args: any[]) => void {
): // tslint:disable-next-line no-any
(...args: any[]) => void {
throw new Error('This should be transpiled');
}
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