Update for latest substrate master metadata (#958)

* Update for latest substrate master metadata

* Add ContractStorageKey type

* Update schedule
This commit is contained in:
Jaco Greeff
2019-06-12 16:45:45 +12:00
committed by Ian He
parent 018c63b641
commit 8de8e3511c
7 changed files with 114 additions and 6 deletions
+2
View File
@@ -90,6 +90,8 @@ These custom types implement specific types that are found as part of the Substr
| [[BlockNumber]] | A representation of a Substrate BlockNumber, implemented as a [[U64]] |
| [[CodeHash]] | The default contract code hash that is used accross the system |
| [[Consensus]] | Log item indicating consensus |
| [[ContractInfo]] | The contract information for a given contract |
| [[ContractStorageKey]] | A representation of a storage key for contracts |
| [[Exposure]] | A snapshot of the stake backing a single validator in the system |
| [[Extrinsic]] | Representation of an Extrinsic in the system |
| [[ExtrinsicEra]] | The era for an extrinsic, indicating either a mortal or immortal extrinsic |
@@ -2972,9 +2972,9 @@
"name": "StorageSizeOffset",
"modifier": "Default",
"type": {
"PlainType": "u64"
"PlainType": "u32"
},
"fallback": "0x0000000000000000",
"fallback": "0x00000000",
"documentation": [
" Size of a contract at the time of creation. This is a simple way to ensure",
" that empty contracts eventually gets deleted."
@@ -3125,7 +3125,7 @@
"type": {
"PlainType": "Gas"
},
"fallback": "0x40420f0000000000",
"fallback": "0x8096980000000000",
"documentation": [
" The maximum amount of gas that could be expended per block."
]
@@ -3147,7 +3147,7 @@
"type": {
"PlainType": "Schedule"
},
"fallback": "0x0000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000000001001000000000",
"fallback": "0x000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000400000000000100100000000020000000",
"documentation": [
" Current cost schedule for contracts."
]
@@ -3326,6 +3326,35 @@
" If contract is not evicted as a result of this call, no actions are taken and",
" the sender is not eligible for the reward."
]
},
{
"name": "restore_to",
"args": [
{
"name": "dest",
"type": "AccountId"
},
{
"name": "code_hash",
"type": "CodeHash"
},
{
"name": "rent_allowance",
"type": "BalanceOf"
},
{
"name": "delta",
"type": "Vec<ContractStorageKey>"
}
],
"documentation": [
" Allows a contract to restore a tombstone by giving its storage.",
"",
" The contract that wants to restore (i.e. origin of the call, or `msg.sender` in Solidity terms) will compute a",
" tombstone with its storage and the given code_hash. If the computed tombstone",
" match the destination one, the destination contract is restored with the rent_allowance` specified,",
" while the origin sends all its funds to the destination and is removed."
]
}
],
"events": [
File diff suppressed because one or more lines are too long
+2
View File
@@ -63,6 +63,8 @@ export default class Type extends Text {
Type._alias('Lookup::Source', 'Address'),
// alias Lookup::Target to AccountId (always the case)
Type._alias('Lookup::Target', 'AccountId'),
// HACK duplication between contracts & primitives, however contracts prefixed with exec
Type._alias('exec::StorageKey', 'ContractStorageKey'),
// flattens tuples with one value, `(AccountId)` -> `AccountId`
Type._flattenSingleTuple()
];
@@ -0,0 +1,25 @@
// 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 { AnyU8a } from '../types';
import U8aFixed from '../codec/U8aFixed';
/**
* @name ContractStorageKey
* @description
* A [u8; 32] representing a storeage key in contracts
*/
export default class ContractStorageKey extends U8aFixed {
constructor (value?: AnyU8a) {
super(value, 256);
}
/**
* @description Returns the base runtime type name for this instance
*/
toRawType (): string {
return '[u8; 32]';
}
}
+50 -1
View File
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import Struct from '../codec/Struct';
import Bool from '../primitive/Bool';
import U32 from '../primitive/U32';
import Gas from './Gas';
@@ -19,13 +20,47 @@ export default class Schedule extends Struct {
growMemCost: Gas,
regularOpCost: Gas,
returnDataPerByteCost: Gas,
eventDataPerByteCost: Gas,
eventPerTopicCost: Gas,
eventBaseCost: Gas,
sandboxDataReadCost: Gas,
sandboxDataWriteCost: Gas,
maxEventTopics: U32,
maxStackHeight: U32,
maxMemoryPages: U32
maxMemoryPages: U32,
enablePrintln: Bool,
maxSubjectLen: U32
}, value);
}
/**
* @description Whether the `ext_println` function is allowed to be used contracts. MUST only be enabled for `dev` chains, NOT for production chains
*/
get enablePrintln (): Bool {
return this.get('enablePrintln') as Bool;
}
/**
* @description Gas cost to deposit an event; the base.
*/
get eventBaseCost (): Gas {
return this.get('eventBaseCost') as Gas;
}
/**
* @description Gas cost to deposit an event; the per-byte portion.
*/
get eventDataPerByteCost (): Gas {
return this.get('eventDataPerByteCost') as Gas;
}
/**
* @description Gas cost to deposit an event; the cost per topic.
*/
get eventPerTopicCost (): Gas {
return this.get('eventPerTopicCost') as Gas;
}
/**
* @description Gas cost of a growing memory by single page.
*/
@@ -33,6 +68,13 @@ export default class Schedule extends Struct {
return this.get('growMemCost') as Gas;
}
/**
* @description The maximum number of topics supported by an event.
*/
get maxEventTopics (): U32 {
return this.get('maxEventTopics') as U32;
}
/**
* @description What is the maximal memory pages amount is allowed to have for a contract.
*/
@@ -47,6 +89,13 @@ export default class Schedule extends Struct {
return this.get('maxStackHeight') as U32;
}
/**
* @description The maximum length of a subject used for PRNG generation.
*/
get maxSubjectLen (): U32 {
return this.get('maxSubjectLen') as U32;
}
/**
* @description Cost of putting a byte of code into the storage.
*/
+1
View File
@@ -19,6 +19,7 @@ export { default as BalanceLock } from './BalanceLock';
export { default as BlockNumber } from './BlockNumber';
export { default as CodeHash } from './CodeHash';
export { default as ContractInfo } from './ContractInfo';
export { default as ContractStorageKey } from './ContractStorageKey';
export { default as Exposure } from './Exposure';
export { default as Extrinsic } from './Extrinsic';
export { default as ExtrinsicEra } from './ExtrinsicEra';