starknet 6.4.2 → 6.5.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 +10 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.global.js +40 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +40 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -125,7 +125,8 @@ __export(constants_exports, {
|
|
|
125
125
|
TRANSACTION_VERSION: () => ETransactionVersion4,
|
|
126
126
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
127
127
|
UDC: () => UDC,
|
|
128
|
-
ZERO: () => ZERO
|
|
128
|
+
ZERO: () => ZERO,
|
|
129
|
+
feeMarginPercentage: () => feeMarginPercentage
|
|
129
130
|
});
|
|
130
131
|
|
|
131
132
|
// src/types/api/index.ts
|
|
@@ -452,6 +453,12 @@ var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
|
|
|
452
453
|
TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
|
|
453
454
|
return TransactionHashPrefix2;
|
|
454
455
|
})(TransactionHashPrefix || {});
|
|
456
|
+
var feeMarginPercentage = /* @__PURE__ */ ((feeMarginPercentage2) => {
|
|
457
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_AMOUNT"] = 50] = "L1_BOUND_MAX_AMOUNT";
|
|
458
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_PRICE_PER_UNIT"] = 50] = "L1_BOUND_MAX_PRICE_PER_UNIT";
|
|
459
|
+
feeMarginPercentage2[feeMarginPercentage2["MAX_FEE"] = 50] = "MAX_FEE";
|
|
460
|
+
return feeMarginPercentage2;
|
|
461
|
+
})(feeMarginPercentage || {});
|
|
455
462
|
var UDC = {
|
|
456
463
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
457
464
|
ENTRYPOINT: "deployContract"
|
|
@@ -2941,10 +2948,10 @@ function signatureToDecimalArray(sig) {
|
|
|
2941
2948
|
function signatureToHexArray(sig) {
|
|
2942
2949
|
return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
|
|
2943
2950
|
}
|
|
2944
|
-
function estimatedFeeToMaxFee(estimatedFee, overhead =
|
|
2945
|
-
return addPercent(estimatedFee, overhead
|
|
2951
|
+
function estimatedFeeToMaxFee(estimatedFee, overhead = 50 /* MAX_FEE */) {
|
|
2952
|
+
return addPercent(estimatedFee, overhead);
|
|
2946
2953
|
}
|
|
2947
|
-
function estimateFeeToBounds(estimate, amountOverhead =
|
|
2954
|
+
function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
|
|
2948
2955
|
if (typeof estimate === "bigint") {
|
|
2949
2956
|
return {
|
|
2950
2957
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -2954,7 +2961,7 @@ function estimateFeeToBounds(estimate, amountOverhead = 10, priceOverhead = 50)
|
|
|
2954
2961
|
if (typeof estimate.gas_consumed === "undefined" || typeof estimate.gas_price === "undefined") {
|
|
2955
2962
|
throw Error("estimateFeeToBounds: estimate is undefined");
|
|
2956
2963
|
}
|
|
2957
|
-
const maxUnits = toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
2964
|
+
const maxUnits = estimate.data_gas_consumed !== void 0 && estimate.data_gas_price !== void 0 ? toHex(addPercent(BigInt(estimate.overall_fee) / BigInt(estimate.gas_price), amountOverhead)) : toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
2958
2965
|
const maxUnitPrice = toHex(addPercent(estimate.gas_price, priceOverhead));
|
|
2959
2966
|
return {
|
|
2960
2967
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -4308,6 +4315,20 @@ var RpcChannel2 = class {
|
|
|
4308
4315
|
|
|
4309
4316
|
// src/utils/responseParser/rpc.ts
|
|
4310
4317
|
var RPCResponseParser = class {
|
|
4318
|
+
margin;
|
|
4319
|
+
constructor(margin) {
|
|
4320
|
+
this.margin = margin;
|
|
4321
|
+
}
|
|
4322
|
+
estimatedFeeToMaxFee(estimatedFee) {
|
|
4323
|
+
return estimatedFeeToMaxFee(estimatedFee, this.margin?.maxFee);
|
|
4324
|
+
}
|
|
4325
|
+
estimateFeeToBounds(estimate) {
|
|
4326
|
+
return estimateFeeToBounds(
|
|
4327
|
+
estimate,
|
|
4328
|
+
this.margin?.l1BoundMaxAmount,
|
|
4329
|
+
this.margin?.l1BoundMaxPricePerUnit
|
|
4330
|
+
);
|
|
4331
|
+
}
|
|
4311
4332
|
parseGetBlockResponse(res) {
|
|
4312
4333
|
return { status: "PENDING", ...res };
|
|
4313
4334
|
}
|
|
@@ -4330,8 +4351,8 @@ var RPCResponseParser = class {
|
|
|
4330
4351
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
4331
4352
|
gas_price: toBigInt(val.gas_price),
|
|
4332
4353
|
unit: val.unit,
|
|
4333
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4334
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
4354
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
4355
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
4335
4356
|
};
|
|
4336
4357
|
}
|
|
4337
4358
|
parseFeeEstimateBulkResponse(res) {
|
|
@@ -4340,16 +4361,16 @@ var RPCResponseParser = class {
|
|
|
4340
4361
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
4341
4362
|
gas_price: toBigInt(val.gas_price),
|
|
4342
4363
|
unit: val.unit,
|
|
4343
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4344
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
4364
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
4365
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
4345
4366
|
}));
|
|
4346
4367
|
}
|
|
4347
4368
|
parseSimulateTransactionResponse(res) {
|
|
4348
4369
|
return res.map((it) => {
|
|
4349
4370
|
return {
|
|
4350
4371
|
...it,
|
|
4351
|
-
suggestedMaxFee: estimatedFeeToMaxFee(
|
|
4352
|
-
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
4372
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(it.fee_estimation.overall_fee),
|
|
4373
|
+
resourceBounds: this.estimateFeeToBounds(it.fee_estimation)
|
|
4353
4374
|
};
|
|
4354
4375
|
});
|
|
4355
4376
|
}
|
|
@@ -4363,13 +4384,15 @@ var RPCResponseParser = class {
|
|
|
4363
4384
|
|
|
4364
4385
|
// src/provider/rpc.ts
|
|
4365
4386
|
var RpcProvider = class {
|
|
4366
|
-
responseParser
|
|
4387
|
+
responseParser;
|
|
4367
4388
|
channel;
|
|
4368
4389
|
constructor(optionsOrProvider) {
|
|
4369
4390
|
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
4370
4391
|
this.channel = optionsOrProvider.channel;
|
|
4392
|
+
this.responseParser = optionsOrProvider.responseParser;
|
|
4371
4393
|
} else {
|
|
4372
4394
|
this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
|
|
4395
|
+
this.responseParser = new RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
|
|
4373
4396
|
}
|
|
4374
4397
|
}
|
|
4375
4398
|
fetch(method, params, id = 0) {
|
|
@@ -4462,7 +4485,7 @@ var RpcProvider = class {
|
|
|
4462
4485
|
* - skipFeeCharge (default true)<br/>
|
|
4463
4486
|
*/
|
|
4464
4487
|
async getSimulateTransaction(invocations, options) {
|
|
4465
|
-
return this.channel.simulateTransaction(invocations, options).then(this.responseParser.parseSimulateTransactionResponse);
|
|
4488
|
+
return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
|
|
4466
4489
|
}
|
|
4467
4490
|
async waitForTransaction(txHash, options) {
|
|
4468
4491
|
return this.channel.waitForTransaction(txHash, options);
|
|
@@ -4519,7 +4542,7 @@ var RpcProvider = class {
|
|
|
4519
4542
|
}
|
|
4520
4543
|
],
|
|
4521
4544
|
{ blockIdentifier, skipValidate }
|
|
4522
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4545
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4523
4546
|
}
|
|
4524
4547
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
4525
4548
|
return this.channel.getEstimateFee(
|
|
@@ -4531,7 +4554,7 @@ var RpcProvider = class {
|
|
|
4531
4554
|
}
|
|
4532
4555
|
],
|
|
4533
4556
|
{ blockIdentifier, skipValidate }
|
|
4534
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4557
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4535
4558
|
}
|
|
4536
4559
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
4537
4560
|
return this.channel.getEstimateFee(
|
|
@@ -4543,10 +4566,10 @@ var RpcProvider = class {
|
|
|
4543
4566
|
}
|
|
4544
4567
|
],
|
|
4545
4568
|
{ blockIdentifier, skipValidate }
|
|
4546
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4569
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4547
4570
|
}
|
|
4548
4571
|
async getEstimateFeeBulk(invocations, options) {
|
|
4549
|
-
return this.channel.getEstimateFee(invocations, options).then(this.responseParser.parseFeeEstimateBulkResponse);
|
|
4572
|
+
return this.channel.getEstimateFee(invocations, options).then((r) => this.responseParser.parseFeeEstimateBulkResponse(r));
|
|
4550
4573
|
}
|
|
4551
4574
|
async invokeFunction(functionInvocation, details) {
|
|
4552
4575
|
return this.channel.invoke(functionInvocation, details);
|