From 4db1d788575ace715acf332e7f7e4e5ba33006f1 Mon Sep 17 00:00:00 2001 From: jasl Date: Wed, 9 Nov 2022 01:01:23 +0800 Subject: [PATCH] Update contract' gas to Weight type --- packages/api-contract/src/types.ts | 8 +-- .../src/interfaces/contracts/definitions.ts | 52 +++++++++---------- .../types/src/interfaces/contracts/types.ts | 52 +++++++++---------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/packages/api-contract/src/types.ts b/packages/api-contract/src/types.ts index 5ab721de6773..2b2de73a61dc 100644 --- a/packages/api-contract/src/types.ts +++ b/packages/api-contract/src/types.ts @@ -3,8 +3,8 @@ import type { ApiBase } from '@polkadot/api/base'; import type { ApiTypes } from '@polkadot/api/types'; -import type { Text, u64 } from '@polkadot/types'; -import type { ContractExecResultResult, ContractSelector, StorageDeposit, WeightV2 } from '@polkadot/types/interfaces'; +import type { Text } from '@polkadot/types'; +import type { ContractExecResultResult, ContractSelector, StorageDeposit, Weight } from '@polkadot/types/interfaces'; import type { Codec, TypeDef } from '@polkadot/types/types'; import type { BN } from '@polkadot/util'; import type { Abi } from '.'; @@ -55,8 +55,8 @@ export interface InterfaceContractCalls { export interface ContractCallOutcome { debugMessage: Text; - gasConsumed: u64; - gasRequired: u64; + gasConsumed: Weight; + gasRequired: Weight; output: Codec | null; result: ContractExecResultResult; storageDeposit: StorageDeposit; diff --git a/packages/types/src/interfaces/contracts/definitions.ts b/packages/types/src/interfaces/contracts/definitions.ts index f0faafdb9e37..38feffc239b5 100644 --- a/packages/types/src/interfaces/contracts/definitions.ts +++ b/packages/types/src/interfaces/contracts/definitions.ts @@ -45,7 +45,7 @@ export default { origin: 'AccountId', dest: 'AccountId', value: 'Balance', - gasLimit: 'u64', + gasLimit: 'Weight', storageDepositLimit: 'Option', inputData: 'Bytes' }, @@ -81,8 +81,8 @@ export default { result: 'ContractExecResultResult' }, ContractExecResult: { - gasConsumed: 'u64', - gasRequired: 'u64', + gasConsumed: 'Weight', + gasRequired: 'Weight', storageDeposit: 'StorageDeposit', debugMessage: 'Text', result: 'ContractExecResultResult' @@ -117,7 +117,7 @@ export default { flags: 'ContractReturnFlags', data: 'Bytes' }, - Gas: 'u64', + Gas: 'Weight', HostFnWeightsTo264: { caller: 'Weight', address: 'Weight', @@ -222,7 +222,7 @@ export default { InstantiateRequestV1: { origin: 'AccountId', value: 'Balance', - gasLimit: 'Gas', + gasLimit: 'u64', code: 'Bytes', data: 'Bytes', salt: 'Bytes' @@ -251,8 +251,8 @@ export default { ContractInstantiateResultTo299: 'Result', ContractInstantiateResult: { _fallback: 'ContractInstantiateResultTo299', - gasConsumed: 'u64', - gasRequired: 'u64', + gasConsumed: 'Weight', + gasRequired: 'Weight', storageDeposit: 'StorageDeposit', debugMessage: 'Text', result: 'InstantiateReturnValue' @@ -358,15 +358,15 @@ export default { }, ScheduleTo212: { version: 'u32', - putCodePerByteCost: 'Gas', - growMemCost: 'Gas', - regularOpCost: 'Gas', - returnDataPerByteCost: 'Gas', - eventDataPerByteCost: 'Gas', - eventPerTopicCost: 'Gas', - eventBaseCost: 'Gas', - sandboxDataReadCost: 'Gas', - sandboxDataWriteCost: 'Gas', + putCodePerByteCost: 'u64', + growMemCost: 'u64', + regularOpCost: 'u64', + returnDataPerByteCost: 'u64', + eventDataPerByteCost: 'u64', + eventPerTopicCost: 'u64', + eventBaseCost: 'u64', + sandboxDataReadCost: 'u64', + sandboxDataWriteCost: 'u64', maxEventTopics: 'u32', maxStackHeight: 'u32', maxMemoryPages: 'u32', @@ -375,16 +375,16 @@ export default { }, ScheduleTo258: { version: 'u32', - putCodePerByteCost: 'Gas', - growMemCost: 'Gas', - regularOpCost: 'Gas', - returnDataPerByteCost: 'Gas', - eventDataPerByteCost: 'Gas', - eventPerTopicCost: 'Gas', - eventBaseCost: 'Gas', - sandboxDataReadCost: 'Gas', - sandboxDataWriteCost: 'Gas', - transferCost: 'Gas', + putCodePerByteCost: 'u64', + growMemCost: 'u64', + regularOpCost: 'u64', + returnDataPerByteCost: 'u64', + eventDataPerByteCost: 'u64', + eventPerTopicCost: 'u64', + eventBaseCost: 'u64', + sandboxDataReadCost: 'u64', + sandboxDataWriteCost: 'u64', + transferCost: 'u64', maxEventTopics: 'u32', maxStackHeight: 'u32', maxMemoryPages: 'u32', diff --git a/packages/types/src/interfaces/contracts/types.ts b/packages/types/src/interfaces/contracts/types.ts index f49d0d6a74c1..95b88dc2897c 100644 --- a/packages/types/src/interfaces/contracts/types.ts +++ b/packages/types/src/interfaces/contracts/types.ts @@ -64,15 +64,15 @@ export interface ContractCallRequest extends Struct { readonly origin: AccountId; readonly dest: AccountId; readonly value: Balance; - readonly gasLimit: u64; + readonly gasLimit: Gas; readonly storageDepositLimit: Option; readonly inputData: Bytes; } /** @name ContractExecResult */ export interface ContractExecResult extends Struct { - readonly gasConsumed: u64; - readonly gasRequired: u64; + readonly gasConsumed: Gas; + readonly gasRequired: Gas; readonly storageDeposit: StorageDeposit; readonly debugMessage: Text; readonly result: ContractExecResultResult; @@ -139,8 +139,8 @@ export interface ContractInfo extends Enum { /** @name ContractInstantiateResult */ export interface ContractInstantiateResult extends Struct { - readonly gasConsumed: u64; - readonly gasRequired: u64; + readonly gasConsumed: Gas; + readonly gasRequired: Gas; readonly storageDeposit: StorageDeposit; readonly debugMessage: Text; readonly result: InstantiateReturnValue; @@ -181,7 +181,7 @@ export interface ExecReturnValue extends Struct { } /** @name Gas */ -export interface Gas extends u64 {} +export interface Gas extends Weight {} /** @name HostFnWeights */ export interface HostFnWeights extends Struct { @@ -303,7 +303,7 @@ export interface InstantiateRequest extends Struct { export interface InstantiateRequestV1 extends Struct { readonly origin: AccountId; readonly value: Balance; - readonly gasLimit: Gas; + readonly gasLimit: u64; readonly code: Bytes; readonly data: Bytes; readonly salt: Bytes; @@ -452,15 +452,15 @@ export interface Schedule extends Struct { /** @name ScheduleTo212 */ export interface ScheduleTo212 extends Struct { readonly version: u32; - readonly putCodePerByteCost: Gas; - readonly growMemCost: Gas; - readonly regularOpCost: Gas; - readonly returnDataPerByteCost: Gas; - readonly eventDataPerByteCost: Gas; - readonly eventPerTopicCost: Gas; - readonly eventBaseCost: Gas; - readonly sandboxDataReadCost: Gas; - readonly sandboxDataWriteCost: Gas; + readonly putCodePerByteCost: u64; + readonly growMemCost: u64; + readonly regularOpCost: u64; + readonly returnDataPerByteCost: u64; + readonly eventDataPerByteCost: u64; + readonly eventPerTopicCost: u64; + readonly eventBaseCost: u64; + readonly sandboxDataReadCost: u64; + readonly sandboxDataWriteCost: u64; readonly maxEventTopics: u32; readonly maxStackHeight: u32; readonly maxMemoryPages: u32; @@ -471,16 +471,16 @@ export interface ScheduleTo212 extends Struct { /** @name ScheduleTo258 */ export interface ScheduleTo258 extends Struct { readonly version: u32; - readonly putCodePerByteCost: Gas; - readonly growMemCost: Gas; - readonly regularOpCost: Gas; - readonly returnDataPerByteCost: Gas; - readonly eventDataPerByteCost: Gas; - readonly eventPerTopicCost: Gas; - readonly eventBaseCost: Gas; - readonly sandboxDataReadCost: Gas; - readonly sandboxDataWriteCost: Gas; - readonly transferCost: Gas; + readonly putCodePerByteCost: u64; + readonly growMemCost: u64; + readonly regularOpCost: u64; + readonly returnDataPerByteCost: u64; + readonly eventDataPerByteCost: u64; + readonly eventPerTopicCost: u64; + readonly eventBaseCost: u64; + readonly sandboxDataReadCost: u64; + readonly sandboxDataWriteCost: u64; + readonly transferCost: u64; readonly maxEventTopics: u32; readonly maxStackHeight: u32; readonly maxMemoryPages: u32;