Pull in latest contract types (#634)

This commit is contained in:
Jaco Greeff
2019-01-24 18:09:09 +01:00
committed by GitHub
parent e3959fb8b7
commit 25c18bb399
3 changed files with 107 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Hash from './Hash';
/**
* @name CodeHash
* @description
* The default contract code hash that is used accross the system. It is a
* wrapper around [[Hash]], representing a 32-byte blake2b (Substrate) value
*/
export default class CodeHash extends Hash {
}
+91
View File
@@ -0,0 +1,91 @@
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Struct from './codec/Struct';
import Gas from './Gas';
import U32 from './U32';
/**
* @name Schedule
* @description
* Definition of the cost schedule and other parameterizations for wasm vm
*/
export default class Schedule extends Struct {
constructor (value?: any) {
super({
version: U32,
putCodePerByteCost: Gas,
growMemCost: Gas,
regularOpCost: Gas,
returnDataPerByteCost: Gas,
sandboxDataReadCost: Gas,
sandboxDataWriteCost: Gas,
maxStackHeight: U32,
maxMemoryPages: U32
}, value);
}
/**
* @description Gas cost of a growing memory by single page.
*/
get growMemCost (): Gas {
return this.get('growMemCost') as Gas;
}
/**
* @description What is the maximal memory pages amount is allowed to have for a contract.
*/
get maxMemoryPages (): U32 {
return this.get('maxMemoryPages') as U32;
}
/**
* @description How tall the stack is allowed to grow?
*/
get maxStackHeight (): U32 {
return this.get('maxStackHeight') as U32;
}
/**
* @description Cost of putting a byte of code into the storage.
*/
get putCodePerByteCost (): Gas {
return this.get('putCodePerByteCost') as Gas;
}
/**
* @description Gas cost of a regular operation.
*/
get regularOpCost (): Gas {
return this.get('regularOpCost') as Gas;
}
/**
* @description Gas cost per one byte returned.
*/
get returnDataPerByteCost (): Gas {
return this.get('returnDataPerByteCost') as Gas;
}
/**
* @description Gas cost per one byte read from the sandbox memory.
*/
get sandboxDataReadCost (): Gas {
return this.get('sandboxDataReadCost') as Gas;
}
/**
* @description Gas cost per one byte written to the sandbox memory.
*/
get sandboxDataWriteCost (): Gas {
return this.get('sandboxDataWriteCost') as Gas;
}
/**
* @description Version of the schedule.
*/
get version (): U32 {
return this.get('version') as U32;
}
}
+2
View File
@@ -27,6 +27,7 @@ export { default as BlockNumber } from './BlockNumber';
export { default as bool } from './Bool';
export { default as Bytes } from './Bytes';
export { default as ChainProperties } from './ChainProperties';
export { default as CodeHash } from './CodeHash';
export { default as Data } from './Data';
export { default as Digest } from './Digest';
export { default as Event } from './Event';
@@ -74,6 +75,7 @@ export { default as ProposalIndex } from './ProposalIndex';
export { default as ReferendumIndex } from './ReferendumIndex';
export { default as ReferendumInfo } from './ReferendumInfo';
export { default as RuntimeVersion } from './RuntimeVersion';
export { default as Schedule } from './Schedule';
export { default as SessionKey } from './SessionKey';
export { default as Signature } from './Signature';
export { default as SignedBlock } from './SignedBlock';