Storage deposit limit changes (#4370)
This commit is contained in:
@@ -56,9 +56,9 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, storageDepositLimit = null, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.instantiate.meta.args.length === 6;
|
||||
const storageDepositLimit = null;
|
||||
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, storageDepositLimit, this.codeHash, this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
@@ -61,9 +61,9 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, storageDepositLimit = null, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.instantiateWithCode.meta.args.length === 6;
|
||||
const storageDepositLimit = null;
|
||||
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.instantiateWithCode(value, gasLimit, storageDepositLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
@@ -106,9 +106,9 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
: gasLimit;
|
||||
};
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, storageDepositLimit = null, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.call.meta.args.length === 5;
|
||||
const storageDepositLimit = null;
|
||||
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.call(this.address, value, this.#getGas(gasLimit), storageDepositLimit, this.abi.findMessage(messageOrId).toU8a(params))
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@@ -133,7 +133,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
);
|
||||
};
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, storageDepositLimit = null, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
@@ -143,7 +143,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.call.meta.args.length === 5;
|
||||
const rpc = hasStorageDeposit
|
||||
? this.api.rx.rpc.contracts.call({ dest: this.address, gasLimit: this.#getGas(gasLimit, true), inputData: message.toU8a(params), origin, value })
|
||||
? this.api.rx.rpc.contracts.call({ dest: this.address, gasLimit: this.#getGas(gasLimit, true), inputData: message.toU8a(params), origin, storageDepositLimit, value })
|
||||
: this.api.rx.rpc.contracts.call({ dest: this.address, gasLimit: this.#getGas(gasLimit, true), inputData: message.toU8a(params), origin, value });
|
||||
|
||||
const mapFn = ({ debugMessage, gasConsumed, gasRequired, result }: ContractExecResult): ContractCallOutcome => ({
|
||||
|
||||
@@ -70,13 +70,12 @@ export interface DecodedMessage {
|
||||
message: AbiMessage;
|
||||
}
|
||||
|
||||
export interface BlueprintOptions {
|
||||
gasLimit?: bigint | string | number | BN;
|
||||
salt?: Uint8Array | string | null;
|
||||
value?: bigint | string | number | BN;
|
||||
}
|
||||
|
||||
export interface ContractOptions {
|
||||
gasLimit?: bigint | BN | string | number;
|
||||
gasLimit?: bigint | string | number | BN;
|
||||
storageDepositLimit?: bigint | string | number | BN | null;
|
||||
value?: bigint | BN | string | number;
|
||||
}
|
||||
|
||||
export interface BlueprintOptions extends ContractOptions {
|
||||
salt?: Uint8Array | string | null;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ declare module '@polkadot/rpc-core/types/jsonrpc' {
|
||||
/**
|
||||
* Executes a call to a contract
|
||||
**/
|
||||
call: AugmentedRpc<(callRequest: ContractCallRequest | { origin?: any; dest?: any; value?: any; gasLimit?: any; inputData?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractExecResult>>;
|
||||
call: AugmentedRpc<(callRequest: ContractCallRequest | { origin?: any; dest?: any; value?: any; gasLimit?: any; storageDepositLimit?: any; inputData?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractExecResult>>;
|
||||
/**
|
||||
* Returns the value under a specified storage key in a contract
|
||||
**/
|
||||
@@ -141,7 +141,7 @@ declare module '@polkadot/rpc-core/types/jsonrpc' {
|
||||
/**
|
||||
* Instantiate a new contract
|
||||
**/
|
||||
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; value?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
|
||||
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; value?: any; gasLimit?: any; storageDepositLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
|
||||
/**
|
||||
* Returns the projected time a given contract will be able to sustain paying its rent
|
||||
**/
|
||||
|
||||
@@ -17,7 +17,7 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { StatementKind } from '@polkadot/types/interfaces/claims';
|
||||
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, StorageDeposit, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import type { ContractConstructorSpecLatest, ContractConstructorSpecV0, ContractConstructorSpecV2, ContractContractSpecV0, ContractContractSpecV2, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpecLatest, ContractEventParamSpecV0, ContractEventParamSpecV2, ContractEventSpecLatest, ContractEventSpecV0, ContractEventSpecV2, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpecLatest, ContractMessageParamSpecV0, ContractMessageParamSpecV2, ContractMessageSpecLatest, ContractMessageSpecV0, ContractMessageSpecV2, ContractMetadata, ContractMetadataLatest, ContractMetadataV0, ContractMetadataV1, ContractMetadataV2, ContractProject, ContractProjectContract, ContractProjectInfo, ContractProjectSource, ContractProjectV0, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
|
||||
import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
|
||||
import type { ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData } from '@polkadot/types/interfaces/cumulus';
|
||||
@@ -914,6 +914,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
StatementKind: StatementKind;
|
||||
StorageChangeSet: StorageChangeSet;
|
||||
StorageData: StorageData;
|
||||
StorageDeposit: StorageDeposit;
|
||||
StorageEntryMetadataLatest: StorageEntryMetadataLatest;
|
||||
StorageEntryMetadataV10: StorageEntryMetadataV10;
|
||||
StorageEntryMetadataV11: StorageEntryMetadataV11;
|
||||
|
||||
@@ -28,6 +28,7 @@ export default {
|
||||
dest: 'AccountId',
|
||||
value: 'Balance',
|
||||
gasLimit: 'u64',
|
||||
storageDepositLimit: 'Option<Balance>',
|
||||
inputData: 'Bytes'
|
||||
},
|
||||
ContractExecResultSuccessTo255: {
|
||||
@@ -82,6 +83,7 @@ export default {
|
||||
ContractExecResult: {
|
||||
gasConsumed: 'u64',
|
||||
gasRequired: 'u64',
|
||||
storageDeposit: 'StorageDeposit',
|
||||
debugMessage: 'Text',
|
||||
result: 'ContractExecResultResult'
|
||||
},
|
||||
@@ -206,6 +208,7 @@ export default {
|
||||
origin: 'AccountId',
|
||||
value: 'Balance',
|
||||
gasLimit: 'Gas',
|
||||
storageDepositLimit: 'Option<Balance>',
|
||||
code: 'Bytes',
|
||||
data: 'Bytes',
|
||||
salt: 'Bytes'
|
||||
@@ -371,6 +374,12 @@ export default {
|
||||
hostFnWeights: 'HostFnWeights'
|
||||
},
|
||||
SeedOf: 'Hash',
|
||||
StorageDeposit: {
|
||||
_enum: {
|
||||
Refund: 'Balance',
|
||||
Charge: 'Balance'
|
||||
}
|
||||
},
|
||||
TombstoneContractInfo: 'Hash',
|
||||
TrieId: 'Bytes'
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface ContractCallRequest extends Struct {
|
||||
readonly dest: AccountId;
|
||||
readonly value: Balance;
|
||||
readonly gasLimit: u64;
|
||||
readonly storageDepositLimit: Option<Balance>;
|
||||
readonly inputData: Bytes;
|
||||
}
|
||||
|
||||
@@ -33,6 +34,7 @@ export interface ContractCallRequest extends Struct {
|
||||
export interface ContractExecResult extends Struct {
|
||||
readonly gasConsumed: u64;
|
||||
readonly gasRequired: u64;
|
||||
readonly storageDeposit: StorageDeposit;
|
||||
readonly debugMessage: Text;
|
||||
readonly result: ContractExecResultResult;
|
||||
}
|
||||
@@ -259,6 +261,7 @@ export interface InstantiateRequest extends Struct {
|
||||
readonly origin: AccountId;
|
||||
readonly value: Balance;
|
||||
readonly gasLimit: Gas;
|
||||
readonly storageDepositLimit: Option<Balance>;
|
||||
readonly code: Bytes;
|
||||
readonly data: Bytes;
|
||||
readonly salt: Bytes;
|
||||
@@ -436,6 +439,15 @@ export interface ScheduleTo264 extends Struct {
|
||||
/** @name SeedOf */
|
||||
export interface SeedOf extends Hash {}
|
||||
|
||||
/** @name StorageDeposit */
|
||||
export interface StorageDeposit extends Enum {
|
||||
readonly isRefund: boolean;
|
||||
readonly asRefund: Balance;
|
||||
readonly isCharge: boolean;
|
||||
readonly asCharge: Balance;
|
||||
readonly type: 'Refund' | 'Charge';
|
||||
}
|
||||
|
||||
/** @name TombstoneContractInfo */
|
||||
export interface TombstoneContractInfo extends Hash {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user