@chipi-stack/chipi-react 14.9.0 → 14.10.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/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { ChipiApiError } from '@chipi-stack/shared';
7
7
  import { OnChainTxStatus, Chain, ChainToken } from '@chipi-stack/types';
8
8
  export { Chain, ChainToken } from '@chipi-stack/types';
9
9
  import * as nc from 'crypto';
10
- import { buildX402TypedData } from '@chipi-stack/core';
10
+ import { buildX402TypedData, derivePoolKeypair, deriveCompanionKeypair, deriveCompanionAddress, getPrivateBalance, requestGasFunding, waitForFunding, GAS_FUND_STRK, execShield, sweepCompanion, execUnshield, ChipiProofProvider } from '@chipi-stack/core';
11
11
 
12
12
  var __defProp = Object.defineProperty;
13
13
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -10712,6 +10712,7 @@ var OutsideExecutionTypesV2 = {
10712
10712
  ]
10713
10713
  };
10714
10714
  var OutsideExecutionVersion = {
10715
+ UNSUPPORTED: "0",
10715
10716
  V1: "1",
10716
10717
  V2: "2"
10717
10718
  };
@@ -18603,9 +18604,76 @@ var BrotherId = class _BrotherId {
18603
18604
  }
18604
18605
  }
18605
18606
  };
18606
- (class extends Mixin(RpcProvider, StarknetId, BrotherId) {
18607
- });
18607
+ var RpcProvider2 = class extends Mixin(RpcProvider, StarknetId, BrotherId) {
18608
+ };
18608
18609
  new RpcProvider({ default: true });
18610
+ var Signer = class {
18611
+ constructor(pk = utils.randomPrivateKey()) {
18612
+ __publicField(this, "pk");
18613
+ this.pk = pk instanceof Uint8Array ? buf2hex(pk) : toHex(pk);
18614
+ }
18615
+ async getPubKey() {
18616
+ return getStarkKey(this.pk);
18617
+ }
18618
+ async signMessage(typedData, accountAddress) {
18619
+ const msgHash = getMessageHash(typedData, accountAddress);
18620
+ return this.signRaw(msgHash);
18621
+ }
18622
+ async signTransaction(transactions, details) {
18623
+ const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
18624
+ let msgHash;
18625
+ if (Object.values(api_exports3.ETransactionVersion3).includes(details.version)) {
18626
+ const det = details;
18627
+ msgHash = calculateInvokeTransactionHash2({
18628
+ ...det,
18629
+ senderAddress: det.walletAddress,
18630
+ compiledCalldata,
18631
+ version: det.version,
18632
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
18633
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
18634
+ });
18635
+ } else {
18636
+ throw Error("unsupported signTransaction version");
18637
+ }
18638
+ return this.signRaw(msgHash);
18639
+ }
18640
+ async signDeployAccountTransaction(details) {
18641
+ const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
18642
+ let msgHash;
18643
+ if (Object.values(api_exports3.ETransactionVersion3).includes(details.version)) {
18644
+ const det = details;
18645
+ msgHash = calculateDeployAccountTransactionHash3({
18646
+ ...det,
18647
+ salt: det.addressSalt,
18648
+ compiledConstructorCalldata,
18649
+ version: det.version,
18650
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
18651
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
18652
+ });
18653
+ } else {
18654
+ throw Error("unsupported signDeployAccountTransaction version");
18655
+ }
18656
+ return this.signRaw(msgHash);
18657
+ }
18658
+ async signDeclareTransaction(details) {
18659
+ let msgHash;
18660
+ if (Object.values(api_exports3.ETransactionVersion3).includes(details.version)) {
18661
+ const det = details;
18662
+ msgHash = calculateDeclareTransactionHash3({
18663
+ ...det,
18664
+ version: det.version,
18665
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
18666
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
18667
+ });
18668
+ } else {
18669
+ throw Error("unsupported signDeclareTransaction version");
18670
+ }
18671
+ return this.signRaw(msgHash);
18672
+ }
18673
+ async signRaw(msgHash) {
18674
+ return sign(msgHash, this.pk);
18675
+ }
18676
+ };
18609
18677
  var uint256_exports = {};
18610
18678
  __export2(uint256_exports, {
18611
18679
  bnToUint256: () => bnToUint256,
@@ -19050,7 +19118,7 @@ var PaymasterRpc = class _PaymasterRpc {
19050
19118
  );
19051
19119
  }
19052
19120
  };
19053
- new PaymasterRpc({ default: true });
19121
+ var defaultPaymaster = new PaymasterRpc({ default: true });
19054
19122
  var Deployer = class {
19055
19123
  constructor(address, entryPoint) {
19056
19124
  __publicField(this, "address");
@@ -19125,8 +19193,791 @@ var Deployer = class {
19125
19193
  };
19126
19194
  }
19127
19195
  };
19128
- new Deployer(UDC.ADDRESS, UDC.ENTRYPOINT);
19196
+ var defaultDeployer = new Deployer(UDC.ADDRESS, UDC.ENTRYPOINT);
19129
19197
  new Deployer(LegacyUDC.ADDRESS, LegacyUDC.ENTRYPOINT);
