starknet 5.14.0 → 5.14.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 +7 -0
- package/dist/index.d.ts +68 -5
- package/dist/index.global.js +63 -38
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +67 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2323,6 +2323,13 @@ function hexToBytes(value) {
|
|
|
2323
2323
|
}
|
|
2324
2324
|
|
|
2325
2325
|
// src/utils/selector.ts
|
|
2326
|
+
var selector_exports = {};
|
|
2327
|
+
__export(selector_exports, {
|
|
2328
|
+
getSelector: () => getSelector,
|
|
2329
|
+
getSelectorFromName: () => getSelectorFromName,
|
|
2330
|
+
keccakBn: () => keccakBn,
|
|
2331
|
+
starknetKeccak: () => starknetKeccak
|
|
2332
|
+
});
|
|
2326
2333
|
import { keccak } from "micro-starknet";
|
|
2327
2334
|
function keccakBn(value) {
|
|
2328
2335
|
const hexWithoutPrefix = removeHexPrefix(toHex(BigInt(value)));
|
|
@@ -3539,34 +3546,6 @@ function computeContractClassHash(contract) {
|
|
|
3539
3546
|
return computeLegacyContractClassHash(compiledContract);
|
|
3540
3547
|
}
|
|
3541
3548
|
|
|
3542
|
-
// src/utils/contract.ts
|
|
3543
|
-
function isSierra(contract) {
|
|
3544
|
-
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
3545
|
-
return "sierra_program" in compiledContract;
|
|
3546
|
-
}
|
|
3547
|
-
function extractContractHashes(payload) {
|
|
3548
|
-
const response = { ...payload };
|
|
3549
|
-
if (isSierra(payload.contract)) {
|
|
3550
|
-
if (!payload.compiledClassHash && payload.casm) {
|
|
3551
|
-
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
3552
|
-
}
|
|
3553
|
-
if (!response.compiledClassHash)
|
|
3554
|
-
throw new Error(
|
|
3555
|
-
"Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
|
|
3556
|
-
);
|
|
3557
|
-
}
|
|
3558
|
-
response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
|
|
3559
|
-
if (!response.classHash)
|
|
3560
|
-
throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
|
|
3561
|
-
return response;
|
|
3562
|
-
}
|
|
3563
|
-
|
|
3564
|
-
// src/utils/fetchPonyfill.ts
|
|
3565
|
-
import isomorphicFetch from "isomorphic-fetch";
|
|
3566
|
-
var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
|
|
3567
|
-
typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
|
|
3568
|
-
isomorphicFetch;
|
|
3569
|
-
|
|
3570
3549
|
// src/utils/stark.ts
|
|
3571
3550
|
var stark_exports = {};
|
|
3572
3551
|
__export(stark_exports, {
|
|
@@ -3623,7 +3602,48 @@ function estimatedFeeToMaxFee(estimatedFee, overhead = 0.5) {
|
|
|
3623
3602
|
return toBigInt(estimatedFee) * toBigInt(overHeadPercent) / 100n;
|
|
3624
3603
|
}
|
|
3625
3604
|
|
|
3605
|
+
// src/utils/contract.ts
|
|
3606
|
+
function isSierra(contract) {
|
|
3607
|
+
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
3608
|
+
return "sierra_program" in compiledContract;
|
|
3609
|
+
}
|
|
3610
|
+
function extractContractHashes(payload) {
|
|
3611
|
+
const response = { ...payload };
|
|
3612
|
+
if (isSierra(payload.contract)) {
|
|
3613
|
+
if (!payload.compiledClassHash && payload.casm) {
|
|
3614
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
3615
|
+
}
|
|
3616
|
+
if (!response.compiledClassHash)
|
|
3617
|
+
throw new Error(
|
|
3618
|
+
"Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
|
|
3619
|
+
);
|
|
3620
|
+
}
|
|
3621
|
+
response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
|
|
3622
|
+
if (!response.classHash)
|
|
3623
|
+
throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
|
|
3624
|
+
return response;
|
|
3625
|
+
}
|
|
3626
|
+
function contractClassResponseToLegacyCompiledContract(ccr) {
|
|
3627
|
+
if (isSierra(ccr)) {
|
|
3628
|
+
throw Error("ContractClassResponse need to be LegacyContractClass (cairo0 response class)");
|
|
3629
|
+
}
|
|
3630
|
+
const contract = ccr;
|
|
3631
|
+
return { ...contract, program: decompressProgram(contract.program) };
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
// src/utils/fetchPonyfill.ts
|
|
3635
|
+
import isomorphicFetch from "isomorphic-fetch";
|
|
3636
|
+
var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
|
|
3637
|
+
typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
|
|
3638
|
+
isomorphicFetch;
|
|
3639
|
+
|
|
3626
3640
|
// src/utils/provider.ts
|
|
3641
|
+
var provider_exports = {};
|
|
3642
|
+
__export(provider_exports, {
|
|
3643
|
+
createSierraContractClass: () => createSierraContractClass,
|
|
3644
|
+
parseContract: () => parseContract,
|
|
3645
|
+
wait: () => wait
|
|
3646
|
+
});
|
|
3627
3647
|
function wait(delay) {
|
|
3628
3648
|
return new Promise((res) => {
|
|
3629
3649
|
setTimeout(res, delay);
|
|
@@ -3642,7 +3662,6 @@ function parseContract(contract) {
|
|
|
3642
3662
|
if (!isSierra(contract)) {
|
|
3643
3663
|
return {
|
|
3644
3664
|
...parsedContract,
|
|
3645
|
-
// TODO: Why do we gzip program object?
|
|
3646
3665
|
..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
|
|
3647
3666
|
};
|
|
3648
3667
|
}
|
|
@@ -4134,14 +4153,13 @@ var RpcProvider = class {
|
|
|
4134
4153
|
}
|
|
4135
4154
|
async declareContract({ contract, signature, senderAddress, compiledClassHash }, details) {
|
|
4136
4155
|
if (!isSierra(contract)) {
|
|
4137
|
-
const legacyContract = contract;
|
|
4138
4156
|
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4139
4157
|
declare_transaction: {
|
|
4140
4158
|
type: RPC.TransactionType.DECLARE,
|
|
4141
4159
|
contract_class: {
|
|
4142
|
-
program:
|
|
4143
|
-
entry_points_by_type:
|
|
4144
|
-
abi:
|
|
4160
|
+
program: contract.program,
|
|
4161
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4162
|
+
abi: contract.abi
|
|
4145
4163
|
},
|
|
4146
4164
|
version: toHex(transactionVersion),
|
|
4147
4165
|
max_fee: toHex(details.maxFee || 0),
|
|
@@ -4151,15 +4169,14 @@ var RpcProvider = class {
|
|
|
4151
4169
|
}
|
|
4152
4170
|
});
|
|
4153
4171
|
}
|
|
4154
|
-
const sierraContract = contract;
|
|
4155
4172
|
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4156
4173
|
declare_transaction: {
|
|
4157
4174
|
type: RPC.TransactionType.DECLARE,
|
|
4158
4175
|
contract_class: {
|
|
4159
|
-
sierra_program: decompressProgram(
|
|
4160
|
-
contract_class_version:
|
|
4161
|
-
entry_points_by_type:
|
|
4162
|
-
abi:
|
|
4176
|
+
sierra_program: decompressProgram(contract.sierra_program),
|
|
4177
|
+
contract_class_version: contract.contract_class_version,
|
|
4178
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4179
|
+
abi: contract.abi
|
|
4163
4180
|
},
|
|
4164
4181
|
compiled_class_hash: compiledClassHash || "",
|
|
4165
4182
|
version: toHex(transactionVersion_2),
|
|
@@ -6332,19 +6349,25 @@ export {
|
|
|
6332
6349
|
buildUrl,
|
|
6333
6350
|
cairo_exports as cairo,
|
|
6334
6351
|
constants_exports as constants,
|
|
6352
|
+
contractClassResponseToLegacyCompiledContract,
|
|
6335
6353
|
defaultProvider,
|
|
6336
6354
|
ec_exports as ec,
|
|
6337
6355
|
encode_exports as encode,
|
|
6356
|
+
extractContractHashes,
|
|
6338
6357
|
fixProto,
|
|
6339
6358
|
fixStack,
|
|
6340
6359
|
getCalldata,
|
|
6341
6360
|
getChecksumAddress,
|
|
6342
6361
|
hash_exports as hash,
|
|
6362
|
+
isSierra,
|
|
6343
6363
|
isUrl,
|
|
6344
6364
|
json_exports as json,
|
|
6345
6365
|
merkle_exports as merkle,
|
|
6346
6366
|
num_exports as num,
|
|
6347
6367
|
number,
|
|
6368
|
+
parseUDCEvent,
|
|
6369
|
+
provider_exports as provider,
|
|
6370
|
+
selector_exports as selector,
|
|
6348
6371
|
shortString_exports as shortString,
|
|
6349
6372
|
splitArgsAndOptions,
|
|
6350
6373
|
stark_exports as stark,
|