starknet 11.5.0 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.ts +178 -9
- package/dist/index.global.js +257 -151
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +257 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -151
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -63,6 +63,8 @@ __export(constants_exports, {
|
|
|
63
63
|
StarknetChainId: () => _StarknetChainId,
|
|
64
64
|
SupportedRpcVersion: () => _SupportedRpcVersion,
|
|
65
65
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
66
|
+
TYPED_DATA_MAX_HASHED_FELTS: () => TYPED_DATA_MAX_HASHED_FELTS,
|
|
67
|
+
TYPED_DATA_MAX_TYPES: () => TYPED_DATA_MAX_TYPES,
|
|
66
68
|
TransactionHashPrefix: () => _TransactionHashPrefix,
|
|
67
69
|
UDC: () => UDC,
|
|
68
70
|
ZERO: () => ZERO
|
|
@@ -293,6 +295,8 @@ var UDC = {
|
|
|
293
295
|
var OutsideExecutionCallerAny = "0x414e595f43414c4c4552";
|
|
294
296
|
var SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181";
|
|
295
297
|
var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
|
|
298
|
+
var TYPED_DATA_MAX_TYPES = 64;
|
|
299
|
+
var TYPED_DATA_MAX_HASHED_FELTS = 13500;
|
|
296
300
|
var HARDENING_BYTE = 128;
|
|
297
301
|
var HARDENING_4BYTES = 2147483648n;
|
|
298
302
|
var _NetworkName = {
|
|
@@ -15903,6 +15907,23 @@ var revisionConfiguration = {
|
|
|
15903
15907
|
presetTypes: {}
|
|
15904
15908
|
}
|
|
15905
15909
|
};
|
|
15910
|
+
var feltsLeft;
|
|
15911
|
+
function spend(felts) {
|
|
15912
|
+
if (feltsLeft === void 0) return;
|
|
15913
|
+
feltsLeft -= felts;
|
|
15914
|
+
if (feltsLeft < 0) {
|
|
15915
|
+
throw new Error(`Cannot encode data: more than ${TYPED_DATA_MAX_HASHED_FELTS} felts to hash`);
|
|
15916
|
+
}
|
|
15917
|
+
}
|
|
15918
|
+
function withBudget(encode) {
|
|
15919
|
+
if (feltsLeft !== void 0) return encode();
|
|
15920
|
+
feltsLeft = TYPED_DATA_MAX_HASHED_FELTS;
|
|
15921
|
+
try {
|
|
15922
|
+
return encode();
|
|
15923
|
+
} finally {
|
|
15924
|
+
feltsLeft = void 0;
|
|
15925
|
+
}
|
|
15926
|
+
}
|
|
15906
15927
|
function assertRange(data, type, { min, max }) {
|
|
15907
15928
|
const value = BigInt(data);
|
|
15908
15929
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
@@ -15943,35 +15964,30 @@ function isMerkleTreeType(type) {
|
|
|
15943
15964
|
return type.type === "merkletree";
|
|
15944
15965
|
}
|
|
15945
15966
|
function getDependencies(types, type, dependencies = [], contains = "", revision = api_exports.TypedDataRevision.LEGACY) {
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
)
|
|
15971
|
-
].filter((dependency) => !p.includes(dependency))
|
|
15972
|
-
],
|
|
15973
|
-
[]
|
|
15974
|
-
);
|
|
15967
|
+
const pointedTypes = (fieldType, fieldContains = "") => {
|
|
15968
|
+
if (fieldType.endsWith("*")) return [fieldType.slice(0, -1)];
|
|
15969
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE && fieldType === "enum") return [fieldContains];
|
|
15970
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE && /^\(.*\)$/.test(fieldType)) {
|
|
15971
|
+
return fieldType.slice(1, -1).split(",").map((param) => param.endsWith("*") ? param.slice(0, -1) : param);
|
|
15972
|
+
}
|
|
15973
|
+
return [fieldType];
|
|
15974
|
+
};
|
|
15975
|
+
const found = /* @__PURE__ */ new Set();
|
|
15976
|
+
const inProgress = /* @__PURE__ */ new Set();
|
|
15977
|
+
const visit = (depType) => {
|
|
15978
|
+
if (inProgress.has(depType)) {
|
|
15979
|
+
throw new Error(`Cannot encode type ${depType}: it refers to itself`);
|
|
15980
|
+
}
|
|
15981
|
+
if (!types[depType] || found.has(depType)) return;
|
|
15982
|
+
found.add(depType);
|
|
15983
|
+
inProgress.add(depType);
|
|
15984
|
+
types[depType].forEach(
|
|
15985
|
+
(field) => pointedTypes(field.type, field.contains).forEach(visit)
|
|
15986
|
+
);
|
|
15987
|
+
inProgress.delete(depType);
|
|
15988
|
+
};
|
|
15989
|
+
pointedTypes(type, contains).filter((depType) => !dependencies.includes(depType)).forEach(visit);
|
|
15990
|
+
return Array.from(found);
|
|
15975
15991
|
}
|
|
15976
15992
|
function getMerkleTreeType(types, ctx) {
|
|
15977
15993
|
if (ctx.parent && ctx.key) {
|
|
@@ -15989,6 +16005,11 @@ function getMerkleTreeType(types, ctx) {
|
|
|
15989
16005
|
return "raw";
|
|
15990
16006
|
}
|
|
15991
16007
|
function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16008
|
+
if (Object.keys(types).length > TYPED_DATA_MAX_TYPES) {
|
|
16009
|
+
throw new Error(
|
|
16010
|
+
`Cannot encode type ${type}: more than ${TYPED_DATA_MAX_TYPES} types are declared`
|
|
16011
|
+
);
|
|
16012
|
+
}
|
|
15992
16013
|
const allTypes = revision === api_exports.TypedDataRevision.ACTIVE ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
15993
16014
|
const [primary, ...dependencies] = getDependencies(
|
|
15994
16015
|
allTypes,
|
|
@@ -15999,7 +16020,7 @@ function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY
|
|
|
15999
16020
|
);
|
|
16000
16021
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
16001
16022
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
16002
|
-
|
|
16023
|
+
const encoded = newTypes.map((dependency) => {
|
|
16003
16024
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
16004
16025
|
const targetType = t.type === "enum" && revision === api_exports.TypedDataRevision.ACTIVE ? t.contains : t.type;
|
|
16005
16026
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
@@ -16007,139 +16028,148 @@ function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY
|
|
|
16007
16028
|
});
|
|
16008
16029
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
16009
16030
|
}).join("");
|
|
16031
|
+
spend(Math.ceil(encoded.length / TEXT_TO_FELT_MAX_LEN));
|
|
16032
|
+
return encoded;
|
|
16010
16033
|
}
|
|
16011
16034
|
function getTypeHash(types, type, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16012
16035
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
16013
16036
|
}
|
|
16014
16037
|
function encodeValue(types, type, data, ctx = {}, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
16019
|
-
return [
|
|
16020
|
-
type,
|
|
16021
|
-
getStructHash(
|
|
16022
|
-
revisionConfiguration[revision].presetTypes,
|
|
16023
|
-
type,
|
|
16024
|
-
data,
|
|
16025
|
-
revision
|
|
16026
|
-
)
|
|
16027
|
-
];
|
|
16028
|
-
}
|
|
16029
|
-
if (type.endsWith("*")) {
|
|
16030
|
-
const hashes = data.map(
|
|
16031
|
-
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
16038
|
+
return withBudget(() => {
|
|
16039
|
+
spend(
|
|
16040
|
+
typeof data === "string" ? Math.max(1, Math.ceil(data.length / TEXT_TO_FELT_MAX_LEN) - 2) : 1
|
|
16032
16041
|
);
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
|
|
16041
|
-
const variantType = enumType.find((t) => t.name === variantKey);
|
|
16042
|
-
const variantIndex = enumType.indexOf(variantType);
|
|
16043
|
-
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
16044
|
-
if (!subtype) return subtype;
|
|
16045
|
-
const subtypeData = variantData[index];
|
|
16046
|
-
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
16047
|
-
});
|
|
16048
|
-
return [
|
|
16042
|
+
if (types[type]) {
|
|
16043
|
+
return [type, getStructHash(types, type, data, revision)];
|
|
16044
|
+
}
|
|
16045
|
+
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
16046
|
+
return [
|
|
16047
|
+
type,
|
|
16048
|
+
getStructHash(
|
|
16049
|
+
revisionConfiguration[revision].presetTypes,
|
|
16049
16050
|
type,
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16051
|
+
data,
|
|
16052
|
+
revision
|
|
16053
|
+
)
|
|
16054
|
+
];
|
|
16054
16055
|
}
|
|
16055
|
-
|
|
16056
|
-
const
|
|
16057
|
-
|
|
16058
|
-
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
16059
|
-
});
|
|
16060
|
-
const { root } = new MerkleTree(
|
|
16061
|
-
structHashes,
|
|
16062
|
-
revisionConfiguration[revision].hashMerkleMethod
|
|
16056
|
+
if (type.endsWith("*")) {
|
|
16057
|
+
const hashes = data.map(
|
|
16058
|
+
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
16063
16059
|
);
|
|
16064
|
-
return [
|
|
16065
|
-
}
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
|
|
16060
|
+
return [type, revisionConfiguration[revision].hashMethod(hashes)];
|
|
16061
|
+
}
|
|
16062
|
+
switch (type) {
|
|
16063
|
+
case "enum": {
|
|
16064
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16065
|
+
const [variantKey, variantData] = Object.entries(data)[0];
|
|
16066
|
+
const parentType = types[ctx.parent].find((t) => t.name === ctx.key);
|
|
16067
|
+
const enumType = types[parentType.contains];
|
|
16068
|
+
const variantType = enumType.find((t) => t.name === variantKey);
|
|
16069
|
+
const variantIndex = enumType.indexOf(variantType);
|
|
16070
|
+
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
16071
|
+
if (!subtype) return subtype;
|
|
16072
|
+
const subtypeData = variantData[index];
|
|
16073
|
+
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
16074
|
+
});
|
|
16075
|
+
return [
|
|
16076
|
+
type,
|
|
16077
|
+
revisionConfiguration[revision].hashMethod([variantIndex, ...encodedSubtypes])
|
|
16078
|
+
];
|
|
16079
|
+
}
|
|
16080
|
+
return [type, getHex(data)];
|
|
16079
16081
|
}
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16082
|
+
case "merkletree": {
|
|
16083
|
+
const merkleTreeType = getMerkleTreeType(types, ctx);
|
|
16084
|
+
const structHashes = data.map((struct) => {
|
|
16085
|
+
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
16086
|
+
});
|
|
16087
|
+
const { root } = new MerkleTree(
|
|
16088
|
+
structHashes,
|
|
16089
|
+
revisionConfiguration[revision].hashMerkleMethod
|
|
16090
|
+
);
|
|
16091
|
+
return ["felt", root];
|
|
16087
16092
|
}
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
case "timestamp":
|
|
16091
|
-
case "u128": {
|
|
16092
|
-
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16093
|
-
assertRange(data, type, RANGE_U128);
|
|
16093
|
+
case "selector": {
|
|
16094
|
+
return ["felt", prepareSelector(data)];
|
|
16094
16095
|
}
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16096
|
+
case "string": {
|
|
16097
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16098
|
+
const byteArray = byteArrayFromString(data);
|
|
16099
|
+
const elements = [
|
|
16100
|
+
byteArray.data.length,
|
|
16101
|
+
...byteArray.data,
|
|
16102
|
+
byteArray.pending_word,
|
|
16103
|
+
byteArray.pending_word_len
|
|
16104
|
+
];
|
|
16105
|
+
return [type, revisionConfiguration[revision].hashMethod(elements)];
|
|
16106
|
+
}
|
|
16107
|
+
return [type, getHex(data)];
|
|
16101
16108
|
}
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
|
|
16105
|
-
|
|
16106
|
-
|
|
16107
|
-
|
|
16109
|
+
case "i128": {
|
|
16110
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16111
|
+
const value = BigInt(data);
|
|
16112
|
+
assertRange(value, type, RANGE_I128);
|
|
16113
|
+
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
16114
|
+
}
|
|
16115
|
+
return [type, getHex(data)];
|
|
16108
16116
|
}
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16117
|
+
case "timestamp":
|
|
16118
|
+
case "u128": {
|
|
16119
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16120
|
+
assertRange(data, type, RANGE_U128);
|
|
16121
|
+
}
|
|
16122
|
+
return [type, getHex(data)];
|
|
16114
16123
|
}
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
|
|
16124
|
+
case "felt":
|
|
16125
|
+
case "shortstring": {
|
|
16126
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16127
|
+
assertRange(getHex(data), type, RANGE_FELT);
|
|
16128
|
+
}
|
|
16129
|
+
return [type, getHex(data)];
|
|
16130
|
+
}
|
|
16131
|
+
case "ClassHash":
|
|
16132
|
+
case "ContractAddress": {
|
|
16133
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16134
|
+
assertRange(data, type, RANGE_FELT);
|
|
16135
|
+
}
|
|
16136
|
+
return [type, getHex(data)];
|
|
16137
|
+
}
|
|
16138
|
+
case "bool": {
|
|
16139
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16140
|
+
assert(isBoolean(data), `Type mismatch for ${type} ${data}`);
|
|
16141
|
+
}
|
|
16142
|
+
return [type, getHex(data)];
|
|
16143
|
+
}
|
|
16144
|
+
default: {
|
|
16145
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16146
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
16147
|
+
}
|
|
16148
|
+
return [type, getHex(data)];
|
|
16120
16149
|
}
|
|
16121
|
-
return [type, getHex(data)];
|
|
16122
16150
|
}
|
|
16123
|
-
}
|
|
16151
|
+
});
|
|
16124
16152
|
}
|
|
16125
16153
|
function encodeData(types, type, data, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
[
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16154
|
+
return withBudget(() => {
|
|
16155
|
+
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
16156
|
+
const [returnTypes, values] = targetType.reduce(
|
|
16157
|
+
([ts, vs], field) => {
|
|
16158
|
+
if (data[field.name] === void 0 || data[field.name] === null && field.type !== "enum") {
|
|
16159
|
+
throw new Error(`Cannot encode data: missing data for '${field.name}'`);
|
|
16160
|
+
}
|
|
16161
|
+
const value = data[field.name];
|
|
16162
|
+
const ctx = { parent: type, key: field.name };
|
|
16163
|
+
const [t, encodedValue] = encodeValue(types, field.type, value, ctx, revision);
|
|
16164
|
+
return [
|
|
16165
|
+
[...ts, t],
|
|
16166
|
+
[...vs, encodedValue]
|
|
16167
|
+
];
|
|
16168
|
+
},
|
|
16169
|
+
[["felt"], [getTypeHash(types, type, revision)]]
|
|
16170
|
+
);
|
|
16171
|
+
return [returnTypes, values];
|
|
16172
|
+
});
|
|
16143
16173
|
}
|
|
16144
16174
|
function getStructHash(types, type, data, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16145
16175
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
@@ -16150,13 +16180,15 @@ function getMessageHash(typedData, accountAddress) {
|
|
|
16150
16180
|
}
|
|
16151
16181
|
const revision = identifyRevision(typedData);
|
|
16152
16182
|
const { domain, hashMethod } = revisionConfiguration[revision];
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16183
|
+
return withBudget(() => {
|
|
16184
|
+
const message = [
|
|
16185
|
+
utf8ToBigInt("StarkNet Message"),
|
|
16186
|
+
getStructHash(typedData.types, domain, typedData.domain, revision),
|
|
16187
|
+
accountAddress,
|
|
16188
|
+
getStructHash(typedData.types, typedData.primaryType, typedData.message, revision)
|
|
16189
|
+
];
|
|
16190
|
+
return hashMethod(message);
|
|
16191
|
+
});
|
|
16160
16192
|
}
|
|
16161
16193
|
function verifyMessage(message, signature, fullPublicKey, accountAddress) {
|
|
16162
16194
|
const isTypedData = validateTypedData(message);
|
|
@@ -18001,18 +18033,92 @@ var RpcProvider = class {
|
|
|
18001
18033
|
}
|
|
18002
18034
|
return { cairo: "0", compiler: "0" };
|
|
18003
18035
|
}
|
|
18036
|
+
/**
|
|
18037
|
+
* Estimates the fee for a given INVOKE transaction
|
|
18038
|
+
*
|
|
18039
|
+
* @param invocation the invocation object containing:
|
|
18040
|
+
* - contractAddress - the address of the contract
|
|
18041
|
+
* - entrypoint - (optional) the entrypoint of the contract
|
|
18042
|
+
* - calldata - (optional, defaults to []) the calldata
|
|
18043
|
+
* - signature - (optional, defaults to []) the signature
|
|
18044
|
+
* @param details - optional details containing:
|
|
18045
|
+
* - nonce - optional nonce
|
|
18046
|
+
* - version - optional version
|
|
18047
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18048
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18049
|
+
* @returns the estimated fee
|
|
18050
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18051
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18052
|
+
* This method will be removed in a future major version, not before v13.
|
|
18053
|
+
* @example
|
|
18054
|
+
* ```typescript
|
|
18055
|
+
* const feeEstimate = await provider.getInvokeEstimateFee(invocation, details);
|
|
18056
|
+
* // Equivalent to:
|
|
18057
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.INVOKE, ...invocation, ...details }]);
|
|
18058
|
+
* ```
|
|
18059
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18060
|
+
*/
|
|
18004
18061
|
async getInvokeEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18005
18062
|
return (await this.getEstimateFeeBulk(
|
|
18006
18063
|
[{ type: api_exports.ETransactionType.INVOKE, ...invocation, ...details }],
|
|
18007
18064
|
{ blockIdentifier, skipValidate }
|
|
18008
18065
|
))[0];
|
|
18009
18066
|
}
|
|
18067
|
+
/**
|
|
18068
|
+
* Estimates the fee for a given DECLARE transaction
|
|
18069
|
+
*
|
|
18070
|
+
* @param invocation transaction payload to be declared containing:
|
|
18071
|
+
* - compiled contract code
|
|
18072
|
+
* - sender address
|
|
18073
|
+
* - signature - (defaults to []) the signature
|
|
18074
|
+
* @param details - optional details containing:
|
|
18075
|
+
* - nonce
|
|
18076
|
+
* - version - optional version
|
|
18077
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18078
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18079
|
+
* @returns the estimated fee
|
|
18080
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18081
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18082
|
+
* This method will be removed in a future major version, not before v13.
|
|
18083
|
+
* @example
|
|
18084
|
+
* ```typescript
|
|
18085
|
+
* const feeEstimate = await provider.getDeclareEstimateFee(transaction, details);
|
|
18086
|
+
* // Equivalent to:
|
|
18087
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DECLARE, ...transaction, ...details }]);
|
|
18088
|
+
* ```
|
|
18089
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18090
|
+
*/
|
|
18010
18091
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18011
18092
|
return (await this.getEstimateFeeBulk(
|
|
18012
18093
|
[{ type: api_exports.ETransactionType.DECLARE, ...invocation, ...details }],
|
|
18013
18094
|
{ blockIdentifier, skipValidate }
|
|
18014
18095
|
))[0];
|
|
18015
18096
|
}
|
|
18097
|
+
/**
|
|
18098
|
+
* Estimates the fee for a given DEPLOY_ACCOUNT transaction
|
|
18099
|
+
*
|
|
18100
|
+
* @param invocation transaction payload to be deployed containing:
|
|
18101
|
+
* - classHash
|
|
18102
|
+
* - constructorCalldata
|
|
18103
|
+
* - addressSalt
|
|
18104
|
+
* - signature - (defaults to []) the signature
|
|
18105
|
+
* @param details - optional details containing:
|
|
18106
|
+
* - nonce
|
|
18107
|
+
* - version - optional version
|
|
18108
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18109
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18110
|
+
* @returns the estimated fee
|
|
18111
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18112
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18113
|
+
* This method will be removed in a future major version, not before v13.
|
|
18114
|
+
* @example
|
|
18115
|
+
* ```typescript
|
|
18116
|
+
* const feeEstimate = await provider.getDeployAccountEstimateFee(transaction, details);
|
|
18117
|
+
* // Equivalent to:
|
|
18118
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DEPLOY_ACCOUNT, ...transaction, ...details }]);
|
|
18119
|
+
* ```
|
|
18120
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18121
|
+
*/
|
|
18016
18122
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18017
18123
|
return (await this.getEstimateFeeBulk(
|
|
18018
18124
|
[{ type: api_exports.ETransactionType.DEPLOY_ACCOUNT, ...invocation, ...details }],
|