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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# [6.5.0](https://github.com/starknet-io/starknet.js/compare/v6.4.2...v6.5.0) (2024-03-14)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- adjust max amount bound calculation for RPC v0.7.0 ([dd34cdb](https://github.com/starknet-io/starknet.js/commit/dd34cdb8b9817a55a16a97d960b1544d75c0059a))
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- make fee margins configurable ([cedd984](https://github.com/starknet-io/starknet.js/commit/cedd984e1106db5b73d17630e282eb956d344a97))
|
|
10
|
+
|
|
1
11
|
## [6.4.2](https://github.com/starknet-io/starknet.js/compare/v6.4.1...v6.4.2) (2024-03-14)
|
|
2
12
|
|
|
3
13
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -2450,6 +2450,11 @@ declare enum TransactionHashPrefix {
|
|
|
2450
2450
|
INVOKE = "0x696e766f6b65",// encodeShortString('invoke'),
|
|
2451
2451
|
L1_HANDLER = "0x6c315f68616e646c6572"
|
|
2452
2452
|
}
|
|
2453
|
+
declare const enum feeMarginPercentage {
|
|
2454
|
+
L1_BOUND_MAX_AMOUNT = 50,
|
|
2455
|
+
L1_BOUND_MAX_PRICE_PER_UNIT = 50,
|
|
2456
|
+
MAX_FEE = 50
|
|
2457
|
+
}
|
|
2453
2458
|
declare const UDC: {
|
|
2454
2459
|
ADDRESS: string;
|
|
2455
2460
|
ENTRYPOINT: string;
|
|
@@ -2479,8 +2484,10 @@ type constants_TransactionHashPrefix = TransactionHashPrefix;
|
|
|
2479
2484
|
declare const constants_TransactionHashPrefix: typeof TransactionHashPrefix;
|
|
2480
2485
|
declare const constants_UDC: typeof UDC;
|
|
2481
2486
|
declare const constants_ZERO: typeof ZERO;
|
|
2487
|
+
type constants_feeMarginPercentage = feeMarginPercentage;
|
|
2488
|
+
declare const constants_feeMarginPercentage: typeof feeMarginPercentage;
|
|
2482
2489
|
declare namespace constants {
|
|
2483
|
-
export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, constants_BaseUrl as BaseUrl, constants_IS_BROWSER as IS_BROWSER, constants_MASK_250 as MASK_250, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, constants_NetworkName as NetworkName, constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION, constants_RPC_NODES as RPC_NODES, constants_StarknetChainId as StarknetChainId, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, ETransactionVersion as TRANSACTION_VERSION, constants_TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO };
|
|
2490
|
+
export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, constants_BaseUrl as BaseUrl, constants_IS_BROWSER as IS_BROWSER, constants_MASK_250 as MASK_250, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, constants_NetworkName as NetworkName, constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION, constants_RPC_NODES as RPC_NODES, constants_StarknetChainId as StarknetChainId, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, ETransactionVersion as TRANSACTION_VERSION, constants_TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO, constants_feeMarginPercentage as feeMarginPercentage };
|
|
2484
2491
|
}
|
|
2485
2492
|
|
|
2486
2493
|
declare const ec_weierstrass: typeof weierstrass;
|
|
@@ -3007,6 +3014,11 @@ type RpcProviderOptions = {
|
|
|
3007
3014
|
specVersion?: string;
|
|
3008
3015
|
default?: boolean;
|
|
3009
3016
|
waitMode?: boolean;
|
|
3017
|
+
feeMarginPercentage?: {
|
|
3018
|
+
l1BoundMaxAmount: number;
|
|
3019
|
+
l1BoundMaxPricePerUnit: number;
|
|
3020
|
+
maxFee: number;
|
|
3021
|
+
};
|
|
3010
3022
|
};
|
|
3011
3023
|
|
|
3012
3024
|
type Simplify<T> = {
|
package/dist/index.global.js
CHANGED
|
@@ -12766,7 +12766,8 @@ var starknet = (() => {
|
|
|
12766
12766
|
TRANSACTION_VERSION: () => ETransactionVersion4,
|
|
12767
12767
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
12768
12768
|
UDC: () => UDC,
|
|
12769
|
-
ZERO: () => ZERO
|
|
12769
|
+
ZERO: () => ZERO,
|
|
12770
|
+
feeMarginPercentage: () => feeMarginPercentage
|
|
12770
12771
|
});
|
|
12771
12772
|
|
|
12772
12773
|
// src/types/api/index.ts
|
|
@@ -13251,6 +13252,12 @@ var starknet = (() => {
|
|
|
13251
13252
|
TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
|
|
13252
13253
|
return TransactionHashPrefix2;
|
|
13253
13254
|
})(TransactionHashPrefix || {});
|
|
13255
|
+
var feeMarginPercentage = /* @__PURE__ */ ((feeMarginPercentage2) => {
|
|
13256
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_AMOUNT"] = 50] = "L1_BOUND_MAX_AMOUNT";
|
|
13257
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_PRICE_PER_UNIT"] = 50] = "L1_BOUND_MAX_PRICE_PER_UNIT";
|
|
13258
|
+
feeMarginPercentage2[feeMarginPercentage2["MAX_FEE"] = 50] = "MAX_FEE";
|
|
13259
|
+
return feeMarginPercentage2;
|
|
13260
|
+
})(feeMarginPercentage || {});
|
|
13254
13261
|
var UDC = {
|
|
13255
13262
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
13256
13263
|
ENTRYPOINT: "deployContract"
|
|
@@ -22997,10 +23004,10 @@ var starknet = (() => {
|
|
|
22997
23004
|
function signatureToHexArray(sig) {
|
|
22998
23005
|
return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
|
|
22999
23006
|
}
|
|
23000
|
-
function estimatedFeeToMaxFee(estimatedFee, overhead =
|
|
23001
|
-
return addPercent(estimatedFee, overhead
|
|
23007
|
+
function estimatedFeeToMaxFee(estimatedFee, overhead = 50 /* MAX_FEE */) {
|
|
23008
|
+
return addPercent(estimatedFee, overhead);
|
|
23002
23009
|
}
|
|
23003
|
-
function estimateFeeToBounds(estimate, amountOverhead =
|
|
23010
|
+
function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
|
|
23004
23011
|
if (typeof estimate === "bigint") {
|
|
23005
23012
|
return {
|
|
23006
23013
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -23010,7 +23017,7 @@ var starknet = (() => {
|
|
|
23010
23017
|
if (typeof estimate.gas_consumed === "undefined" || typeof estimate.gas_price === "undefined") {
|
|
23011
23018
|
throw Error("estimateFeeToBounds: estimate is undefined");
|
|
23012
23019
|
}
|
|
23013
|
-
const maxUnits = toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
23020
|
+
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));
|
|
23014
23021
|
const maxUnitPrice = toHex(addPercent(estimate.gas_price, priceOverhead));
|
|
23015
23022
|
return {
|
|
23016
23023
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -24523,6 +24530,20 @@ var starknet = (() => {
|
|
|
24523
24530
|
|
|
24524
24531
|
// src/utils/responseParser/rpc.ts
|
|
24525
24532
|
var RPCResponseParser = class {
|
|
24533
|
+
margin;
|
|
24534
|
+
constructor(margin) {
|
|
24535
|
+
this.margin = margin;
|
|
24536
|
+
}
|
|
24537
|
+
estimatedFeeToMaxFee(estimatedFee) {
|
|
24538
|
+
return estimatedFeeToMaxFee(estimatedFee, this.margin?.maxFee);
|
|
24539
|
+
}
|
|
24540
|
+
estimateFeeToBounds(estimate) {
|
|
24541
|
+
return estimateFeeToBounds(
|
|
24542
|
+
estimate,
|
|
24543
|
+
this.margin?.l1BoundMaxAmount,
|
|
24544
|
+
this.margin?.l1BoundMaxPricePerUnit
|
|
24545
|
+
);
|
|
24546
|
+
}
|
|
24526
24547
|
parseGetBlockResponse(res) {
|
|
24527
24548
|
return { status: "PENDING", ...res };
|
|
24528
24549
|
}
|
|
@@ -24545,8 +24566,8 @@ var starknet = (() => {
|
|
|
24545
24566
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
24546
24567
|
gas_price: toBigInt(val.gas_price),
|
|
24547
24568
|
unit: val.unit,
|
|
24548
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
24549
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
24569
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
24570
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
24550
24571
|
};
|
|
24551
24572
|
}
|
|
24552
24573
|
parseFeeEstimateBulkResponse(res) {
|
|
@@ -24555,16 +24576,16 @@ var starknet = (() => {
|
|
|
24555
24576
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
24556
24577
|
gas_price: toBigInt(val.gas_price),
|
|
24557
24578
|
unit: val.unit,
|
|
24558
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
24559
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
24579
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
24580
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
24560
24581
|
}));
|
|
24561
24582
|
}
|
|
24562
24583
|
parseSimulateTransactionResponse(res) {
|
|
24563
24584
|
return res.map((it) => {
|
|
24564
24585
|
return {
|
|
24565
24586
|
...it,
|
|
24566
|
-
suggestedMaxFee: estimatedFeeToMaxFee(
|
|
24567
|
-
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
24587
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(it.fee_estimation.overall_fee),
|
|
24588
|
+
resourceBounds: this.estimateFeeToBounds(it.fee_estimation)
|
|
24568
24589
|
};
|
|
24569
24590
|
});
|
|
24570
24591
|
}
|
|
@@ -24578,13 +24599,15 @@ var starknet = (() => {
|
|
|
24578
24599
|
|
|
24579
24600
|
// src/provider/rpc.ts
|
|
24580
24601
|
var RpcProvider = class {
|
|
24581
|
-
responseParser
|
|
24602
|
+
responseParser;
|
|
24582
24603
|
channel;
|
|
24583
24604
|
constructor(optionsOrProvider) {
|
|
24584
24605
|
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
24585
24606
|
this.channel = optionsOrProvider.channel;
|
|
24607
|
+
this.responseParser = optionsOrProvider.responseParser;
|
|
24586
24608
|
} else {
|
|
24587
24609
|
this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
|
|
24610
|
+
this.responseParser = new RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
|
|
24588
24611
|
}
|
|
24589
24612
|
}
|
|
24590
24613
|
fetch(method, params, id = 0) {
|
|
@@ -24677,7 +24700,7 @@ var starknet = (() => {
|
|
|
24677
24700
|
* - skipFeeCharge (default true)<br/>
|
|
24678
24701
|
*/
|
|
24679
24702
|
async getSimulateTransaction(invocations, options) {
|
|
24680
|
-
return this.channel.simulateTransaction(invocations, options).then(this.responseParser.parseSimulateTransactionResponse);
|
|
24703
|
+
return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
|
|
24681
24704
|
}
|
|
24682
24705
|
async waitForTransaction(txHash, options) {
|
|
24683
24706
|
return this.channel.waitForTransaction(txHash, options);
|
|
@@ -24734,7 +24757,7 @@ var starknet = (() => {
|
|
|
24734
24757
|
}
|
|
24735
24758
|
],
|
|
24736
24759
|
{ blockIdentifier, skipValidate }
|
|
24737
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24760
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24738
24761
|
}
|
|
24739
24762
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
24740
24763
|
return this.channel.getEstimateFee(
|
|
@@ -24746,7 +24769,7 @@ var starknet = (() => {
|
|
|
24746
24769
|
}
|
|
24747
24770
|
],
|
|
24748
24771
|
{ blockIdentifier, skipValidate }
|
|
24749
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24772
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24750
24773
|
}
|
|
24751
24774
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
24752
24775
|
return this.channel.getEstimateFee(
|
|
@@ -24758,10 +24781,10 @@ var starknet = (() => {
|
|
|
24758
24781
|
}
|
|
24759
24782
|
],
|
|
24760
24783
|
{ blockIdentifier, skipValidate }
|
|
24761
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24784
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24762
24785
|
}
|
|
24763
24786
|
async getEstimateFeeBulk(invocations, options) {
|
|
24764
|
-
return this.channel.getEstimateFee(invocations, options).then(this.responseParser.parseFeeEstimateBulkResponse);
|
|
24787
|
+
return this.channel.getEstimateFee(invocations, options).then((r) => this.responseParser.parseFeeEstimateBulkResponse(r));
|
|
24765
24788
|
}
|
|
24766
24789
|
async invokeFunction(functionInvocation, details) {
|
|
24767
24790
|
return this.channel.invoke(functionInvocation, details);
|