19198
+ var Account = class extends RpcProvider2 {
19199
+ constructor(options) {
19200
+ const {
19201
+ provider,
19202
+ address,
19203
+ signer,
19204
+ cairoVersion,
19205
+ transactionVersion,
19206
+ paymaster,
19207
+ defaultTipType
19208
+ } = options;
19209
+ super(provider);
19210
+ __publicField(this, "signer");
19211
+ __publicField(this, "address");
19212
+ __publicField(this, "cairoVersion");
19213
+ __publicField(this, "transactionVersion");
19214
+ __publicField(this, "paymaster");
19215
+ __publicField(this, "deployer");
19216
+ __publicField(this, "defaultTipType");
19217
+ __publicField(this, "deploySelf", this.deployAccount);
19218
+ this.address = address.toLowerCase();
19219
+ this.signer = isString(signer) || signer instanceof Uint8Array ? new Signer(signer) : signer;
19220
+ if (cairoVersion) {
19221
+ this.cairoVersion = cairoVersion.toString();
19222
+ }
19223
+ this.transactionVersion = transactionVersion ?? config2.get("transactionVersion");
19224
+ this.paymaster = paymaster ? new PaymasterRpc(paymaster) : defaultPaymaster;
19225
+ this.deployer = options.deployer ?? defaultDeployer;
19226
+ this.defaultTipType = defaultTipType ?? config2.get("defaultTipType");
19227
+ logger.debug("Account setup", {
19228
+ transactionVersion: this.transactionVersion,
19229
+ cairoVersion: this.cairoVersion,
19230
+ channel: this.channel.id
19231
+ });
19232
+ }
19233
+ /** @deprecated @hidden */
19234
+ // The deprecation tag is meant to discourage use, not to signal future removal
19235
+ // it should only be removed if the relationship with the corresponding Provider.create(...) method changes
19236
+ static async create() {
19237
+ throw new LibraryError("Not supported");
19238
+ }
19239
+ async getNonce(blockIdentifier) {
19240
+ return super.getNonceForAddress(this.address, blockIdentifier);
19241
+ }
19242
+ async getNonceSafe(nonce) {
19243
+ try {
19244
+ return toBigInt(nonce ?? await this.getNonce());
19245
+ } catch (error) {
19246
+ return 0n;
19247
+ }
19248
+ }
19249
+ /**
19250
+ * Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
19251
+ * @param classHash if provided detects Cairo version from classHash, otherwise from the account address
19252
+ */
19253
+ async getCairoVersion(classHash) {
19254
+ if (!this.cairoVersion) {
19255
+ const { cairo } = classHash ? await super.getContractVersion(void 0, classHash) : await super.getContractVersion(this.address);
19256
+ this.cairoVersion = cairo;
19257
+ }
19258
+ return this.cairoVersion;
19259
+ }
19260
+ // TODO: TT Cairo version is still needed for invoke on existing contracts
19261
+ async estimateInvokeFee(calls, details = {}) {
19262
+ const invocations = [{ type: api_exports3.ETransactionType.INVOKE, payload: [calls].flat() }];
19263
+ const estimateBulk = await this.estimateFeeBulk(invocations, details);
19264
+ return estimateBulk[0];
19265
+ }
19266
+ async estimateDeclareFee(payload, details = {}) {
19267
+ assert(
19268
+ isSierra(payload.contract),
19269
+ "Declare fee estimation is not supported for Cairo0 contracts"
19270
+ );
19271
+ const invocations = [
19272
+ {
19273
+ type: api_exports3.ETransactionType.DECLARE,
19274
+ payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
19275
+ }
19276
+ ];
19277
+ const estimateBulk = await this.estimateFeeBulk(invocations, details);
19278
+ return estimateBulk[0];
19279
+ }
19280
+ async estimateAccountDeployFee({
19281
+ classHash,
19282
+ addressSalt = 0,
19283
+ constructorCalldata = [],
19284
+ contractAddress
19285
+ }, details = {}) {
19286
+ const compiledCalldata = CallData.compile(constructorCalldata);
19287
+ const contractAddressFinal = contractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
19288
+ const invocations = [
19289
+ {
19290
+ type: api_exports3.ETransactionType.DEPLOY_ACCOUNT,
19291
+ payload: {
19292
+ classHash,
19293
+ constructorCalldata: compiledCalldata,
19294
+ addressSalt,
19295
+ contractAddress: contractAddressFinal
19296
+ }
19297
+ }
19298
+ ];
19299
+ const estimateBulk = await this.estimateFeeBulk(invocations, details);
19300
+ return estimateBulk[0];
19301
+ }
19302
+ async estimateDeployFee(payload, details = {}) {
19303
+ const { calls } = this.deployer.buildDeployerCall(payload, this.address);
19304
+ return this.estimateInvokeFee(calls, details);
19305
+ }
19306
+ async estimateFeeBulk(invocations, details = {}) {
19307
+ if (!invocations.length) throw TypeError("Invocations should be non-empty array");
19308
+ if (details.resourceBounds)
19309
+ return [resourceBoundsToEstimateFeeResponse(details.resourceBounds)];
19310
+ const { nonce, blockIdentifier, version, skipValidate } = details;
19311
+ const detailsWithTip = await this.resolveDetailsWithTip(details);
19312
+ const accountInvocations = await this.accountInvocationsFactory(invocations, {
19313
+ ...v3Details(detailsWithTip),
19314
+ versions: [
19315
+ toTransactionVersion(
19316
+ toFeeVersion(this.transactionVersion) || ETransactionVersion33.F3,
19317
+ version
19318
+ )
19319
+ // sierra
19320
+ ],
19321
+ nonce,
19322
+ blockIdentifier,
19323
+ skipValidate
19324
+ });
19325
+ return super.getEstimateFeeBulk(accountInvocations, {
19326
+ blockIdentifier,
19327
+ skipValidate
19328
+ });
19329
+ }
19330
+ async simulateTransaction(invocations, details = {}) {
19331
+ if (!invocations.length) throw TypeError("Invocations should be non-empty array");
19332
+ const {
19333
+ nonce,
19334
+ blockIdentifier,
19335
+ skipValidate = true,
19336
+ skipExecute,
19337
+ version: providedVersion
19338
+ } = details;
19339
+ const detailsWithTip = await this.resolveDetailsWithTip(details);
19340
+ const accountInvocations = await this.accountInvocationsFactory(invocations, {
19341
+ ...v3Details(detailsWithTip),
19342
+ versions: [this.resolveTransactionVersion(providedVersion)],
19343
+ nonce,
19344
+ blockIdentifier,
19345
+ skipValidate
19346
+ });
19347
+ return super.getSimulateTransaction(accountInvocations, {
19348
+ blockIdentifier,
19349
+ skipValidate,
19350
+ skipExecute
19351
+ });
19352
+ }
19353
+ async execute(transactions, transactionsDetail = {}) {
19354
+ const calls = [transactions].flat();
19355
+ const detailsWithTip = await this.resolveDetailsWithTip(transactionsDetail);
19356
+ const { resourceBounds: providedResourceBounds } = transactionsDetail;
19357
+ let resourceBounds = providedResourceBounds;
19358
+ if (!resourceBounds) {
19359
+ const estimateResponse = await this.estimateInvokeFee(calls, detailsWithTip);
19360
+ resourceBounds = estimateResponse.resourceBounds;
19361
+ }
19362
+ const accountInvocations = await this.accountInvocationsFactory(
19363
+ [{ type: api_exports3.ETransactionType.INVOKE, payload: calls }],
19364
+ {
19365
+ ...v3Details(detailsWithTip),
19366
+ resourceBounds,
19367
+ versions: [this.resolveTransactionVersion(transactionsDetail.version)],
19368
+ nonce: transactionsDetail.nonce,
19369
+ skipValidate: false
19370
+ }
19371
+ );
19372
+ const invocation = accountInvocations[0];
19373
+ return this.invokeFunction(
19374
+ {
19375
+ contractAddress: invocation.contractAddress,
19376
+ calldata: invocation.calldata,
19377
+ signature: invocation.signature
19378
+ },
19379
+ {
19380
+ ...v3Details(detailsWithTip),
19381
+ resourceBounds: invocation.resourceBounds,
19382
+ nonce: invocation.nonce,
19383
+ version: invocation.version
19384
+ }
19385
+ );
19386
+ }
19387
+ /**
19388
+ * Execute one or multiple calls through the account contract,
19389
+ * responding as soon as a new transaction is possible with the same account.
19390
+ * Useful for gaming usage.
19391
+ * - This method requires the provider to be initialized with `pre_confirmed` blockIdentifier option.
19392
+ * - Rpc 0.9 minimum.
19393
+ * - In a normal myAccount.execute() call, followed by myProvider.waitForTransaction(), you have an immediate access to the events and to the transaction report. Here, we are processing consecutive transactions faster, but events & transaction reports are not available immediately.
19394
+ * - As a consequence of the previous point, do not use contract/account deployment with this method.
19395
+ * @param {AllowArray<Call>} transactions - Single call or array of calls to execute
19396
+ * @param {UniversalDetails} [transactionsDetail] - Transaction execution options
19397
+ * @param {fastWaitForTransactionOptions} [waitDetail={retries: 50, retryInterval: 500}] - options to scan the network for the next possible transaction. `retries` is the number of times to retry, `retryInterval` is the time in ms between retries.
19398
+ * @returns {Promise<fastExecuteResponse>} Response containing the transaction result and status for the next transaction. If `isReady` is true, you can execute the next transaction. If false, timeout has been reached before the next transaction was possible.
19399
+ * @example
19400
+ * ```typescript
19401
+ * const myProvider = new RpcProvider({ nodeUrl: url, blockIdentifier: BlockTag.PRE_CONFIRMED });
19402
+ * const myAccount = new Account({ provider: myProvider, address: accountAddress0, signer: privateKey0 });
19403
+ * const resp = await myAccount.fastExecute(
19404
+ * call, { tip: recommendedTip},
19405
+ * { retries: 30, retryInterval: 500 });
19406
+ * // if resp.isReady is true, you can launch immediately a new tx.
19407
+ * ```
19408
+ */
19409
+ async fastExecute(transactions, transactionsDetail = {}, waitDetail = {}) {
19410
+ assert(
19411
+ this.channel.blockIdentifier === BlockTag.PRE_CONFIRMED,
19412
+ "Provider needs to be initialized with `pre_confirmed` blockIdentifier option."
19413
+ );
19414
+ const initNonce = BigInt(
19415
+ transactionsDetail.nonce ?? await this.getNonceForAddress(this.address, BlockTag.PRE_CONFIRMED)
19416
+ );
19417
+ const details = { ...transactionsDetail, nonce: initNonce };
19418
+ const resultTx = await this.execute(transactions, details);
19419
+ const resultWait = await this.fastWaitForTransaction(
19420
+ resultTx.transaction_hash,
19421
+ this.address,
19422
+ initNonce,
19423
+ waitDetail
19424
+ );
19425
+ return { txResult: resultTx, isReady: resultWait };
19426
+ }
19427
+ /**
19428
+ * First check if contract is already declared, if not declare it
19429
+ * If contract already declared returned transaction_hash is ''.
19430
+ * Method will pass even if contract is already declared
19431
+ * @param transactionsDetail (optional)
19432
+ */
19433
+ async declareIfNot(payload, transactionsDetail = {}) {
19434
+ const declareContractPayload = extractContractHashes(
19435
+ payload,
19436
+ await this.channel.getStarknetVersion()
19437
+ );
19438
+ try {
19439
+ await this.getClassByHash(declareContractPayload.classHash);
19440
+ } catch (error) {
19441
+ return this.declare(payload, transactionsDetail);
19442
+ }
19443
+ return {
19444
+ transaction_hash: "",
19445
+ class_hash: declareContractPayload.classHash
19446
+ };
19447
+ }
19448
+ async declare(payload, details = {}) {
19449
+ assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
19450
+ const declareContractPayload = extractContractHashes(
19451
+ payload,
19452
+ await this.channel.getStarknetVersion()
19453
+ );
19454
+ const detailsWithTip = await this.resolveDetailsWithTip(details);
19455
+ const { resourceBounds: providedResourceBounds } = details;
19456
+ let resourceBounds = providedResourceBounds;
19457
+ if (!resourceBounds) {
19458
+ const estimateResponse = await this.estimateDeclareFee(payload, detailsWithTip);
19459
+ resourceBounds = estimateResponse.resourceBounds;
19460
+ }
19461
+ const accountInvocations = await this.accountInvocationsFactory(
19462
+ [{ type: api_exports3.ETransactionType.DECLARE, payload: declareContractPayload }],
19463
+ {
19464
+ ...v3Details(detailsWithTip),
19465
+ resourceBounds,
19466
+ versions: [this.resolveTransactionVersion(details.version)],
19467
+ nonce: details.nonce,
19468
+ skipValidate: false
19469
+ }
19470
+ );
19471
+ const declaration = accountInvocations[0];
19472
+ return super.declareContract(
19473
+ {
19474
+ senderAddress: declaration.senderAddress,
19475
+ signature: declaration.signature,
19476
+ contract: declaration.contract,
19477
+ compiledClassHash: declaration.compiledClassHash
19478
+ },
19479
+ {
19480
+ ...v3Details(detailsWithTip),
19481
+ nonce: declaration.nonce,
19482
+ resourceBounds: declaration.resourceBounds,
19483
+ version: declaration.version
19484
+ }
19485
+ );
19486
+ }
19487
+ async deploy(payload, details = {}) {
19488
+ const { calls, addresses } = this.deployer.buildDeployerCall(payload, this.address);
19489
+ const invokeResponse = await this.execute(calls, details);
19490
+ return {
19491
+ ...invokeResponse,
19492
+ contract_address: addresses
19493
+ };
19494
+ }
19495
+ async deployContract(payload, details = {}) {
19496
+ const deployTx = await this.deploy(payload, details);
19497
+ const txReceipt = await this.waitForTransaction(deployTx.transaction_hash, details);
19498
+ return this.deployer.parseDeployerEvent(
19499
+ txReceipt
19500
+ );
19501
+ }
19502
+ async declareAndDeploy(payload, details = {}) {
19503
+ let declare = await this.declareIfNot(payload, details);
19504
+ if (declare.transaction_hash !== "") {
19505
+ const tx = await this.waitForTransaction(declare.transaction_hash, details);
19506
+ declare = { ...declare, ...tx };
19507
+ }
19508
+ const deploy = await this.deployContract(
19509
+ { ...payload, classHash: declare.class_hash },
19510
+ details
19511
+ );
19512
+ return { declare: { ...declare }, deploy };
19513
+ }
19514
+ async deployAccount({
19515
+ classHash,
19516
+ constructorCalldata = [],
19517
+ addressSalt = 0,
19518
+ contractAddress: providedContractAddress
19519
+ }, details = {}) {
19520
+ const compiledCalldata = CallData.compile(constructorCalldata);
19521
+ const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
19522
+ const detailsWithTip = await this.resolveDetailsWithTip(details);
19523
+ const { resourceBounds: providedResourceBounds } = details;
19524
+ let resourceBounds = providedResourceBounds;
19525
+ if (!resourceBounds) {
19526
+ const estimateResponse = await this.estimateAccountDeployFee(
19527
+ {
19528
+ classHash,
19529
+ constructorCalldata,
19530
+ addressSalt,
19531
+ contractAddress
19532
+ },
19533
+ detailsWithTip
19534
+ );
19535
+ resourceBounds = estimateResponse.resourceBounds;
19536
+ }
19537
+ const accountInvocations = await this.accountInvocationsFactory(
19538
+ [
19539
+ {
19540
+ type: api_exports3.ETransactionType.DEPLOY_ACCOUNT,
19541
+ payload: {
19542
+ classHash,
19543
+ constructorCalldata: compiledCalldata,
19544
+ addressSalt,
19545
+ contractAddress
19546
+ }
19547
+ }
19548
+ ],
19549
+ {
19550
+ ...v3Details(detailsWithTip),
19551
+ resourceBounds,
19552
+ versions: [this.resolveTransactionVersion(details.version)],
19553
+ nonce: ZERO,
19554
+ // DEPLOY_ACCOUNT always uses nonce 0
19555
+ skipValidate: false
19556
+ }
19557
+ );
19558
+ const deployment = accountInvocations[0];
19559
+ return super.deployAccountContract(
19560
+ {
19561
+ classHash: deployment.classHash,
19562
+ addressSalt: deployment.addressSalt,
19563
+ constructorCalldata: deployment.constructorCalldata,
19564
+ signature: deployment.signature
19565
+ },
19566
+ {
19567
+ ...v3Details(detailsWithTip),
19568
+ nonce: deployment.nonce,
19569
+ resourceBounds: deployment.resourceBounds,
19570
+ version: deployment.version
19571
+ }
19572
+ );
19573
+ }
19574
+ async signMessage(typedData) {
19575
+ return this.signer.signMessage(typedData, this.address);
19576
+ }
19577
+ async hashMessage(typedData) {
19578
+ return getMessageHash(typedData, this.address);
19579
+ }
19580
+ /**
19581
+ * Verify if an account is compatible with SNIP-9 outside execution, and with which version of this standard.
19582
+ * @returns {OutsideExecutionVersion} Not compatible, V1, V2.
19583
+ * @example
19584
+ * ```typescript
19585
+ * const result = myAccount.getSnip9Version();
19586
+ * // result = "V1"
19587
+ * ```
19588
+ */
19589
+ async getSnip9Version() {
19590
+ if (await supportsInterface(this, this.address, SNIP9_V2_INTERFACE_ID)) {
19591
+ return OutsideExecutionVersion.V2;
19592
+ }
19593
+ if (await supportsInterface(this, this.address, SNIP9_V1_INTERFACE_ID)) {
19594
+ return OutsideExecutionVersion.V1;
19595
+ }
19596
+ return OutsideExecutionVersion.UNSUPPORTED;
19597
+ }
19598
+ /**
19599
+ * Verify if a SNIP-9 nonce has not yet been used by the account.
19600
+ * @param {BigNumberish} nonce SNIP-9 nonce to test.
19601
+ * @returns {boolean} true if SNIP-9 nonce not yet used.
19602
+ * @example
19603
+ * ```typescript
19604
+ * const result = myAccount.isValidSnip9Nonce(1234);
19605
+ * // result = true
19606
+ * ```
19607
+ */
19608
+ async isValidSnip9Nonce(nonce) {
19609
+ try {
19610
+ const call = {
19611
+ contractAddress: this.address,
19612
+ entrypoint: "is_valid_outside_execution_nonce",
19613
+ calldata: [toHex(nonce)]
19614
+ };
19615
+ const resp = await this.callContract(call);
19616
+ return BigInt(resp[0]) !== 0n;
19617
+ } catch (error) {
19618
+ throw new Error(`Failed to check if nonce is valid: ${error}`);
19619
+ }
19620
+ }
19621
+ /**
19622
+ * Outside transaction needs a specific SNIP-9 nonce, that we get in this function.
19623
+ * A SNIP-9 nonce can be any number not yet used ; no ordering is needed.
19624
+ * @returns {string} an Hex string of a SNIP-9 nonce.
19625
+ * @example
19626
+ * ```typescript
19627
+ * const result = myAccount.getSnip9Nonce();
19628
+ * // result = "0x28a612590dbc36927933c8ee0f357eee639c8b22b3d3aa86949eed3ada4ac55"
19629
+ * ```
19630
+ */
19631
+ async getSnip9Nonce() {
19632
+ const nonce = randomAddress();
19633
+ const isValidNonce = await this.isValidSnip9Nonce(nonce);
19634
+ if (!isValidNonce) {
19635
+ return this.getSnip9Nonce();
19636
+ }
19637
+ return nonce;
19638
+ }
19639
+ /**
19640
+ * Creates an object containing transaction(s) that can be executed by an other account with` Account.executeFromOutside()`, called Outside Transaction.
19641
+ * @param {OutsideExecutionOptions} options Parameters of the transaction(s).
19642
+ * @param {AllowArray<Call>} calls Transaction(s) to execute.
19643
+ * @param {OutsideExecutionVersion} [version] SNIP-9 version of the Account that creates the outside transaction.
19644
+ * @param {BigNumberish} [nonce] Outside Nonce.
19645
+ * @returns {OutsideTransaction} and object that can be used in `Account.executeFromOutside()`
19646
+ * @example
19647
+ * ```typescript
19648
+ * const now_seconds = Math.floor(Date.now() / 1000);
19649
+ * const callOptions: OutsideExecutionOptions = {
19650
+ caller: executorAccount.address, execute_after: now_seconds - 3600, execute_before: now_seconds + 3600 };
19651
+ * const call1: Call = { contractAddress: ethAddress, entrypoint: 'transfer', calldata: {
19652
+ * recipient: recipientAccount.address, amount: cairo.uint256(100) } };
19653
+ * const outsideTransaction1: OutsideTransaction = await signerAccount.getOutsideTransaction(callOptions, call3);
19654
+ * // result = {
19655
+ * // outsideExecution: {
19656
+ * // caller: '0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691',
19657
+ * // nonce: '0x28a612590dbc36927933c8ee0f357eee639c8b22b3d3aa86949eed3ada4ac55',
19658
+ * // execute_after: 1723650229, execute_before: 1723704229, calls: [[Object]] },
19659
+ * // signature: Signature {
19660
+ * // r: 67518627037915514985321278857825384106482999609634873287406612756843916814n,
19661
+ * // s: 737198738569840639192844101690009498983611654458636624293579534560862067709n, recovery: 0 },
19662
+ * // signerAddress: '0x655f8fd7c4013c07cf12a92184aa6c314d181443913e21f7e209a18f0c78492',
19663
+ * // version: '2'
19664
+ * // }
19665
+ * ```
19666
+ */
19667
+ async getOutsideTransaction(options, calls, version, nonce) {
19668
+ if (!isHex2(options.caller) && options.caller !== "ANY_CALLER") {
19669
+ throw new Error(`The caller ${options.caller} is not valid.`);
19670
+ }
19671
+ const codedCaller = isHex2(options.caller) ? options.caller : OutsideExecutionCallerAny;
19672
+ const myCalls = [calls].flat();
19673
+ const supportedVersion = version ?? await this.getSnip9Version();
19674
+ if (!supportedVersion) {
19675
+ throw new Error("This account is not handling outside transactions.");
19676
+ }
19677
+ const myNonce = nonce ? toHex(nonce) : await this.getSnip9Nonce();
19678
+ const message = getTypedData(
19679
+ await this.getChainId(),
19680
+ {
19681
+ caller: codedCaller,
19682
+ execute_after: options.execute_after,
19683
+ execute_before: options.execute_before
19684
+ },
19685
+ myNonce,
19686
+ myCalls,
19687
+ supportedVersion
19688
+ );
19689
+ const sign2 = await this.signMessage(message);
19690
+ const toExecute = {
19691
+ caller: codedCaller,
19692
+ nonce: myNonce,
19693
+ execute_after: options.execute_after,
19694
+ execute_before: options.execute_before,
19695
+ calls: myCalls.map(getOutsideCall)
19696
+ };
19697
+ return {
19698
+ outsideExecution: toExecute,
19699
+ signature: sign2,
19700
+ signerAddress: this.address,
19701
+ version: supportedVersion
19702
+ };
19703
+ }
19704
+ /**
19705
+ * An account B executes a transaction that has been signed by an account A.
19706
+ * Fees are paid by B.
19707
+ * @param {AllowArray<OutsideTransaction>} outsideTransaction the signed transaction generated by `Account.getOutsideTransaction()`.
19708
+ * @param {UniversalDetails} [opts] same options than `Account.execute()`.
19709
+ * @returns {InvokeFunctionResponse} same response than `Account.execute()`.
19710
+ * @example
19711
+ * ```typescript
19712
+ * const outsideTransaction1: OutsideTransaction = await signerAccount.getOutsideTransaction(callOptions, call1);
19713
+ * const outsideTransaction2: OutsideTransaction = await signerAccount.getOutsideTransaction(callOptions4, call4);
19714
+ * const result = await myAccount.executeFromOutside([
19715
+ outsideTransaction1,
19716
+ outsideTransaction2,
19717
+ ]);
19718
+ * // result = { transaction_hash: '0x11233...`}
19719
+ * ```
19720
+ */
19721
+ async executeFromOutside(outsideTransaction, opts) {
19722
+ const multiCall = buildExecuteFromOutsideCall(outsideTransaction);
19723
+ return this.execute(multiCall, opts);
19724
+ }
19725
+ /*
19726
+ * Support methods
19727
+ */
19728
+ /**
19729
+ * Helper method to resolve details with tip estimation
19730
+ * @private
19731
+ */
19732
+ async resolveDetailsWithTip(details) {
19733
+ return {
19734
+ ...details,
19735
+ tip: details.tip ?? (await this.getEstimateTip())[this.defaultTipType]
19736
+ };
19737
+ }
19738
+ /**
19739
+ * Helper method to resolve transaction version
19740
+ * @private
19741
+ */
19742
+ resolveTransactionVersion(providedVersion) {
19743
+ return toTransactionVersion(
19744
+ this.transactionVersion || ETransactionVersion33.V3,
19745
+ providedVersion
19746
+ );
19747
+ }
19748
+ async buildInvocation(call, details) {
19749
+ const calldata = getExecuteCalldata(call, await this.getCairoVersion());
19750
+ const signature = !details.skipValidate ? await this.signer.signTransaction(call, details) : [];
19751
+ return {
19752
+ ...v3Details(details),
19753
+ contractAddress: this.address,
19754
+ calldata,
19755
+ signature
19756
+ };
19757
+ }
19758
+ async buildDeclarePayload(payload, details) {
19759
+ const { classHash, contract, compiledClassHash } = extractContractHashes(
19760
+ payload,
19761
+ await this.channel.getStarknetVersion()
19762
+ );
19763
+ const compressedCompiledContract = parseContract(contract);
19764
+ assert(
19765
+ !isUndefined(compiledClassHash) && (details.version === ETransactionVersion33.F3 || details.version === ETransactionVersion33.V3),
19766
+ "V3 Transaction work with Cairo1 Contracts and require compiledClassHash"
19767
+ );
19768
+ const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
19769
+ ...details,
19770
+ ...v3Details(details),
19771
+ classHash,
19772
+ compiledClassHash,
19773
+ senderAddress: details.walletAddress
19774
+ }) : [];
19775
+ return {
19776
+ senderAddress: details.walletAddress,
19777
+ signature,
19778
+ contract: compressedCompiledContract,
19779
+ compiledClassHash
19780
+ };
19781
+ }
19782
+ async buildAccountDeployPayload({
19783
+ classHash,
19784
+ addressSalt = 0,
19785
+ constructorCalldata = [],
19786
+ contractAddress: providedContractAddress
19787
+ }, details) {
19788
+ const compiledCalldata = CallData.compile(constructorCalldata);
19789
+ const contractAddress = providedContractAddress ?? calculateContractAddressFromHash(addressSalt, classHash, compiledCalldata, 0);
19790
+ const signature = !details.skipValidate ? await this.signer.signDeployAccountTransaction({
19791
+ ...details,
19792
+ ...v3Details(details),
19793
+ classHash,
19794
+ contractAddress,
19795
+ addressSalt,
19796
+ constructorCalldata: compiledCalldata
19797
+ }) : [];
19798
+ return {
19799
+ ...v3Details(details),
19800
+ classHash,
19801
+ addressSalt,
19802
+ constructorCalldata: compiledCalldata,
19803
+ signature
19804
+ };
19805
+ }
19806
+ async accountInvocationsFactory(invocations, details) {
19807
+ const { nonce, blockIdentifier, skipValidate = true } = details;
19808
+ const safeNonce = await this.getNonceSafe(nonce);
19809
+ const chainId = await this.getChainId();
19810
+ const versions = details.versions.map((it) => toTransactionVersion(it));
19811
+ const tx0Payload = "payload" in invocations[0] ? invocations[0].payload : invocations[0];
19812
+ const cairoVersion = invocations[0].type === api_exports3.ETransactionType.DEPLOY_ACCOUNT ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
19813
+ return Promise.all(
19814
+ [].concat(invocations).map(async (transaction, index) => {
19815
+ const txPayload = "payload" in transaction ? transaction.payload : transaction;
19816
+ const signerDetails = {
19817
+ ...v3Details(details),
19818
+ walletAddress: this.address,
19819
+ nonce: toBigInt(Number(safeNonce) + index),
19820
+ chainId,
19821
+ cairoVersion,
19822
+ version: versions[0],
19823
+ skipValidate
19824
+ };
19825
+ const common2 = {
19826
+ type: transaction.type,
19827
+ nonce: toBigInt(Number(safeNonce) + index),
19828
+ blockIdentifier,
19829
+ version: versions[0]
19830
+ };
19831
+ if (transaction.type === api_exports3.ETransactionType.INVOKE) {
19832
+ const payload = await this.buildInvocation(
19833
+ [].concat(txPayload),
19834
+ signerDetails
19835
+ );
19836
+ return {
19837
+ ...common2,
19838
+ ...payload,
19839
+ ...signerDetails
19840
+ };
19841
+ }
19842
+ if (transaction.type === api_exports3.ETransactionType.DEPLOY) {
19843
+ const { calls } = this.deployer.buildDeployerCall(txPayload, this.address);
19844
+ const payload = await this.buildInvocation(calls, signerDetails);
19845
+ return {
19846
+ ...common2,
19847
+ ...payload,
19848
+ ...signerDetails,
19849
+ type: api_exports3.ETransactionType.INVOKE
19850
+ };
19851
+ }
19852
+ if (transaction.type === api_exports3.ETransactionType.DECLARE) {
19853
+ assert(
19854
+ isSierra(txPayload.contract),
19855
+ "Declare fee estimation is not supported for Cairo0 contracts"
19856
+ );
19857
+ const payload = await this.buildDeclarePayload(txPayload, signerDetails);
19858
+ return {
19859
+ ...common2,
19860
+ ...payload,
19861
+ ...signerDetails
19862
+ };
19863
+ }
19864
+ if (transaction.type === api_exports3.ETransactionType.DEPLOY_ACCOUNT) {
19865
+ const payload = await this.buildAccountDeployPayload(txPayload, signerDetails);
19866
+ return {
19867
+ ...common2,
19868
+ ...payload,
19869
+ ...signerDetails
19870
+ };
19871
+ }
19872
+ throw Error(`accountInvocationsFactory: unsupported transaction type: ${transaction}`);
19873
+ })
19874
+ );
19875
+ }
19876
+ /*
19877
+ * SNIP-29 Paymaster
19878
+ */
19879
+ async buildPaymasterTransaction(calls, paymasterDetails) {
19880
+ if (!paymasterDetails.deploymentData) {
19881
+ const snip9Version = await this.getSnip9Version();
19882
+ if (snip9Version === OutsideExecutionVersion.UNSUPPORTED) {
19883
+ throw Error("Account is not compatible with SNIP-9");
19884
+ }
19885
+ }
19886
+ const parameters = {
19887
+ version: "0x1",
19888
+ feeMode: paymasterDetails.feeMode,
19889
+ timeBounds: paymasterDetails.timeBounds
19890
+ };
19891
+ let transaction;
19892
+ if (paymasterDetails.deploymentData) {
19893
+ if (calls.length > 0) {
19894
+ transaction = {
19895
+ type: "deploy_and_invoke",
19896
+ invoke: { userAddress: this.address, calls },
19897
+ deployment: paymasterDetails.deploymentData
19898
+ };
19899
+ } else {
19900
+ transaction = {
19901
+ type: "deploy",
19902
+ deployment: paymasterDetails.deploymentData
19903
+ };
19904
+ }
19905
+ } else {
19906
+ transaction = {
19907
+ type: "invoke",
19908
+ invoke: { userAddress: this.address, calls }
19909
+ };
19910
+ }
19911
+ return this.paymaster.buildTransaction(transaction, parameters);
19912
+ }
19913
+ async estimatePaymasterTransactionFee(calls, paymasterDetails) {
19914
+ const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
19915
+ return preparedTransaction.fee;
19916
+ }
19917
+ async preparePaymasterTransaction(preparedTransaction) {
19918
+ let transaction;
19919
+ switch (preparedTransaction.type) {
19920
+ case "deploy_and_invoke": {
19921
+ const signature = await this.signMessage(preparedTransaction.typed_data);
19922
+ transaction = {
19923
+ type: "deploy_and_invoke",
19924
+ invoke: {
19925
+ userAddress: this.address,
19926
+ typedData: preparedTransaction.typed_data,
19927
+ signature: signatureToHexArray(signature)
19928
+ },
19929
+ deployment: preparedTransaction.deployment
19930
+ };
19931
+ break;
19932
+ }
19933
+ case "invoke": {
19934
+ const signature = await this.signMessage(preparedTransaction.typed_data);
19935
+ transaction = {
19936
+ type: "invoke",
19937
+ invoke: {
19938
+ userAddress: this.address,
19939
+ typedData: preparedTransaction.typed_data,
19940
+ signature: signatureToHexArray(signature)
19941
+ }
19942
+ };
19943
+ break;
19944
+ }
19945
+ case "deploy": {
19946
+ transaction = {
19947
+ type: "deploy",
19948
+ deployment: preparedTransaction.deployment
19949
+ };
19950
+ break;
19951
+ }
19952
+ default:
19953
+ throw Error("Invalid transaction type");
19954
+ }
19955
+ return transaction;
19956
+ }
19957
+ async executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken) {
19958
+ const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
19959
+ assertPaymasterTransactionSafety(
19960
+ preparedTransaction,
19961
+ calls,
19962
+ paymasterDetails,
19963
+ maxFeeInGasToken
19964
+ );
19965
+ const transaction = await this.preparePaymasterTransaction(preparedTransaction);
19966
+ return this.paymaster.executeTransaction(transaction, preparedTransaction.parameters).then((response) => ({ transaction_hash: response.transaction_hash }));
19967
+ }
19968
+ /*
19969
+ * External methods
19970
+ */
19971
+ /**
19972
+ * Get the Starknet ID for an address
19973
+ * @param address - The address to get the Starknet ID for
19974
+ * @param StarknetIdContract - The Starknet ID contract address (optional)
19975
+ * @returns The Starknet ID for the address
19976
+ */
19977
+ async getStarkName(address = this.address, StarknetIdContract2) {
19978
+ return super.getStarkName(address, StarknetIdContract2);
19979
+ }
19980
+ };
19130
19981
  var connect_exports = {};
