@fuel-ts/account 0.0.0-rc-2238-20240514192918 → 0.0.0-rc-2143-20240514195947

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
33
33
  import { AbstractAccount } from "@fuel-ts/interfaces";
34
- import { bn as bn19 } from "@fuel-ts/math";
34
+ import { bn as bn20 } from "@fuel-ts/math";
35
35
  import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
36
36
  import { clone as clone4 } from "ramda";
37
37
 
@@ -73,7 +73,7 @@ var addAmountToCoinQuantities = (params) => {
73
73
  // src/providers/provider.ts
74
74
  import { Address as Address2 } from "@fuel-ts/address";
75
75
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
76
- import { BN, bn as bn17 } from "@fuel-ts/math";
76
+ import { BN, bn as bn18 } from "@fuel-ts/math";
77
77
  import {
78
78
  InputType as InputType7,
79
79
  TransactionType as TransactionType8,
@@ -2377,6 +2377,15 @@ var BaseTransactionRequest = class {
2377
2377
  }
2378
2378
  });
2379
2379
  }
2380
+ shiftPredicateData() {
2381
+ this.inputs.forEach((input) => {
2382
+ if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2383
+ input.predicateData = input.padPredicateData(
2384
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2385
+ );
2386
+ }
2387
+ });
2388
+ }
2380
2389
  };
2381
2390
 
