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.mjs
CHANGED
|
@@ -717,31 +717,15 @@ function stringFromByteArray(myByteArray) {
|
|
|
717
717
|
return cumuledString + add;
|
|
718
718
|
}, "") + pending_word;
|
|
719
719
|
}
|
|
720
|
-
function byteArrayFromString(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
pending_word_len: 0
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
const myShortStrings = splitLongString(myString);
|
|
729
|
-
const remains = myShortStrings[myShortStrings.length - 1];
|
|
730
|
-
const myShortStringsEncoded = myShortStrings.map(
|
|
731
|
-
(shortStr) => encodeShortString(shortStr)
|
|
732
|
-
);
|
|
733
|
-
if (remains.length === 31) {
|
|
734
|
-
return {
|
|
735
|
-
data: myShortStringsEncoded,
|
|
736
|
-
pending_word: "0x00",
|
|
737
|
-
pending_word_len: 0
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
const pendingEncodedWord = myShortStringsEncoded.pop();
|
|
720
|
+
function byteArrayFromString(targetString) {
|
|
721
|
+
const shortStrings = splitLongString(targetString);
|
|
722
|
+
const remainder = shortStrings[shortStrings.length - 1];
|
|
723
|
+
const shortStringsEncoded = shortStrings.map(encodeShortString);
|
|
724
|
+
const [pendingWord, pendingWordLength] = remainder === void 0 || remainder.length === 31 ? ["0x00", 0] : [shortStringsEncoded.pop(), remainder.length];
|
|
741
725
|
return {
|
|
742
|
-
data:
|
|
743
|
-
pending_word:
|
|
744
|
-
pending_word_len:
|
|
726
|
+
data: shortStringsEncoded.length === 0 ? [] : shortStringsEncoded,
|
|
727
|
+
pending_word: pendingWord,
|
|
728
|
+
pending_word_len: pendingWordLength
|
|
745
729
|
};
|
|
746
730
|
}
|
|
747
731
|
|
|
@@ -2345,6 +2329,7 @@ __export(hash_exports, {
|
|
|
2345
2329
|
formatSpaces: () => formatSpaces,
|
|
2346
2330
|
getSelector: () => getSelector,
|
|
2347
2331
|
getSelectorFromName: () => getSelectorFromName,
|
|
2332
|
+
hashByteCodeSegments: () => hashByteCodeSegments,
|
|
2348
2333
|
keccakBn: () => keccakBn,
|
|
2349
2334
|
poseidon: () => poseidon,
|
|
2350
2335
|
starknetKeccak: () => starknetKeccak
|
|
@@ -2731,13 +2716,23 @@ function hashEntryPoint(data) {
|
|
|
2731
2716
|
});
|
|
2732
2717
|
return poseidonHashMany2(base);
|
|
2733
2718
|
}
|
|
2719
|
+
function hashByteCodeSegments(casm) {
|
|
2720
|
+
const byteCode = casm.bytecode.map((n) => BigInt(n));
|
|
2721
|
+
const bytecodeSegmentLengths = casm.bytecode_segment_lengths ?? [];
|
|
2722
|
+
let segmentStart = 0;
|
|
2723
|
+
const hashLeaves = bytecodeSegmentLengths.flatMap((len) => {
|
|
2724
|
+
const segment = byteCode.slice(segmentStart, segmentStart += len);
|
|
2725
|
+
return [BigInt(len), poseidonHashMany2(segment)];
|
|
2726
|
+
});
|
|
2727
|
+
return 1n + poseidonHashMany2(hashLeaves);
|
|
2728
|
+
}
|
|
2734
2729
|
function computeCompiledClassHash(casm) {
|
|
2735
2730
|
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
2736
2731
|
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
2737
2732
|
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
2738
2733
|
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
2739
2734
|
const constructor = hashEntryPoint(casm.entry_points_by_type.CONSTRUCTOR);
|
|
2740
|
-
const bytecode = poseidonHashMany2(casm.bytecode.map((it) => BigInt(it)));
|
|
2735
|
+
const bytecode = casm.bytecode_segment_lengths ? hashByteCodeSegments(casm) : poseidonHashMany2(casm.bytecode.map((it) => BigInt(it)));
|
|
2741
2736
|
return toHex(
|
|
2742
2737
|
poseidonHashMany2([
|
|
2743
2738
|
compiledClassVersion,
|
|
@@ -4953,7 +4948,6 @@ var SignerInterface = class {
|
|
|
4953
4948
|
var typedData_exports = {};
|
|
4954
4949
|
__export(typedData_exports, {
|
|
4955
4950
|
TypedDataRevision: () => TypedDataRevision,
|
|
4956
|
-
byteArrayFromString: () => byteArrayFromString2,
|
|
4957
4951
|
encodeData: () => encodeData,
|
|
4958
4952
|
encodeType: () => encodeType,
|
|
4959
4953
|
encodeValue: () => encodeValue,
|
|
@@ -5072,17 +5066,6 @@ var revisionConfiguration = {
|
|
|
5072
5066
|
presetTypes: {}
|
|
5073
5067
|
}
|
|
5074
5068
|
};
|
|
5075
|
-
function byteArrayFromString2(targetString) {
|
|
5076
|
-
const shortStrings = splitLongString(targetString);
|
|
5077
|
-
const remainder = shortStrings[shortStrings.length - 1];
|
|
5078
|
-
const shortStringsEncoded = shortStrings.map(encodeShortString);
|
|
5079
|
-
const [pendingWord, pendingWordLength] = remainder === void 0 || remainder.length === 31 ? ["0x00", 0] : [shortStringsEncoded.pop(), remainder.length];
|
|
5080
|
-
return {
|
|
5081
|
-
data: shortStringsEncoded.length === 0 ? ["0x00"] : shortStringsEncoded,
|
|
5082
|
-
pending_word: pendingWord,
|
|
5083
|
-
pending_word_len: pendingWordLength
|
|
5084
|
-
};
|
|
5085
|
-
}
|
|
5086
5069
|
function identifyRevision({ types, domain }) {
|
|
5087
5070
|
if (revisionConfiguration["1" /* Active */].domain in types && domain.revision === "1" /* Active */)
|
|
5088
5071
|
return "1" /* Active */;
|
|
@@ -5154,11 +5137,18 @@ function getMerkleTreeType(types, ctx) {
|
|
|
5154
5137
|
return "raw";
|
|
5155
5138
|
}
|
|
5156
5139
|
function encodeType(types, type, revision = "0" /* Legacy */) {
|
|
5157
|
-
const
|
|
5140
|
+
const allTypes = revision === "1" /* Active */ ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
5141
|
+
const [primary, ...dependencies] = getDependencies(
|
|
5142
|
+
allTypes,
|
|
5143
|
+
type,
|
|
5144
|
+
void 0,
|
|
5145
|
+
void 0,
|
|
5146
|
+
revision
|
|
5147
|
+
);
|
|
5158
5148
|
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
5159
5149
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
5160
5150
|
return newTypes.map((dependency) => {
|
|
5161
|
-
const dependencyElements =
|
|
5151
|
+
const dependencyElements = allTypes[dependency].map((t) => {
|
|
5162
5152
|
const targetType = t.type === "enum" && revision === "1" /* Active */ ? t.contains : t.type;
|
|
5163
5153
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
5164
5154
|
return `${esc(t.name)}:${typeString}`;
|
|
@@ -5227,7 +5217,7 @@ function encodeValue(types, type, data, ctx = {}, revision = "0" /* Legacy */) {
|
|
|
5227
5217
|
}
|
|
5228
5218
|
case "string": {
|
|
5229
5219
|
if (revision === "1" /* Active */) {
|
|
5230
|
-
const byteArray =
|
|
5220
|
+
const byteArray = byteArrayFromString(data);
|
|
5231
5221
|
const elements = [
|
|
5232
5222
|
byteArray.data.length,
|
|
5233
5223
|
...byteArray.data,
|
|
@@ -5556,7 +5546,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5556
5546
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
5557
5547
|
}
|
|
5558
5548
|
async estimateInvokeFee(calls, details = {}) {
|
|
5559
|
-
const {
|
|
5549
|
+
const {
|
|
5550
|
+
nonce: providedNonce,
|
|
5551
|
+
blockIdentifier,
|
|
5552
|
+
version: providedVersion,
|
|
5553
|
+
skipValidate = true
|
|
5554
|
+
} = details;
|
|
5560
5555
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
5561
5556
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5562
5557
|
const version = toTransactionVersion(
|
|
@@ -5571,7 +5566,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5571
5566
|
maxFee: ZERO,
|
|
5572
5567
|
version,
|
|
5573
5568
|
chainId,
|
|
5574
|
-
cairoVersion: await this.getCairoVersion()
|
|
5569
|
+
cairoVersion: await this.getCairoVersion(),
|
|
5570
|
+
skipValidate
|
|
5575
5571
|
};
|
|
5576
5572
|
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
5577
5573
|
return super.getInvokeEstimateFee(
|
|
@@ -5582,7 +5578,12 @@ var Account = class extends RpcProvider2 {
|
|
|
5582
5578
|
);
|
|
5583
5579
|
}
|
|
5584
5580
|
async estimateDeclareFee(payload, details = {}) {
|
|
5585
|
-
const {
|
|
5581
|
+
const {
|
|
5582
|
+
blockIdentifier,
|
|
5583
|
+
nonce: providedNonce,
|
|
5584
|
+
version: providedVersion,
|
|
5585
|
+
skipValidate = true
|
|
5586
|
+
} = details;
|
|
5586
5587
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5587
5588
|
const version = toTransactionVersion(
|
|
5588
5589
|
!isSierra(payload.contract) ? "0x100000000000000000000000000000001" /* F1 */ : this.getPreferredVersion("0x100000000000000000000000000000002" /* F2 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
@@ -5596,8 +5597,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5596
5597
|
version,
|
|
5597
5598
|
walletAddress: this.address,
|
|
5598
5599
|
maxFee: ZERO,
|
|
5599
|
-
cairoVersion: void 0
|
|
5600
|
+
cairoVersion: void 0,
|
|
5600
5601
|
// unused parameter
|
|
5602
|
+
skipValidate
|
|
5601
5603
|
});
|
|
5602
5604
|
return super.getDeclareEstimateFee(
|
|
5603
5605
|
declareContractTransaction,
|
|
@@ -5612,7 +5614,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5612
5614
|
constructorCalldata = [],
|
|
5613
5615
|
contractAddress
|
|
5614
5616
|
}, details = {}) {
|
|
5615
|
-
const { blockIdentifier, version: providedVersion } = details;
|
|
5617
|
+
const { blockIdentifier, version: providedVersion, skipValidate = true } = details;
|
|
5616
5618
|
const version = toTransactionVersion(
|
|
5617
5619
|
this.getPreferredVersion("0x100000000000000000000000000000001" /* F1 */, "0x100000000000000000000000000000003" /* F3 */),
|
|
5618
5620
|
toFeeVersion(providedVersion)
|
|
@@ -5629,8 +5631,9 @@ var Account = class extends RpcProvider2 {
|
|
|
5629
5631
|
walletAddress: this.address,
|
|
5630
5632
|
// unused parameter
|
|
5631
5633
|
maxFee: ZERO,
|
|
5632
|
-
cairoVersion: void 0
|
|
5634
|
+
cairoVersion: void 0,
|
|
5633
5635
|
// unused parameter,
|
|
5636
|
+
skipValidate
|
|
5634
5637
|
}
|
|
5635
5638
|
);
|
|
5636
5639
|
return super.getDeployAccountEstimateFee(
|
|
@@ -5666,7 +5669,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5666
5669
|
});
|
|
5667
5670
|
}
|
|
5668
5671
|
async simulateTransaction(invocations, details = {}) {
|
|
5669
|
-
const { nonce, blockIdentifier, skipValidate, skipExecute, version } = details;
|
|
5672
|
+
const { nonce, blockIdentifier, skipValidate = true, skipExecute, version } = details;
|
|
5670
5673
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
5671
5674
|
...v3Details(details),
|
|
5672
5675
|
versions: [
|
|
@@ -5678,7 +5681,8 @@ var Account = class extends RpcProvider2 {
|
|
|
5678
5681
|
)
|
|
5679
5682
|
],
|
|
5680
5683
|
nonce,
|
|
5681
|
-
blockIdentifier
|
|
5684
|
+
blockIdentifier,
|
|
5685
|
+
skipValidate
|
|
5682
5686
|
});
|
|
5683
5687
|
return super.getSimulateTransaction(accountInvocations, {
|
|
5684
5688
|
blockIdentifier,
|
|
@@ -5964,7 +5968,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5964
5968
|
}
|
|
5965
5969
|
async buildInvocation(call, details) {
|
|
5966
5970
|
const calldata = getExecuteCalldata(call, await this.getCairoVersion());
|
|
5967
|
-
const signature = await this.signer.signTransaction(call, details);
|
|
5971
|
+
const signature = !details.skipValidate ? await this.signer.signTransaction(call, details) : [];
|
|
5968
5972
|
return {
|
|
5969
5973
|
...v3Details(details),
|
|
5970
5974
|
contractAddress: this.address,
|
|
@@ -5978,14 +5982,14 @@ var Account = class extends RpcProvider2 {
|
|
|
5978
5982
|
if (typeof compiledClassHash === "undefined" && (details.version === "0x100000000000000000000000000000003" /* F3 */ || details.version === "0x3" /* V3 */)) {
|
|
5979
5983
|
throw Error("V3 Transaction work with Cairo1 Contracts and require compiledClassHash");
|
|
5980
5984
|
}
|
|
5981
|
-
const signature = await this.signer.signDeclareTransaction({
|
|
5985
|
+
const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
|
|
5982
5986
|
...details,
|
|
5983
5987
|
...v3Details(details),
|
|
5984
5988
|
classHash,
|
|
5985
5989
|
compiledClassHash,
|
|
5986
|
-
// TODO: TS
|
|
5990
|
+
// TODO: TS, cast because optional for v2 and required for v3, thrown if not present
|
|
5987
5991
|
senderAddress: details.walletAddress
|
|
5988
|
-
});
|
|
5992
|
+
}) : [];
|
|
5989
5993
|
return {
|
|
5990
5994
|
senderAddress: details.walletAddress,
|
|
5991
5995
|
signature,
|
|
@@ -6001,14 +6005,14 @@ var Account = class extends RpcProvider2 {
|
|
|
6001
6005
|
}, details) {
|
|
6002
6006
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
6003
6007
|
const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
|
|
6004
|
-
const signature = await this.signer.signDeployAccountTransaction({
|
|
6008
|
+
const signature = !details.skipValidate ? await this.signer.signDeployAccountTransaction({
|
|
6005
6009
|
...details,
|
|
6006
6010
|
...v3Details(details),
|
|
6007
6011
|
classHash,
|
|
6008
6012
|
contractAddress,
|
|
6009
6013
|
addressSalt,
|
|
6010
6014
|
constructorCalldata: compiledCalldata
|
|
6011
|
-
});
|
|
6015
|
+
}) : [];
|
|
6012
6016
|
return {
|
|
6013
6017
|
...v3Details(details),
|
|
6014
6018
|
classHash,
|
|
@@ -6041,7 +6045,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6041
6045
|
return calls;
|
|
6042
6046
|
}
|
|
6043
6047
|
async accountInvocationsFactory(invocations, details) {
|
|
6044
|
-
const { nonce, blockIdentifier } = details;
|
|
6048
|
+
const { nonce, blockIdentifier, skipValidate = true } = details;
|
|
6045
6049
|
const safeNonce = await this.getNonceSafe(nonce);
|
|
6046
6050
|
const chainId = await this.getChainId();
|
|
6047
6051
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
@@ -6057,7 +6061,8 @@ var Account = class extends RpcProvider2 {
|
|
|
6057
6061
|
maxFee: ZERO,
|
|
6058
6062
|
chainId,
|
|
6059
6063
|
cairoVersion,
|
|
6060
|
-
version: ""
|
|
6064
|
+
version: "",
|
|
6065
|
+
skipValidate
|
|
6061
6066
|
};
|
|
6062
6067
|
const common = {
|
|
6063
6068
|
type: transaction.type,
|