starknet 6.4.1 → 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/dist/index.mjs CHANGED
@@ -21,7 +21,8 @@ __export(constants_exports, {
21
21
  TRANSACTION_VERSION: () => ETransactionVersion4,
22
22
  TransactionHashPrefix: () => TransactionHashPrefix,
23
23
  UDC: () => UDC,
24
- ZERO: () => ZERO
24
+ ZERO: () => ZERO,
25
+ feeMarginPercentage: () => feeMarginPercentage
25
26
  });
26
27
 
27
28
  // src/types/api/index.ts
@@ -348,6 +349,12 @@ var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
348
349
  TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
349
350
  return TransactionHashPrefix2;
350
351
  })(TransactionHashPrefix || {});
352
+ var feeMarginPercentage = /* @__PURE__ */ ((feeMarginPercentage2) => {
353
+ feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_AMOUNT"] = 50] = "L1_BOUND_MAX_AMOUNT";
354
+ feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_PRICE_PER_UNIT"] = 50] = "L1_BOUND_MAX_PRICE_PER_UNIT";
355
+ feeMarginPercentage2[feeMarginPercentage2["MAX_FEE"] = 50] = "MAX_FEE";
356
+ return feeMarginPercentage2;
357
+ })(feeMarginPercentage || {});
351
358
  var UDC = {
352
359
  ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
353
360
  ENTRYPOINT: "deployContract"
@@ -2837,10 +2844,10 @@ function signatureToDecimalArray(sig) {
2837
2844
  function signatureToHexArray(sig) {
2838
2845
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
2839
2846
  }
2840
- function estimatedFeeToMaxFee(estimatedFee, overhead = 0.5) {
2841
- return addPercent(estimatedFee, overhead * 100);
2847
+ function estimatedFeeToMaxFee(estimatedFee, overhead = 50 /* MAX_FEE */) {
2848
+ return addPercent(estimatedFee, overhead);
2842
2849
  }
2843
- function estimateFeeToBounds(estimate, amountOverhead = 10, priceOverhead = 50) {
2850
+ function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
2844
2851
  if (typeof estimate === "bigint") {
2845
2852
  return {
2846
2853
  l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
@@ -2850,7 +2857,7 @@ function estimateFeeToBounds(estimate, amountOverhead = 10, priceOverhead = 50)
2850
2857
  if (typeof estimate.gas_consumed === "undefined" || typeof estimate.gas_price === "undefined") {
2851
2858
  throw Error("estimateFeeToBounds: estimate is undefined");
2852
2859
  }
2853
- const maxUnits = toHex(addPercent(estimate.gas_consumed, amountOverhead));
2860
+ 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));
2854
2861
  const maxUnitPrice = toHex(addPercent(estimate.gas_price, priceOverhead));
2855
2862
  return {
2856
2863
  l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
@@ -4204,6 +4211,20 @@ var RpcChannel2 = class {
4204
4211
 
4205
4212
  // src/utils/responseParser/rpc.ts
4206
4213
  var RPCResponseParser = class {
4214
+ margin;
4215
+ constructor(margin) {
4216
+ this.margin = margin;
4217
+ }
4218
+ estimatedFeeToMaxFee(estimatedFee) {
4219
+ return estimatedFeeToMaxFee(estimatedFee, this.margin?.maxFee);
4220
+ }
4221
+ estimateFeeToBounds(estimate) {
4222
+ return estimateFeeToBounds(
4223
+ estimate,
4224
+ this.margin?.l1BoundMaxAmount,
4225
+ this.margin?.l1BoundMaxPricePerUnit
4226
+ );
4227
+ }
4207
4228
  parseGetBlockResponse(res) {
4208
4229
  return { status: "PENDING", ...res };
4209
4230
  }
@@ -4226,8 +4247,8 @@ var RPCResponseParser = class {
4226
4247
  gas_consumed: toBigInt(val.gas_consumed),
4227
4248
  gas_price: toBigInt(val.gas_price),
4228
4249
  unit: val.unit,
4229
- suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
4230
- resourceBounds: estimateFeeToBounds(val)
4250
+ suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
4251
+ resourceBounds: this.estimateFeeToBounds(val)
4231
4252
  };
4232
4253
  }
4233
4254
  parseFeeEstimateBulkResponse(res) {
@@ -4236,16 +4257,16 @@ var RPCResponseParser = class {
4236
4257
  gas_consumed: toBigInt(val.gas_consumed),
4237
4258
  gas_price: toBigInt(val.gas_price),
4238
4259
  unit: val.unit,
4239
- suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
4240
- resourceBounds: estimateFeeToBounds(val)
4260
+ suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
4261
+ resourceBounds: this.estimateFeeToBounds(val)
4241
4262
  }));
4242
4263
  }
4243
4264
  parseSimulateTransactionResponse(res) {
4244
4265
  return res.map((it) => {
4245
4266
  return {
4246
4267
  ...it,
4247
- suggestedMaxFee: estimatedFeeToMaxFee(BigInt(it.fee_estimation.overall_fee)),
4248
- resourceBounds: estimateFeeToBounds(it.fee_estimation)
4268
+ suggestedMaxFee: this.estimatedFeeToMaxFee(it.fee_estimation.overall_fee),
4269
+ resourceBounds: this.estimateFeeToBounds(it.fee_estimation)
4249
4270
  };
4250
4271
  });
4251
4272
  }
@@ -4259,13 +4280,15 @@ var RPCResponseParser = class {
4259
4280
 
4260
4281
  // src/provider/rpc.ts
4261
4282
  var RpcProvider = class {
4262
- responseParser = new RPCResponseParser();
4283
+ responseParser;
4263
4284
  channel;
4264
4285
  constructor(optionsOrProvider) {
4265
4286
  if (optionsOrProvider && "channel" in optionsOrProvider) {
4266
4287
  this.channel = optionsOrProvider.channel;
4288
+ this.responseParser = optionsOrProvider.responseParser;
4267
4289
  } else {
4268
4290
  this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
4291
+ this.responseParser = new RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
4269
4292
  }
4270
4293
  }
4271
4294
  fetch(method, params, id = 0) {
@@ -4358,7 +4381,7 @@ var RpcProvider = class {
4358
4381
  * - skipFeeCharge (default true)<br/>
4359
4382
  */
4360
4383
  async getSimulateTransaction(invocations, options) {
4361
- return this.channel.simulateTransaction(invocations, options).then(this.responseParser.parseSimulateTransactionResponse);
4384
+ return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
4362
4385
  }
4363
4386
  async waitForTransaction(txHash, options) {
4364
4387
  return this.channel.waitForTransaction(txHash, options);
@@ -4415,7 +4438,7 @@ var RpcProvider = class {
4415
4438
  }
4416
4439
  ],
4417
4440
  { blockIdentifier, skipValidate }
4418
- ).then(this.responseParser.parseFeeEstimateResponse);
4441
+ ).then((r) => this.responseParser.parseFeeEstimateResponse(r));
4419
4442
  }
4420
4443
  async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
4421
4444
  return this.channel.getEstimateFee(
@@ -4427,7 +4450,7 @@ var RpcProvider = class {
4427
4450
  }
4428
4451
  ],
4429
4452
  { blockIdentifier, skipValidate }
4430
- ).then(this.responseParser.parseFeeEstimateResponse);
4453
+ ).then((r) => this.responseParser.parseFeeEstimateResponse(r));
4431
4454
  }
4432
4455
  async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
4433
4456
  return this.channel.getEstimateFee(
@@ -4439,10 +4462,10 @@ var RpcProvider = class {
4439
4462
  }
4440
4463
  ],
4441
4464
  { blockIdentifier, skipValidate }
4442
- ).then(this.responseParser.parseFeeEstimateResponse);
4465
+ ).then((r) => this.responseParser.parseFeeEstimateResponse(r));
4443
4466
  }