2382
2391
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2799,12 +2808,12 @@ var transactionRequestify = (obj) => {
2799
2808
 
2800
2809
  // src/providers/transaction-response/transaction-response.ts
2801
2810
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2802
- import { bn as bn16 } from "@fuel-ts/math";
2811
+ import { bn as bn17 } from "@fuel-ts/math";
2803
2812
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2804
2813
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2805
2814
 
2806
2815
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2807
- import { bn as bn15 } from "@fuel-ts/math";
2816
+ import { bn as bn16 } from "@fuel-ts/math";
2808
2817
  import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2809
2818
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2810
2819
 
@@ -2881,32 +2890,43 @@ var calculateTXFeeForSummary = (params) => {
2881
2890
  // src/providers/transaction-summary/operations.ts
2882
2891
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2883
2892
  import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2884
- import { bn as bn13 } from "@fuel-ts/math";
2893
+ import { bn as bn14 } from "@fuel-ts/math";
2885
2894
  import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2886
2895
 
2887
2896
  // src/providers/transaction-summary/call.ts
2888
- import { Interface as Interface2 } from "@fuel-ts/abi-coder";
2889
- var getFunctionCall = ({ abi, receipt }) => {
2897
+ import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2898
+ import { bn as bn13 } from "@fuel-ts/math";
2899
+ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2890
2900
  const abiInterface = new Interface2(abi);
2891
2901
  const callFunctionSelector = receipt.param1.toHex(8);
2892
2902
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2893
2903
  const inputs = functionFragment.jsonFn.inputs;
2894
- const encodedArgs = receipt.param2.toHex();
2904
+ let encodedArgs;
2905
+ if (functionFragment.isInputDataPointer) {
2906
+ if (rawPayload) {
2907
+ const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2908
+ encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2909
+ }
2910
+ } else {
2911
+ encodedArgs = receipt.param2.toHex();
2912
+ }
2895
2913
  let argumentsProvided;
2896
- const data = functionFragment.decodeArguments(encodedArgs);
2897
- if (data) {
2898
- argumentsProvided = inputs.reduce((prev, input, index) => {
2899
- const value = data[index];
2900
- const name = input.name;
2901
- if (name) {
2902
- return {
2903
- ...prev,
2904
- // reparse to remove bn
2905
- [name]: JSON.parse(JSON.stringify(value))
2906
- };
2907
- }
2908
- return prev;
2909
- }, {});
2914
+ if (encodedArgs) {
2915
+ const data = functionFragment.decodeArguments(encodedArgs);
2916
+ if (data) {
2917
+ argumentsProvided = inputs.reduce((prev, input, index) => {
2918
+ const value = data[index];
2919
+ const name = input.name;
2920
+ if (name) {
2921
+ return {
2922
+ ...prev,
2923
+ // reparse to remove bn
2924
+ [name]: JSON.parse(JSON.stringify(value))
2925
+ };
2926
+ }
2927
+ return prev;
2928
+ }, {});
2929
+ }
2910
2930
  }
2911
2931
  const call = {
2912
2932
  functionSignature: functionFragment.signature,
@@ -3092,7 +3112,7 @@ var mergeAssets = (op1, op2) => {
3092
3112
  if (!matchingAsset) {
3093
3113
  return asset1;
3094
3114
  }
3095
- const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
3115
+ const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
3096
3116
  return { ...asset1, amount: mergedAmount };
3097
3117
  });
3098
3118
  return mergedAssets.concat(filteredAssets);
@@ -3418,7 +3438,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3418
3438
 
3419
3439
  // src/providers/transaction-summary/status.ts
3420
3440
  import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3421
- import { bn as bn14 } from "@fuel-ts/math";
3441
+ import { bn as bn15 } from "@fuel-ts/math";
3422
3442
  var getTransactionStatusName = (gqlStatus) => {
3423
3443
  switch (gqlStatus) {
3424
3444
  case "FailureStatus":
@@ -3452,15 +3472,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3452
3472
  time = gqlTransactionStatus.time;
3453
3473
  blockId = gqlTransactionStatus.block.id;
3454
3474
  isStatusSuccess = true;
3455
- totalFee = bn14(gqlTransactionStatus.totalFee);
3456
- totalGas = bn14(gqlTransactionStatus.totalGas);
3475
+ totalFee = bn15(gqlTransactionStatus.totalFee);
3476
+ totalGas = bn15(gqlTransactionStatus.totalGas);
3457
3477
  break;
3458
3478
  case "FailureStatus":
3459
3479
  time = gqlTransactionStatus.time;
3460
3480
  blockId = gqlTransactionStatus.block.id;
3461
3481
  isStatusFailure = true;
3462
- totalFee = bn14(gqlTransactionStatus.totalFee);
3463
- totalGas = bn14(gqlTransactionStatus.totalGas);
3482
+ totalFee = bn15(gqlTransactionStatus.totalFee);
3483
+ totalGas = bn15(gqlTransactionStatus.totalGas);
3464
3484
  break;
3465
3485
  case "SubmittedStatus":
3466
3486
  time = gqlTransactionStatus.time;
@@ -3510,7 +3530,7 @@ function assembleTransactionSummary(params) {
3510
3530
  maxInputs
3511
3531
  });
3512
3532
  const typeName = getTransactionTypeName(transaction.type);
3513
- const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3533
+ const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3514
3534
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3515
3535
  const fee = calculateTXFeeForSummary({
3516
3536
  totalFee,
@@ -3581,7 +3601,7 @@ var TransactionResponse = class {
3581
3601
  /** Current provider */
3582
3602
  provider;
3583
3603
  /** Gas used on the transaction */
3584
- gasUsed = bn16(0);
3604
+ gasUsed = bn17(0);
3585
3605
  /** The graphql Transaction with receipts object. */
3586
3606
  gqlTransaction;
3587
3607
  abis;
@@ -3815,47 +3835,47 @@ var processGqlChain = (chain) => {
3815
3835
  } = consensusParameters;
3816
3836
  return {
3817
3837
  name,
3818
- baseChainHeight: bn17(daHeight),
3838
+ baseChainHeight: bn18(daHeight),
3819
3839
  consensusParameters: {
3820
3840
  version,
3821
- chainId: bn17(chainId),
3841
+ chainId: bn18(chainId),
3822
3842
  baseAssetId,
3823
3843
  feeParameters: {
3824
3844
  version: feeParams.version,
3825
- gasPerByte: bn17(feeParams.gasPerByte),
3826
- gasPriceFactor: bn17(feeParams.gasPriceFactor)
3845
+ gasPerByte: bn18(feeParams.gasPerByte),
3846
+ gasPriceFactor: bn18(feeParams.gasPriceFactor)
3827
3847
  },
3828
3848
  contractParameters: {
3829
3849
  version: contractParams.version,
3830
- contractMaxSize: bn17(contractParams.contractMaxSize),
3831
- maxStorageSlots: bn17(contractParams.maxStorageSlots)
3850
+ contractMaxSize: bn18(contractParams.contractMaxSize),
3851
+ maxStorageSlots: bn18(contractParams.maxStorageSlots)
3832
3852
  },
3833
3853
  txParameters: {
3834
3854
  version: txParams.version,
3835
- maxInputs: bn17(txParams.maxInputs),
3836
- maxOutputs: bn17(txParams.maxOutputs),
3837
- maxWitnesses: bn17(txParams.maxWitnesses),
3838
- maxGasPerTx: bn17(txParams.maxGasPerTx),
3839
- maxSize: bn17(txParams.maxSize),
3840
- maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
3855
+ maxInputs: bn18(txParams.maxInputs),
3856
+ maxOutputs: bn18(txParams.maxOutputs),
3857
+ maxWitnesses: bn18(txParams.maxWitnesses),
3858
+ maxGasPerTx: bn18(txParams.maxGasPerTx),
3859
+ maxSize: bn18(txParams.maxSize),
3860
+ maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
3841
3861
  },
3842
3862
  predicateParameters: {
3843
3863
  version: predicateParams.version,
3844
- maxPredicateLength: bn17(predicateParams.maxPredicateLength),
3845
- maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
3846
- maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
3847
- maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
3864
+ maxPredicateLength: bn18(predicateParams.maxPredicateLength),
3865
+ maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
3866
+ maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
3867
+ maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
3848
3868
  },
3849
3869
  scriptParameters: {
3850
3870
  version: scriptParams.version,
3851
- maxScriptLength: bn17(scriptParams.maxScriptLength),
3852
- maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
3871
+ maxScriptLength: bn18(scriptParams.maxScriptLength),
3872
+ maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
3853
3873
  },
3854
3874
  gasCosts
3855
3875
  },
3856
3876
  latestBlock: {
3857
3877
  id: latestBlock.id,
3858
- height: bn17(latestBlock.height),
3878
+ height: bn18(latestBlock.height),
3859
3879
  time: latestBlock.header.time,
3860
3880
  transactions: latestBlock.transactions.map((i) => ({
3861
3881
  id: i.id
@@ -4051,7 +4071,7 @@ Supported fuel-core version: ${supportedVersion}.`
4051
4071
  */
4052
4072
  async getBlockNumber() {
4053
4073
  const { chain } = await this.operations.getChain();
4054
- return bn17(chain.latestBlock.height, 10);
4074
+ return bn18(chain.latestBlock.height, 10);
4055
4075
  }
4056
4076
  /**
4057
4077
  * Returns the chain information.
@@ -4061,8 +4081,8 @@ Supported fuel-core version: ${supportedVersion}.`
4061
4081
  async fetchNode() {
4062
4082
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
4083
  const processedNodeInfo = {
4064
- maxDepth: bn17(nodeInfo.maxDepth),
4065
- maxTx: bn17(nodeInfo.maxTx),
4084
+ maxDepth: bn18(nodeInfo.maxDepth),
4085
+ maxTx: bn18(nodeInfo.maxTx),
4066
4086
  nodeVersion: nodeInfo.nodeVersion,
4067
4087
  utxoValidation: nodeInfo.utxoValidation,
4068
4088
  vmBacktrace: nodeInfo.vmBacktrace
@@ -4194,7 +4214,7 @@ Supported fuel-core version: ${supportedVersion}.`
4194
4214
  } = response;
4195
4215
  if (inputs) {
4196
4216
  inputs.forEach((input, index) => {
4197
- if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
4217
+ if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
4198
4218
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4199
4219
  }
4200
4220
  });
@@ -4352,12 +4372,12 @@ Supported fuel-core version: ${supportedVersion}.`
4352
4372
  gasPrice = await this.estimateGasPrice(10);
4353
4373
  }
4354
4374
  const minFee = calculateGasFee({
4355
- gasPrice: bn17(gasPrice),
4375
+ gasPrice: bn18(gasPrice),
4356
4376
  gas: minGas,
4357
4377
  priceFactor: gasPriceFactor,
4358
4378
  tip: transactionRequest.tip
4359
4379
  }).add(1);
4360
- let gasLimit = bn17(0);
4380
+ let gasLimit = bn18(0);
4361
4381
  if (transactionRequest.type === TransactionType8.Script) {
4362
4382
  gasLimit = transactionRequest.gasLimit;
4363
4383
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4370,7 +4390,7 @@ Supported fuel-core version: ${supportedVersion}.`
4370
4390
  }
4371
4391
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4372
4392
  const maxFee = calculateGasFee({
4373
- gasPrice: bn17(gasPrice),
4393
+ gasPrice: bn18(gasPrice),
4374
4394
  gas: maxGas,
4375
4395
  priceFactor: gasPriceFactor,
4376
4396
  tip: transactionRequest.tip
@@ -4435,7 +4455,7 @@ Supported fuel-core version: ${supportedVersion}.`
4435
4455
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4436
4456
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4437
4457
  if (isScriptTransaction) {
4438
- txRequestClone.gasLimit = bn17(0);
4458
+ txRequestClone.gasLimit = bn18(0);
4439
4459
  }
4440
4460
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4441
4461
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4456,7 +4476,7 @@ Supported fuel-core version: ${supportedVersion}.`
4456
4476
  let dryRunStatus;
4457
4477
  let missingContractIds = [];
4458
4478
  let outputVariables = 0;
4459
- let gasUsed = bn17(0);
4479
+ let gasUsed = bn18(0);
4460
4480
  txRequestClone.maxFee = maxFee;
4461
4481
  if (isScriptTransaction) {
4462
4482
  txRequestClone.gasLimit = gasLimit;
@@ -4521,10 +4541,10 @@ Supported fuel-core version: ${supportedVersion}.`
4521
4541
  return coins.map((coin) => ({
4522
4542
  id: coin.utxoId,
4523
4543
  assetId: coin.assetId,
4524
- amount: bn17(coin.amount),
4544
+ amount: bn18(coin.amount),
4525
4545
  owner: Address2.fromAddressOrString(coin.owner),
4526
- blockCreated: bn17(coin.blockCreated),
4527
- txCreatedIdx: bn17(coin.txCreatedIdx)
4546
+ blockCreated: bn18(coin.blockCreated),
4547
+ txCreatedIdx: bn18(coin.txCreatedIdx)
4528
4548
  }));
4529
4549
  }
4530
4550
  /**
@@ -4561,9 +4581,9 @@ Supported fuel-core version: ${supportedVersion}.`
4561
4581
  switch (coin.type) {
4562
4582
  case "MessageCoin":
4563
4583
  return {
4564
- amount: bn17(coin.amount),
4584
+ amount: bn18(coin.amount),
4565
4585
  assetId: coin.assetId,
4566
- daHeight: bn17(coin.daHeight),
4586
+ daHeight: bn18(coin.daHeight),
4567
4587
  sender: Address2.fromAddressOrString(coin.sender),
4568
4588
  recipient: Address2.fromAddressOrString(coin.recipient),
4569
4589
  nonce: coin.nonce
@@ -4571,11 +4591,11 @@ Supported fuel-core version: ${supportedVersion}.`
4571
4591
  case "Coin":
4572
4592
  return {
4573
4593
  id: coin.utxoId,
4574
- amount: bn17(coin.amount),
4594
+ amount: bn18(coin.amount),
4575
4595
  assetId: coin.assetId,
4576
4596
  owner: Address2.fromAddressOrString(coin.owner),
4577
- blockCreated: bn17(coin.blockCreated),
4578
- txCreatedIdx: bn17(coin.txCreatedIdx)
4597
+ blockCreated: bn18(coin.blockCreated),
4598
+ txCreatedIdx: bn18(coin.txCreatedIdx)
4579
4599
  };
4580
4600
  default:
4581
4601
  return null;
@@ -4592,13 +4612,13 @@ Supported fuel-core version: ${supportedVersion}.`
4592
4612
  async getBlock(idOrHeight) {
4593
4613
  let variables;
4594
4614
  if (typeof idOrHeight === "number") {
4595
- variables = { height: bn17(idOrHeight).toString(10) };
4615
+ variables = { height: bn18(idOrHeight).toString(10) };
4596
4616
  } else if (idOrHeight === "latest") {
4597
4617
  variables = { height: (await this.getBlockNumber()).toString(10) };
4598
4618
  } else if (idOrHeight.length === 66) {
4599
4619
  variables = { blockId: idOrHeight };
4600
4620
  } else {
4601
- variables = { blockId: bn17(idOrHeight).toString(10) };
4621
+ variables = { blockId: bn18(idOrHeight).toString(10) };
4602
4622
  }
4603
4623
  const { block } = await this.operations.getBlock(variables);
4604
4624
  if (!block) {
@@ -4606,7 +4626,7 @@ Supported fuel-core version: ${supportedVersion}.`
4606
4626
  }
4607
4627
  return {
4608
4628
  id: block.id,
4609
- height: bn17(block.height),
4629
+ height: bn18(block.height),
4610
4630
  time: block.header.time,
4611
4631
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4632
  };
@@ -4621,7 +4641,7 @@ Supported fuel-core version: ${supportedVersion}.`
4621
4641
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4622
4642
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4623
4643
  id: block.id,
4624
- height: bn17(block.height),
4644
+ height: bn18(block.height),
4625
4645
  time: block.header.time,
4626
4646
  transactionIds: block.transactions.map((tx) => tx.id)
4627
4647
  }));
@@ -4636,7 +4656,7 @@ Supported fuel-core version: ${supportedVersion}.`
4636
4656
  async getBlockWithTransactions(idOrHeight) {
4637
4657
  let variables;
4638
4658
  if (typeof idOrHeight === "number") {
4639
- variables = { blockHeight: bn17(idOrHeight).toString(10) };
4659
+ variables = { blockHeight: bn18(idOrHeight).toString(10) };
4640
4660
  } else if (idOrHeight === "latest") {
4641
4661
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4642
4662
  } else {
@@ -4648,7 +4668,7 @@ Supported fuel-core version: ${supportedVersion}.`
4648
4668
  }
4649
4669
  return {
4650
4670
  id: block.id,
4651
- height: bn17(block.height, 10),
4671
+ height: bn18(block.height, 10),
4652
4672
  time: block.header.time,
4653
4673
  transactionIds: block.transactions.map((tx) => tx.id),
4654
4674
  transactions: block.transactions.map(
@@ -4697,7 +4717,7 @@ Supported fuel-core version: ${supportedVersion}.`
4697
4717
  contract: Address2.fromAddressOrString(contractId).toB256(),
4698
4718
  asset: hexlify12(assetId)
4699
4719
  });
4700
- return bn17(contractBalance.amount, 10);
4720
+ return bn18(contractBalance.amount, 10);
4701
4721
  }
4702
4722
  /**
4703
4723
  * Returns the balance for the given owner for the given asset ID.
@@ -4711,7 +4731,7 @@ Supported fuel-core version: ${supportedVersion}.`
4711
4731
  owner: Address2.fromAddressOrString(owner).toB256(),
4712
4732
  assetId: hexlify12(assetId)
4713
4733
  });
4714
- return bn17(balance.amount, 10);
4734
+ return bn18(balance.amount, 10);
4715
4735
  }
4716
4736
  /**
4717
4737
  * Returns balances for the given owner.
@@ -4729,7 +4749,7 @@ Supported fuel-core version: ${supportedVersion}.`
4729
4749
  const balances = result.balances.edges.map((edge) => edge.node);
4730
4750
  return balances.map((balance) => ({
4731
4751
  assetId: balance.assetId,
4732
- amount: bn17(balance.amount)
4752
+ amount: bn18(balance.amount)
4733
4753
  }));
4734
4754
  }
4735
4755
  /**
@@ -4751,15 +4771,15 @@ Supported fuel-core version: ${supportedVersion}.`
4751
4771
  sender: message.sender,
4752
4772
  recipient: message.recipient,
4753
4773
  nonce: message.nonce,
4754
- amount: bn17(message.amount),
4774
+ amount: bn18(message.amount),
4755
4775
  data: message.data
4756
4776
  }),
4757
4777
  sender: Address2.fromAddressOrString(message.sender),
4758
4778
  recipient: Address2.fromAddressOrString(message.recipient),
4759
4779
  nonce: message.nonce,
4760
- amount: bn17(message.amount),
4780
+ amount: bn18(message.amount),
4761
4781
  data: InputMessageCoder.decodeData(message.data),
4762
- daHeight: bn17(message.daHeight)
4782
+ daHeight: bn18(message.daHeight)
4763
4783
  }));
4764
4784
  }
4765
4785
  /**
@@ -4812,19 +4832,19 @@ Supported fuel-core version: ${supportedVersion}.`
4812
4832
  } = result.messageProof;
4813
4833
  return {
4814
4834
  messageProof: {
4815
- proofIndex: bn17(messageProof.proofIndex),
4835
+ proofIndex: bn18(messageProof.proofIndex),
4816
4836
  proofSet: messageProof.proofSet
4817
4837
  },
4818
4838
  blockProof: {
4819
- proofIndex: bn17(blockProof.proofIndex),
4839
+ proofIndex: bn18(blockProof.proofIndex),
4820
4840
  proofSet: blockProof.proofSet
4821
4841
  },
4822
4842
  messageBlockHeader: {
4823
4843
  id: messageBlockHeader.id,
4824
- daHeight: bn17(messageBlockHeader.daHeight),
4844
+ daHeight: bn18(messageBlockHeader.daHeight),
4825
4845
  transactionsCount: Number(messageBlockHeader.transactionsCount),
4826
4846
  transactionsRoot: messageBlockHeader.transactionsRoot,
4827
- height: bn17(messageBlockHeader.height),
4847
+ height: bn18(messageBlockHeader.height),
4828
4848
  prevRoot: messageBlockHeader.prevRoot,
4829
4849
  time: messageBlockHeader.time,
4830
4850
  applicationHash: messageBlockHeader.applicationHash,
@@ -4836,10 +4856,10 @@ Supported fuel-core version: ${supportedVersion}.`
4836
4856
  },
4837
4857
  commitBlockHeader: {
4838
4858
  id: commitBlockHeader.id,
4839
- daHeight: bn17(commitBlockHeader.daHeight),
4859
+ daHeight: bn18(commitBlockHeader.daHeight),
4840
4860
  transactionsCount: Number(commitBlockHeader.transactionsCount),
4841
4861
  transactionsRoot: commitBlockHeader.transactionsRoot,
4842
- height: bn17(commitBlockHeader.height),
4862
+ height: bn18(commitBlockHeader.height),
4843
4863
  prevRoot: commitBlockHeader.prevRoot,
4844
4864
  time: commitBlockHeader.time,
4845
4865
  applicationHash: commitBlockHeader.applicationHash,
@@ -4852,19 +4872,19 @@ Supported fuel-core version: ${supportedVersion}.`
4852
4872
  sender: Address2.fromAddressOrString(sender),
4853
4873
  recipient: Address2.fromAddressOrString(recipient),
4854
4874
  nonce,
4855
- amount: bn17(amount),
4875
+ amount: bn18(amount),
4856
4876
  data
4857
4877
  };
4858
4878
  }
4859
4879
  async getLatestGasPrice() {
4860
4880
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4861
- return bn17(latestGasPrice.gasPrice);
4881
+ return bn18(latestGasPrice.gasPrice);
4862
4882
  }
4863
4883
  async estimateGasPrice(blockHorizon) {
4864
4884
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4865
4885
  blockHorizon: String(blockHorizon)
4866
4886
  });
4867
- return bn17(estimateGasPrice.gasPrice);
4887
+ return bn18(estimateGasPrice.gasPrice);
4868
4888
  }
4869
4889
  /**
4870
4890
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4885,10 +4905,10 @@ Supported fuel-core version: ${supportedVersion}.`
4885
4905
  */
4886
4906
  async produceBlocks(amount, startTime) {
4887
4907
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4888
- blocksToProduce: bn17(amount).toString(10),
4908
+ blocksToProduce: bn18(amount).toString(10),
4889
4909
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4890
4910
  });
4891
- return bn17(latestBlockHeight);
4911
+ return bn18(latestBlockHeight);
4892
4912
  }
4893
4913
  // eslint-disable-next-line @typescript-eslint/require-await
4894
4914
  async getTransactionResponse(transactionId) {
@@ -4934,7 +4954,7 @@ __publicField(Provider, "nodeInfoCache", {});
4934
4954
 
4935
4955
  // src/providers/transaction-summary/get-transaction-summary.ts
4936
4956
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4937
- import { bn as bn18 } from "@fuel-ts/math";
4957
+ import { bn as bn19 } from "@fuel-ts/math";
4938
4958
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4939
4959
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4940
4960
  async function getTransactionSummary(params) {
@@ -4971,8 +4991,8 @@ async function getTransactionSummary(params) {
4971
4991
  transaction: decodedTransaction,
4972
4992
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4973
4993
  gqlTransactionStatus: gqlTransaction.status,
4974
- gasPerByte: bn18(gasPerByte),
4975
- gasPriceFactor: bn18(gasPriceFactor),
4994
+ gasPerByte: bn19(gasPerByte),
4995
+ gasPriceFactor: bn19(gasPriceFactor),
4976
4996
  abiMap,
4977
4997
  maxInputs,
4978
4998
  gasCosts,
@@ -5381,9 +5401,9 @@ var Account = class extends AbstractAccount {
5381
5401
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
5382
5402
  const fee = request.maxFee;
5383
5403
  const baseAssetId = this.provider.getBaseAssetId();
5384
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
5404
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
5385
5405
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5386
- amount: bn19(fee),
5406
+ amount: bn20(fee),
5387
5407
  assetId: baseAssetId,
5388
5408
  coinQuantities: requiredQuantities
5389
5409
  });
@@ -5391,7 +5411,7 @@ var Account = class extends AbstractAccount {
5391
5411
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5392
5412
  quantitiesDict[assetId] = {
5393
5413
  required: amount,
5394
- owned: bn19(0)
5414
+ owned: bn20(0)
5395
5415
  };
5396
5416
  });
5397
5417
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -5418,6 +5438,7 @@ var Account = class extends AbstractAccount {
5418
5438
  cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5419
5439
  );
5420
5440
  request.addResources(resources);
5441
+ request.shiftPredicateData();
5421
5442
  request.updatePredicateGasUsed(estimatedPredicates);
5422
5443
  const requestToReestimate2 = clone4(request);
5423
5444
  if (addedSignatures) {
@@ -5449,6 +5470,7 @@ var Account = class extends AbstractAccount {
5449
5470
  }
5450
5471
  fundingAttempts += 1;
5451
5472
  }
5473
+ request.shiftPredicateData();
5452
5474
  request.updatePredicateGasUsed(estimatedPredicates);
5453
5475
  const requestToReestimate = clone4(request);
5454
5476
  if (addedSignatures) {
@@ -5499,7 +5521,7 @@ var Account = class extends AbstractAccount {
5499
5521
  * @returns A promise that resolves to the transaction response.
5500
5522
  */
5501
5523
  async transfer(destination, amount, assetId, txParams = {}) {
5502
- if (bn19(amount).lte(0)) {
5524
+ if (bn20(amount).lte(0)) {
5503
5525
  throw new FuelError15(
5504
5526
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5505
5527
  "Transfer amount must be a positive number."
@@ -5519,7 +5541,7 @@ var Account = class extends AbstractAccount {
5519
5541
  * @returns A promise that resolves to the transaction response.
5520
5542
  */
5521
5543
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5522
- if (bn19(amount).lte(0)) {
5544
+ if (bn20(amount).lte(0)) {
5523
5545
  throw new FuelError15(
5524
5546
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5525
5547
  "Transfer amount must be a positive number."
@@ -5529,7 +5551,7 @@ var Account = class extends AbstractAccount {
5529
5551
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5530
5552
  const { script, scriptData } = await assembleTransferToContractScript({
5531
5553
  hexlifiedContractId: contractAddress.toB256(),
5532
- amountToTransfer: bn19(amount),
5554
+ amountToTransfer: bn20(amount),
5533
5555
  assetId: assetIdToTransfer
5534
5556
  });
5535
5557
  let request = new ScriptTransactionRequest({
@@ -5540,7 +5562,7 @@ var Account = class extends AbstractAccount {
5540
5562
  request.addContractInputAndOutput(contractAddress);
5541
5563
  const txCost = await this.provider.getTransactionCost(request, {
5542
5564
  resourcesOwner: this,
5543
- quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
5565
+ quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
5544
5566
  });
5545
5567
  request = this.validateGasLimitAndMaxFee({
5546
5568
  transactionRequest: request,
@@ -5565,7 +5587,7 @@ var Account = class extends AbstractAccount {
5565
5587
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5566
5588
  );
5567
5589
  const amountDataArray = arrayify14(
5568
- "0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
5590
+ "0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
5569
5591
  );
5570
5592
  const script = new Uint8Array([
5571
5593
  ...arrayify14(withdrawScript.bytes),
@@ -5575,7 +5597,7 @@ var Account = class extends AbstractAccount {
5575
5597
  const params = { script, ...txParams };
5576
5598
  const baseAssetId = this.provider.getBaseAssetId();
5577
5599
  let request = new ScriptTransactionRequest(params);
5578
- const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
5600
+ const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
5579
5601
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5580
5602
  request = this.validateGasLimitAndMaxFee({
5581
5603
  transactionRequest: request,
@@ -5996,7 +6018,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5996
6018
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
5997
6019
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5998
6020
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5999
- import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
6021
+ import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
6000
6022
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
6001
6023
 
6002
6024
  // src/mnemonic/mnemonic.ts
@@ -8466,7 +8488,7 @@ var HDWallet = class {
8466
8488
  const IR = bytes.slice(32);
8467
8489
  if (privateKey) {
8468
8490
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8469
- const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
8491
+ const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
8470
8492
  return new HDWallet({
8471
8493
  privateKey: ki,
8472
8494
  chainCode: IR,
@@ -9145,9 +9167,16 @@ var StorageAbstract = class {
9145
9167
  };
9146
9168
 
9147
9169
  // src/predicate/predicate.ts
9148
- import { Interface as Interface4 } from "@fuel-ts/abi-coder";
9170
+ import {
9171
+ Interface as Interface4,
9172
+ INPUT_COIN_FIXED_SIZE,
9173
+ WORD_SIZE,
9174
+ calculateVmTxMemory as calculateVmTxMemory2,
9175
+ SCRIPT_FIXED_SIZE
9176
+ } from "@fuel-ts/abi-coder";
9149
9177
  import { Address as Address9 } from "@fuel-ts/address";
9150
9178
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
9179
+ import { ByteArrayCoder } from "@fuel-ts/transactions";
9151
9180
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
9152
9181
 
9153
9182
  // src/predicate/utils/getPredicateRoot.ts
@@ -9205,6 +9234,7 @@ var Predicate = class extends Account {
9205
9234
  */
9206
9235
  populateTransactionPredicateData(transactionRequestLike) {
9207
9236
  const request = transactionRequestify(transactionRequestLike);
9237
+ const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9208
9238
  const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
9209
9239
  if (placeholderIndex !== -1) {
9210
9240
  request.removeWitness(placeholderIndex);
@@ -9212,7 +9242,7 @@ var Predicate = class extends Account {
9212
9242
  request.inputs.filter(isRequestInputResource).forEach((input) => {
9213
9243
  if (isRequestInputResourceFromOwner(input, this.address)) {
9214
9244
  input.predicate = hexlify19(this.bytes);
9215
- input.predicateData = hexlify19(this.getPredicateData());
9245
+ input.predicateData = hexlify19(this.getPredicateData(policies.length));
9216
9246
  input.witnessIndex = 0;
9217
9247
  }
9218
9248
  });
@@ -9238,12 +9268,17 @@ var Predicate = class extends Account {
9238
9268
  const transactionRequest = transactionRequestify(transactionRequestLike);
9239
9269
  return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
9240
9270
  }
9241
- getPredicateData() {
9271
+ getPredicateData(policiesLength) {
9242
9272
  if (!this.predicateData.length) {
9243
9273
  return new Uint8Array();
9244
9274
  }
9245
9275
  const mainFn = this.interface?.functions.main;
9246
- return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
9276
+ const paddedCode = new ByteArrayCoder(this.bytes.length).encode(this.bytes);
9277
+ const VM_TX_MEMORY = calculateVmTxMemory2({
9278
+ maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9279
+ });
9280
+ const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
9281
+ return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
9247
9282
  }
9248
9283
  /**
9249
9284
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -9292,7 +9327,8 @@ var Predicate = class extends Account {
9292
9327
  );
9293
9328
  return resources.map((resource) => ({
9294
9329
  ...resource,
9295
- predicate: hexlify19(this.bytes)
9330
+ predicate: hexlify19(this.bytes),
9331
+ padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
9296
9332
  }));
9297
9333
  }
9298
9334
  /**