starknet 5.1.1 → 5.3.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 +21 -0
- package/README.md +2 -5
- package/dist/index.d.ts +1018 -823
- package/dist/index.global.js +3601 -4361
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +332 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,15 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/types/lib.ts
|
|
7
|
+
// src/types/lib/contract/index.ts
|
|
8
|
+
var EntryPointType = /* @__PURE__ */ ((EntryPointType2) => {
|
|
9
|
+
EntryPointType2["EXTERNAL"] = "EXTERNAL";
|
|
10
|
+
EntryPointType2["L1_HANDLER"] = "L1_HANDLER";
|
|
11
|
+
EntryPointType2["CONSTRUCTOR"] = "CONSTRUCTOR";
|
|
12
|
+
return EntryPointType2;
|
|
13
|
+
})(EntryPointType || {});
|
|
14
|
+
|
|
15
|
+
// src/types/lib/index.ts
|
|
8
16
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
9
17
|
TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
10
18
|
TransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
@@ -48,19 +56,23 @@ __export(hash_exports, {
|
|
|
48
56
|
calculateDeployTransactionHash: () => calculateDeployTransactionHash,
|
|
49
57
|
calculateTransactionHash: () => calculateTransactionHash,
|
|
50
58
|
calculateTransactionHashCommon: () => calculateTransactionHashCommon,
|
|
59
|
+
computeCompiledClassHash: () => computeCompiledClassHash,
|
|
51
60
|
computeContractClassHash: () => computeContractClassHash,
|
|
52
61
|
computeHashOnElements: () => computeHashOnElements,
|
|
62
|
+
computeLegacyContractClassHash: () => computeLegacyContractClassHash,
|
|
63
|
+
computeSierraContractClassHash: () => computeSierraContractClassHash,
|
|
53
64
|
default: () => computeHintedClassHash,
|
|
54
65
|
feeTransactionVersion: () => feeTransactionVersion,
|
|
66
|
+
formatSpaces: () => formatSpaces,
|
|
55
67
|
getSelector: () => getSelector,
|
|
56
68
|
getSelectorFromName: () => getSelectorFromName,
|
|
57
69
|
keccakBn: () => keccakBn,
|
|
58
70
|
poseidon: () => poseidon,
|
|
59
71
|
starknetKeccak: () => starknetKeccak,
|
|
60
|
-
transactionVersion: () => transactionVersion
|
|
72
|
+
transactionVersion: () => transactionVersion,
|
|
73
|
+
transactionVersion_2: () => transactionVersion_2
|
|
61
74
|
});
|
|
62
|
-
import {
|
|
63
|
-
import { hexToBytes } from "ethereum-cryptography/utils.js";
|
|
75
|
+
import { keccak, poseidonHashMany } from "micro-starknet";
|
|
64
76
|
|
|
65
77
|
// src/constants.ts
|
|
66
78
|
var constants_exports = {};
|
|
@@ -2227,6 +2239,7 @@ __export(num_exports, {
|
|
|
2227
2239
|
getDecimalString: () => getDecimalString,
|
|
2228
2240
|
getHexString: () => getHexString,
|
|
2229
2241
|
getHexStringArray: () => getHexStringArray,
|
|
2242
|
+
hexToBytes: () => hexToBytes,
|
|
2230
2243
|
hexToDecimalString: () => hexToDecimalString,
|
|
2231
2244
|
isBigInt: () => isBigInt,
|
|
2232
2245
|
isHex: () => isHex,
|
|
@@ -2236,6 +2249,7 @@ __export(num_exports, {
|
|
|
2236
2249
|
toHex: () => toHex,
|
|
2237
2250
|
toHexString: () => toHexString
|
|
2238
2251
|
});
|
|
2252
|
+
import { hexToBytes as hexToBytesNoble } from "@noble/curves/abstract/utils";
|
|
2239
2253
|
|
|
2240
2254
|
// src/utils/assert.ts
|
|
2241
2255
|
function assert(condition, message) {
|
|
@@ -2301,6 +2315,15 @@ function getHexStringArray(value) {
|
|
|
2301
2315
|
return value.map((el) => getHexString(el));
|
|
2302
2316
|
}
|
|
2303
2317
|
var toCairoBool = (value) => (+value).toString();
|
|
2318
|
+
function hexToBytes(value) {
|
|
2319
|
+
if (!isHex(value))
|
|
2320
|
+
throw new Error(`${value} need to be a hex-string`);
|
|
2321
|
+
let adaptedValue = removeHexPrefix(value);
|
|
2322
|
+
if (adaptedValue.length % 2 !== 0) {
|
|
2323
|
+
adaptedValue = `0${adaptedValue}`;
|
|
2324
|
+
}
|
|
2325
|
+
return hexToBytesNoble(adaptedValue);
|
|
2326
|
+
}
|
|
2304
2327
|
|
|
2305
2328
|
// src/utils/shortString.ts
|
|
2306
2329
|
var shortString_exports = {};
|
|
@@ -2415,7 +2438,7 @@ __export(ec_exports, {
|
|
|
2415
2438
|
starkCurve: () => starkCurve,
|
|
2416
2439
|
weierstrass: () => weierstrass
|
|
2417
2440
|
});
|
|
2418
|
-
import * as starkCurve from "
|
|
2441
|
+
import * as starkCurve from "micro-starknet";
|
|
2419
2442
|
import * as weierstrass from "@noble/curves/abstract/weierstrass";
|
|
2420
2443
|
|
|
2421
2444
|
// src/utils/json.ts
|
|
@@ -2443,14 +2466,15 @@ var json_default = { parse, stringify };
|
|
|
2443
2466
|
// src/utils/hash.ts
|
|
2444
2467
|
import * as poseidon from "@noble/curves/abstract/poseidon";
|
|
2445
2468
|
var transactionVersion = 1n;
|
|
2469
|
+
var transactionVersion_2 = 2n;
|
|
2446
2470
|
var feeTransactionVersion = 2n ** 128n + transactionVersion;
|
|
2447
2471
|
function keccakBn(value) {
|
|
2448
2472
|
const hexWithoutPrefix = removeHexPrefix(toHex(BigInt(value)));
|
|
2449
2473
|
const evenHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
|
|
2450
|
-
return addHexPrefix(
|
|
2474
|
+
return addHexPrefix(keccak(hexToBytes(addHexPrefix(evenHex))).toString(16));
|
|
2451
2475
|
}
|
|
2452
2476
|
function keccakHex(value) {
|
|
2453
|
-
return addHexPrefix(
|
|
2477
|
+
return addHexPrefix(keccak(utf8ToArray(value)).toString(16));
|
|
2454
2478
|
}
|
|
2455
2479
|
function starknetKeccak(value) {
|
|
2456
2480
|
const hash = BigInt(keccakHex(value));
|
|
@@ -2496,7 +2520,7 @@ function calculateDeployTransactionHash(contractAddress, constructorCalldata, ve
|
|
|
2496
2520
|
chainId
|
|
2497
2521
|
);
|
|
2498
2522
|
}
|
|
2499
|
-
function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce) {
|
|
2523
|
+
function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce, compiledClassHash) {
|
|
2500
2524
|
return calculateTransactionHashCommon(
|
|
2501
2525
|
"0x6465636c617265" /* DECLARE */,
|
|
2502
2526
|
version,
|
|
@@ -2505,7 +2529,7 @@ function calculateDeclareTransactionHash(classHash, senderAddress, version, maxF
|
|
|
2505
2529
|
[classHash],
|
|
2506
2530
|
maxFee,
|
|
2507
2531
|
chainId,
|
|
2508
|
-
[nonce]
|
|
2532
|
+
[nonce, ...compiledClassHash ? [compiledClassHash] : []]
|
|
2509
2533
|
);
|
|
2510
2534
|
}
|
|
2511
2535
|
function calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce) {
|
|
@@ -2553,32 +2577,28 @@ function nullSkipReplacer(key, value) {
|
|
|
2553
2577
|
}
|
|
2554
2578
|
return value === null ? void 0 : value;
|
|
2555
2579
|
}
|
|
2580
|
+
function formatSpaces(json2) {
|
|
2581
|
+
let insideQuotes = false;
|
|
2582
|
+
let newString = "";
|
|
2583
|
+
for (const char of json2) {
|
|
2584
|
+
if (char === '"' && newString.endsWith("\\") === false) {
|
|
2585
|
+
insideQuotes = !insideQuotes;
|
|
2586
|
+
}
|
|
2587
|
+
if (insideQuotes) {
|
|
2588
|
+
newString += char;
|
|
2589
|
+
} else {
|
|
2590
|
+
newString += char === ":" ? ": " : char === "," ? ", " : char;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return newString;
|
|
2594
|
+
}
|
|
2556
2595
|
function computeHintedClassHash(compiledContract) {
|
|
2557
2596
|
const { abi, program } = compiledContract;
|
|
2558
2597
|
const contractClass = { abi, program };
|
|
2559
|
-
const
|
|
2560
|
-
|
|
2561
|
-
if (char === '"' && newString[newString.length - 1] !== "\\") {
|
|
2562
|
-
insideQuotes = !insideQuotes;
|
|
2563
|
-
}
|
|
2564
|
-
if (insideQuotes) {
|
|
2565
|
-
newString += char;
|
|
2566
|
-
return [insideQuotes, newString];
|
|
2567
|
-
}
|
|
2568
|
-
if (char === ":" && !insideQuotes) {
|
|
2569
|
-
newString += ": ";
|
|
2570
|
-
} else if (char === "," && !insideQuotes) {
|
|
2571
|
-
newString += ", ";
|
|
2572
|
-
} else {
|
|
2573
|
-
newString += char;
|
|
2574
|
-
}
|
|
2575
|
-
return [insideQuotes, newString];
|
|
2576
|
-
},
|
|
2577
|
-
[false, ""]
|
|
2578
|
-
)[1];
|
|
2579
|
-
return addHexPrefix(starkCurve.keccak(utf8ToArray(serialisedJson)).toString(16));
|
|
2598
|
+
const serializedJson = formatSpaces(stringify(contractClass, nullSkipReplacer));
|
|
2599
|
+
return addHexPrefix(starkCurve.keccak(utf8ToArray(serializedJson)).toString(16));
|
|
2580
2600
|
}
|
|
2581
|
-
function
|
|
2601
|
+
function computeLegacyContractClassHash(contract) {
|
|
2582
2602
|
const compiledContract = typeof contract === "string" ? parse(contract) : contract;
|
|
2583
2603
|
const apiVersion = toHex(API_VERSION);
|
|
2584
2604
|
const externalEntryPointsHash = computeHashOnElements(
|
|
@@ -2605,6 +2625,95 @@ function computeContractClassHash(contract) {
|
|
|
2605
2625
|
dataHash
|
|
2606
2626
|
]);
|
|
2607
2627
|
}
|
|
2628
|
+
function hashBuiltins(builtins) {
|
|
2629
|
+
return poseidonHashMany(
|
|
2630
|
+
builtins.flatMap((it) => {
|
|
2631
|
+
return BigInt(encodeShortString(it));
|
|
2632
|
+
})
|
|
2633
|
+
);
|
|
2634
|
+
}
|
|
2635
|
+
function hashEntryPoint(data) {
|
|
2636
|
+
const base = data.flatMap((it) => {
|
|
2637
|
+
return [BigInt(it.selector), BigInt(it.offset), hashBuiltins(it.builtins)];
|
|
2638
|
+
});
|
|
2639
|
+
return poseidonHashMany(base);
|
|
2640
|
+
}
|
|
2641
|
+
function computeCompiledClassHash(casm) {
|
|
2642
|
+
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
2643
|
+
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
2644
|
+
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
2645
|
+
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
2646
|
+
const constructor = hashEntryPoint(casm.entry_points_by_type.CONSTRUCTOR);
|
|
2647
|
+
const bytecode = poseidonHashMany(casm.bytecode.map((it) => BigInt(it)));
|
|
2648
|
+
return toHex(
|
|
2649
|
+
poseidonHashMany([
|
|
2650
|
+
compiledClassVersion,
|
|
2651
|
+
externalEntryPointsHash,
|
|
2652
|
+
l1Handlers,
|
|
2653
|
+
constructor,
|
|
2654
|
+
bytecode
|
|
2655
|
+
])
|
|
2656
|
+
);
|
|
2657
|
+
}
|
|
2658
|
+
function hashEntryPointSierra(data) {
|
|
2659
|
+
const base = data.flatMap((it) => {
|
|
2660
|
+
return [BigInt(it.selector), BigInt(it.function_idx)];
|
|
2661
|
+
});
|
|
2662
|
+
return poseidonHashMany(base);
|
|
2663
|
+
}
|
|
2664
|
+
function hashAbi(sierra) {
|
|
2665
|
+
const indentString = formatSpaces(stringify(sierra.abi, null));
|
|
2666
|
+
return BigInt(addHexPrefix(starkCurve.keccak(utf8ToArray(indentString)).toString(16)));
|
|
2667
|
+
}
|
|
2668
|
+
function computeSierraContractClassHash(sierra) {
|
|
2669
|
+
const CONTRACT_CLASS_VERSION = "CONTRACT_CLASS_V0.1.0";
|
|
2670
|
+
const compiledClassVersion = BigInt(encodeShortString(CONTRACT_CLASS_VERSION));
|
|
2671
|
+
const externalEntryPointsHash = hashEntryPointSierra(sierra.entry_points_by_type.EXTERNAL);
|
|
2672
|
+
const l1Handlers = hashEntryPointSierra(sierra.entry_points_by_type.L1_HANDLER);
|
|
2673
|
+
const constructor = hashEntryPointSierra(sierra.entry_points_by_type.CONSTRUCTOR);
|
|
2674
|
+
const abiHash = hashAbi(sierra);
|
|
2675
|
+
const sierraProgram = poseidonHashMany(sierra.sierra_program.map((it) => BigInt(it)));
|
|
2676
|
+
return toHex(
|
|
2677
|
+
poseidonHashMany([
|
|
2678
|
+
compiledClassVersion,
|
|
2679
|
+
externalEntryPointsHash,
|
|
2680
|
+
l1Handlers,
|
|
2681
|
+
constructor,
|
|
2682
|
+
abiHash,
|
|
2683
|
+
sierraProgram
|
|
2684
|
+
])
|
|
2685
|
+
);
|
|
2686
|
+
}
|
|
2687
|
+
function computeContractClassHash(contract) {
|
|
2688
|
+
const compiledContract = typeof contract === "string" ? parse(contract) : contract;
|
|
2689
|
+
if ("sierra_program" in compiledContract) {
|
|
2690
|
+
return computeSierraContractClassHash(compiledContract);
|
|
2691
|
+
}
|
|
2692
|
+
return computeLegacyContractClassHash(compiledContract);
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// src/utils/contract.ts
|
|
2696
|
+
import { parse as parse2 } from "json-bigint";
|
|
2697
|
+
function isSierra(contract) {
|
|
2698
|
+
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
2699
|
+
return "sierra_program" in compiledContract;
|
|
2700
|
+
}
|
|
2701
|
+
function extractContractHashes(payload) {
|
|
2702
|
+
const response = { ...payload };
|
|
2703
|
+
if (isSierra(payload.contract)) {
|
|
2704
|
+
if (!payload.compiledClassHash && payload.casm) {
|
|
2705
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
2706
|
+
}
|
|
2707
|
+
if (!response.compiledClassHash)
|
|
2708
|
+
throw new Error(
|
|
2709
|
+
"Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
|
|
2710
|
+
);
|
|
2711
|
+
}
|
|
2712
|
+
response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
|
|
2713
|
+
if (!response.classHash)
|
|
2714
|
+
throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
|
|
2715
|
+
return response;
|
|
2716
|
+
}
|
|
2608
2717
|
|
|
2609
2718
|
// src/utils/stark.ts
|
|
2610
2719
|
var stark_exports = {};
|
|
@@ -2619,7 +2728,7 @@ __export(stark_exports, {
|
|
|
2619
2728
|
signatureToDecimalArray: () => signatureToDecimalArray,
|
|
2620
2729
|
signatureToHexArray: () => signatureToHexArray
|
|
2621
2730
|
});
|
|
2622
|
-
import { Signature, getStarkKey, utils } from "
|
|
2731
|
+
import { Signature, getStarkKey, utils } from "micro-starknet";
|
|
2623
2732
|
import { gzip } from "pako";
|
|
2624
2733
|
function compressProgram(jsonProgram) {
|
|
2625
2734
|
const stringified = typeof jsonProgram === "string" ? jsonProgram : stringify(jsonProgram);
|
|
@@ -2689,12 +2798,23 @@ function parseCalldata(calldata = []) {
|
|
|
2689
2798
|
return toHex(data);
|
|
2690
2799
|
});
|
|
2691
2800
|
}
|
|
2801
|
+
function createSierraContractClass(contract) {
|
|
2802
|
+
const result = { ...contract };
|
|
2803
|
+
delete result.sierra_program_debug_info;
|
|
2804
|
+
result.abi = formatSpaces(stringify(contract.abi));
|
|
2805
|
+
result.sierra_program = formatSpaces(stringify(contract.sierra_program));
|
|
2806
|
+
result.sierra_program = compressProgram(result.sierra_program);
|
|
2807
|
+
return result;
|
|
2808
|
+
}
|
|
2692
2809
|
function parseContract(contract) {
|
|
2693
2810
|
const parsedContract = typeof contract === "string" ? parse(contract) : contract;
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2811
|
+
if (!isSierra(contract)) {
|
|
2812
|
+
return {
|
|
2813
|
+
...parsedContract,
|
|
2814
|
+
..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
return createSierraContractClass(parsedContract);
|
|
2698
2818
|
}
|
|
2699
2819
|
|
|
2700
2820
|
// src/utils/responseParser/rpc.ts
|
|
@@ -2714,6 +2834,7 @@ var RPCResponseParser = class {
|
|
|
2714
2834
|
return {
|
|
2715
2835
|
calldata: res.calldata || [],
|
|
2716
2836
|
contract_address: res.contract_address,
|
|
2837
|
+
sender_address: res.contract_address,
|
|
2717
2838
|
max_fee: res.max_fee,
|
|
2718
2839
|
nonce: res.nonce,
|
|
2719
2840
|
signature: res.signature || [],
|
|
@@ -3083,22 +3204,25 @@ var RpcProvider = class {
|
|
|
3083
3204
|
}
|
|
3084
3205
|
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
3085
3206
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3207
|
+
if ("program" in contractDefinition) {
|
|
3208
|
+
return this.fetchEndpoint("starknet_estimateFee", {
|
|
3209
|
+
request: {
|
|
3210
|
+
type: RPC.TransactionType.DECLARE,
|
|
3211
|
+
contract_class: {
|
|
3212
|
+
program: contractDefinition.program,
|
|
3213
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
3214
|
+
abi: contractDefinition.abi
|
|
3215
|
+
},
|
|
3216
|
+
sender_address: senderAddress,
|
|
3217
|
+
signature: signatureToHexArray(signature),
|
|
3218
|
+
version: toHex((details == null ? void 0 : details.version) || 0),
|
|
3219
|
+
nonce: toHex(details.nonce),
|
|
3220
|
+
max_fee: toHex((details == null ? void 0 : details.maxFee) || 0)
|
|
3093
3221
|
},
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
max_fee: toHex((details == null ? void 0 : details.maxFee) || 0)
|
|
3099
|
-
},
|
|
3100
|
-
block_id
|
|
3101
|
-
}).then(this.responseParser.parseFeeEstimateResponse);
|
|
3222
|
+
block_id
|
|
3223
|
+
}).then(this.responseParser.parseFeeEstimateResponse);
|
|
3224
|
+
}
|
|
3225
|
+
throw new Error("RPC do not support Sierra Contracts yet");
|
|
3102
3226
|
}
|
|
3103
3227
|
async getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
3104
3228
|
const block_id = new Block(blockIdentifier).identifier;
|
|
@@ -3120,21 +3244,24 @@ var RpcProvider = class {
|
|
|
3120
3244
|
throw new Error("RPC does not implement getInvokeEstimateFeeBulk function");
|
|
3121
3245
|
}
|
|
3122
3246
|
async declareContract({ contractDefinition, signature, senderAddress }, details) {
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3247
|
+
if ("program" in contractDefinition) {
|
|
3248
|
+
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
3249
|
+
declare_transaction: {
|
|
3250
|
+
contract_class: {
|
|
3251
|
+
program: contractDefinition.program,
|
|
3252
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
3253
|
+
abi: contractDefinition.abi
|
|
3254
|
+
},
|
|
3255
|
+
type: RPC.TransactionType.DECLARE,
|
|
3256
|
+
version: "0x1",
|
|
3257
|
+
max_fee: toHex(details.maxFee || 0),
|
|
3258
|
+
signature: signatureToHexArray(signature),
|
|
3259
|
+
sender_address: senderAddress,
|
|
3260
|
+
nonce: toHex(details.nonce)
|
|
3261
|
+
}
|
|
3262
|
+
});
|
|
3263
|
+
}
|
|
3264
|
+
throw new Error("RPC do not support Sierra Contracts yet");
|
|
3138
3265
|
}
|
|
3139
3266
|
async deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }, details) {
|
|
3140
3267
|
return this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
@@ -3157,7 +3284,7 @@ var RpcProvider = class {
|
|
|
3157
3284
|
calldata: parseCalldata(functionInvocation.calldata),
|
|
3158
3285
|
type: RPC.TransactionType.INVOKE,
|
|
3159
3286
|
max_fee: toHex(details.maxFee || 0),
|
|
3160
|
-
version:
|
|
3287
|
+
version: "0x1",
|
|
3161
3288
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
3162
3289
|
nonce: toHex(details.nonce)
|
|
3163
3290
|
}
|
|
@@ -3266,7 +3393,6 @@ var SequencerAPIResponseParser = class extends ResponseParser {
|
|
|
3266
3393
|
return {
|
|
3267
3394
|
...res,
|
|
3268
3395
|
calldata: "calldata" in res.transaction ? res.transaction.calldata : [],
|
|
3269
|
-
contract_address: "contract_address" in res.transaction ? res.transaction.contract_address : void 0,
|
|
3270
3396
|
contract_class: "contract_class" in res.transaction ? res.transaction.contract_class : void 0,
|
|
3271
3397
|
entry_point_selector: "entry_point_selector" in res.transaction ? res.transaction.entry_point_selector : void 0,
|
|
3272
3398
|
max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
|
|
@@ -3384,24 +3510,18 @@ var SequencerAPIResponseParser = class extends ResponseParser {
|
|
|
3384
3510
|
};
|
|
3385
3511
|
}
|
|
3386
3512
|
parseGetStateUpdateResponse(res) {
|
|
3387
|
-
const nonces =
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
return {
|
|
3395
|
-
address,
|
|
3396
|
-
storage_entries
|
|
3397
|
-
};
|
|
3398
|
-
});
|
|
3513
|
+
const nonces = Object.entries(res.state_diff.nonces).map(([contract_address, nonce]) => ({
|
|
3514
|
+
contract_address,
|
|
3515
|
+
nonce
|
|
3516
|
+
}));
|
|
3517
|
+
const storage_diffs = Object.entries(res.state_diff.storage_diffs).map(
|
|
3518
|
+
([address, storage_entries]) => ({ address, storage_entries })
|
|
3519
|
+
);
|
|
3399
3520
|
return {
|
|
3400
3521
|
...res,
|
|
3401
3522
|
state_diff: {
|
|
3523
|
+
...res.state_diff,
|
|
3402
3524
|
storage_diffs,
|
|
3403
|
-
declared_contract_hashes: res.state_diff.declared_contract_hashes,
|
|
3404
|
-
deployed_contracts: res.state_diff.deployed_contracts,
|
|
3405
3525
|
nonces
|
|
3406
3526
|
}
|
|
3407
3527
|
};
|
|
@@ -3575,7 +3695,6 @@ var SequencerProvider = class {
|
|
|
3575
3695
|
"call_contract",
|
|
3576
3696
|
{ blockIdentifier },
|
|
3577
3697
|
{
|
|
3578
|
-
signature: [],
|
|
3579
3698
|
contract_address: contractAddress,
|
|
3580
3699
|
entry_point_selector: getSelectorFromName(entryPointSelector),
|
|
3581
3700
|
calldata
|
|
@@ -3620,18 +3739,23 @@ var SequencerProvider = class {
|
|
|
3620
3739
|
async getClassHashAt(contractAddress, blockIdentifier = this.blockIdentifier) {
|
|
3621
3740
|
return this.fetchEndpoint("get_class_hash_at", { blockIdentifier, contractAddress });
|
|
3622
3741
|
}
|
|
3623
|
-
async getClassByHash(classHash) {
|
|
3624
|
-
return this.fetchEndpoint("get_class_by_hash", { classHash }).then(
|
|
3742
|
+
async getClassByHash(classHash, blockIdentifier = this.blockIdentifier) {
|
|
3743
|
+
return this.fetchEndpoint("get_class_by_hash", { classHash, blockIdentifier }).then(
|
|
3744
|
+
parseContract
|
|
3745
|
+
);
|
|
3746
|
+
}
|
|
3747
|
+
async getCompiledClassByClassHash(classHash, blockIdentifier = this.blockIdentifier) {
|
|
3748
|
+
return this.fetchEndpoint("get_compiled_class_by_class_hash", { classHash, blockIdentifier });
|
|
3625
3749
|
}
|
|
3626
3750
|
async invokeFunction(functionInvocation, details) {
|
|
3627
3751
|
return this.fetchEndpoint("add_transaction", void 0, {
|
|
3628
3752
|
type: "INVOKE_FUNCTION" /* INVOKE */,
|
|
3629
|
-
|
|
3753
|
+
sender_address: functionInvocation.contractAddress,
|
|
3630
3754
|
calldata: bigNumberishArrayToDecimalStringArray(functionInvocation.calldata ?? []),
|
|
3631
3755
|
signature: signatureToDecimalArray(functionInvocation.signature),
|
|
3632
3756
|
nonce: toHex(details.nonce),
|
|
3633
3757
|
max_fee: toHex(details.maxFee || 0),
|
|
3634
|
-
version:
|
|
3758
|
+
version: "0x1"
|
|
3635
3759
|
}).then(this.responseParser.parseInvokeFunctionResponse);
|
|
3636
3760
|
}
|
|
3637
3761
|
async deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }, details) {
|
|
@@ -3646,27 +3770,39 @@ var SequencerProvider = class {
|
|
|
3646
3770
|
signature: signatureToDecimalArray(signature)
|
|
3647
3771
|
}).then(this.responseParser.parseDeployContractResponse);
|
|
3648
3772
|
}
|
|
3649
|
-
async declareContract({ senderAddress, contractDefinition, signature }, details) {
|
|
3773
|
+
async declareContract({ senderAddress, contractDefinition, signature, compiledClassHash }, details) {
|
|
3774
|
+
if (!isSierra(contractDefinition)) {
|
|
3775
|
+
return this.fetchEndpoint("add_transaction", void 0, {
|
|
3776
|
+
type: "DECLARE" /* DECLARE */,
|
|
3777
|
+
contract_class: contractDefinition,
|
|
3778
|
+
nonce: toHex(details.nonce),
|
|
3779
|
+
signature: signatureToDecimalArray(signature),
|
|
3780
|
+
sender_address: senderAddress,
|
|
3781
|
+
max_fee: toHex(details.maxFee || 0),
|
|
3782
|
+
version: "0x1"
|
|
3783
|
+
}).then(this.responseParser.parseDeclareContractResponse);
|
|
3784
|
+
}
|
|
3650
3785
|
return this.fetchEndpoint("add_transaction", void 0, {
|
|
3651
3786
|
type: "DECLARE" /* DECLARE */,
|
|
3787
|
+
sender_address: senderAddress,
|
|
3788
|
+
compiled_class_hash: compiledClassHash,
|
|
3652
3789
|
contract_class: contractDefinition,
|
|
3653
3790
|
nonce: toHex(details.nonce),
|
|
3654
3791
|
signature: signatureToDecimalArray(signature),
|
|
3655
|
-
sender_address: senderAddress,
|
|
3656
3792
|
max_fee: toHex(details.maxFee || 0),
|
|
3657
|
-
version:
|
|
3793
|
+
version: "0x2"
|
|
3658
3794
|
}).then(this.responseParser.parseDeclareContractResponse);
|
|
3659
3795
|
}
|
|
3660
|
-
async getEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
3661
|
-
return this.getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier);
|
|
3796
|
+
async getEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
3797
|
+
return this.getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier, skipValidate);
|
|
3662
3798
|
}
|
|
3663
|
-
async getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
3799
|
+
async getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
3664
3800
|
return this.fetchEndpoint(
|
|
3665
3801
|
"estimate_fee",
|
|
3666
|
-
{ blockIdentifier },
|
|
3802
|
+
{ blockIdentifier, skipValidate },
|
|
3667
3803
|
{
|
|
3668
3804
|
type: "INVOKE_FUNCTION" /* INVOKE */,
|
|
3669
|
-
|
|
3805
|
+
sender_address: invocation.contractAddress,
|
|
3670
3806
|
calldata: invocation.calldata ?? [],
|
|
3671
3807
|
signature: signatureToDecimalArray(invocation.signature),
|
|
3672
3808
|
version: toHex((invocationDetails == null ? void 0 : invocationDetails.version) || 1),
|
|
@@ -3674,24 +3810,39 @@ var SequencerProvider = class {
|
|
|
3674
3810
|
}
|
|
3675
3811
|
).then(this.responseParser.parseFeeEstimateResponse);
|
|
3676
3812
|
}
|
|
3677
|
-
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
3813
|
+
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature, compiledClassHash }, details, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
3814
|
+
if (!isSierra(contractDefinition)) {
|
|
3815
|
+
return this.fetchEndpoint(
|
|
3816
|
+
"estimate_fee",
|
|
3817
|
+
{ blockIdentifier, skipValidate },
|
|
3818
|
+
{
|
|
3819
|
+
type: "DECLARE" /* DECLARE */,
|
|
3820
|
+
sender_address: senderAddress,
|
|
3821
|
+
contract_class: contractDefinition,
|
|
3822
|
+
signature: signatureToDecimalArray(signature),
|
|
3823
|
+
version: toHex((details == null ? void 0 : details.version) || toBigInt(feeTransactionVersion)),
|
|
3824
|
+
nonce: toHex(details.nonce)
|
|
3825
|
+
}
|
|
3826
|
+
).then(this.responseParser.parseFeeEstimateResponse);
|
|
3827
|
+
}
|
|
3678
3828
|
return this.fetchEndpoint(
|
|
3679
3829
|
"estimate_fee",
|
|
3680
|
-
{ blockIdentifier },
|
|
3830
|
+
{ blockIdentifier, skipValidate },
|
|
3681
3831
|
{
|
|
3682
3832
|
type: "DECLARE" /* DECLARE */,
|
|
3683
3833
|
sender_address: senderAddress,
|
|
3834
|
+
compiled_class_hash: compiledClassHash,
|
|
3684
3835
|
contract_class: contractDefinition,
|
|
3836
|
+
nonce: toHex(details.nonce),
|
|
3685
3837
|
signature: signatureToDecimalArray(signature),
|
|
3686
|
-
version:
|
|
3687
|
-
nonce: toHex(details.nonce)
|
|
3838
|
+
version: "0x2"
|
|
3688
3839
|
}
|
|
3689
3840
|
).then(this.responseParser.parseFeeEstimateResponse);
|
|
3690
3841
|
}
|
|
3691
|
-
async getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
3842
|
+
async getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }, details, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
3692
3843
|
return this.fetchEndpoint(
|
|
3693
3844
|
"estimate_fee",
|
|
3694
|
-
{ blockIdentifier },
|
|
3845
|
+
{ blockIdentifier, skipValidate },
|
|
3695
3846
|
{
|
|
3696
3847
|
type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
|
|
3697
3848
|
class_hash: toHex(classHash),
|
|
@@ -3709,7 +3860,7 @@ var SequencerProvider = class {
|
|
|
3709
3860
|
if (invocation.type === "INVOKE_FUNCTION") {
|
|
3710
3861
|
res = {
|
|
3711
3862
|
type: invocation.type,
|
|
3712
|
-
|
|
3863
|
+
sender_address: invocation.contractAddress,
|
|
3713
3864
|
calldata: invocation.calldata ?? []
|
|
3714
3865
|
};
|
|
3715
3866
|
} else if (invocation.type === "DECLARE") {
|
|
@@ -3788,13 +3939,13 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
3788
3939
|
};
|
|
3789
3940
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
3790
3941
|
}
|
|
3791
|
-
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
3942
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
3792
3943
|
return this.fetchEndpoint(
|
|
3793
3944
|
"simulate_transaction",
|
|
3794
|
-
{ blockIdentifier },
|
|
3945
|
+
{ blockIdentifier, skipValidate },
|
|
3795
3946
|
{
|
|
3796
3947
|
type: "INVOKE_FUNCTION",
|
|
3797
|
-
|
|
3948
|
+
sender_address: invocation.contractAddress,
|
|
3798
3949
|
calldata: invocation.calldata ?? [],
|
|
3799
3950
|
signature: signatureToDecimalArray(invocation.signature),
|
|
3800
3951
|
version: toHex((invocationDetails == null ? void 0 : invocationDetails.version) || 1),
|
|
@@ -3854,11 +4005,12 @@ var Provider = class {
|
|
|
3854
4005
|
async getEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier) {
|
|
3855
4006
|
return this.provider.getEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier);
|
|
3856
4007
|
}
|
|
3857
|
-
async getInvokeEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier) {
|
|
4008
|
+
async getInvokeEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier, skipValidate) {
|
|
3858
4009
|
return this.provider.getInvokeEstimateFee(
|
|
3859
4010
|
invocationWithTxType,
|
|
3860
4011
|
invocationDetails,
|
|
3861
|
-
blockIdentifier
|
|
4012
|
+
blockIdentifier,
|
|
4013
|
+
skipValidate
|
|
3862
4014
|
);
|
|
3863
4015
|
}
|
|
3864
4016
|
async getEstimateFeeBulk(invocations, blockIdentifier) {
|
|
@@ -3888,11 +4040,16 @@ var Provider = class {
|
|
|
3888
4040
|
async declareContract(transaction, details) {
|
|
3889
4041
|
return this.provider.declareContract(transaction, details);
|
|
3890
4042
|
}
|
|
3891
|
-
async getDeclareEstimateFee(transaction, details, blockIdentifier) {
|
|
3892
|
-
return this.provider.getDeclareEstimateFee(transaction, details, blockIdentifier);
|
|
4043
|
+
async getDeclareEstimateFee(transaction, details, blockIdentifier, skipValidate) {
|
|
4044
|
+
return this.provider.getDeclareEstimateFee(transaction, details, blockIdentifier, skipValidate);
|
|
3893
4045
|
}
|
|
3894
|
-
getDeployAccountEstimateFee(transaction, details, blockIdentifier) {
|
|
3895
|
-
return this.provider.getDeployAccountEstimateFee(
|
|
4046
|
+
getDeployAccountEstimateFee(transaction, details, blockIdentifier, skipValidate) {
|
|
4047
|
+
return this.provider.getDeployAccountEstimateFee(
|
|
4048
|
+
transaction,
|
|
4049
|
+
details,
|
|
4050
|
+
blockIdentifier,
|
|
4051
|
+
skipValidate
|
|
4052
|
+
);
|
|
3896
4053
|
}
|
|
3897
4054
|
async getCode(contractAddress, blockIdentifier) {
|
|
3898
4055
|
return this.provider.getCode(contractAddress, blockIdentifier);
|
|
@@ -3900,8 +4057,13 @@ var Provider = class {
|
|
|
3900
4057
|
async waitForTransaction(txHash, options) {
|
|
3901
4058
|
return this.provider.waitForTransaction(txHash, options);
|
|
3902
4059
|
}
|
|
3903
|
-
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
3904
|
-
return this.provider.getSimulateTransaction(
|
|
4060
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier, skipValidate) {
|
|
4061
|
+
return this.provider.getSimulateTransaction(
|
|
4062
|
+
invocation,
|
|
4063
|
+
invocationDetails,
|
|
4064
|
+
blockIdentifier,
|
|
4065
|
+
skipValidate
|
|
4066
|
+
);
|
|
3905
4067
|
}
|
|
3906
4068
|
async getStateUpdate(blockIdentifier) {
|
|
3907
4069
|
return this.provider.getStateUpdate(blockIdentifier);
|
|
@@ -4879,14 +5041,23 @@ var Signer = class {
|
|
|
4879
5041
|
);
|
|
4880
5042
|
return starkCurve.sign(msgHash, this.pk);
|
|
4881
5043
|
}
|
|
4882
|
-
async signDeclareTransaction({
|
|
5044
|
+
async signDeclareTransaction({
|
|
5045
|
+
classHash,
|
|
5046
|
+
senderAddress,
|
|
5047
|
+
chainId,
|
|
5048
|
+
maxFee,
|
|
5049
|
+
version,
|
|
5050
|
+
nonce,
|
|
5051
|
+
compiledClassHash
|
|
5052
|
+
}) {
|
|
4883
5053
|
const msgHash = calculateDeclareTransactionHash(
|
|
4884
5054
|
classHash,
|
|
4885
5055
|
senderAddress,
|
|
4886
5056
|
version,
|
|
4887
5057
|
maxFee,
|
|
4888
5058
|
chainId,
|
|
4889
|
-
nonce
|
|
5059
|
+
nonce,
|
|
5060
|
+
compiledClassHash
|
|
4890
5061
|
);
|
|
4891
5062
|
return starkCurve.sign(msgHash, this.pk);
|
|
4892
5063
|
}
|
|
@@ -4928,7 +5099,7 @@ var Account = class extends Provider {
|
|
|
4928
5099
|
async estimateFee(calls, estimateFeeDetails) {
|
|
4929
5100
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
4930
5101
|
}
|
|
4931
|
-
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
5102
|
+
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
4932
5103
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
4933
5104
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
4934
5105
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -4944,7 +5115,8 @@ var Account = class extends Provider {
|
|
|
4944
5115
|
const response = await super.getInvokeEstimateFee(
|
|
4945
5116
|
{ ...invocation },
|
|
4946
5117
|
{ version, nonce },
|
|
4947
|
-
blockIdentifier
|
|
5118
|
+
blockIdentifier,
|
|
5119
|
+
skipValidate
|
|
4948
5120
|
);
|
|
4949
5121
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
4950
5122
|
return {
|
|
@@ -4952,18 +5124,19 @@ var Account = class extends Provider {
|
|
|
4952
5124
|
suggestedMaxFee
|
|
4953
5125
|
};
|
|
4954
5126
|
}
|
|
4955
|
-
async estimateDeclareFee({ contract, classHash: providedClassHash }, { blockIdentifier, nonce: providedNonce } = {}) {
|
|
5127
|
+
async estimateDeclareFee({ contract, classHash: providedClassHash, casm, compiledClassHash }, { blockIdentifier, nonce: providedNonce, skipValidate } = {}) {
|
|
4956
5128
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
4957
|
-
const version = toBigInt(feeTransactionVersion);
|
|
5129
|
+
const version = !isSierra(contract) ? toBigInt(feeTransactionVersion) : transactionVersion_2;
|
|
4958
5130
|
const chainId = await this.getChainId();
|
|
4959
|
-
const
|
|
4960
|
-
{ classHash: providedClassHash, contract },
|
|
5131
|
+
const declareContractTransaction = await this.buildDeclarePayload(
|
|
5132
|
+
{ classHash: providedClassHash, contract, casm, compiledClassHash },
|
|
4961
5133
|
{ nonce, chainId, version, walletAddress: this.address, maxFee: ZERO }
|
|
4962
5134
|
);
|
|
4963
5135
|
const response = await super.getDeclareEstimateFee(
|
|
4964
|
-
|
|
5136
|
+
declareContractTransaction,
|
|
4965
5137
|
{ version, nonce },
|
|
4966
|
-
blockIdentifier
|
|
5138
|
+
blockIdentifier,
|
|
5139
|
+
skipValidate
|
|
4967
5140
|
);
|
|
4968
5141
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
4969
5142
|
return {
|
|
@@ -4976,7 +5149,7 @@ var Account = class extends Provider {
|
|
|
4976
5149
|
addressSalt = 0,
|
|
4977
5150
|
constructorCalldata = [],
|
|
4978
5151
|
contractAddress: providedContractAddress
|
|
4979
|
-
}, { blockIdentifier } = {}) {
|
|
5152
|
+
}, { blockIdentifier, skipValidate } = {}) {
|
|
4980
5153
|
const version = toBigInt(feeTransactionVersion);
|
|
4981
5154
|
const nonce = ZERO;
|
|
4982
5155
|
const chainId = await this.getChainId();
|
|
@@ -4987,7 +5160,8 @@ var Account = class extends Provider {
|
|
|
4987
5160
|
const response = await super.getDeployAccountEstimateFee(
|
|
4988
5161
|
{ ...payload },
|
|
4989
5162
|
{ version, nonce },
|
|
4990
|
-
blockIdentifier
|
|
5163
|
+
blockIdentifier,
|
|
5164
|
+
skipValidate
|
|
4991
5165
|
);
|
|
4992
5166
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
4993
5167
|
return {
|
|
@@ -5103,32 +5277,24 @@ var Account = class extends Provider {
|
|
|
5103
5277
|
}
|
|
5104
5278
|
);
|
|
5105
5279
|
}
|
|
5106
|
-
async declare(
|
|
5107
|
-
const
|
|
5108
|
-
const
|
|
5109
|
-
|
|
5110
|
-
|
|
5280
|
+
async declare(payload, transactionsDetail = {}) {
|
|
5281
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
5282
|
+
const details = {};
|
|
5283
|
+
details.nonce = toBigInt(transactionsDetail.nonce ?? await this.getNonce());
|
|
5284
|
+
details.maxFee = transactionsDetail.maxFee ?? await this.getSuggestedMaxFee(
|
|
5285
|
+
{
|
|
5286
|
+
type: "DECLARE" /* DECLARE */,
|
|
5287
|
+
payload: declareContractPayload
|
|
5288
|
+
},
|
|
5111
5289
|
transactionsDetail
|
|
5112
5290
|
);
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
const
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
chainId,
|
|
5119
|
-
maxFee,
|
|
5120
|
-
version,
|
|
5121
|
-
nonce
|
|
5291
|
+
details.version = !isSierra(payload.contract) ? transactionVersion : transactionVersion_2;
|
|
5292
|
+
details.chainId = await this.getChainId();
|
|
5293
|
+
const declareContractTransaction = await this.buildDeclarePayload(declareContractPayload, {
|
|
5294
|
+
...details,
|
|
5295
|
+
walletAddress: this.address
|
|
5122
5296
|
});
|
|
5123
|
-
|
|
5124
|
-
return this.declareContract(
|
|
5125
|
-
{ contractDefinition, senderAddress: this.address, signature },
|
|
5126
|
-
{
|
|
5127
|
-
nonce,
|
|
5128
|
-
maxFee,
|
|
5129
|
-
version
|
|
5130
|
-
}
|
|
5131
|
-
);
|
|
5297
|
+
return this.declareContract(declareContractTransaction, details);
|
|
5132
5298
|
}
|
|
5133
5299
|
async deploy(payload, details) {
|
|
5134
5300
|
const params = [].concat(payload).map((it) => {
|
|
@@ -5269,11 +5435,12 @@ var Account = class extends Provider {
|
|
|
5269
5435
|
}
|
|
5270
5436
|
return feeEstimate.suggestedMaxFee.toString();
|
|
5271
5437
|
}
|
|
5272
|
-
async buildDeclarePayload(
|
|
5438
|
+
async buildDeclarePayload(payload, { nonce, chainId, version, walletAddress, maxFee }) {
|
|
5439
|
+
const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
|
|
5273
5440
|
const contractDefinition = parseContract(contract);
|
|
5274
|
-
const classHash = providedClassHash ?? computeContractClassHash(contract);
|
|
5275
5441
|
const signature = await this.signer.signDeclareTransaction({
|
|
5276
5442
|
classHash,
|
|
5443
|
+
compiledClassHash,
|
|
5277
5444
|
senderAddress: walletAddress,
|
|
5278
5445
|
chainId,
|
|
5279
5446
|
maxFee,
|
|
@@ -5283,7 +5450,8 @@ var Account = class extends Provider {
|
|
|
5283
5450
|
return {
|
|
5284
5451
|
senderAddress: walletAddress,
|
|
5285
5452
|
signature,
|
|
5286
|
-
contractDefinition
|
|
5453
|
+
contractDefinition,
|
|
5454
|
+
compiledClassHash
|
|
5287
5455
|
};
|
|
5288
5456
|
}
|
|
5289
5457
|
async buildAccountDeployPayload({
|
|
@@ -5333,7 +5501,7 @@ var Account = class extends Provider {
|
|
|
5333
5501
|
});
|
|
5334
5502
|
return calls;
|
|
5335
5503
|
}
|
|
5336
|
-
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
5504
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
5337
5505
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
5338
5506
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
5339
5507
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -5349,7 +5517,8 @@ var Account = class extends Provider {
|
|
|
5349
5517
|
const response = await super.getSimulateTransaction(
|
|
5350
5518
|
invocation,
|
|
5351
5519
|
{ version, nonce },
|
|
5352
|
-
blockIdentifier
|
|
5520
|
+
blockIdentifier,
|
|
5521
|
+
skipValidate
|
|
5353
5522
|
);
|
|
5354
5523
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
5355
5524
|
return {
|
|
@@ -5370,7 +5539,7 @@ var AccountInterface = class extends ProviderInterface {
|
|
|
5370
5539
|
};
|
|
5371
5540
|
|
|
5372
5541
|
// src/utils/address.ts
|
|
5373
|
-
import {
|
|
5542
|
+
import { hexToBytes as hexToBytes2 } from "@noble/curves/abstract/utils";
|
|
5374
5543
|
function addAddressPadding(address) {
|
|
5375
5544
|
return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));
|
|
5376
5545
|
}
|
|
@@ -5384,7 +5553,8 @@ function validateAndParseAddress(address) {
|
|
|
5384
5553
|
}
|
|
5385
5554
|
function getChecksumAddress(address) {
|
|
5386
5555
|
const chars = removeHexPrefix(validateAndParseAddress(address)).toLowerCase().split("");
|
|
5387
|
-
const
|
|
5556
|
+
const hex = removeHexPrefix(keccakBn(address));
|
|
5557
|
+
const hashed = hexToBytes2(hex.padStart(64, "0"));
|
|
5388
5558
|
for (let i = 0; i < chars.length; i += 2) {
|
|
5389
5559
|
if (hashed[i >> 1] >> 4 >= 8) {
|
|
5390
5560
|
chars[i] = chars[i].toUpperCase();
|
|
@@ -5404,9 +5574,11 @@ var number = num_exports;
|
|
|
5404
5574
|
export {
|
|
5405
5575
|
Account,
|
|
5406
5576
|
AccountInterface,
|
|
5577
|
+
CallData,
|
|
5407
5578
|
Contract,
|
|
5408
5579
|
ContractFactory,
|
|
5409
5580
|
ContractInterface,
|
|
5581
|
+
EntryPointType,
|
|
5410
5582
|
GatewayError,
|
|
5411
5583
|
HttpError,
|
|
5412
5584
|
LibraryError,
|