starknet 5.13.2 → 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 +63 -109
- package/dist/index.d.ts +92 -5
- package/dist/index.global.js +80 -38
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +84 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -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)));
|
|
@@ -2406,6 +2413,7 @@ __export(cairo_exports, {
|
|
|
2406
2413
|
Uint: () => Uint,
|
|
2407
2414
|
felt: () => felt,
|
|
2408
2415
|
getArrayType: () => getArrayType,
|
|
2416
|
+
isCairo1Abi: () => isCairo1Abi,
|
|
2409
2417
|
isCairo1Type: () => isCairo1Type,
|
|
2410
2418
|
isLen: () => isLen,
|
|
2411
2419
|
isTypeArray: () => isTypeArray,
|
|
@@ -2475,6 +2483,19 @@ var getArrayType = (type) => {
|
|
|
2475
2483
|
}
|
|
2476
2484
|
return type.replace("*", "");
|
|
2477
2485
|
};
|
|
2486
|
+
function isCairo1Abi(abi) {
|
|
2487
|
+
const firstFunction = abi.find((entry) => entry.type === "function");
|
|
2488
|
+
if (!firstFunction) {
|
|
2489
|
+
throw new Error(`Error in ABI. No function in ABI.`);
|
|
2490
|
+
}
|
|
2491
|
+
if (firstFunction.inputs.length) {
|
|
2492
|
+
return isCairo1Type(firstFunction.inputs[0].type);
|
|
2493
|
+
}
|
|
2494
|
+
if (firstFunction.outputs.length) {
|
|
2495
|
+
return isCairo1Type(firstFunction.outputs[0].type);
|
|
2496
|
+
}
|
|
2497
|
+
throw new Error(`Error in ABI. No input/output in function ${firstFunction.name}`);
|
|
2498
|
+
}
|
|
2478
2499
|
var uint256 = (it) => {
|
|
2479
2500
|
const bn = BigInt(it);
|
|
2480
2501
|
if (!isUint256(bn))
|
|
@@ -3525,34 +3546,6 @@ function computeContractClassHash(contract) {
|
|
|
3525
3546
|
return computeLegacyContractClassHash(compiledContract);
|
|
3526
3547
|
}
|
|
3527
3548
|
|
|
3528
|
-
// src/utils/contract.ts
|
|
3529
|
-
function isSierra(contract) {
|
|
3530
|
-
const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
|
|
3531
|
-
return "sierra_program" in compiledContract;
|
|
3532
|
-
}
|
|
3533
|
-
function extractContractHashes(payload) {
|
|
3534
|
-
const response = { ...payload };
|
|
3535
|
-
if (isSierra(payload.contract)) {
|
|
3536
|
-
if (!payload.compiledClassHash && payload.casm) {
|
|
3537
|
-
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
3538
|
-
}
|
|
3539
|
-
if (!response.compiledClassHash)
|
|
3540
|
-
throw new Error(
|
|
3541
|
-
"Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
|
|
3542
|
-
);
|
|
3543
|
-
}
|
|
3544
|
-
response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
|
|
3545
|
-
if (!response.classHash)
|
|
3546
|
-
throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
|
|
3547
|
-
return response;
|
|
3548
|
-
}
|
|
3549
|
-
|
|
3550
|
-
// src/utils/fetchPonyfill.ts
|
|
3551
|
-
import isomorphicFetch from "isomorphic-fetch";
|
|
3552
|
-
var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
|
|
3553
|
-
typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
|
|
3554
|
-
isomorphicFetch;
|
|
3555
|
-
|
|
3556
3549
|
// src/utils/stark.ts
|
|
3557
3550
|
var stark_exports = {};
|
|
3558
3551
|
__export(stark_exports, {
|
|
@@ -3609,7 +3602,48 @@ function estimatedFeeToMaxFee(estimatedFee, overhead = 0.5) {
|
|
|
3609
3602
|
return toBigInt(estimatedFee) * toBigInt(overHeadPercent) / 100n;
|
|
3610
3603
|
}
|
|
3611
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
|
+
|
|
3612
3640
|
// src/utils/provider.ts
|
|
3641
|
+
var provider_exports = {};
|
|
3642
|
+
__export(provider_exports, {
|
|
3643
|
+
createSierraContractClass: () => createSierraContractClass,
|
|
3644
|
+
parseContract: () => parseContract,
|
|
3645
|
+
wait: () => wait
|
|
3646
|
+
});
|
|
3613
3647
|
function wait(delay) {
|
|
3614
3648
|
return new Promise((res) => {
|
|
3615
3649
|
setTimeout(res, delay);
|
|
@@ -3628,7 +3662,6 @@ function parseContract(contract) {
|
|
|
3628
3662
|
if (!isSierra(contract)) {
|
|
3629
3663
|
return {
|
|
3630
3664
|
...parsedContract,
|
|
3631
|
-
// TODO: Why do we gzip program object?
|
|
3632
3665
|
..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
|
|
3633
3666
|
};
|
|
3634
3667
|
}
|
|
@@ -4120,14 +4153,13 @@ var RpcProvider = class {
|
|
|
4120
4153
|
}
|
|
4121
4154
|
async declareContract({ contract, signature, senderAddress, compiledClassHash }, details) {
|
|
4122
4155
|
if (!isSierra(contract)) {
|
|
4123
|
-
const legacyContract = contract;
|
|
4124
4156
|
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4125
4157
|
declare_transaction: {
|
|
4126
4158
|
type: RPC.TransactionType.DECLARE,
|
|
4127
4159
|
contract_class: {
|
|
4128
|
-
program:
|
|
4129
|
-
entry_points_by_type:
|
|
4130
|
-
abi:
|
|
4160
|
+
program: contract.program,
|
|
4161
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4162
|
+
abi: contract.abi
|
|
4131
4163
|
},
|
|
4132
4164
|
version: toHex(transactionVersion),
|
|
4133
4165
|
max_fee: toHex(details.maxFee || 0),
|
|
@@ -4137,15 +4169,14 @@ var RpcProvider = class {
|
|
|
4137
4169
|
}
|
|
4138
4170
|
});
|
|
4139
4171
|
}
|
|
4140
|
-
const sierraContract = contract;
|
|
4141
4172
|
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4142
4173
|
declare_transaction: {
|
|
4143
4174
|
type: RPC.TransactionType.DECLARE,
|
|
4144
4175
|
contract_class: {
|
|
4145
|
-
sierra_program: decompressProgram(
|
|
4146
|
-
contract_class_version:
|
|
4147
|
-
entry_points_by_type:
|
|
4148
|
-
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
|
|
4149
4180
|
},
|
|
4150
4181
|
compiled_class_hash: compiledClassHash || "",
|
|
4151
4182
|
version: toHex(transactionVersion_2),
|
|
@@ -6186,6 +6217,9 @@ var Contract = class {
|
|
|
6186
6217
|
calldata
|
|
6187
6218
|
};
|
|
6188
6219
|
}
|
|
6220
|
+
isCairo1() {
|
|
6221
|
+
return cairo_exports.isCairo1Abi(this.abi);
|
|
6222
|
+
}
|
|
6189
6223
|
};
|
|
6190
6224
|
|
|
6191
6225
|
// src/contract/interface.ts
|
|
@@ -6315,19 +6349,25 @@ export {
|
|
|
6315
6349
|
buildUrl,
|
|
6316
6350
|
cairo_exports as cairo,
|
|
6317
6351
|
constants_exports as constants,
|
|
6352
|
+
contractClassResponseToLegacyCompiledContract,
|
|
6318
6353
|
defaultProvider,
|
|
6319
6354
|
ec_exports as ec,
|
|
6320
6355
|
encode_exports as encode,
|
|
6356
|
+
extractContractHashes,
|
|
6321
6357
|
fixProto,
|
|
6322
6358
|
fixStack,
|
|
6323
6359
|
getCalldata,
|
|
6324
6360
|
getChecksumAddress,
|
|
6325
6361
|
hash_exports as hash,
|
|
6362
|
+
isSierra,
|
|
6326
6363
|
isUrl,
|
|
6327
6364
|
json_exports as json,
|
|
6328
6365
|
merkle_exports as merkle,
|
|
6329
6366
|
num_exports as num,
|
|
6330
6367
|
number,
|
|
6368
|
+
parseUDCEvent,
|
|
6369
|
+
provider_exports as provider,
|
|
6370
|
+
selector_exports as selector,
|
|
6331
6371
|
shortString_exports as shortString,
|
|
6332
6372
|
splitArgsAndOptions,
|
|
6333
6373
|
stark_exports as stark,
|