4444
4467
  async getEstimateFeeBulk(invocations, options) {
4445
- return this.channel.getEstimateFee(invocations, options).then(this.responseParser.parseFeeEstimateBulkResponse);
4468
+ return this.channel.getEstimateFee(invocations, options).then((r) => this.responseParser.parseFeeEstimateBulkResponse(r));
4446
4469
  }
4447
4470
  async invokeFunction(functionInvocation, details) {
4448
4471
  return this.channel.invoke(functionInvocation, details);
@@ -4590,7 +4613,7 @@ function useEncoded(decoded) {
4590
4613
  var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
4591
4614
  StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
4592
4615
  StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
4593
- StarknetIdContract2["TESTNET_SEPOLIA"] = "0x5847d20f9757de24395a7b3b47303684003753858737bf288716855dfb0aaf2";
4616
+ StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
4594
4617
  return StarknetIdContract2;
4595
4618
  })(StarknetIdContract || {});
4596
4619
  function getStarknetIdContract(chainId) {
@@ -4600,7 +4623,7 @@ function getStarknetIdContract(chainId) {
4600
4623
  case "0x534e5f474f45524c49" /* SN_GOERLI */:
4601
4624
  return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
4602
4625
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
4603
- return "0x5847d20f9757de24395a7b3b47303684003753858737bf288716855dfb0aaf2" /* TESTNET_SEPOLIA */;
4626
+ return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
4604
4627
  default:
4605
4628
  throw new Error("Starknet.id is not yet deployed on this network");
4606
4629
  }
@@ -4608,7 +4631,7 @@ function getStarknetIdContract(chainId) {
4608
4631
  var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
4609
4632
  StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
4610
4633
  StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
4611
- StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x718d9172f6e36183abeeff1a0db76a1851cef4ed9b9c13896da79ef4bfcb4d0";
4634
+ StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
4612
4635
  return StarknetIdIdentityContract2;
4613
4636
  })(StarknetIdIdentityContract || {});
