Update with new consumed Weight structures (#2928)
* Update with new consumed Weight structures * dispatch(Info, Error} optional in result * Update for maximumBlockWeight
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, ContractExecResult, EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
@@ -145,7 +145,9 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return gasLimit.lten(0)
|
||||
? isCall
|
||||
? MAX_CALL_GAS
|
||||
: this.api.consts.system.maximumBlockWeight.muln(64).divn(100)
|
||||
: this.api.consts.system.blockWeights
|
||||
? this.api.consts.system.blockWeights.perClass.normal.maxExtrinsic.sub(this.api.consts.system.blockWeights.perClass.normal.baseExtrinsic)
|
||||
: (this.api.consts.system.maximumBlockWeight as Weight).muln(64).divn(100)
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
|
||||
import type { Vec, u16, u32, u64 } from '@polkadot/types';
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { BlockWeights } from '@polkadot/types/interfaces/system';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
|
||||
declare module '@polkadot/api/types/consts' {
|
||||
@@ -314,30 +315,18 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
system: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The base weight of executing a block, independent of the transactions in the block.
|
||||
**/
|
||||
blockExecutionWeight: Weight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of blocks to allow in mortal eras.
|
||||
**/
|
||||
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The weight configuration (limits & base values) for each class of extrinsics and block.
|
||||
**/
|
||||
blockWeights: BlockWeights & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The weight of runtime database operations the runtime can invoke.
|
||||
**/
|
||||
dbWeight: RuntimeDbWeight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The base weight of an Extrinsic in the block, independent of the of extrinsic being executed.
|
||||
**/
|
||||
extrinsicBaseWeight: Weight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of a block (in bytes).
|
||||
**/
|
||||
maximumBlockLength: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum weight of a block.
|
||||
**/
|
||||
maximumBlockWeight: Weight & AugmentedConst<ApiType>;
|
||||
};
|
||||
timestamp: {
|
||||
[key: string]: Codec;
|
||||
|
||||
@@ -18,12 +18,12 @@ import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { AccountInfo, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { Multisig } from '@polkadot/types/interfaces/utility';
|
||||
@@ -822,7 +822,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* The current weight for the block.
|
||||
**/
|
||||
blockWeight: AugmentedQuery<ApiType, () => Observable<ExtrinsicsWeight>> & QueryableStorageEntry<ApiType>;
|
||||
blockWeight: AugmentedQuery<ApiType, () => Observable<ConsumedWeight>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Digest of the current block, also part of the block header.
|
||||
**/
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
"name": "BlockWeight",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "ExtrinsicsWeight"
|
||||
"Plain": "ConsumedWeight"
|
||||
},
|
||||
"fallback": "0x00000000000000000000000000000000",
|
||||
"fallback": "0x000000000000000000000000000000000000000000000000",
|
||||
"documentation": [
|
||||
" The current weight for the block."
|
||||
]
|
||||
@@ -462,14 +462,6 @@
|
||||
" The maximum number of blocks to allow in mortal eras."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaximumBlockWeight",
|
||||
"type": "Weight",
|
||||
"value": "0x00204aa9d1010000",
|
||||
"documentation": [
|
||||
" The maximum weight of a block."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DbWeight",
|
||||
"type": "RuntimeDbWeight",
|
||||
@@ -479,27 +471,11 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "BlockExecutionWeight",
|
||||
"type": "Weight",
|
||||
"value": "0x00f2052a01000000",
|
||||
"name": "BlockWeights",
|
||||
"type": "BlockWeights",
|
||||
"value": "0x00f2052a0100000000204aa9d1010000405973070000000001c06e96a62e010000010098f73e5d010000010000000000000000405973070000000001c0f6e810a30100000100204aa9d1010000010088526a740000004059730700000000000000",
|
||||
"documentation": [
|
||||
" The base weight of executing a block, independent of the transactions in the block."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ExtrinsicBaseWeight",
|
||||
"type": "Weight",
|
||||
"value": "0x4059730700000000",
|
||||
"documentation": [
|
||||
" The base weight of an Extrinsic in the block, independent of the of extrinsic being executed."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaximumBlockLength",
|
||||
"type": "u32",
|
||||
"value": "0x00005000",
|
||||
"documentation": [
|
||||
" The maximum length of a block (in bytes)."
|
||||
" The weight configuration (limits & base values) for each class of extrinsics and block."
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -44,7 +44,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, ApplyExtrinsicResult, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -1167,12 +1167,18 @@ declare module '@polkadot/types/types/registry' {
|
||||
ApplyExtrinsicResult: ApplyExtrinsicResult;
|
||||
'Option<ApplyExtrinsicResult>': Option<ApplyExtrinsicResult>;
|
||||
'Vec<ApplyExtrinsicResult>': Vec<ApplyExtrinsicResult>;
|
||||
BlockWeights: BlockWeights;
|
||||
'Option<BlockWeights>': Option<BlockWeights>;
|
||||
'Vec<BlockWeights>': Vec<BlockWeights>;
|
||||
ChainProperties: ChainProperties;
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
ChainType: ChainType;
|
||||
'Option<ChainType>': Option<ChainType>;
|
||||
'Vec<ChainType>': Vec<ChainType>;
|
||||
ConsumedWeight: ConsumedWeight;
|
||||
'Option<ConsumedWeight>': Option<ConsumedWeight>;
|
||||
'Vec<ConsumedWeight>': Vec<ConsumedWeight>;
|
||||
DigestOf: DigestOf;
|
||||
'Option<DigestOf>': Option<DigestOf>;
|
||||
'Vec<DigestOf>': Vec<DigestOf>;
|
||||
@@ -1264,6 +1270,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
PeerInfo: PeerInfo;
|
||||
'Option<PeerInfo>': Option<PeerInfo>;
|
||||
'Vec<PeerInfo>': Vec<PeerInfo>;
|
||||
PerDispatchClass: PerDispatchClass;
|
||||
'Option<PerDispatchClass>': Option<PerDispatchClass>;
|
||||
'Vec<PerDispatchClass>': Vec<PerDispatchClass>;
|
||||
Phase: Phase;
|
||||
'Option<Phase>': Option<Phase>;
|
||||
'Vec<Phase>': Vec<Phase>;
|
||||
@@ -1290,6 +1299,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
UnknownTransaction: UnknownTransaction;
|
||||
'Option<UnknownTransaction>': Option<UnknownTransaction>;
|
||||
'Vec<UnknownTransaction>': Vec<UnknownTransaction>;
|
||||
WeightPerClass: WeightPerClass;
|
||||
'Option<WeightPerClass>': Option<WeightPerClass>;
|
||||
'Vec<WeightPerClass>': Vec<WeightPerClass>;
|
||||
Bounty: Bounty;
|
||||
'Option<Bounty>': Option<Bounty>;
|
||||
'Vec<Bounty>': Vec<Bounty>;
|
||||
|
||||
@@ -139,6 +139,11 @@ export default {
|
||||
data: 'AccountData'
|
||||
},
|
||||
ApplyExtrinsicResult: 'Result<DispatchOutcome, TransactionValidityError>',
|
||||
BlockWeights: {
|
||||
baseBlock: 'Weight',
|
||||
maxBlock: 'Weight',
|
||||
perClass: 'PerDispatchClass'
|
||||
},
|
||||
ChainProperties: {
|
||||
ss58Format: 'Option<u8>',
|
||||
tokenDecimals: 'Option<u32>',
|
||||
@@ -152,6 +157,7 @@ export default {
|
||||
Custom: 'Text'
|
||||
}
|
||||
},
|
||||
ConsumedWeight: 'PerDispatchClass',
|
||||
DigestOf: 'Digest',
|
||||
DispatchClass: {
|
||||
_enum: ['Normal', 'Operational', 'Mandatory']
|
||||
@@ -283,6 +289,11 @@ export default {
|
||||
bestHash: 'Hash',
|
||||
bestNumber: 'BlockNumber'
|
||||
},
|
||||
PerDispatchClass: {
|
||||
normal: 'WeightPerClass',
|
||||
operational: 'WeightPerClass',
|
||||
mandatory: 'WeightPerClass'
|
||||
},
|
||||
Phase: {
|
||||
_enum: {
|
||||
ApplyExtrinsic: 'u32',
|
||||
@@ -317,6 +328,12 @@ export default {
|
||||
NoUnsignedValidator: 'Null',
|
||||
Custom: 'u8'
|
||||
}
|
||||
},
|
||||
WeightPerClass: {
|
||||
baseExtrinsic: 'Weight',
|
||||
maxExtrinsic: 'Weight',
|
||||
maxTotal: 'Option<Weight>',
|
||||
reserved: 'Option<Weight>'
|
||||
}
|
||||
}
|
||||
} as Definitions;
|
||||
|
||||
@@ -21,6 +21,13 @@ export interface ApplyExtrinsicResult extends Result<DispatchOutcome, Transactio
|
||||
readonly asOk: DispatchOutcome;
|
||||
}
|
||||
|
||||
/** @name BlockWeights */
|
||||
export interface BlockWeights extends Struct {
|
||||
readonly baseBlock: Weight;
|
||||
readonly maxBlock: Weight;
|
||||
readonly perClass: PerDispatchClass;
|
||||
}
|
||||
|
||||
/** @name ChainProperties */
|
||||
export interface ChainProperties extends Struct {
|
||||
readonly ss58Format: Option<u8>;
|
||||
@@ -37,6 +44,9 @@ export interface ChainType extends Enum {
|
||||
readonly asCustom: Text;
|
||||
}
|
||||
|
||||
/** @name ConsumedWeight */
|
||||
export interface ConsumedWeight extends PerDispatchClass {}
|
||||
|
||||
/** @name DigestOf */
|
||||
export interface DigestOf extends Digest {}
|
||||
|
||||
@@ -238,6 +248,13 @@ export interface PeerPing extends Struct {
|
||||
readonly secs: u64;
|
||||
}
|
||||
|
||||
/** @name PerDispatchClass */
|
||||
export interface PerDispatchClass extends Struct {
|
||||
readonly normal: WeightPerClass;
|
||||
readonly operational: WeightPerClass;
|
||||
readonly mandatory: WeightPerClass;
|
||||
}
|
||||
|
||||
/** @name Phase */
|
||||
export interface Phase extends Enum {
|
||||
readonly isApplyExtrinsic: boolean;
|
||||
@@ -286,4 +303,12 @@ export interface UnknownTransaction extends Enum {
|
||||
readonly asCustom: u8;
|
||||
}
|
||||
|
||||
/** @name WeightPerClass */
|
||||
export interface WeightPerClass extends Struct {
|
||||
readonly baseExtrinsic: Weight;
|
||||
readonly maxExtrinsic: Weight;
|
||||
readonly maxTotal: Option<Weight>;
|
||||
readonly reserved: Option<Weight>;
|
||||
}
|
||||
|
||||
export type PHANTOM_SYSTEM = 'system';
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
import { ExtrinsicStatus } from '../interfaces/author';
|
||||
import { EcdsaSignature, Ed25519Signature, Sr25519Signature } from '../interfaces/extrinsics';
|
||||
import { Address, Balance, Call, H256, Index } from '../interfaces/runtime';
|
||||
import { EventRecord } from '../interfaces/system';
|
||||
import { DispatchError, DispatchInfo, EventRecord } from '../interfaces/system';
|
||||
import { Codec } from './codec';
|
||||
import { AnyJson, AnyNumber, AnyU8a } from './helpers';
|
||||
import { ICompact, IKeyringPair, IMethod, IRuntimeVersion } from './interfaces';
|
||||
|
||||
export interface ISubmittableResult {
|
||||
readonly dispatchError?: DispatchError;
|
||||
readonly dispatchInfo?: DispatchInfo;
|
||||
readonly events: EventRecord[];
|
||||
readonly status: ExtrinsicStatus;
|
||||
readonly isCompleted: boolean;
|
||||
|
||||
Reference in New Issue
Block a user