starknet 6.3.0 → 6.4.1
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 +17 -0
- package/dist/index.d.ts +18 -11
- package/dist/index.global.js +61 -56
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +61 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -821,31 +821,15 @@ function stringFromByteArray(myByteArray) {
|
|
|
821
821
|
return cumuledString + add;
|
|
822
822
|
}, "") + pending_word;
|
|
823
823
|
}
|
|
824
|
-
function byteArrayFromString(
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
pending_word_len: 0
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
const myShortStrings = splitLongString(myString);
|
|
833
|
-
const remains = myShortStrings[myShortStrings.length - 1];
|
|
834
|
-
const myShortStringsEncoded = myShortStrings.map(
|
|
835
|
-
(shortStr) => encodeShortString(shortStr)
|
|
836
|
-
);
|
|
837
|
-
if (remains.length === 31) {
|
|
838
|
-
return {
|
|
839
|
-
data: myShortStringsEncoded,
|
|
840
|
-
pending_word: "0x00",
|
|
841
|
-
pending_word_len: 0
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
const pendingEncodedWord = myShortStringsEncoded.pop();
|
|
824
|
+
function byteArrayFromString(targetString) {
|
|
825
|
+
const shortStrings = splitLongString(targetString);
|
|
826
|
+
const remainder = shortStrings[shortStrings.length - 1];
|
|
827
|
+
const shortStringsEncoded = shortStrings.map(encodeShortString);
|
|
828
|
+
const [pendingWord, pendingWordLength] = remainder === void 0 || remainder.length === 31 ? ["0x00", 0] : [shortStringsEncoded.pop(), remainder.length];
|
|
845
829
|
return {
|
|
846
|
-
data:
|
|
847
|
-
pending_word:
|
|
848
|
-
pending_word_len:
|
|
830
|
+
data: shortStringsEncoded.length === 0 ? [] : shortStringsEncoded,
|
|
831
|
+
pending_word: pendingWord,
|
|
832
|
+
pending_word_len: pendingWordLength
|
|
849
833
|
};
|
|
850
834
|
}
|
|
851
835
|
|
|
@@ -2449,6 +2433,7 @@ __export(hash_exports, {
|
|
|
2449
2433
|
formatSpaces: () => formatSpaces,
|
|
2450
2434
|
getSelector: () => getSelector,
|
|
2451
2435
|
getSelectorFromName: () => getSelectorFromName,
|
|
2436
|
+
hashByteCodeSegments: () => hashByteCodeSegments,
|
|
2452
2437
|
keccakBn: () => keccakBn,
|
|
2453
2438
|
poseidon: () => poseidon,
|
|
2454
2439
|
starknetKeccak: () => starknetKeccak
|
|
@@ -2835,13 +2820,23 @@ function hashEntryPoint(data) {
|
|
|
2835
2820
|
});
|
|
2836
2821
|
return (0, import_starknet3.poseidonHashMany)(base);
|
|
2837
2822
|
}
|
|
2823
|
+
function hashByteCodeSegments(casm) {
|
|
2824
|
+
const byteCode = casm.bytecode.map((n) => BigInt(n));
|
|
2825
|
+
const bytecodeSegmentLengths = casm.bytecode_segment_lengths ?? [];
|
|
2826
|
+
let segmentStart = 0;
|
|
2827
|
+
const hashLeaves = bytecodeSegmentLengths.flatMap((len) => {
|
|
2828
|
+
const segment = byteCode.slice(segmentStart, segmentStart += len);
|
|
2829
|
+
return [BigInt(len), (0, import_starknet3.poseidonHashMany)(segment)];
|
|
2830
|
+
});
|
|
2831
|
+
return 1n + (0, import_starknet3.poseidonHashMany)(hashLeaves);
|
|
2832
|
+
}
|
|
2838
2833
|
function computeCompiledClassHash(casm) {
|
|
2839
2834
|
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
2840
2835
|
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
2841
2836
|
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
2842
2837
|
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
2843
2838
|
const constructor = hashEntryPoint(casm.entry_points_by_type.CONSTRUCTOR);
|
|
2844
|
-
const bytecode = (0, import_starknet3.poseidonHashMany)(casm.bytecode.map((it) => BigInt(it)));
|
|
2839
|
+
const bytecode = casm.bytecode_segment_lengths ? hashByteCodeSegments(casm) : (0, import_starknet3.poseidonHashMany)(casm.bytecode.map((it) => BigInt(it)));
|
|
2845
2840
|
return toHex(
|
|
2846
2841
|
(0, import_starknet3.poseidonHashMany)([
|
|
2847
2842
|
compiledClassVersion,
|
|
@@ -5057,7 +5052,6 @@ var SignerInterface = class {
|
|
|
5057
5052
|
var typedData_exports = {};
|
|
5058
5053
|
__export(typedData_exports, {
|
|
5059
5054
|
TypedDataRevision: () => TypedDataRevision,
|
|
5060
|
-
byteArrayFromString: () => byteArrayFromString2,
|
|
5061
5055
|
encodeData: () => encodeData,
|
|
5062
5056
|
encodeType: () => encodeType,
|
|
5063
5057
|
encodeValue: () => encodeValue,
|
|
@@ -5176,17 +5170,6 @@ var revisionConfiguration = {
|
|
|
5176
5170
|
presetTypes: {}
|
|
5177
5171
|
}
|
|
5178
5172
|
};
|
|
5179
|
-
function byteArrayFromString2(targetString) {
|
|
5180
|
-
const shortStrings = splitLongString(targetString);
|
|
5181
|
-
const remainder = shortStrings[shortStrings.length - 1];
|
|
5182
|
-
const shortStringsEncoded = shortStrings.map(encodeShortString);
|
|
5183
|
-
const [pendingWord, pendingWordLength] = remainder === void 0 || remainder.length === 31 ? ["0x00", 0] : [shortStringsEncoded.pop(), remainder.length];
|
|
5184
|
-
return {
|
|
5185
|
-
data: shortStringsEncoded.length === 0 ? ["0x00"] : shortStringsEncoded,
|
|
5186
|
-
pending_word: pendingWord,
|
|
5187
|
-
pending_word_len: pendingWordLength
|
|
5188
|
-
};
|
|
5189
|
-
}
|
|
5190
5173
|
function identifyRevision({ types, domain }) {
|
|
5191
5174
|
if (revisionConfiguration["1" /* Active */].domain in types && domain.revision === "1" /* Active */)
|
|
5192
5175
|
return "1" /* Active */;
|
|
@@ -5258,11 +5241,18 @@ function getMerkleTreeType(types, ctx) {
|
|
|
5258
5241
|
return "raw";
|
|
5259
5242
|
}
|
|
5260
5243
|
function encodeType(types, type, revision = "0" /* Legacy */) {
|
|
5261
|
-
const
|
|
5244
|
+
const allTypes = revision === "1" /* Active */ ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
5245
|
+
const [primary, ...dependencies] = getDependencies(
|
|
5246
|
+
allTypes,
|
|
5247
|
+
type,
|
|
5248
|
+
void 0,
|
|
5249
|
+
void 0,
|
|
5250
|
+
revision
|
|
5251
|
+
);
|
|
5262
5252
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
5263
5253
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
5264
5254
|
return newTypes.map((dependency) => {
|
|
5265
|
-
const dependencyElements =
|
|
5255
|
+
const dependencyElements = allTypes[dependency].map((t) => {
|
|
5266
5256
|
const targetType = t.type === "enum" && revision === "1" /* Active */ ? t.contains : t.type;
|
|
5267
5257
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
5268
5258
|
return `${esc(t.name)}:${typeString}`;
|
|
@@ -5331,7 +5321,7 @@ function encodeValue(types, type, data, ctx = {}, revision = "0" /* Legacy */) {
|
|
|
5331
5321
|
}
|
|
5332
5322
|
case "string": {
|
|
5333
5323
|
if (revision === "1" /* Active */) {
|
|
5334
|
-
const byteArray =
|
|
5324
|
+
const byteArray = byteArrayFromString(data);
|
|
5335
5325
|
const elements = [
|
|
5336
5326
|
byteArray.data.length,
|
|
5337
5327
|
...byteArray.data,
|
|
@@ -5660,7 +5650,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5660
5650
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
5661
5651
|
}
|
|
5662
5652
|
async estimateInvokeFee(calls, details = {}) {
|
|
5663
|
-
const {
|
|
5653
|
+
const {
|
|
5654
|
+
nonce: providedNonce,
|
|
5655
|
+
blockIdentifier,
|
|
5656
|
+
version: providedVersion,
|
|
5657
|
+
skipValidate = true
|
|
5658
|
+
} = details;
|
|
5664
5659
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
5665
5660
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5666
5661
|
const version = toTransactionVersion(
|
|
@@ -5675,7 +5670,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5675
5670
|
maxFee: ZERO,
|
|
5676
5671
|
version,
|
|
5677
5672
|
chainId,
|
|
5678
|
-
cairoVersion: await this.getCairoVersion()
|
|
5673
|
+
cairoVersion: await this.getCairoVersion(),
|
|
5674
|
+
skipValidate
|
|
5679
5675
|
};
|
|
5680
5676
|
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
5681
5677
|
return super.getInvokeEstimateFee(
|
|
@@ -5686,7 +5682,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5686
5682
|
);
|
|
5687
5683
|
}
|
|
5688
5684
|
async estimateDeclareFee(payload, details = {}) {
|
|
5689
|
-
const {
|
|
5685
|
+
const {
|
|
5686
|
+
blockIdentifier,
|
|
5687
|
+
nonce: providedNonce,
|
|
5688
|
+
version: providedVersion,
|
|
5689
|
+
skipValidate = true
|
|
5690
|
+
} = details;
|
|
5690
5691
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5691
5692
|
const version = toTransactionVersion(
|
|
5692
5693
|
!isSierra(payload.contract) ? "0x100000000000000000000000000000001" /* F1 */ : this.getPreferredVersion("0x100000000000000000000000000000002" /* F2 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
@@ -5700,8 +5701,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5700
5701
|
version,
|
|
5701
5702
|
walletAddress: this.address,
|
|
5702
5703
|
maxFee: ZERO,
|
|
5703
|
-
cairoVersion: void 0
|
|
5704
|
+
cairoVersion: void 0,
|
|
5704
5705
|
// unused parameter
|
|
5706
|
+
skipValidate
|
|
5705
5707
|
});
|
|
5706
5708
|
return super.getDeclareEstimateFee(
|
|
5707
5709
|
declareContractTransaction,
|
|
@@ -5716,7 +5718,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5716
5718
|
constructorCalldata = [],
|
|
5717
5719
|
contractAddress
|
|
5718
5720
|
}, details = {}) {
|
|
5719
|
-
const { blockIdentifier, version: providedVersion } = details;
|
|
5721
|
+
const { blockIdentifier, version: providedVersion, skipValidate = true } = details;
|
|
5720
5722
|
const version = toTransactionVersion(
|
|
5721
5723
|
this.getPreferredVersion("0x100000000000000000000000000000001" /* F1 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
5722
5724
|
toFeeVersion(providedVersion)
|
|
@@ -5733,8 +5735,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5733
5735
|
walletAddress: this.address,
|
|
5734
5736
|
// unused parameter
|
|
5735
5737
|
maxFee: ZERO,
|
|
5736
|
-
cairoVersion: void 0
|
|
5738
|
+
cairoVersion: void 0,
|
|
5737
5739
|
// unused parameter,
|
|
5740
|
+
skipValidate
|
|
5738
5741
|
}
|
|
5739
5742
|
);
|
|
5740
5743
|
return super.getDeployAccountEstimateFee(
|
|
@@ -5770,7 +5773,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5770
5773
|
});
|
|
5771
5774
|
}
|
|
5772
5775
|
async simulateTransaction(invocations, details = {}) {
|
|
5773
|
-
const { nonce, blockIdentifier, skipValidate, skipExecute, version } = details;
|
|
5776
|
+
const { nonce, blockIdentifier, skipValidate = true, skipExecute, version } = details;
|
|
5774
5777
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
5775
5778
|
...v3Details(details),
|
|
5776
5779
|
versions: [
|
|
@@ -5782,7 +5785,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5782
5785
|
)
|
|
5783
5786
|
],
|
|
5784
5787
|
nonce,
|
|
5785
|
-
blockIdentifier
|
|
5788
|
+
blockIdentifier,
|
|
5789
|
+
skipValidate
|
|
5786
5790
|
});
|
|
5787
5791
|
return super.getSimulateTransaction(accountInvocations, {
|
|
5788
5792
|
blockIdentifier,
|
|
@@ -6068,7 +6072,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6068
6072
|
}
|
|
6069
6073
|
async buildInvocation(call, details) {
|
|
6070
6074
|
const calldata = getExecuteCalldata(call, await this.getCairoVersion());
|
|
6071
|
-
const signature = await this.signer.signTransaction(call, details);
|
|
6075
|
+
const signature = !details.skipValidate ? await this.signer.signTransaction(call, details) : [];
|
|
6072
6076
|
return {
|
|
6073
6077
|
...v3Details(details),
|
|
6074
6078
|
contractAddress: this.address,
|
|
@@ -6082,14 +6086,14 @@ var Account = class extends RpcProvider2 {
|
|
|
6082
6086
|
if (typeof compiledClassHash === "undefined" && (details.version === "0x100000000000000000000000000000003" /* F3 */ || details.version === "0x3" /* V3 */)) {
|
|
6083
6087
|
throw Error("V3 Transaction work with Cairo1 Contracts and require compiledClassHash");
|
|
6084
6088
|
}
|
|
6085
|
-
const signature = await this.signer.signDeclareTransaction({
|
|
6089
|
+
const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
|
|
6086
6090
|
...details,
|
|
6087
6091
|
...v3Details(details),
|
|
6088
6092
|
classHash,
|
|
6089
6093
|
compiledClassHash,
|
|
6090
|
-
// TODO: TS
|
|
6094
|
+
// TODO: TS, cast because optional for v2 and required for v3, thrown if not present
|
|
6091
6095
|
senderAddress: details.walletAddress
|
|
6092
|
-
});
|
|
6096
|
+
}) : [];
|
|
6093
6097
|
return {
|
|
6094
6098
|
senderAddress: details.walletAddress,
|
|
6095
6099
|
signature,
|
|
@@ -6105,14 +6109,14 @@ var Account = class extends RpcProvider2 {
|
|
|
6105
6109
|
}, details) {
|
|
6106
6110
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
6107
6111
|
const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
6108
|
-
const signature = await this.signer.signDeployAccountTransaction({
|
|
6112
|
+
const signature = !details.skipValidate ? await this.signer.signDeployAccountTransaction({
|
|
6109
6113
|
...details,
|
|
6110
6114
|
...v3Details(details),
|
|
6111
6115
|
classHash,
|
|
6112
6116
|
contractAddress,
|
|
6113
6117
|
addressSalt,
|
|
6114
6118
|
constructorCalldata: compiledCalldata
|
|
6115
|
-
});
|
|
6119
|
+
}) : [];
|
|
6116
6120
|
return {
|
|
6117
6121
|
...v3Details(details),
|
|
6118
6122
|
classHash,
|
|
@@ -6145,7 +6149,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6145
6149
|
return calls;
|
|
6146
6150
|
}
|
|
6147
6151
|
async accountInvocationsFactory(invocations, details) {
|
|
6148
|
-
const { nonce, blockIdentifier } = details;
|
|
6152
|
+
const { nonce, blockIdentifier, skipValidate = true } = details;
|
|
6149
6153
|
const safeNonce = await this.getNonceSafe(nonce);
|
|
6150
6154
|
const chainId = await this.getChainId();
|
|
6151
6155
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
@@ -6161,7 +6165,8 @@ var Account = class extends RpcProvider2 {
|
|
|
6161
6165
|
maxFee: ZERO,
|
|
6162
6166
|
chainId,
|
|
6163
6167
|
cairoVersion,
|
|
6164
|
-
version: ""
|
|
6168
|
+
version: "",
|
|
6169
|
+
skipValidate
|
|
6165
6170
|
};
|
|
6166
6171
|
const common = {
|
|
6167
6172
|
type: transaction.type,
|