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.global.js
CHANGED
|
@@ -286,6 +286,8 @@ var starknet = (() => {
|
|
|
286
286
|
StarknetChainId: () => _StarknetChainId,
|
|
287
287
|
SupportedRpcVersion: () => _SupportedRpcVersion,
|
|
288
288
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
289
|
+
TYPED_DATA_MAX_HASHED_FELTS: () => TYPED_DATA_MAX_HASHED_FELTS,
|
|
290
|
+
TYPED_DATA_MAX_TYPES: () => TYPED_DATA_MAX_TYPES,
|
|
289
291
|
TransactionHashPrefix: () => _TransactionHashPrefix,
|
|
290
292
|
UDC: () => UDC,
|
|
291
293
|
ZERO: () => ZERO
|
|
@@ -1251,6 +1253,8 @@ var starknet = (() => {
|
|
|
1251
1253
|
var OutsideExecutionCallerAny = "0x414e595f43414c4c4552";
|
|
1252
1254
|
var SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181";
|
|
1253
1255
|
var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
|
|
1256
|
+
var TYPED_DATA_MAX_TYPES = 64;
|
|
1257
|
+
var TYPED_DATA_MAX_HASHED_FELTS = 13500;
|
|
1254
1258
|
var HARDENING_BYTE = 128;
|
|
1255
1259
|
var HARDENING_4BYTES = 2147483648n;
|
|
1256
1260
|
var _NetworkName = {
|
|
@@ -21664,6 +21668,23 @@ ${indent}}` : "}";
|
|
|
21664
21668
|
presetTypes: {}
|
|
21665
21669
|
}
|
|
21666
21670
|
};
|
|
21671
|
+
var feltsLeft;
|
|
21672
|
+
function spend(felts) {
|
|
21673
|
+
if (feltsLeft === void 0) return;
|
|
21674
|
+
feltsLeft -= felts;
|
|
21675
|
+
if (feltsLeft < 0) {
|
|
21676
|
+
throw new Error(`Cannot encode data: more than ${TYPED_DATA_MAX_HASHED_FELTS} felts to hash`);
|
|
21677
|
+
}
|
|
21678
|
+
}
|
|
21679
|
+
function withBudget(encode) {
|
|
21680
|
+
if (feltsLeft !== void 0) return encode();
|
|
21681
|
+
feltsLeft = TYPED_DATA_MAX_HASHED_FELTS;
|
|
21682
|
+
try {
|
|
21683
|
+
return encode();
|
|
21684
|
+
} finally {
|
|
21685
|
+
feltsLeft = void 0;
|
|
21686
|
+
}
|
|
21687
|
+
}
|
|
21667
21688
|
function assertRange(data, type, { min, max }) {
|
|
21668
21689
|
const value = BigInt(data);
|
|
21669
21690
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
@@ -21704,35 +21725,30 @@ ${indent}}` : "}";
|
|
|
21704
21725
|
return type.type === "merkletree";
|
|
21705
21726
|
}
|
|
21706
21727
|
function getDependencies(types, type, dependencies = [], contains = "", revision = TypedDataRevision2.LEGACY) {
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
|
|
21724
|
-
|
|
21725
|
-
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21729
|
-
|
|
21730
|
-
|
|
21731
|
-
)
|
|
21732
|
-
].filter((dependency) => !p.includes(dependency))
|
|
21733
|
-
],
|
|
21734
|
-
[]
|
|
21735
|
-
);
|
|
21728
|
+
const pointedTypes = (fieldType, fieldContains = "") => {
|
|
21729
|
+
if (fieldType.endsWith("*")) return [fieldType.slice(0, -1)];
|
|
21730
|
+
if (revision === TypedDataRevision2.ACTIVE && fieldType === "enum") return [fieldContains];
|
|
21731
|
+
if (revision === TypedDataRevision2.ACTIVE && /^\(.*\)$/.test(fieldType)) {
|
|
21732
|
+
return fieldType.slice(1, -1).split(",").map((param) => param.endsWith("*") ? param.slice(0, -1) : param);
|
|
21733
|
+
}
|
|
21734
|
+
return [fieldType];
|
|
21735
|
+
};
|
|
21736
|
+
const found = /* @__PURE__ */ new Set();
|
|
21737
|
+
const inProgress = /* @__PURE__ */ new Set();
|
|
21738
|
+
const visit = (depType) => {
|
|
21739
|
+
if (inProgress.has(depType)) {
|
|
21740
|
+
throw new Error(`Cannot encode type ${depType}: it refers to itself`);
|
|
21741
|
+
}
|
|
21742
|
+
if (!types[depType] || found.has(depType)) return;
|
|
21743
|
+
found.add(depType);
|
|
21744
|
+
inProgress.add(depType);
|
|
21745
|
+
types[depType].forEach(
|
|
21746
|
+
(field) => pointedTypes(field.type, field.contains).forEach(visit)
|
|
21747
|
+
);
|
|
21748
|
+
inProgress.delete(depType);
|
|
21749
|
+
};
|
|
21750
|
+
pointedTypes(type, contains).filter((depType) => !dependencies.includes(depType)).forEach(visit);
|
|
21751
|
+
return Array.from(found);
|
|
21736
21752
|
}
|
|
21737
21753
|
function getMerkleTreeType(types, ctx) {
|
|
21738
21754
|
if (ctx.parent && ctx.key) {
|
|
@@ -21750,6 +21766,11 @@ ${indent}}` : "}";
|
|
|
21750
21766
|
return "raw";
|
|
21751
21767
|
}
|
|
21752
21768
|
function encodeType(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
21769
|
+
if (Object.keys(types).length > TYPED_DATA_MAX_TYPES) {
|
|
21770
|
+
throw new Error(
|
|
21771
|
+
`Cannot encode type ${type}: more than ${TYPED_DATA_MAX_TYPES} types are declared`
|
|
21772
|
+
);
|
|
21773
|
+
}
|
|
21753
21774
|
const allTypes = revision === TypedDataRevision2.ACTIVE ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
21754
21775
|
const [primary, ...dependencies] = getDependencies(
|
|
21755
21776
|
allTypes,
|
|
@@ -21760,7 +21781,7 @@ ${indent}}` : "}";
|
|
|
21760
21781
|
);
|
|
21761
21782
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
21762
21783
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
21763
|
-
|
|
21784
|
+
const encoded = newTypes.map((dependency) => {
|
|
21764
21785
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
21765
21786
|
const targetType = t.type === "enum" && revision === TypedDataRevision2.ACTIVE ? t.contains : t.type;
|
|
21766
21787
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
@@ -21768,139 +21789,148 @@ ${indent}}` : "}";
|
|
|
21768
21789
|
});
|
|
21769
21790
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
21770
21791
|
}).join("");
|
|
21792
|
+
spend(Math.ceil(encoded.length / TEXT_TO_FELT_MAX_LEN));
|
|
21793
|
+
return encoded;
|
|
21771
21794
|
}
|
|
21772
21795
|
function getTypeHash(types, type, revision = TypedDataRevision2.LEGACY) {
|
|
21773
21796
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
21774
21797
|
}
|
|
21775
21798
|
function encodeValue(types, type, data, ctx = {}, revision = TypedDataRevision2.LEGACY) {
|
|
21776
|
-
|
|
21777
|
-
|
|
21778
|
-
|
|
21779
|
-
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
21780
|
-
return [
|
|
21781
|
-
type,
|
|
21782
|
-
getStructHash(
|
|
21783
|
-
revisionConfiguration[revision].presetTypes,
|
|
21784
|
-
type,
|
|
21785
|
-
data,
|
|
21786
|
-
revision
|
|
21787
|
-
)
|
|
21788
|
-
];
|
|
21789
|
-
}
|
|
21790
|
-
if (type.endsWith("*")) {
|
|
21791
|
-
const hashes = data.map(
|
|
21792
|
-
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
21799
|
+
return withBudget(() => {
|
|
21800
|
+
spend(
|
|
21801
|
+
typeof data === "string" ? Math.max(1, Math.ceil(data.length / TEXT_TO_FELT_MAX_LEN) - 2) : 1
|
|
21793
21802
|
);
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
const variantType = enumType.find((t) => t.name === variantKey);
|
|
21803
|
-
const variantIndex = enumType.indexOf(variantType);
|
|
21804
|
-
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
21805
|
-
if (!subtype) return subtype;
|
|
21806
|
-
const subtypeData = variantData[index];
|
|
21807
|
-
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
21808
|
-
});
|
|
21809
|
-
return [
|
|
21803
|
+
if (types[type]) {
|
|
21804
|
+
return [type, getStructHash(types, type, data, revision)];
|
|
21805
|
+
}
|
|
21806
|
+
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
21807
|
+
return [
|
|
21808
|
+
type,
|
|
21809
|
+
getStructHash(
|
|
21810
|
+
revisionConfiguration[revision].presetTypes,
|
|
21810
21811
|
type,
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
|
|
21812
|
+
data,
|
|
21813
|
+
revision
|
|
21814
|
+
)
|
|
21815
|
+
];
|
|
21815
21816
|
}
|
|
21816
|
-
|
|
21817
|
-
const
|
|
21818
|
-
|
|
21819
|
-
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
21820
|
-
});
|
|
21821
|
-
const { root } = new MerkleTree(
|
|
21822
|
-
structHashes,
|
|
21823
|
-
revisionConfiguration[revision].hashMerkleMethod
|
|
21817
|
+
if (type.endsWith("*")) {
|
|
21818
|
+
const hashes = data.map(
|
|
21819
|
+
(entry) => encodeValue(types, type.slice(0, -1), entry, void 0, revision)[1]
|
|
21824
21820
|
);
|
|
21825
|
-
return [
|
|
21826
|
-
}
|
|
21827
|
-
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
|
|
21839
|
-
|
|
21821
|
+
return [type, revisionConfiguration[revision].hashMethod(hashes)];
|
|
21822
|
+
}
|
|
21823
|
+
switch (type) {
|
|
21824
|
+
case "enum": {
|
|
21825
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21826
|
+
const [variantKey, variantData] = Object.entries(data)[0];
|
|
21827
|
+
const parentType = types[ctx.parent].find((t) => t.name === ctx.key);
|
|
21828
|
+
const enumType = types[parentType.contains];
|
|
21829
|
+
const variantType = enumType.find((t) => t.name === variantKey);
|
|
21830
|
+
const variantIndex = enumType.indexOf(variantType);
|
|
21831
|
+
const encodedSubtypes = variantType.type.slice(1, -1).split(",").map((subtype, index) => {
|
|
21832
|
+
if (!subtype) return subtype;
|
|
21833
|
+
const subtypeData = variantData[index];
|
|
21834
|
+
return encodeValue(types, subtype, subtypeData, void 0, revision)[1];
|
|
21835
|
+
});
|
|
21836
|
+
return [
|
|
21837
|
+
type,
|
|
21838
|
+
revisionConfiguration[revision].hashMethod([variantIndex, ...encodedSubtypes])
|
|
21839
|
+
];
|
|
21840
|
+
}
|
|
21841
|
+
return [type, getHex(data)];
|
|
21840
21842
|
}
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21843
|
+
case "merkletree": {
|
|
21844
|
+
const merkleTreeType = getMerkleTreeType(types, ctx);
|
|
21845
|
+
const structHashes = data.map((struct) => {
|
|
21846
|
+
return encodeValue(types, merkleTreeType, struct, void 0, revision)[1];
|
|
21847
|
+
});
|
|
21848
|
+
const { root } = new MerkleTree(
|
|
21849
|
+
structHashes,
|
|
21850
|
+
revisionConfiguration[revision].hashMerkleMethod
|
|
21851
|
+
);
|
|
21852
|
+
return ["felt", root];
|
|
21848
21853
|
}
|
|
21849
|
-
|
|
21850
|
-
|
|
21851
|
-
case "timestamp":
|
|
21852
|
-
case "u128": {
|
|
21853
|
-
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21854
|
-
assertRange(data, type, RANGE_U128);
|
|
21854
|
+
case "selector": {
|
|
21855
|
+
return ["felt", prepareSelector(data)];
|
|
21855
21856
|
}
|
|
21856
|
-
|
|
21857
|
-
|
|
21858
|
-
|
|
21859
|
-
|
|
21860
|
-
|
|
21861
|
-
|
|
21857
|
+
case "string": {
|
|
21858
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21859
|
+
const byteArray = byteArrayFromString(data);
|
|
21860
|
+
const elements = [
|
|
21861
|
+
byteArray.data.length,
|
|
21862
|
+
...byteArray.data,
|
|
21863
|
+
byteArray.pending_word,
|
|
21864
|
+
byteArray.pending_word_len
|
|
21865
|
+
];
|
|
21866
|
+
return [type, revisionConfiguration[revision].hashMethod(elements)];
|
|
21867
|
+
}
|
|
21868
|
+
return [type, getHex(data)];
|
|
21862
21869
|
}
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21870
|
+
case "i128": {
|
|
21871
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21872
|
+
const value = BigInt(data);
|
|
21873
|
+
assertRange(value, type, RANGE_I128);
|
|
21874
|
+
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
21875
|
+
}
|
|
21876
|
+
return [type, getHex(data)];
|
|
21869
21877
|
}
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21873
|
-
|
|
21874
|
-
|
|
21878
|
+
case "timestamp":
|
|
21879
|
+
case "u128": {
|
|
21880
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21881
|
+
assertRange(data, type, RANGE_U128);
|
|
21882
|
+
}
|
|
21883
|
+
return [type, getHex(data)];
|
|
21875
21884
|
}
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
|
|
21879
|
-
|
|
21880
|
-
|
|
21885
|
+
case "felt":
|
|
21886
|
+
case "shortstring": {
|
|
21887
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21888
|
+
assertRange(getHex(data), type, RANGE_FELT);
|
|
21889
|
+
}
|
|
21890
|
+
return [type, getHex(data)];
|
|
21891
|
+
}
|
|
21892
|
+
case "ClassHash":
|
|
21893
|
+
case "ContractAddress": {
|
|
21894
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21895
|
+
assertRange(data, type, RANGE_FELT);
|
|
21896
|
+
}
|
|
21897
|
+
return [type, getHex(data)];
|
|
21898
|
+
}
|
|
21899
|
+
case "bool": {
|
|
21900
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21901
|
+
assert(isBoolean(data), `Type mismatch for ${type} ${data}`);
|
|
21902
|
+
}
|
|
21903
|
+
return [type, getHex(data)];
|
|
21904
|
+
}
|
|
21905
|
+
default: {
|
|
21906
|
+
if (revision === TypedDataRevision2.ACTIVE) {
|
|
21907
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
21908
|
+
}
|
|
21909
|
+
return [type, getHex(data)];
|
|
21881
21910
|
}
|
|
21882
|
-
return [type, getHex(data)];
|
|
21883
21911
|
}
|
|
21884
|
-
}
|
|
21912
|
+
});
|
|
21885
21913
|
}
|
|
21886
21914
|
function encodeData(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
21887
|
-
|
|
21888
|
-
|
|
21889
|
-
|
|
21890
|
-
|
|
21891
|
-
|
|
21892
|
-
|
|
21893
|
-
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
21897
|
-
[
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
|
|
21901
|
-
|
|
21902
|
-
|
|
21903
|
-
|
|
21915
|
+
return withBudget(() => {
|
|
21916
|
+
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
21917
|
+
const [returnTypes, values] = targetType.reduce(
|
|
21918
|
+
([ts, vs], field) => {
|
|
21919
|
+
if (data[field.name] === void 0 || data[field.name] === null && field.type !== "enum") {
|
|
21920
|
+
throw new Error(`Cannot encode data: missing data for '${field.name}'`);
|
|
21921
|
+
}
|
|
21922
|
+
const value = data[field.name];
|
|
21923
|
+
const ctx = { parent: type, key: field.name };
|
|
21924
|
+
const [t, encodedValue] = encodeValue(types, field.type, value, ctx, revision);
|
|
21925
|
+
return [
|
|
21926
|
+
[...ts, t],
|
|
21927
|
+
[...vs, encodedValue]
|
|
21928
|
+
];
|
|
21929
|
+
},
|
|
21930
|
+
[["felt"], [getTypeHash(types, type, revision)]]
|
|
21931
|
+
);
|
|
21932
|
+
return [returnTypes, values];
|
|
21933
|
+
});
|
|
21904
21934
|
}
|
|
21905
21935
|
function getStructHash(types, type, data, revision = TypedDataRevision2.LEGACY) {
|
|
21906
21936
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
@@ -21911,13 +21941,15 @@ ${indent}}` : "}";
|
|
|
21911
21941
|
}
|
|
21912
21942
|
const revision = identifyRevision(typedData);
|
|
21913
21943
|
const { domain, hashMethod } = revisionConfiguration[revision];
|
|
21914
|
-
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21944
|
+
return withBudget(() => {
|
|
21945
|
+
const message = [
|
|
21946
|
+
utf8ToBigInt("StarkNet Message"),
|
|
21947
|
+
getStructHash(typedData.types, domain, typedData.domain, revision),
|
|
21948
|
+
accountAddress,
|
|
21949
|
+
getStructHash(typedData.types, typedData.primaryType, typedData.message, revision)
|
|
21950
|
+
];
|
|
21951
|
+
return hashMethod(message);
|
|
21952
|
+
});
|
|
21921
21953
|
}
|
|
21922
21954
|
function verifyMessage(message, signature, fullPublicKey, accountAddress) {
|
|
21923
21955
|
const isTypedData = validateTypedData(message);
|
|
@@ -23762,18 +23794,92 @@ ${indent}}` : "}";
|
|
|
23762
23794
|
}
|
|
23763
23795
|
return { cairo: "0", compiler: "0" };
|
|
23764
23796
|
}
|
|
23797
|
+
/**
|
|
23798
|
+
* Estimates the fee for a given INVOKE transaction
|
|
23799
|
+
*
|
|
23800
|
+
* @param invocation the invocation object containing:
|
|
23801
|
+
* - contractAddress - the address of the contract
|
|
23802
|
+
* - entrypoint - (optional) the entrypoint of the contract
|
|
23803
|
+
* - calldata - (optional, defaults to []) the calldata
|
|
23804
|
+
* - signature - (optional, defaults to []) the signature
|
|
23805
|
+
* @param details - optional details containing:
|
|
23806
|
+
* - nonce - optional nonce
|
|
23807
|
+
* - version - optional version
|
|
23808
|
+
* @param blockIdentifier - (optional) block identifier
|
|
23809
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
23810
|
+
* @returns the estimated fee
|
|
23811
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
23812
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
23813
|
+
* This method will be removed in a future major version, not before v13.
|
|
23814
|
+
* @example
|
|
23815
|
+
* ```typescript
|
|
23816
|
+
* const feeEstimate = await provider.getInvokeEstimateFee(invocation, details);
|
|
23817
|
+
* // Equivalent to:
|
|
23818
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.INVOKE, ...invocation, ...details }]);
|
|
23819
|
+
* ```
|
|
23820
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
23821
|
+
*/
|
|
23765
23822
|
async getInvokeEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
23766
23823
|
return (await this.getEstimateFeeBulk(
|
|
23767
23824
|
[{ type: ETransactionType2.INVOKE, ...invocation, ...details }],
|
|
23768
23825
|
{ blockIdentifier, skipValidate }
|
|
23769
23826
|
))[0];
|
|
23770
23827
|
}
|
|
23828
|
+
/**
|
|
23829
|
+
* Estimates the fee for a given DECLARE transaction
|
|
23830
|
+
*
|
|
23831
|
+
* @param invocation transaction payload to be declared containing:
|
|
23832
|
+
* - compiled contract code
|
|
23833
|
+
* - sender address
|
|
23834
|
+
* - signature - (defaults to []) the signature
|
|
23835
|
+
* @param details - optional details containing:
|
|
23836
|
+
* - nonce
|
|
23837
|
+
* - version - optional version
|
|
23838
|
+
* @param blockIdentifier - (optional) block identifier
|
|
23839
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
23840
|
+
* @returns the estimated fee
|
|
23841
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
23842
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
23843
|
+
* This method will be removed in a future major version, not before v13.
|
|
23844
|
+
* @example
|
|
23845
|
+
* ```typescript
|
|
23846
|
+
* const feeEstimate = await provider.getDeclareEstimateFee(transaction, details);
|
|
23847
|
+
* // Equivalent to:
|
|
23848
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DECLARE, ...transaction, ...details }]);
|
|
23849
|
+
* ```
|
|
23850
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
23851
|
+
*/
|
|
23771
23852
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
23772
23853
|
return (await this.getEstimateFeeBulk(
|
|
23773
23854
|
[{ type: ETransactionType2.DECLARE, ...invocation, ...details }],
|
|
23774
23855
|
{ blockIdentifier, skipValidate }
|
|
23775
23856
|
))[0];
|
|
23776
23857
|
}
|
|
23858
|
+
/**
|
|
23859
|
+
* Estimates the fee for a given DEPLOY_ACCOUNT transaction
|
|
23860
|
+
*
|
|
23861
|
+
* @param invocation transaction payload to be deployed containing:
|
|
23862
|
+
* - classHash
|
|
23863
|
+
* - constructorCalldata
|
|
23864
|
+
* - addressSalt
|
|
23865
|
+
* - signature - (defaults to []) the signature
|
|
23866
|
+
* @param details - optional details containing:
|
|
23867
|
+
* - nonce
|
|
23868
|
+
* - version - optional version
|
|
23869
|
+
* @param blockIdentifier - (optional) block identifier
|
|
23870
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
23871
|
+
* @returns the estimated fee
|
|
23872
|
+
* @deprecated This method only calls `getEstimateFeeBulk` with one transaction. Use
|
|
23873
|
+
* {@link RpcProvider.getEstimateFeeBulk | getEstimateFeeBulk} instead (see the example).
|
|
23874
|
+
* This method will be removed in a future major version, not before v13.
|
|
23875
|
+
* @example
|
|
23876
|
+
* ```typescript
|
|
23877
|
+
* const feeEstimate = await provider.getDeployAccountEstimateFee(transaction, details);
|
|
23878
|
+
* // Equivalent to:
|
|
23879
|
+
* const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: TransactionType.DEPLOY_ACCOUNT, ...transaction, ...details }]);
|
|
23880
|
+
* ```
|
|
23881
|
+
* @remarks This method is an alias that calls getEstimateFeeBulk with a single transaction
|
|
23882
|
+
*/
|
|
23777
23883
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
23778
23884
|
return (await this.getEstimateFeeBulk(
|
|
23779
23885
|
[{ type: ETransactionType2.DEPLOY_ACCOUNT, ...invocation, ...details }],
|