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.js
CHANGED
|
@@ -272,6 +272,8 @@ __export(constants_exports, {
|
|
|
272
272
|
StarknetChainId: () => _StarknetChainId,
|
|
273
273
|
SupportedRpcVersion: () => _SupportedRpcVersion,
|
|
274
274
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
275
|
+
TYPED_DATA_MAX_HASHED_FELTS: () => TYPED_DATA_MAX_HASHED_FELTS,
|
|
276
|
+
TYPED_DATA_MAX_TYPES: () => TYPED_DATA_MAX_TYPES,
|
|
275
277
|
TransactionHashPrefix: () => _TransactionHashPrefix,
|
|
276
278
|
UDC: () => UDC,
|
|
277
279
|
ZERO: () => ZERO
|
|
@@ -501,6 +503,8 @@ var UDC = {
|
|
|
501
503
|
var OutsideExecutionCallerAny = "0x414e595f43414c4c4552";
|
|
502
504
|
var SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181";
|
|
503
505
|
var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
|
|
506
|
+
var TYPED_DATA_MAX_TYPES = 64;
|
|
507
|
+
var TYPED_DATA_MAX_HASHED_FELTS = 13500;
|
|
504
508
|
var HARDENING_BYTE = 128;
|
|
505
509
|
var HARDENING_4BYTES = 2147483648n;
|
|
506
510
|
var _NetworkName = {
|
|
@@ -16111,6 +16115,23 @@ var revisionConfiguration = {
|
|
|
16111
16115
|
presetTypes: {}
|
|
16112
16116
|
}
|
|
16113
16117
|
};
|
|
16118
|
+
var feltsLeft;
|
|
16119
|
+
function spend(felts) {
|
|
16120
|
+
if (feltsLeft === void 0) return;
|
|
16121
|
+
feltsLeft -= felts;
|
|
16122
|
+
if (feltsLeft < 0) {
|
|
16123
|
+
throw new Error(`Cannot encode data: more than ${TYPED_DATA_MAX_HASHED_FELTS} felts to hash`);
|
|
16124
|
+
}
|
|
16125
|
+
}
|
|
16126
|
+
function withBudget(encode) {
|
|
16127
|
+
if (feltsLeft !== void 0) return encode();
|
|
16128
|
+
feltsLeft = TYPED_DATA_MAX_HASHED_FELTS;
|
|
16129
|
+
try {
|
|
16130
|
+
return encode();
|
|
16131
|
+
} finally {
|
|
16132
|
+
feltsLeft = void 0;
|
|
16133
|
+
}
|
|
16134
|
+
}
|
|
16114
16135
|
function assertRange(data, type, { min, max }) {
|
|
16115
16136
|
const value = BigInt(data);
|
|
16116
16137
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
@@ -16151,35 +16172,30 @@ function isMerkleTreeType(type) {
|
|
|
16151
16172
|
return type.type === "merkletree";
|
|
16152
16173
|
}
|
|
16153
16174
|
function getDependencies(types, type, dependencies = [], contains = "", revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
)
|
|
16179
|
-
].filter((dependency) => !p.includes(dependency))
|
|
16180
|
-
],
|
|
16181
|
-
[]
|
|
16182
|
-
);
|
|
16175
|
+
const pointedTypes = (fieldType, fieldContains = "") => {
|
|
16176
|
+
if (fieldType.endsWith("*")) return [fieldType.slice(0, -1)];
|
|
16177
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE && fieldType === "enum") return [fieldContains];
|
|
16178
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE && /^\(.*\)$/.test(fieldType)) {
|
|
16179
|
+
return fieldType.slice(1, -1).split(",").map((param) => param.endsWith("*") ? param.slice(0, -1) : param);
|
|
16180
|
+
}
|
|
16181
|
+
return [fieldType];
|
|
16182
|
+
};
|
|
16183
|
+
const found = /* @__PURE__ */ new Set();
|
|
16184
|
+
const inProgress = /* @__PURE__ */ new Set();
|
|
16185
|
+
const visit = (depType) => {
|
|
16186
|
+
if (inProgress.has(depType)) {
|
|
16187
|
+
throw new Error(`Cannot encode type ${depType}: it refers to itself`);
|
|
16188
|
+
}
|
|
16189
|
+
if (!types[depType] || found.has(depType)) return;
|
|
16190
|
+
found.add(depType);
|
|
16191
|
+
inProgress.add(depType);
|
|
16192
|
+
types[depType].forEach(
|
|
16193
|
+
(field) => pointedTypes(field.type, field.contains).forEach(visit)
|
|
16194
|
+
);
|
|
16195
|
+
inProgress.delete(depType);
|
|
16196
|
+
};
|
|
16197
|
+
pointedTypes(type, contains).filter((depType) => !dependencies.includes(depType)).forEach(visit);
|
|
16198
|
+
return Array.from(found);
|
|
16183
16199
|
}
|
|
16184
16200
|
function getMerkleTreeType(types, ctx) {
|
|
16185
16201
|
if (ctx.parent && ctx.key) {
|
|
@@ -16197,6 +16213,11 @@ function getMerkleTreeType(types, ctx) {
|
|
|
16197
16213
|
return "raw";
|
|
16198
16214
|
}
|
|
16199
16215
|
function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16216
|
+
if (Object.keys(types).length > TYPED_DATA_MAX_TYPES) {
|
|
16217
|
+
throw new Error(
|
|
16218
|
+
`Cannot encode type ${type}: more than ${TYPED_DATA_MAX_TYPES} types are declared`
|
|
16219
|
+
);
|
|
16220
|
+
}
|
|
16200
16221
|
const allTypes = revision === api_exports.TypedDataRevision.ACTIVE ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
16201
16222
|
const [primary, ...dependencies] = getDependencies(
|
|
16202
16223
|
allTypes,
|
|
@@ -16207,7 +16228,7 @@ function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY
|
|
|
16207
16228
|
);
|
|
16208
16229
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
16209
16230
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
16210
|
-
|
|
16231
|
+
const encoded = newTypes.map((dependency) => {
|
|
16211
16232
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
16212
16233
|
const targetType = t.type === "enum" && revision === api_exports.TypedDataRevision.ACTIVE ? t.contains : t.type;
|
|
16213
16234
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
@@ -16215,139 +16236,148 @@ function encodeType(types, type, revision = api_exports.TypedDataRevision.LEGACY
|
|
|
16215
16236
|
});
|
|
16216
16237
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
16217
16238
|
}).join("");
|
|
16239
|
+
spend(Math.ceil(encoded.length / TEXT_TO_FELT_MAX_LEN));
|
|
16240
|
+
return encoded;
|
|
16218
16241
|
}
|
|
16219
16242
|
function getTypeHash(types, type, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16220
16243
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
16221
16244
|
}
|
|
16222
16245
|
function encodeValue(types, type, data, ctx = {}, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
16227
|
-
return [
|
|
16228
|
-
type,
|
|
16229
|
-
getStructHash(
|
|
16230
|
-
revisionConfiguration[revision].presetTypes,
|
|
16231
|
-
type,
|
|
16232
|
-
data,
|
|
16233
|
-
revision
|
|
16234
|
-
)
|
|
16235
|
-
];
|
|
16236
|
-
}
|
|
16237
|
-
if (type.endsWith("*")) {
|
|
16238
|
-
const hashes = data.map(
|
|
16239
|
-
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
16246
|
+
return withBudget(() => {
|
|
16247
|
+
spend(
|
|
16248
|
+
typeof data === "string" ? Math.max(1, Math.ceil(data.length / TEXT_TO_FELT_MAX_LEN) - 2) : 1
|
|
16240
16249
|
);
|
|
16241
|
-
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
|
|
16247
|
-
|
|
16248
|
-
|
|
16249
|
-
const variantType = enumType.find((t) => t.name === variantKey);
|
|
16250
|
-
const variantIndex = enumType.indexOf(variantType);
|
|
16251
|
-
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
16252
|
-
if (!subtype) return subtype;
|
|
16253
|
-
const subtypeData = variantData[index];
|
|
16254
|
-
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
16255
|
-
});
|
|
16256
|
-
return [
|
|
16250
|
+
if (types[type]) {
|
|
16251
|
+
return [type, getStructHash(types, type, data, revision)];
|
|
16252
|
+
}
|
|
16253
|
+
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
16254
|
+
return [
|
|
16255
|
+
type,
|
|
16256
|
+
getStructHash(
|
|
16257
|
+
revisionConfiguration[revision].presetTypes,
|
|
16257
16258
|
type,
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16259
|
+
data,
|
|
16260
|
+
revision
|
|
16261
|
+
)
|
|
16262
|
+
];
|
|
16262
16263
|
}
|
|
16263
|
-
|
|
16264
|
-
const
|
|
16265
|
-
|
|
16266
|
-
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
16267
|
-
});
|
|
16268
|
-
const { root } = new MerkleTree(
|
|
16269
|
-
structHashes,
|
|
16270
|
-
revisionConfiguration[revision].hashMerkleMethod
|
|
16264
|
+
if (type.endsWith("*")) {
|
|
16265
|
+
const hashes = data.map(
|
|
16266
|
+
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
16271
16267
|
);
|
|
16272
|
-
return [
|
|
16273
|
-
}
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16268
|
+
return [type, revisionConfiguration[revision].hashMethod(hashes)];
|
|
16269
|
+
}
|
|
16270
|
+
switch (type) {
|
|
16271
|
+
case "enum": {
|
|
16272
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16273
|
+
const [variantKey, variantData] = Object.entries(data)[0];
|
|
16274
|
+
const parentType = types[ctx.parent].find((t) => t.name === ctx.key);
|
|
16275
|
+
const enumType = types[parentType.contains];
|
|
16276
|
+
const variantType = enumType.find((t) => t.name === variantKey);
|
|
16277
|
+
const variantIndex = enumType.indexOf(variantType);
|
|
16278
|
+
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
16279
|
+
if (!subtype) return subtype;
|
|
16280
|
+
const subtypeData = variantData[index];
|
|
16281
|
+
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
16282
|
+
});
|
|
16283
|
+
return [
|
|
16284
|
+
type,
|
|
16285
|
+
revisionConfiguration[revision].hashMethod([variantIndex, ...encodedSubtypes])
|
|
16286
|
+
];
|
|
16287
|
+
}
|
|
16288
|
+
return [type, getHex(data)];
|
|
16287
16289
|
}
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16290
|
+
case "merkletree": {
|
|
16291
|
+
const merkleTreeType = getMerkleTreeType(types, ctx);
|
|
16292
|
+
const structHashes = data.map((struct) => {
|
|
16293
|
+
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
16294
|
+
});
|
|
16295
|
+
const { root } = new MerkleTree(
|
|
16296
|
+
structHashes,
|
|
16297
|
+
revisionConfiguration[revision].hashMerkleMethod
|
|
16298
|
+
);
|
|
16299
|
+
return ["felt", root];
|
|
16295
16300
|
}
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
case "timestamp":
|
|
16299
|
-
case "u128": {
|
|
16300
|
-
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16301
|
-
assertRange(data, type, RANGE_U128);
|
|
16301
|
+
case "selector": {
|
|
16302
|
+
return ["felt", prepareSelector(data)];
|
|
16302
16303
|
}
|
|
16303
|
-
|
|
16304
|
-
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16308
|
-
|
|
16304
|
+
case "string": {
|
|
16305
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16306
|
+
const byteArray = byteArrayFromString(data);
|
|
16307
|
+
const elements = [
|
|
16308
|
+
byteArray.data.length,
|
|
16309
|
+
...byteArray.data,
|
|
16310
|
+
byteArray.pending_word,
|
|
16311
|
+
byteArray.pending_word_len
|
|
16312
|
+
];
|
|
16313
|
+
return [type, revisionConfiguration[revision].hashMethod(elements)];
|
|
16314
|
+
}
|
|
16315
|
+
return [type, getHex(data)];
|
|
16309
16316
|
}
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16317
|
+
case "i128": {
|
|
16318
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16319
|
+
const value = BigInt(data);
|
|
16320
|
+
assertRange(value, type, RANGE_I128);
|
|
16321
|
+
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
16322
|
+
}
|
|
16323
|
+
return [type, getHex(data)];
|
|
16316
16324
|
}
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16325
|
+
case "timestamp":
|
|
16326
|
+
case "u128": {
|
|
16327
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16328
|
+
assertRange(data, type, RANGE_U128);
|
|
16329
|
+
}
|
|
16330
|
+
return [type, getHex(data)];
|
|
16322
16331
|
}
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16332
|
+
case "felt":
|
|
16333
|
+
case "shortstring": {
|
|
16334
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16335
|
+
assertRange(getHex(data), type, RANGE_FELT);
|
|
16336
|
+
}
|
|
16337
|
+
return [type, getHex(data)];
|
|
16338
|
+
}
|
|
16339
|
+
case "ClassHash":
|
|
16340
|
+
case "ContractAddress": {
|
|
16341
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16342
|
+
assertRange(data, type, RANGE_FELT);
|
|
16343
|
+
}
|
|
16344
|
+
return [type, getHex(data)];
|
|
16345
|
+
}
|
|
16346
|
+
case "bool": {
|
|
16347
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16348
|
+
assert(isBoolean(data), `Type mismatch for ${type} ${data}`);
|
|
16349
|
+
}
|
|
16350
|
+
return [type, getHex(data)];
|
|
16351
|
+
}
|
|
16352
|
+
default: {
|
|
16353
|
+
if (revision === api_exports.TypedDataRevision.ACTIVE) {
|
|
16354
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
16355
|
+
}
|
|
16356
|
+
return [type, getHex(data)];
|
|
16328
16357
|
}
|
|
16329
|
-
return [type, getHex(data)];
|
|
16330
16358
|
}
|
|
16331
|
-
}
|
|
16359
|
+
});
|
|
16332
16360
|
}
|
|
16333
16361
|
function encodeData(types, type, data, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16342
|
-
|
|
16343
|
-
|
|
16344
|
-
[
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16362
|
+
return withBudget(() => {
|
|
16363
|
+
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
16364
|
+
const [returnTypes, values] = targetType.reduce(
|
|
16365
|
+
([ts, vs], field) => {
|
|
16366
|
+
if (data[field.name] === void 0 || data[field.name] === null && field.type !== "enum") {
|
|
16367
|
+
throw new Error(`Cannot encode data: missing data for '${field.name}'`);
|
|
16368
|
+
}
|
|
16369
|
+
const value = data[field.name];
|
|
16370
|
+
const ctx = { parent: type, key: field.name };
|
|
16371
|
+
const [t, encodedValue] = encodeValue(types, field.type, value, ctx, revision);
|
|
16372
|
+
return [
|
|
16373
|
+
[...ts, t],
|
|
16374
|
+
[...vs, encodedValue]
|
|
16375
|
+
];
|
|
16376
|
+
},
|
|
16377
|
+
[["felt"], [getTypeHash(types, type, revision)]]
|
|
16378
|
+
);
|
|
16379
|
+
return [returnTypes, values];
|
|
16380
|
+
});
|
|
16351
16381
|
}
|
|
16352
16382
|
function getStructHash(types, type, data, revision = api_exports.TypedDataRevision.LEGACY) {
|
|
16353
16383
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
@@ -16358,13 +16388,15 @@ function getMessageHash(typedData, accountAddress) {
|
|
|
16358
16388
|
}
|
|
16359
16389
|
const revision = identifyRevision(typedData);
|
|
16360
16390
|
const { domain, hashMethod } = revisionConfiguration[revision];
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16391
|
+
return withBudget(() => {
|
|
16392
|
+
const message = [
|
|
16393
|
+
utf8ToBigInt("StarkNet Message"),
|
|
16394
|
+
getStructHash(typedData.types, domain, typedData.domain, revision),
|
|
16395
|
+
accountAddress,
|
|
16396
|
+
getStructHash(typedData.types, typedData.primaryType, typedData.message, revision)
|
|
16397
|
+
];
|
|
16398
|
+
return hashMethod(message);
|
|
16399
|
+
});
|
|
16368
16400
|
}
|
|
16369
16401
|
function verifyMessage(message, signature, fullPublicKey, accountAddress) {
|
|
16370
16402
|
const isTypedData = validateTypedData(message);
|
|
@@ -18209,18 +18241,92 @@ var RpcProvider = class {
|
|
|
18209
18241
|
}
|
|
18210
18242
|
return { cairo: "0", compiler: "0" };
|
|
18211
18243
|
}
|
|
18244
|
+
/**
|
|
18245
|
+
* Estimates the fee for a given INVOKE transaction
|
|
18246
|
+
*
|
|
18247
|
+
* @param invocation the invocation object containing:
|
|
18248
|
+
* - contractAddress - the address of the contract
|
|
18249
|
+
* - entrypoint - (optional) the entrypoint of the contract
|
|
18250
|
+
* - calldata - (optional, defaults to []) the calldata
|
|
18251
|
+
* - signature - (optional, defaults to []) the signature
|
|
18252
|
+
* @param details - optional details containing:
|
|
18253
|
+
* - nonce - optional nonce
|
|
18254
|
+
* - version - optional version
|
|
18255
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18256
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18257
|
+
* @returns the estimated fee
|
|
18258
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18259
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18260
|
+
* This method will be removed in a future major version, not before v13.
|
|
18261
|
+
* @example
|
|
18262
|
+
* ```typescript
|
|
18263
|
+
* const feeEstimate = await provider.getInvokeEstimateFee(invocation, details);
|
|
18264
|
+
* // Equivalent to:
|
|
18265
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.INVOKE, ...invocation, ...details }]);
|
|
18266
|
+
* ```
|
|
18267
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18268
|
+
*/
|
|
18212
18269
|
async getInvokeEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18213
18270
|
return (await this.getEstimateFeeBulk(
|
|
18214
18271
|
[{ type: api_exports.ETransactionType.INVOKE, ...invocation, ...details }],
|
|
18215
18272
|
{ blockIdentifier, skipValidate }
|
|
18216
18273
|
))[0];
|
|
18217
18274
|
}
|
|
18275
|
+
/**
|
|
18276
|
+
* Estimates the fee for a given DECLARE transaction
|
|
18277
|
+
*
|
|
18278
|
+
* @param invocation transaction payload to be declared containing:
|
|
18279
|
+
* - compiled contract code
|
|
18280
|
+
* - sender address
|
|
18281
|
+
* - signature - (defaults to []) the signature
|
|
18282
|
+
* @param details - optional details containing:
|
|
18283
|
+
* - nonce
|
|
18284
|
+
* - version - optional version
|
|
18285
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18286
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18287
|
+
* @returns the estimated fee
|
|
18288
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18289
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18290
|
+
* This method will be removed in a future major version, not before v13.
|
|
18291
|
+
* @example
|
|
18292
|
+
* ```typescript
|
|
18293
|
+
* const feeEstimate = await provider.getDeclareEstimateFee(transaction, details);
|
|
18294
|
+
* // Equivalent to:
|
|
18295
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DECLARE, ...transaction, ...details }]);
|
|
18296
|
+
* ```
|
|
18297
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18298
|
+
*/
|
|
18218
18299
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18219
18300
|
return (await this.getEstimateFeeBulk(
|
|
18220
18301
|
[{ type: api_exports.ETransactionType.DECLARE, ...invocation, ...details }],
|
|
18221
18302
|
{ blockIdentifier, skipValidate }
|
|
18222
18303
|
))[0];
|
|
18223
18304
|
}
|
|
18305
|
+
/**
|
|
18306
|
+
* Estimates the fee for a given DEPLOY_ACCOUNT transaction
|
|
18307
|
+
*
|
|
18308
|
+
* @param invocation transaction payload to be deployed containing:
|
|
18309
|
+
* - classHash
|
|
18310
|
+
* - constructorCalldata
|
|
18311
|
+
* - addressSalt
|
|
18312
|
+
* - signature - (defaults to []) the signature
|
|
18313
|
+
* @param details - optional details containing:
|
|
18314
|
+
* - nonce
|
|
18315
|
+
* - version - optional version
|
|
18316
|
+
* @param blockIdentifier - (optional) block identifier
|
|
18317
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
18318
|
+
* @returns the estimated fee
|
|
18319
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
18320
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
18321
|
+
* This method will be removed in a future major version, not before v13.
|
|
18322
|
+
* @example
|
|
18323
|
+
* ```typescript
|
|
18324
|
+
* const feeEstimate = await provider.getDeployAccountEstimateFee(transaction, details);
|
|
18325
|
+
* // Equivalent to:
|
|
18326
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DEPLOY_ACCOUNT, ...transaction, ...details }]);
|
|
18327
|
+
* ```
|
|
18328
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
18329
|
+
*/
|
|
18224
18330
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
18225
18331
|
return (await this.getEstimateFeeBulk(
|
|
18226
18332
|
[{ type: api_exports.ETransactionType.DEPLOY_ACCOUNT, ...invocation, ...details }],
|