starknet 8.5.5 → 8.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 +6 -0
- package/dist/index.d.ts +141 -19
- package/dist/index.global.js +656 -86
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +249 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +248 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -315,7 +315,8 @@ var DEFAULT_GLOBAL_CONFIG = {
|
|
|
315
315
|
defaultTipType: "recommendedTip",
|
|
316
316
|
fetch: void 0,
|
|
317
317
|
websocket: void 0,
|
|
318
|
-
buffer: void 0
|
|
318
|
+
buffer: void 0,
|
|
319
|
+
blake: void 0
|
|
319
320
|
};
|
|
320
321
|
var RPC_DEFAULT_NODES = {
|
|
321
322
|
SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
|
|
@@ -4612,12 +4613,16 @@ var CallData = class _CallData {
|
|
|
4612
4613
|
// src/utils/hash/index.ts
|
|
4613
4614
|
var hash_exports = {};
|
|
4614
4615
|
__export(hash_exports, {
|
|
4616
|
+
COMPILED_CLASS_VERSION: () => COMPILED_CLASS_VERSION,
|
|
4617
|
+
blake2sHashMany: () => blake2sHashMany,
|
|
4615
4618
|
calculateContractAddressFromHash: () => calculateContractAddressFromHash,
|
|
4616
4619
|
calculateDeclareTransactionHash: () => calculateDeclareTransactionHash3,
|
|
4617
4620
|
calculateDeployAccountTransactionHash: () => calculateDeployAccountTransactionHash3,
|
|
4618
4621
|
calculateInvokeTransactionHash: () => calculateInvokeTransactionHash2,
|
|
4619
4622
|
calculateL2MessageTxHash: () => calculateL2MessageTxHash,
|
|
4620
4623
|
computeCompiledClassHash: () => computeCompiledClassHash,
|
|
4624
|
+
computeCompiledClassHashBlake: () => computeCompiledClassHashBlake,
|
|
4625
|
+
computeCompiledClassHashPoseidon: () => computeCompiledClassHashPoseidon,
|
|
4621
4626
|
computeContractClassHash: () => computeContractClassHash,
|
|
4622
4627
|
computeHashOnElements: () => computeHashOnElements2,
|
|
4623
4628
|
computeHintedClassHash: () => computeHintedClassHash,
|
|
@@ -4627,13 +4632,17 @@ __export(hash_exports, {
|
|
|
4627
4632
|
computePoseidonHash: () => computePoseidonHash,
|
|
4628
4633
|
computePoseidonHashOnElements: () => computePoseidonHashOnElements,
|
|
4629
4634
|
computeSierraContractClassHash: () => computeSierraContractClassHash,
|
|
4635
|
+
encodeBuiltins: () => encodeBuiltins,
|
|
4636
|
+
flattenEntryPointData: () => flattenEntryPointData,
|
|
4630
4637
|
formatSpaces: () => formatSpaces,
|
|
4631
4638
|
getL1MessageHash: () => getL1MessageHash,
|
|
4632
4639
|
getL2MessageHash: () => getL2MessageHash,
|
|
4633
4640
|
getSelector: () => getSelector,
|
|
4634
4641
|
getSelectorFromName: () => getSelectorFromName,
|
|
4635
4642
|
hashByteCodeSegments: () => hashByteCodeSegments,
|
|
4643
|
+
hashByteCodeSegmentsBlake: () => hashByteCodeSegmentsBlake,
|
|
4636
4644
|
keccakBn: () => keccakBn,
|
|
4645
|
+
nullSkipReplacer: () => nullSkipReplacer,
|
|
4637
4646
|
poseidon: () => poseidon,
|
|
4638
4647
|
solidityUint256PackedKeccak256: () => solidityUint256PackedKeccak256,
|
|
4639
4648
|
starknetKeccak: () => starknetKeccak
|
|
@@ -4898,21 +4907,51 @@ function calculateDeployAccountTransactionHash3(args) {
|
|
|
4898
4907
|
throw new Error("Invalid Tx version for hash calculation");
|
|
4899
4908
|
}
|
|
4900
4909
|
|
|
4901
|
-
// src/utils/hash/classHash.ts
|
|
4902
|
-
|
|
4910
|
+
// src/utils/hash/classHash/util.ts
|
|
4911
|
+
var COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
4912
|
+
function formatSpaces(json2) {
|
|
4913
|
+
let insideQuotes = false;
|
|
4914
|
+
const newString = [];
|
|
4915
|
+
for (const char of json2) {
|
|
4916
|
+
if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
|
|
4917
|
+
insideQuotes = !insideQuotes;
|
|
4918
|
+
}
|
|
4919
|
+
if (insideQuotes) {
|
|
4920
|
+
newString.push(char);
|
|
4921
|
+
} else {
|
|
4922
|
+
newString.push(char === ":" ? ": " : char === "," ? ", " : char);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
return newString.join("");
|
|
4926
|
+
}
|
|
4927
|
+
function nullSkipReplacer(key, value) {
|
|
4928
|
+
if (key === "attributes" || key === "accessible_scopes") {
|
|
4929
|
+
return Array.isArray(value) && value.length === 0 ? void 0 : value;
|
|
4930
|
+
}
|
|
4931
|
+
if (key === "debug_info") {
|
|
4932
|
+
return null;
|
|
4933
|
+
}
|
|
4934
|
+
return value === null ? void 0 : value;
|
|
4935
|
+
}
|
|
4936
|
+
function encodeBuiltins(builtins) {
|
|
4937
|
+
return builtins.map((it) => BigInt(encodeShortString(it)));
|
|
4938
|
+
}
|
|
4939
|
+
function flattenEntryPointData(data, encodedBuiltinsArray) {
|
|
4940
|
+
return data.flatMap((it, index) => [
|
|
4941
|
+
BigInt(it.selector),
|
|
4942
|
+
BigInt(it.offset),
|
|
4943
|
+
...encodedBuiltinsArray[index]
|
|
4944
|
+
]);
|
|
4945
|
+
}
|
|
4946
|
+
|
|
4947
|
+
// src/utils/hash/classHash/pedersen.ts
|
|
4903
4948
|
function computePedersenHash(a, b) {
|
|
4904
4949
|
return starkCurve.pedersen(BigInt(a), BigInt(b));
|
|
4905
4950
|
}
|
|
4906
|
-
function computePoseidonHash(a, b) {
|
|
4907
|
-
return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
|
|
4908
|
-
}
|
|
4909
4951
|
function computeHashOnElements2(data) {
|
|
4910
4952
|
return [...data, data.length].reduce((x, y) => starkCurve.pedersen(BigInt(x), BigInt(y)), 0).toString();
|
|
4911
4953
|
}
|
|
4912
4954
|
var computePedersenHashOnElements = computeHashOnElements2;
|
|
4913
|
-
function computePoseidonHashOnElements(data) {
|
|
4914
|
-
return toHex(poseidonHashMany2(data.map((x) => BigInt(x))));
|
|
4915
|
-
}
|
|
4916
4955
|
function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
|
|
4917
4956
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
4918
4957
|
const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
|
|
@@ -4926,30 +4965,6 @@ function calculateContractAddressFromHash(salt, classHash, constructorCalldata,
|
|
|
4926
4965
|
]);
|
|
4927
4966
|
return toHex(BigInt(hash) % ADDR_BOUND);
|
|
4928
4967
|
}
|
|
4929
|
-
function nullSkipReplacer(key, value) {
|
|
4930
|
-
if (key === "attributes" || key === "accessible_scopes") {
|
|
4931
|
-
return Array.isArray(value) && value.length === 0 ? void 0 : value;
|
|
4932
|
-
}
|
|
4933
|
-
if (key === "debug_info") {
|
|
4934
|
-
return null;
|
|
4935
|
-
}
|
|
4936
|
-
return value === null ? void 0 : value;
|
|
4937
|
-
}
|
|
4938
|
-
function formatSpaces(json2) {
|
|
4939
|
-
let insideQuotes = false;
|
|
4940
|
-
const newString = [];
|
|
4941
|
-
for (const char of json2) {
|
|
4942
|
-
if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
|
|
4943
|
-
insideQuotes = !insideQuotes;
|
|
4944
|
-
}
|
|
4945
|
-
if (insideQuotes) {
|
|
4946
|
-
newString.push(char);
|
|
4947
|
-
} else {
|
|
4948
|
-
newString.push(char === ":" ? ": " : char === "," ? ", " : char);
|
|
4949
|
-
}
|
|
4950
|
-
}
|
|
4951
|
-
return newString.join("");
|
|
4952
|
-
}
|
|
4953
4968
|
function computeHintedClassHash(compiledContract) {
|
|
4954
4969
|
const { abi, program } = compiledContract;
|
|
4955
4970
|
const contractClass = { abi, program };
|
|
@@ -4983,12 +4998,17 @@ function computeLegacyContractClassHash(contract) {
|
|
|
4983
4998
|
dataHash
|
|
4984
4999
|
]);
|
|
4985
5000
|
}
|
|
5001
|
+
|
|
5002
|
+
// src/utils/hash/classHash/poseidon.ts
|
|
5003
|
+
import { poseidonHashMany as poseidonHashMany2 } from "@scure/starknet";
|
|
5004
|
+
function computePoseidonHash(a, b) {
|
|
5005
|
+
return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
|
|
5006
|
+
}
|
|
5007
|
+
function computePoseidonHashOnElements(data) {
|
|
5008
|
+
return toHex(poseidonHashMany2(data.map((x) => BigInt(x))));
|
|
5009
|
+
}
|
|
4986
5010
|
function hashBuiltins(builtins) {
|
|
4987
|
-
return poseidonHashMany2(
|
|
4988
|
-
builtins.flatMap((it) => {
|
|
4989
|
-
return BigInt(encodeShortString(it));
|
|
4990
|
-
})
|
|
4991
|
-
);
|
|
5011
|
+
return poseidonHashMany2(encodeBuiltins(builtins));
|
|
4992
5012
|
}
|
|
4993
5013
|
function hashEntryPoint(data) {
|
|
4994
5014
|
const base = data.flatMap((it) => {
|
|
@@ -5006,8 +5026,7 @@ function hashByteCodeSegments(casm) {
|
|
|
5006
5026
|
});
|
|
5007
5027
|
return 1n + poseidonHashMany2(hashLeaves);
|
|
5008
5028
|
}
|
|
5009
|
-
function
|
|
5010
|
-
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
5029
|
+
function computeCompiledClassHashPoseidon(casm) {
|
|
5011
5030
|
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
5012
5031
|
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
5013
5032
|
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
@@ -5052,6 +5071,161 @@ function computeSierraContractClassHash(sierra) {
|
|
|
5052
5071
|
])
|
|
5053
5072
|
);
|
|
5054
5073
|
}
|
|
5074
|
+
|
|
5075
|
+
// src/utils/connect/blake.ts
|
|
5076
|
+
import { blake2s } from "@noble/hashes/blake2s";
|
|
5077
|
+
function blakeHash(uint8Array) {
|
|
5078
|
+
return config.get("blake")?.(uint8Array) || blake2s(uint8Array, { dkLen: 32 });
|
|
5079
|
+
}
|
|
5080
|
+
|
|
5081
|
+
// src/utils/hash/classHash/blake.ts
|
|
5082
|
+
function blake2sHashMany(data) {
|
|
5083
|
+
const SMALL_THRESHOLD = 0x8000000000000000n;
|
|
5084
|
+
const BIG_MARKER = 2147483648;
|
|
5085
|
+
const u32Words = [];
|
|
5086
|
+
const buf = new ArrayBuffer(32);
|
|
5087
|
+
const feltView = new DataView(buf);
|
|
5088
|
+
for (const felt2 of data) {
|
|
5089
|
+
const u64_0 = felt2 & 0xffffffffffffffffn;
|
|
5090
|
+
const u64_1 = (felt2 & 0xffffffffffffffff0000000000000000n) >> 64n;
|
|
5091
|
+
const u64_2 = (felt2 & 0xffffffffffffffff00000000000000000000000000000000n) >> 128n;
|
|
5092
|
+
const u64_3 = (felt2 & 0xffffffffffffffff000000000000000000000000000000000000000000000000n) >> 192n;
|
|
5093
|
+
feltView.setBigUint64(0, u64_3, false);
|
|
5094
|
+
feltView.setBigUint64(8, u64_2, false);
|
|
5095
|
+
feltView.setBigUint64(16, u64_1, false);
|
|
5096
|
+
feltView.setBigUint64(24, u64_0, false);
|
|
5097
|
+
if (felt2 < SMALL_THRESHOLD) {
|
|
5098
|
+
const hi0 = feltView.getUint32(24, false);
|
|
5099
|
+
const lo0 = feltView.getUint32(28, false);
|
|
5100
|
+
u32Words.push(hi0, lo0);
|
|
5101
|
+
} else {
|
|
5102
|
+
const word0 = feltView.getUint32(0, false) | BIG_MARKER;
|
|
5103
|
+
const word1 = feltView.getUint32(4, false);
|
|
5104
|
+
const word2 = feltView.getUint32(8, false);
|
|
5105
|
+
const word3 = feltView.getUint32(12, false);
|
|
5106
|
+
const word4 = feltView.getUint32(16, false);
|
|
5107
|
+
const word5 = feltView.getUint32(20, false);
|
|
5108
|
+
const word6 = feltView.getUint32(24, false);
|
|
5109
|
+
const word7 = feltView.getUint32(28, false);
|
|
5110
|
+
u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
const bytes = new ArrayBuffer(u32Words.length * 4);
|
|
5114
|
+
const bytesView = new DataView(bytes);
|
|
5115
|
+
for (let i = 0; i < u32Words.length; i++) {
|
|
5116
|
+
bytesView.setUint32(i * 4, u32Words[i], true);
|
|
5117
|
+
}
|
|
5118
|
+
const hash = blakeHash(new Uint8Array(bytes));
|
|
5119
|
+
let hashBigInt = 0n;
|
|
5120
|
+
for (let i = 0; i < 32; i++) {
|
|
5121
|
+
hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
|
|
5122
|
+
}
|
|
5123
|
+
return hashBigInt % PRIME;
|
|
5124
|
+
}
|
|
5125
|
+
function hashBuiltinsBlake(builtins) {
|
|
5126
|
+
return blake2sHashMany(encodeBuiltins(builtins));
|
|
5127
|
+
}
|
|
5128
|
+
function hashEntryPointBlake(data) {
|
|
5129
|
+
const base = data.flatMap((it) => {
|
|
5130
|
+
return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
|
|
5131
|
+
});
|
|
5132
|
+
return blake2sHashMany(base);
|
|
5133
|
+
}
|
|
5134
|
+
function bytecodeHashNodeBlake(iter, node) {
|
|
5135
|
+
if (typeof node === "number") {
|
|
5136
|
+
const data = [];
|
|
5137
|
+
for (let i = 0; i < node; i++) {
|
|
5138
|
+
const next = iter.next();
|
|
5139
|
+
if (next.done) throw new Error("Bytecode length mismatch");
|
|
5140
|
+
data.push(next.value);
|
|
5141
|
+
}
|
|
5142
|
+
return [node, blake2sHashMany(data)];
|
|
5143
|
+
}
|
|
5144
|
+
const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
|
|
5145
|
+
const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
|
|
5146
|
+
const hash = blake2sHashMany(flatData) + 1n;
|
|
5147
|
+
const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
|
|
5148
|
+
return [totalLen, hash];
|
|
5149
|
+
}
|
|
5150
|
+
function hashByteCodeSegmentsBlake(casm) {
|
|
5151
|
+
const byteCode = casm.bytecode.map((n) => BigInt(n));
|
|
5152
|
+
const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
|
|
5153
|
+
if (!bytecodeSegmentLengths) {
|
|
5154
|
+
return blake2sHashMany(byteCode);
|
|
5155
|
+
}
|
|
5156
|
+
const iter = byteCode[Symbol.iterator]();
|
|
5157
|
+
const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
|
|
5158
|
+
if (len !== byteCode.length) {
|
|
5159
|
+
throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
|
|
5160
|
+
}
|
|
5161
|
+
return hash;
|
|
5162
|
+
}
|
|
5163
|
+
function computeCompiledClassHashBlake(casm) {
|
|
5164
|
+
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
5165
|
+
const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
|
|
5166
|
+
const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
|
|
5167
|
+
const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
|
|
5168
|
+
const bytecode = hashByteCodeSegmentsBlake(casm);
|
|
5169
|
+
return toHex(
|
|
5170
|
+
blake2sHashMany([
|
|
5171
|
+
compiledClassVersion,
|
|
5172
|
+
externalEntryPointsHash,
|
|
5173
|
+
l1Handlers,
|
|
5174
|
+
constructor,
|
|
5175
|
+
bytecode
|
|
5176
|
+
])
|
|
5177
|
+
);
|
|
5178
|
+
}
|
|
5179
|
+
|
|
5180
|
+
// src/utils/resolve.ts
|
|
5181
|
+
function isV3Tx(details) {
|
|
5182
|
+
const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
|
|
5183
|
+
return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
|
|
5184
|
+
}
|
|
5185
|
+
function isVersion(expected, provided) {
|
|
5186
|
+
const expectedParts = expected.split(".");
|
|
5187
|
+
const providedParts = provided.split(".");
|
|
5188
|
+
return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
|
|
5189
|
+
}
|
|
5190
|
+
function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
|
|
5191
|
+
return Object.values(_SupportedRpcVersion).some(
|
|
5192
|
+
(v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
|
|
5193
|
+
);
|
|
5194
|
+
}
|
|
5195
|
+
function toAnyPatchVersion(version) {
|
|
5196
|
+
const parts = version.split(".");
|
|
5197
|
+
if (parts.length < 3) {
|
|
5198
|
+
return version;
|
|
5199
|
+
}
|
|
5200
|
+
return `${parts[0]}.${parts[1]}.*`;
|
|
5201
|
+
}
|
|
5202
|
+
function toApiVersion(version) {
|
|
5203
|
+
const [major, minor] = version.replace(/^v/, "").split(".");
|
|
5204
|
+
return `v${major}_${minor}`;
|
|
5205
|
+
}
|
|
5206
|
+
function compareVersions(a, b) {
|
|
5207
|
+
const aParts = a.split(".").map(Number);
|
|
5208
|
+
const bParts = b.split(".").map(Number);
|
|
5209
|
+
const maxLen = Math.max(aParts.length, bParts.length);
|
|
5210
|
+
for (let i = 0; i < maxLen; i += 1) {
|
|
5211
|
+
const aNum = aParts[i] || 0;
|
|
5212
|
+
const bNum = bParts[i] || 0;
|
|
5213
|
+
if (aNum > bNum) return 1;
|
|
5214
|
+
if (aNum < bNum) return -1;
|
|
5215
|
+
}
|
|
5216
|
+
return 0;
|
|
5217
|
+
}
|
|
5218
|
+
function isPendingBlock(response) {
|
|
5219
|
+
return response.status === "PENDING";
|
|
5220
|
+
}
|
|
5221
|
+
function isPendingTransaction(response) {
|
|
5222
|
+
return !("block_hash" in response);
|
|
5223
|
+
}
|
|
5224
|
+
function isPendingStateUpdate(response) {
|
|
5225
|
+
return !("block_hash" in response);
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
// src/utils/hash/classHash/index.ts
|
|
5055
5229
|
function computeContractClassHash(contract) {
|
|
5056
5230
|
const compiledContract = isString(contract) ? parse2(contract) : contract;
|
|
5057
5231
|
if ("sierra_program" in compiledContract) {
|
|
@@ -5059,6 +5233,12 @@ function computeContractClassHash(contract) {
|
|
|
5059
5233
|
}
|
|
5060
5234
|
return computeLegacyContractClassHash(compiledContract);
|
|
5061
5235
|
}
|
|
5236
|
+
function computeCompiledClassHash(casm, specVersion) {
|
|
5237
|
+
if (specVersion && compareVersions(specVersion, "0.10.0") >= 0) {
|
|
5238
|
+
return computeCompiledClassHashBlake(casm);
|
|
5239
|
+
}
|
|
5240
|
+
return computeCompiledClassHashPoseidon(casm);
|
|
5241
|
+
}
|
|
5062
5242
|
|
|
5063
5243
|
// src/utils/stark/index.ts
|
|
5064
5244
|
var stark_exports = {};
|
|
@@ -5264,11 +5444,11 @@ function isSierra(contract) {
|
|
|
5264
5444
|
const compiledContract = isString(contract) ? parse2(contract) : contract;
|
|
5265
5445
|
return "sierra_program" in compiledContract;
|
|
5266
5446
|
}
|
|
5267
|
-
function extractContractHashes(payload) {
|
|
5447
|
+
function extractContractHashes(payload, specVersion) {
|
|
5268
5448
|
const response = { ...payload };
|
|
5269
5449
|
if (isSierra(payload.contract)) {
|
|
5270
5450
|
if (!payload.compiledClassHash && payload.casm) {
|
|
5271
|
-
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
5451
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm, specVersion);
|
|
5272
5452
|
}
|
|
5273
5453
|
if (!response.compiledClassHash)
|
|
5274
5454
|
throw new Error(
|
|
@@ -5325,44 +5505,6 @@ __export(provider_exports, {
|
|
|
5325
5505
|
validBlockTags: () => validBlockTags,
|
|
5326
5506
|
wait: () => wait
|
|
5327
5507
|
});
|
|
5328
|
-
|
|
5329
|
-
// src/utils/resolve.ts
|
|
5330
|
-
function isV3Tx(details) {
|
|
5331
|
-
const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
|
|
5332
|
-
return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
|
|
5333
|
-
}
|
|
5334
|
-
function isVersion(expected, provided) {
|
|
5335
|
-
const expectedParts = expected.split(".");
|
|
5336
|
-
const providedParts = provided.split(".");
|
|
5337
|
-
return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
|
|
5338
|
-
}
|
|
5339
|
-
function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
|
|
5340
|
-
return Object.values(_SupportedRpcVersion).some(
|
|
5341
|
-
(v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
|
|
5342
|
-
);
|
|
5343
|
-
}
|
|
5344
|
-
function toAnyPatchVersion(version) {
|
|
5345
|
-
const parts = version.split(".");
|
|
5346
|
-
if (parts.length < 3) {
|
|
5347
|
-
return version;
|
|
5348
|
-
}
|
|
5349
|
-
return `${parts[0]}.${parts[1]}.*`;
|
|
5350
|
-
}
|
|
5351
|
-
function toApiVersion(version) {
|
|
5352
|
-
const [major, minor] = version.replace(/^v/, "").split(".");
|
|
5353
|
-
return `v${major}_${minor}`;
|
|
5354
|
-
}
|
|
5355
|
-
function isPendingBlock(response) {
|
|
5356
|
-
return response.status === "PENDING";
|
|
5357
|
-
}
|
|
5358
|
-
function isPendingTransaction(response) {
|
|
5359
|
-
return !("block_hash" in response);
|
|
5360
|
-
}
|
|
5361
|
-
function isPendingStateUpdate(response) {
|
|
5362
|
-
return !("block_hash" in response);
|
|
5363
|
-
}
|
|
5364
|
-
|
|
5365
|
-
// src/utils/provider.ts
|
|
5366
5508
|
function wait(delay) {
|
|
5367
5509
|
return new Promise((res) => {
|
|
5368
5510
|
setTimeout(res, delay);
|
|
@@ -8536,7 +8678,10 @@ var RpcProvider = class {
|
|
|
8536
8678
|
async isClassDeclared(contractClassIdentifier, blockIdentifier) {
|
|
8537
8679
|
let classHash;
|
|
8538
8680
|
if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
|
|
8539
|
-
const hashes = extractContractHashes(
|
|
8681
|
+
const hashes = extractContractHashes(
|
|
8682
|
+
contractClassIdentifier,
|
|
8683
|
+
await this.channel.setUpSpecVersion()
|
|
8684
|
+
);
|
|
8540
8685
|
classHash = hashes.classHash;
|
|
8541
8686
|
} else if (contractClassIdentifier.classHash) {
|
|
8542
8687
|
classHash = contractClassIdentifier.classHash;
|
|
@@ -10907,7 +11052,10 @@ var Account = class extends RpcProvider2 {
|
|
|
10907
11052
|
"Declare fee estimation is not supported for Cairo0 contracts"
|
|
10908
11053
|
);
|
|
10909
11054
|
const invocations = [
|
|
10910
|
-
{
|
|
11055
|
+
{
|
|
11056
|
+
type: api_exports.ETransactionType.DECLARE,
|
|
11057
|
+
payload: extractContractHashes(payload, await this.channel.setUpSpecVersion())
|
|
11058
|
+
}
|
|
10911
11059
|
];
|
|
10912
11060
|
const estimateBulk = await this.estimateFeeBulk(invocations, details);
|
|
10913
11061
|
return estimateBulk[0];
|
|
@@ -11070,7 +11218,10 @@ var Account = class extends RpcProvider2 {
|
|
|
11070
11218
|
* @param transactionsDetail (optional)
|
|
11071
11219
|
*/
|
|
11072
11220
|
async declareIfNot(payload, transactionsDetail = {}) {
|
|
11073
|
-
const declareContractPayload = extractContractHashes(
|
|
11221
|
+
const declareContractPayload = extractContractHashes(
|
|
11222
|
+
payload,
|
|
11223
|
+
await this.channel.setUpSpecVersion()
|
|
11224
|
+
);
|
|
11074
11225
|
try {
|
|
11075
11226
|
await this.getClassByHash(declareContractPayload.classHash);
|
|
11076
11227
|
} catch (error) {
|
|
@@ -11083,7 +11234,10 @@ var Account = class extends RpcProvider2 {
|
|
|
11083
11234
|
}
|
|
11084
11235
|
async declare(payload, details = {}) {
|
|
11085
11236
|
assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
|
|
11086
|
-
const declareContractPayload = extractContractHashes(
|
|
11237
|
+
const declareContractPayload = extractContractHashes(
|
|
11238
|
+
payload,
|
|
11239
|
+
await this.channel.setUpSpecVersion()
|
|
11240
|
+
);
|
|
11087
11241
|
const detailsWithTip = await this.resolveDetailsWithTip(details);
|
|
11088
11242
|
const { resourceBounds: providedResourceBounds } = details;
|
|
11089
11243
|
let resourceBounds = providedResourceBounds;
|
|
@@ -11390,7 +11544,10 @@ var Account = class extends RpcProvider2 {
|
|
|
11390
11544
|
};
|
|
11391
11545
|
}
|
|
11392
11546
|
async buildDeclarePayload(payload, details) {
|
|
11393
|
-
const { classHash, contract, compiledClassHash } = extractContractHashes(
|
|
11547
|
+
const { classHash, contract, compiledClassHash } = extractContractHashes(
|
|
11548
|
+
payload,
|
|
11549
|
+
await this.channel.setUpSpecVersion()
|
|
11550
|
+
);
|
|
11394
11551
|
const compressedCompiledContract = parseContract(contract);
|
|
11395
11552
|
assert(
|
|
11396
11553
|
!isUndefined(compiledClassHash) && (details.version === ETransactionVersion3.F3 || details.version === ETransactionVersion3.V3),
|
|
@@ -11736,8 +11893,11 @@ var WalletAccount = class _WalletAccount extends Account {
|
|
|
11736
11893
|
};
|
|
11737
11894
|
return addInvokeTransaction(this.walletProvider, params);
|
|
11738
11895
|
}
|
|
11739
|
-
declare(payload) {
|
|
11740
|
-
const declareContractPayload = extractContractHashes(
|
|
11896
|
+
async declare(payload) {
|
|
11897
|
+
const declareContractPayload = extractContractHashes(
|
|
11898
|
+
payload,
|
|
11899
|
+
await this.channel.setUpSpecVersion()
|
|
11900
|
+
);
|
|
11741
11901
|
const pContract = payload.contract;
|
|
11742
11902
|
const cairo1Contract = {
|
|
11743
11903
|
...pContract,
|
|
@@ -12449,6 +12609,7 @@ export {
|
|
|
12449
12609
|
addAddressPadding,
|
|
12450
12610
|
byteArray_exports as byteArray,
|
|
12451
12611
|
cairo_exports as cairo,
|
|
12612
|
+
compareVersions,
|
|
12452
12613
|
config,
|
|
12453
12614
|
constants_exports as constants,
|
|
12454
12615
|
contractClassResponseToLegacyCompiledContract,
|