4614
4637
  function getStarknetIdIdentityContract(chainId) {
@@ -4618,7 +4641,7 @@ function getStarknetIdIdentityContract(chainId) {
4618
4641
  case "0x534e5f474f45524c49" /* SN_GOERLI */:
4619
4642
  return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
4620
4643
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
4621
- return "0x718d9172f6e36183abeeff1a0db76a1851cef4ed9b9c13896da79ef4bfcb4d0" /* TESTNET_SEPOLIA */;
4644
+ return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
4622
4645
  default:
4623
4646
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
4624
4647
  }
@@ -4639,7 +4662,7 @@ function getStarknetIdMulticallContract(chainId) {
4639
4662
  var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
4640
4663
  StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
4641
4664
  StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
4642
- StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf";
4665
+ StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
4643
4666
  return StarknetIdVerifierContract2;
4644
4667
  })(StarknetIdVerifierContract || {});
4645
4668
  function getStarknetIdVerifierContract(chainId) {
@@ -4649,7 +4672,7 @@ function getStarknetIdVerifierContract(chainId) {
4649
4672
  case "0x534e5f474f45524c49" /* SN_GOERLI */:
4650
4673
  return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
4651
4674
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
4652
- return "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf" /* TESTNET_SEPOLIA */;
4675
+ return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
4653
4676
  default:
4654
4677
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
4655
4678
  }
@@ -4657,7 +4680,7 @@ function getStarknetIdVerifierContract(chainId) {
4657
4680
  var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
4658
4681
  StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
4659
4682
  StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
4660
- StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x070c035557d6fed57eed2ed7fa861616b487f8a95439347b805639ca076f29f0";
4683
+ StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
4661
4684
  return StarknetIdPfpContract2;
4662
4685
  })(StarknetIdPfpContract || {});
4663
4686
  function getStarknetIdPfpContract(chainId) {
@@ -4667,7 +4690,7 @@ function getStarknetIdPfpContract(chainId) {
4667
4690
  case "0x534e5f474f45524c49" /* SN_GOERLI */:
4668
4691
  return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
4669
4692
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
4670
- return "0x070c035557d6fed57eed2ed7fa861616b487f8a95439347b805639ca076f29f0" /* TESTNET_SEPOLIA */;
4693
+ return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
4671
4694
  default:
4672
4695
  throw new Error(
4673
4696
  "Starknet.id profile picture verifier contract is not yet deployed on this network"
@@ -4677,7 +4700,7 @@ function getStarknetIdPfpContract(chainId) {
4677
4700
  var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
4678
4701
  StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
4679
4702
  StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
4680
- StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x00f80f68443becd0e0a4a08ff5734e36dd8028507333e4a0ec034dcfdf1b793e";
4703
+ StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
4681
4704
  return StarknetIdPopContract2;
4682
4705
  })(StarknetIdPopContract || {});
4683
4706
  function getStarknetIdPopContract(chainId) {
@@ -4687,7 +4710,7 @@ function getStarknetIdPopContract(chainId) {
4687
4710
  case "0x534e5f474f45524c49" /* SN_GOERLI */:
4688
4711
  return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
4689
4712
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
4690
- return "0x00f80f68443becd0e0a4a08ff5734e36dd8028507333e4a0ec034dcfdf1b793e" /* TESTNET_SEPOLIA */;
4713
+ return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
4691
4714
  default:
4692
4715
  throw new Error(
4693
4716
  "Starknet.id proof of personhood verifier contract is not yet deployed on this network"