starknet 6.3.0 → 6.4.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 +11 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.global.js +52 -19
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +52 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2345,6 +2345,7 @@ __export(hash_exports, {
|
|
|
2345
2345
|
formatSpaces: () => formatSpaces,
|
|
2346
2346
|
getSelector: () => getSelector,
|
|
2347
2347
|
getSelectorFromName: () => getSelectorFromName,
|
|
2348
|
+
hashByteCodeSegments: () => hashByteCodeSegments,
|
|
2348
2349
|
keccakBn: () => keccakBn,
|
|
2349
2350
|
poseidon: () => poseidon,
|
|
2350
2351
|
starknetKeccak: () => starknetKeccak
|
|
@@ -2731,13 +2732,23 @@ function hashEntryPoint(data) {
|
|
|
2731
2732
|
});
|
|
2732
2733
|
return poseidonHashMany2(base);
|
|
2733
2734
|
}
|
|
2735
|
+
function hashByteCodeSegments(casm) {
|
|
2736
|
+
const byteCode = casm.bytecode.map((n) => BigInt(n));
|
|
2737
|
+
const bytecodeSegmentLengths = casm.bytecode_segment_lengths ?? [];
|
|
2738
|
+
let segmentStart = 0;
|
|
2739
|
+
const hashLeaves = bytecodeSegmentLengths.flatMap((len) => {
|
|
2740
|
+
const segment = byteCode.slice(segmentStart, segmentStart += len);
|
|
2741
|
+
return [BigInt(len), poseidonHashMany2(segment)];
|
|
2742
|
+
});
|
|
2743
|
+
return 1n + poseidonHashMany2(hashLeaves);
|
|
2744
|
+
}
|
|
2734
2745
|
function computeCompiledClassHash(casm) {
|
|
2735
2746
|
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
2736
2747
|
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
2737
2748
|
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
2738
2749
|
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
2739
2750
|
const constructor = hashEntryPoint(casm.entry_points_by_type.CONSTRUCTOR);
|
|
2740
|
-
const bytecode = poseidonHashMany2(casm.bytecode.map((it) => BigInt(it)));
|
|
2751
|
+
const bytecode = casm.bytecode_segment_lengths ? hashByteCodeSegments(casm) : poseidonHashMany2(casm.bytecode.map((it) => BigInt(it)));
|
|
2741
2752
|
return toHex(
|
|
2742
2753
|
poseidonHashMany2([
|
|
2743
2754
|
compiledClassVersion,
|
|
@@ -5154,11 +5165,18 @@ function getMerkleTreeType(types, ctx) {
|
|
|
5154
5165
|
return "raw";
|
|
5155
5166
|
}
|
|
5156
5167
|
function encodeType(types, type, revision = "0" /* Legacy */) {
|
|
5157
|
-
const
|
|
5168
|
+
const allTypes = revision === "1" /* Active */ ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
5169
|
+
const [primary, ...dependencies] = getDependencies(
|
|
5170
|
+
allTypes,
|
|
5171
|
+
type,
|
|
5172
|
+
void 0,
|
|
5173
|
+
void 0,
|
|
5174
|
+
revision
|
|
5175
|
+
);
|
|
5158
5176
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
5159
5177
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
5160
5178
|
return newTypes.map((dependency) => {
|
|
5161
|
-
const dependencyElements =
|
|
5179
|
+
const dependencyElements = allTypes[dependency].map((t) => {
|
|
5162
5180
|
const targetType = t.type === "enum" && revision === "1" /* Active */ ? t.contains : t.type;
|
|
5163
5181
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
5164
5182
|
return `${esc(t.name)}:${typeString}`;
|
|
@@ -5556,7 +5574,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5556
5574
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
5557
5575
|
}
|
|
5558
5576
|
async estimateInvokeFee(calls, details = {}) {
|
|
5559
|
-
const {
|
|
5577
|
+
const {
|
|
5578
|
+
nonce: providedNonce,
|
|
5579
|
+
blockIdentifier,
|
|
5580
|
+
version: providedVersion,
|
|
5581
|
+
skipValidate = true
|
|
5582
|
+
} = details;
|
|
5560
5583
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
5561
5584
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5562
5585
|
const version = toTransactionVersion(
|
|
@@ -5571,7 +5594,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5571
5594
|
maxFee: ZERO,
|
|
5572
5595
|
version,
|
|
5573
5596
|
chainId,
|
|
5574
|
-
cairoVersion: await this.getCairoVersion()
|
|
5597
|
+
cairoVersion: await this.getCairoVersion(),
|
|
5598
|
+
skipValidate
|
|
5575
5599
|
};
|
|
5576
5600
|
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
5577
5601
|
return super.getInvokeEstimateFee(
|
|
@@ -5582,7 +5606,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5582
5606
|
);
|
|
5583
5607
|
}
|
|
5584
5608
|
async estimateDeclareFee(payload, details = {}) {
|
|
5585
|
-
const {
|
|
5609
|
+
const {
|
|
5610
|
+
blockIdentifier,
|
|
5611
|
+
nonce: providedNonce,
|
|
5612
|
+
version: providedVersion,
|
|
5613
|
+
skipValidate = true
|
|
5614
|
+
} = details;
|
|
5586
5615
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5587
5616
|
const version = toTransactionVersion(
|
|
5588
5617
|
!isSierra(payload.contract) ? "0x100000000000000000000000000000001" /* F1 */ : this.getPreferredVersion("0x100000000000000000000000000000002" /* F2 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
@@ -5596,8 +5625,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5596
5625
|
version,
|
|
5597
5626
|
walletAddress: this.address,
|
|
5598
5627
|
maxFee: ZERO,
|
|
5599
|
-
cairoVersion: void 0
|
|
5628
|
+
cairoVersion: void 0,
|
|
5600
5629
|
// unused parameter
|
|
5630
|
+
skipValidate
|
|
5601
5631
|
});
|
|
5602
5632
|
return super.getDeclareEstimateFee(
|
|
5603
5633
|
declareContractTransaction,
|
|
@@ -5612,7 +5642,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5612
5642
|
constructorCalldata = [],
|
|
5613
5643
|
contractAddress
|
|
5614
5644
|
}, details = {}) {
|
|
5615
|
-
const { blockIdentifier, version: providedVersion } = details;
|
|
5645
|
+
const { blockIdentifier, version: providedVersion, skipValidate = true } = details;
|
|
5616
5646
|
const version = toTransactionVersion(
|
|
5617
5647
|
this.getPreferredVersion("0x100000000000000000000000000000001" /* F1 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
5618
5648
|
toFeeVersion(providedVersion)
|
|
@@ -5629,8 +5659,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5629
5659
|
walletAddress: this.address,
|
|
5630
5660
|
// unused parameter
|
|
5631
5661
|
maxFee: ZERO,
|
|
5632
|
-
cairoVersion: void 0
|
|
5662
|
+
cairoVersion: void 0,
|
|
5633
5663
|
// unused parameter,
|
|
5664
|
+
skipValidate
|
|
5634
5665
|
}
|
|
5635
5666
|
);
|
|
5636
5667
|
return super.getDeployAccountEstimateFee(
|
|
@@ -5666,7 +5697,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5666
5697
|
});
|
|
5667
5698
|
}
|
|
5668
5699
|
async simulateTransaction(invocations, details = {}) {
|
|
5669
|
-
const { nonce, blockIdentifier, skipValidate, skipExecute, version } = details;
|
|
5700
|
+
const { nonce, blockIdentifier, skipValidate = true, skipExecute, version } = details;
|
|
5670
5701
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
5671
5702
|
...v3Details(details),
|
|
5672
5703
|
versions: [
|
|
@@ -5678,7 +5709,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5678
5709
|
)
|
|
5679
5710
|
],
|
|
5680
5711
|
nonce,
|
|
5681
|
-
blockIdentifier
|
|
5712
|
+
blockIdentifier,
|
|
5713
|
+
skipValidate
|
|
5682
5714
|
});
|
|
5683
5715
|
return super.getSimulateTransaction(accountInvocations, {
|
|
5684
5716
|
blockIdentifier,
|
|
@@ -5964,7 +5996,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5964
5996
|
}
|
|
5965
5997
|
async buildInvocation(call, details) {
|
|
5966
5998
|
const calldata = getExecuteCalldata(call, await this.getCairoVersion());
|
|
5967
|
-
const signature = await this.signer.signTransaction(call, details);
|
|
5999
|
+
const signature = !details.skipValidate ? await this.signer.signTransaction(call, details) : [];
|
|
5968
6000
|
return {
|
|
5969
6001
|
...v3Details(details),
|
|
5970
6002
|
contractAddress: this.address,
|
|
@@ -5978,14 +6010,14 @@ var Account = class extends RpcProvider2 {
|
|
|
5978
6010
|
if (typeof compiledClassHash === "undefined" && (details.version === "0x100000000000000000000000000000003" /* F3 */ || details.version === "0x3" /* V3 */)) {
|
|
5979
6011
|
throw Error("V3 Transaction work with Cairo1 Contracts and require compiledClassHash");
|
|
5980
6012
|
}
|
|
5981
|
-
const signature = await this.signer.signDeclareTransaction({
|
|
6013
|
+
const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
|
|
5982
6014
|
...details,
|
|
5983
6015
|
...v3Details(details),
|
|
5984
6016
|
classHash,
|
|
5985
6017
|
compiledClassHash,
|
|
5986
|
-
// TODO: TS
|
|
6018
|
+
// TODO: TS, cast because optional for v2 and required for v3, thrown if not present
|
|
5987
6019
|
senderAddress: details.walletAddress
|
|
5988
|
-
});
|
|
6020
|
+
}) : [];
|
|
5989
6021
|
return {
|
|
5990
6022
|
senderAddress: details.walletAddress,
|
|
5991
6023
|
signature,
|
|
@@ -6001,14 +6033,14 @@ var Account = class extends RpcProvider2 {
|
|
|
6001
6033
|
}, details) {
|
|
6002
6034
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
6003
6035
|
const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
6004
|
-
const signature = await this.signer.signDeployAccountTransaction({
|
|
6036
|
+
const signature = !details.skipValidate ? await this.signer.signDeployAccountTransaction({
|
|
6005
6037
|
...details,
|
|
6006
6038
|
...v3Details(details),
|
|
6007
6039
|
classHash,
|
|
6008
6040
|
contractAddress,
|
|
6009
6041
|
addressSalt,
|
|
6010
6042
|
constructorCalldata: compiledCalldata
|
|
6011
|
-
});
|
|
6043
|
+
}) : [];
|
|
6012
6044
|
return {
|
|
6013
6045
|
...v3Details(details),
|
|
6014
6046
|
classHash,
|
|
@@ -6041,7 +6073,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6041
6073
|
return calls;
|
|
6042
6074
|
}
|
|
6043
6075
|
async accountInvocationsFactory(invocations, details) {
|
|
6044
|
-
const { nonce, blockIdentifier } = details;
|
|
6076
|
+
const { nonce, blockIdentifier, skipValidate = true } = details;
|
|
6045
6077
|
const safeNonce = await this.getNonceSafe(nonce);
|
|
6046
6078
|
const chainId = await this.getChainId();
|
|
6047
6079
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
@@ -6057,7 +6089,8 @@ var Account = class extends RpcProvider2 {
|
|
|
6057
6089
|
maxFee: ZERO,
|
|
6058
6090
|
chainId,
|
|
6059
6091
|
cairoVersion,
|
|
6060
|
-
version: ""
|
|
6092
|
+
version: "",
|
|
6093
|
+
skipValidate
|
|
6061
6094
|
};
|
|
6062
6095
|
const common = {
|
|
6063
6096
|
type: transaction.type,
|