19131
19982
  __export2(connect_exports, {
19132
19983
  addDeclareTransaction: () => addDeclareTransaction,
@@ -20052,6 +20903,178 @@ function useThresholdSign(opts) {
20052
20903
  finalize
20053
20904
  };
20054
20905
  }
20906
+ var DEFAULTS = {
20907
+ apiBaseUrl: "https://api.chipipay.com/v1",
20908
+ rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet",
20909
+ chainId: "0x534e5f4d41494e",
20910
+ gasTankAddress: "0x232f9c4ec684c03caae94f75987ea0540c06173d96dd5c6705521eb45e28b0a"
20911
+ };
20912
+ async function derivePrivacyAccount(p) {
20913
+ const pool = await derivePoolKeypair({
20914
+ anchorSecret: p.anchorSecret,
20915
+ seedDomainTag: p.seedDomainTag
20916
+ });
20917
+ const companion = await deriveCompanionKeypair(p.anchorSecret);
20918
+ return {
20919
+ companionAddress: deriveCompanionAddress({
20920
+ publicKey: companion.publicKey,
20921
+ classHash: p.classHash
20922
+ }),
20923
+ companionKey: companion.privateKey,
20924
+ classHash: p.classHash,
20925
+ poolKey: BigInt(pool.privateKey)
20926
+ };
20927
+ }
20928
+ function buildCtx(config3, keys) {
20929
+ const rpcUrl = config3.rpcUrl ?? DEFAULTS.rpcUrl;
20930
+ return {
20931
+ provider: new RpcProvider2({ nodeUrl: rpcUrl }),
20932
+ chainId: config3.chainId ?? DEFAULTS.chainId,
20933
+ companionAddress: keys.companionAddress,
20934
+ companionKey: keys.companionKey,
20935
+ classHash: keys.classHash,
20936
+ poolKey: keys.poolKey,
20937
+ provingProvider: new ChipiProofProvider({
20938
+ baseUrl: config3.apiBaseUrl ?? DEFAULTS.apiBaseUrl,
20939
+ apiKey: config3.apiPublicKey,
20940
+ getBearerToken: config3.getBearerToken,
20941
+ chainId: config3.chainId ?? DEFAULTS.chainId
20942
+ }),
20943
+ gatewaySubmitUrl: config3.gatewaySubmitUrl,
20944
+ rpcUrl
20945
+ };
20946
+ }
20947
+ async function runShield(input) {
20948
+ const { config: config3, keys } = input;
20949
+ const ctx = buildCtx(config3, keys);
20950
+ input.onStep?.("prepare");
20951
+ input.onStep?.("fund");
20952
+ await requestGasFunding(keys.companionAddress, {
20953
+ baseUrl: config3.apiBaseUrl ?? DEFAULTS.apiBaseUrl,
20954
+ apiKey: config3.apiPublicKey,
20955
+ getBearerToken: config3.getBearerToken
20956
+ });
20957
+ if (input.fundDeposit) {
20958
+ input.onStep?.("deposit");
20959
+ await input.fundDeposit(keys.companionAddress, input.amount);
20960
+ }
20961
+ await waitForFunding(ctx.provider, keys.companionAddress, {
20962
+ strk: GAS_FUND_STRK,
20963
+ token: input.fundDeposit ? { address: input.token, amount: input.amount } : void 0
20964
+ });
20965
+ input.onStep?.("prove");
20966
+ const result = await execShield(ctx, input.token, input.amount);
20967
+ input.onStep?.("finish");
20968
+ void sweepCompanion({
20969
+ provider: ctx.provider,
20970
+ companionAddress: keys.companionAddress,
20971
+ companionKey: keys.companionKey,
20972
+ gasTank: config3.gasTankAddress ?? DEFAULTS.gasTankAddress
20973
+ });
20974
+ return result;
20975
+ }
20976
+ async function runUnshield(input) {
20977
+ const { config: config3, keys } = input;
20978
+ const ctx = buildCtx(config3, keys);
20979
+ input.onStep?.("prepare");
20980
+ input.onStep?.("fund");
20981
+ await requestGasFunding(keys.companionAddress, {
20982
+ baseUrl: config3.apiBaseUrl ?? DEFAULTS.apiBaseUrl,
20983
+ apiKey: config3.apiPublicKey,
20984
+ getBearerToken: config3.getBearerToken
20985
+ });
20986
+ await waitForFunding(ctx.provider, keys.companionAddress, { strk: GAS_FUND_STRK });
20987
+ input.onStep?.("prove");
20988
+ const result = await execUnshield(ctx, input.token, input.amount);
20989
+ input.onStep?.("finish");
20990
+ const swept = await sweepCompanion({
20991
+ provider: ctx.provider,
20992
+ companionAddress: keys.companionAddress,
20993
+ companionKey: keys.companionKey,
20994
+ gasTank: config3.gasTankAddress ?? DEFAULTS.gasTankAddress,
20995
+ deliverToken: { address: input.token, to: input.deliverTo },
20996
+ strict: true
20997
+ });
20998
+ if (swept.transactionHash === null) {
20999
+ throw new Error(
21000
+ "unshield_undelivered: the withdrawal settled but delivery to your wallet could not be confirmed \u2014 funds are safe in the companion account; retry"
21001
+ );
21002
+ }
21003
+ return result;
21004
+ }
21005
+ function useShield() {
21006
+ const mutation = useMutation({ mutationFn: runShield });
21007
+ return {
21008
+ shield: mutation.mutate,
21009
+ shieldAsync: mutation.mutateAsync,
21010
+ data: mutation.data,
21011
+ isLoading: mutation.isPending,
21012
+ isError: mutation.isError,
21013
+ error: mutation.error,
21014
+ isSuccess: mutation.isSuccess,
21015
+ reset: mutation.reset
21016
+ };
21017
+ }
21018
+ function useUnshield() {
21019
+ const mutation = useMutation({
21020
+ mutationFn: runUnshield
21021
+ });
21022
+ return {
21023
+ unshield: mutation.mutate,
21024
+ unshieldAsync: mutation.mutateAsync,
21025
+ data: mutation.data,
21026
+ isLoading: mutation.isPending,
21027
+ isError: mutation.isError,
21028
+ error: mutation.error,
21029
+ isSuccess: mutation.isSuccess,
21030
+ reset: mutation.reset
21031
+ };
21032
+ }
21033
+ function netPrivateBalance(events) {
21034
+ const byToken = {};
21035
+ for (const e of events) {
21036
+ const signed = e.direction === "shield" ? e.amount : -e.amount;
21037
+ byToken[e.token] = (byToken[e.token] ?? 0n) + signed;
21038
+ }
21039
+ for (const k of Object.keys(byToken)) if (byToken[k] < 0n) byToken[k] = 0n;
21040
+ return byToken;
21041
+ }
21042
+ function usePrivateBalance(input) {
21043
+ const query = useQuery({
21044
+ queryKey: [
21045
+ "chipi-private-balance",
21046
+ input.mode,
21047
+ // A stale cache here is a stale MONEY balance (review finding m1):
21048
+ // ledger mode keys on a content digest (length alone missed same-count
21049
+ // edits); onchain mode keys on the account AND the token filter.
21050
+ input.mode === "ledger" ? input.events.reduce((h, e) => h + (e.direction === "shield" ? e.amount : -e.amount), 0n).toString() + ":" + input.events.length : input.keys.companionAddress + ":" + (input.tokens ?? []).join(",")
21051
+ ],
21052
+ queryFn: async () => {
21053
+ if (input.mode === "ledger") return netPrivateBalance(input.events);
21054
+ const ctx = buildCtx(input.config, input.keys);
21055
+ const { byToken } = await getPrivateBalance({
21056
+ provider: ctx.provider,
21057
+ account: new Account({
21058
+ provider: ctx.provider,
21059
+ address: input.keys.companionAddress,
21060
+ signer: input.keys.companionKey,
21061
+ cairoVersion: "1"
21062
+ }),
21063
+ viewingKey: input.keys.poolKey,
21064
+ provingProvider: ctx.provingProvider,
21065
+ tokens: input.tokens
21066
+ });
21067
+ return byToken;
21068
+ }
21069
+ });
21070
+ return {
21071
+ byToken: query.data ?? {},
21072
+ isLoading: query.isLoading,
21073
+ isError: query.isError,
21074
+ error: query.error,
21075
+ refetch: query.refetch
21076
+ };
21077
+ }
20055
21078
 
20056
21079
  // src/connect/window-object.ts
20057
21080
  var SUPPORTED_SPECS = ["0.8"];
@@ -20390,6 +21413,6 @@ pako/dist/pako.esm.mjs:
20390
21413
  (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
20391
21414
  */
20392
21415
 
20393
- export { ChipiInjector, ChipiProvider, Recover, createChipiWindowObject, injectChipiWallet, useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiContext, useChipiSession, useChipiWallet, useChipiWalletObject, useCreateSessionKey, useCreateWallet, useExecuteWithSession, useGetSessionData, useGetSku, useGetSkuList, useGetSkuPurchase, useGetTokenBalance, useGetTransaction, useGetTransactionList, useGetTransactionStatus, useGetWallet, useGuardianRecovery, useMigrateWalletToPasskey, useMigrateWalletToShhh, usePurchaseSku, useRecordSendTransaction, useRevokeSessionKey, useShhhSigner, useSignTypedData, useSyncOnChainTransfers, useThresholdSign, useTransfer, useUpdateWalletEncryption, useX402Payment };
21416
+ export { ChipiInjector, ChipiProvider, Recover, createChipiWindowObject, derivePrivacyAccount, injectChipiWallet, netPrivateBalance, useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiContext, useChipiSession, useChipiWallet, useChipiWalletObject, useCreateSessionKey, useCreateWallet, useExecuteWithSession, useGetSessionData, useGetSku, useGetSkuList, useGetSkuPurchase, useGetTokenBalance, useGetTransaction, useGetTransactionList, useGetTransactionStatus, useGetWallet, useGuardianRecovery, useMigrateWalletToPasskey, useMigrateWalletToShhh, usePrivateBalance, usePurchaseSku, useRecordSendTransaction, useRevokeSessionKey, useShhhSigner, useShield, useSignTypedData, useSyncOnChainTransfers, useThresholdSign, useTransfer, useUnshield, useUpdateWalletEncryption, useX402Payment };
20394
21417
  //# sourceMappingURL=index.mjs.map
20395
21418
  //# sourceMappingURL=index.mjs.map