Update contract' gas to Weight type (#5324)
* Update contract' gas to Weight type * Make Contracts Runtime Calls support WeightV2 * fix gasConsumed & gasConsumed type * Regenerate contracts types * Correct ContractCallOutcome * `gasLimit` are optional * Apply suggestion * Add ContractCallRequestV1 and specify old rpc use that * Add back getGas * Port jg-ContractsApi-v2 (#5330) * Run yarn build:metadata * There is no 'ContractCallRequestV1', only 'ContractCallRequest' * api.tx.contracts.call.meta no version field, _isOldWeight still work?
This commit is contained in:
@@ -81,6 +81,13 @@ export default {
|
||||
result: 'ContractExecResultResult'
|
||||
},
|
||||
ContractExecResult: {
|
||||
gasConsumed: 'Weight',
|
||||
gasRequired: 'Weight',
|
||||
storageDeposit: 'StorageDeposit',
|
||||
debugMessage: 'Text',
|
||||
result: 'ContractExecResultResult'
|
||||
},
|
||||
ContractExecResultU64: {
|
||||
gasConsumed: 'u64',
|
||||
gasRequired: 'u64',
|
||||
storageDeposit: 'StorageDeposit',
|
||||
@@ -250,6 +257,15 @@ export default {
|
||||
ContractInstantiateResultTo267: 'Result<InstantiateReturnValueTo267, Null>',
|
||||
ContractInstantiateResultTo299: 'Result<InstantiateReturnValueOk, Null>',
|
||||
ContractInstantiateResult: {
|
||||
gasConsumed: 'WeightV2',
|
||||
gasRequired: 'WeightV2',
|
||||
storageDeposit: 'StorageDeposit',
|
||||
debugMessage: 'Text',
|
||||
result: 'InstantiateReturnValue'
|
||||
},
|
||||
ContractInstantiateResultU64: {
|
||||
// only this one can fail, the current version (above) _should_ be correctly
|
||||
// versioned now, aka no more deprecated RPCs involved, only runtime calls
|
||||
_fallback: 'ContractInstantiateResultTo299',
|
||||
gasConsumed: 'u64',
|
||||
gasRequired: 'u64',
|
||||
|
||||
@@ -48,7 +48,7 @@ export const rpc: DefinitionsRpc = {
|
||||
params: [
|
||||
{
|
||||
name: 'request',
|
||||
type: 'InstantiateRequest'
|
||||
type: 'InstantiateRequestV1'
|
||||
},
|
||||
{
|
||||
isHistoric: true,
|
||||
|
||||
@@ -1,12 +1,118 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DefinitionsCall } from '../../types';
|
||||
import type { DefinitionCall, DefinitionsCall } from '../../types';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
const SHARED_V1_V2: Record<string, DefinitionCall> = {
|
||||
get_storage: {
|
||||
description: 'Query a given storage key in a given contract.',
|
||||
params: [
|
||||
{
|
||||
name: 'address',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'Option<Bytes>'
|
||||
},
|
||||
upload_code: {
|
||||
description: 'Upload new code without instantiating a contract from it.',
|
||||
params: [
|
||||
{
|
||||
name: 'origin',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'code',
|
||||
type: 'Bytes'
|
||||
},
|
||||
{
|
||||
name: 'storageDepositLimit',
|
||||
type: 'Option<Balance>'
|
||||
}
|
||||
],
|
||||
type: 'CodeUploadResult'
|
||||
}
|
||||
};
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
ContractsApi: [
|
||||
{
|
||||
methods: {
|
||||
methods: objectSpread({
|
||||
call: {
|
||||
description: 'Perform a call from a specified account to a given contract.',
|
||||
params: [
|
||||
{
|
||||
name: 'origin',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'dest',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'value',
|
||||
type: 'Balance'
|
||||
},
|
||||
{
|
||||
name: 'gasLimit',
|
||||
type: 'Option<WeightV2>'
|
||||
},
|
||||
{
|
||||
name: 'storageDepositLimit',
|
||||
type: 'Option<Balance>'
|
||||
},
|
||||
{
|
||||
name: 'inputData',
|
||||
type: 'Vec<u8>'
|
||||
}
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
},
|
||||
instantiate: {
|
||||
description: 'Instantiate a new contract.',
|
||||
params: [
|
||||
{
|
||||
name: 'origin',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'value',
|
||||
type: 'Balance'
|
||||
},
|
||||
{
|
||||
name: 'gasLimit',
|
||||
type: 'Option<WeightV2>'
|
||||
},
|
||||
{
|
||||
name: 'storageDepositLimit',
|
||||
type: 'Option<Balance>'
|
||||
},
|
||||
{
|
||||
name: 'code',
|
||||
type: 'CodeSource'
|
||||
},
|
||||
{
|
||||
name: 'data',
|
||||
type: 'Bytes'
|
||||
},
|
||||
{
|
||||
name: 'salt',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'ContractInstantiateResult'
|
||||
}
|
||||
}, SHARED_V1_V2),
|
||||
version: 2
|
||||
},
|
||||
{
|
||||
methods: objectSpread({
|
||||
call: {
|
||||
description: 'Perform a call from a specified account to a given contract.',
|
||||
params: [
|
||||
@@ -35,21 +141,7 @@ export const runtime: DefinitionsCall = {
|
||||
type: 'Vec<u8>'
|
||||
}
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
},
|
||||
get_storage: {
|
||||
description: 'Query a given storage key in a given contract.',
|
||||
params: [
|
||||
{
|
||||
name: 'address',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'Option<Bytes>'
|
||||
type: 'ContractExecResultU64'
|
||||
},
|
||||
instantiate: {
|
||||
description: 'Instantiate a new contract.',
|
||||
@@ -83,27 +175,9 @@ export const runtime: DefinitionsCall = {
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'ContractInstantiateResult'
|
||||
},
|
||||
upload_code: {
|
||||
description: 'Upload new code without instantiating a contract from it.',
|
||||
params: [
|
||||
{
|
||||
name: 'origin',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'code',
|
||||
type: 'Bytes'
|
||||
},
|
||||
{
|
||||
name: 'storageDepositLimit',
|
||||
type: 'Option<Balance>'
|
||||
}
|
||||
],
|
||||
type: 'CodeUploadResult'
|
||||
type: 'ContractInstantiateResultU64'
|
||||
}
|
||||
},
|
||||
}, SHARED_V1_V2),
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Bytes, Compact, Enum, Null, Option, Raw, Result, Set, Struct, Text, U8aFixed, bool, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { AccountId, Balance, BlockNumber, Hash, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, Balance, BlockNumber, Hash, Weight, WeightV2 } from '@polkadot/types/interfaces/runtime';
|
||||
import type { DispatchError } from '@polkadot/types/interfaces/system';
|
||||
|
||||
/** @name AliveContractInfo */
|
||||
@@ -71,8 +71,8 @@ export interface ContractCallRequest extends Struct {
|
||||
|
||||
/** @name ContractExecResult */
|
||||
export interface ContractExecResult extends Struct {
|
||||
readonly gasConsumed: u64;
|
||||
readonly gasRequired: u64;
|
||||
readonly gasConsumed: Weight;
|
||||
readonly gasRequired: Weight;
|
||||
readonly storageDeposit: StorageDeposit;
|
||||
readonly debugMessage: Text;
|
||||
readonly result: ContractExecResultResult;
|
||||
@@ -128,6 +128,15 @@ export interface ContractExecResultTo267 extends Struct {
|
||||
readonly result: ContractExecResultResult;
|
||||
}
|
||||
|
||||
/** @name ContractExecResultU64 */
|
||||
export interface ContractExecResultU64 extends Struct {
|
||||
readonly gasConsumed: u64;
|
||||
readonly gasRequired: u64;
|
||||
readonly storageDeposit: StorageDeposit;
|
||||
readonly debugMessage: Text;
|
||||
readonly result: ContractExecResultResult;
|
||||
}
|
||||
|
||||
/** @name ContractInfo */
|
||||
export interface ContractInfo extends Enum {
|
||||
readonly isAlive: boolean;
|
||||
@@ -139,8 +148,8 @@ export interface ContractInfo extends Enum {
|
||||
|
||||
/** @name ContractInstantiateResult */
|
||||
export interface ContractInstantiateResult extends Struct {
|
||||
readonly gasConsumed: u64;
|
||||
readonly gasRequired: u64;
|
||||
readonly gasConsumed: WeightV2;
|
||||
readonly gasRequired: WeightV2;
|
||||
readonly storageDeposit: StorageDeposit;
|
||||
readonly debugMessage: Text;
|
||||
readonly result: InstantiateReturnValue;
|
||||
@@ -160,6 +169,15 @@ export interface ContractInstantiateResultTo299 extends Result<InstantiateReturn
|
||||
readonly asOk: InstantiateReturnValueOk;
|
||||
}
|
||||
|
||||
/** @name ContractInstantiateResultU64 */
|
||||
export interface ContractInstantiateResultU64 extends Struct {
|
||||
readonly gasConsumed: u64;
|
||||
readonly gasRequired: u64;
|
||||
readonly storageDeposit: StorageDeposit;
|
||||
readonly debugMessage: Text;
|
||||
readonly result: InstantiateReturnValue;
|
||||
}
|
||||
|
||||
/** @name ContractReturnFlags */
|
||||
export interface ContractReturnFlags extends Set {
|
||||
readonly isRevert: boolean;
|
||||
|
||||
Reference in New Issue
Block a user