@fuel-ts/account 0.94.9 → 0.96.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.
@@ -28920,9 +28920,9 @@ spurious results.`);
28920
28920
  // ../versions/dist/index.mjs
28921
28921
  function getBuiltinVersions() {
28922
28922
  return {
28923
- FORC: "0.64.0",
28924
- FUEL_CORE: "0.37.0",
28925
- FUELS: "0.94.9"
28923
+ FORC: "0.65.2",
28924
+ FUEL_CORE: "0.38.0",
28925
+ FUELS: "0.96.0"
28926
28926
  };
28927
28927
  }
28928
28928
  function parseVersion(version) {
@@ -29106,21 +29106,6 @@ This unreleased fuel-core build may include features and updates not yet support
29106
29106
  var DEFAULT_PRECISION = 9;
29107
29107
  var DEFAULT_MIN_PRECISION = 3;
29108
29108
  var DEFAULT_DECIMAL_UNITS = 9;
29109
- function toFixed(value, options) {
29110
- const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
29111
- const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
29112
- const groupRegex = /(\d)(?=(\d{3})+\b)/g;
29113
- const units = valueUnits.replace(groupRegex, "$1,");
29114
- let decimals = valueDecimals.slice(0, precision);
29115
- if (minPrecision < precision) {
29116
- const trimmedDecimal = decimals.match(/.*[1-9]{1}/);
29117
- const lastNonZeroIndex = trimmedDecimal?.[0].length || 0;
29118
- const keepChars = Math.max(minPrecision, lastNonZeroIndex);
29119
- decimals = decimals.slice(0, keepChars);
29120
- }
29121
- const decimalPortion = decimals ? `.${decimals}` : "";
29122
- return `${units}${decimalPortion}`;
29123
- }
29124
29109
  var BN = class extends import_bn.default {
29125
29110
  MAX_U64 = "0xFFFFFFFFFFFFFFFF";
29126
29111
  constructor(value, base, endian) {
@@ -29172,28 +29157,53 @@ This unreleased fuel-core build may include features and updates not yet support
29172
29157
  format(options) {
29173
29158
  const {
29174
29159
  units = DEFAULT_DECIMAL_UNITS,
29175
- precision = DEFAULT_PRECISION,
29176
- minPrecision = DEFAULT_MIN_PRECISION
29160
+ precision: initialPrecision = DEFAULT_PRECISION,
29161
+ minPrecision: initialMinPrecision = DEFAULT_MIN_PRECISION
29177
29162
  } = options || {};
29163
+ if (units === 0) {
29164
+ return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
29165
+ }
29166
+ const minPrecision = initialMinPrecision > initialPrecision ? initialPrecision : initialMinPrecision;
29167
+ const precision = initialPrecision > initialMinPrecision ? initialPrecision : initialMinPrecision;
29178
29168
  const formattedUnits = this.formatUnits(units);
29179
- const formattedFixed = toFixed(formattedUnits, { precision, minPrecision });
29180
- if (!parseFloat(formattedFixed)) {
29181
- const [, originalDecimals = "0"] = formattedUnits.split(".");
29182
- const firstNonZero = originalDecimals.match(/[1-9]/);
29183
- if (firstNonZero && firstNonZero.index && firstNonZero.index + 1 > precision) {
29184
- const [valueUnits = "0"] = formattedFixed.split(".");
29185
- return `${valueUnits}.${originalDecimals.slice(0, firstNonZero.index + 1)}`;
29169
+ const [integerPart, fractionalPart = ""] = formattedUnits.split(".");
29170
+ const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
29171
+ if (precision === 0) {
29172
+ return formattedInteger;
29173
+ }
29174
+ let formattedFractional = fractionalPart.replace(/0+$/, "");
29175
+ if (formattedFractional.length > precision) {
29176
+ if (integerPart === "0") {
29177
+ const firstNonZeroIndex = formattedFractional.search(/[1-9]/);
29178
+ if (firstNonZeroIndex >= 0 && firstNonZeroIndex < precision) {
29179
+ formattedFractional = formattedFractional.slice(0, precision);
29180
+ } else {
29181
+ formattedFractional = formattedFractional.slice(0, firstNonZeroIndex + 1);
29182
+ }
29183
+ } else {
29184
+ formattedFractional = formattedFractional.slice(0, precision);
29186
29185
  }
29186
+ } else {
29187
+ formattedFractional = formattedFractional.slice(0, precision);
29188
+ }
29189
+ if (formattedFractional.length < minPrecision) {
29190
+ formattedFractional = formattedFractional.padEnd(minPrecision, "0");
29187
29191
  }
29188
- return formattedFixed;
29192
+ if (formattedFractional === "" && minPrecision === 0) {
29193
+ return formattedInteger;
29194
+ }
29195
+ return formattedFractional ? `${formattedInteger}.${formattedFractional}` : formattedInteger;
29189
29196
  }
29190
29197
  formatUnits(units = DEFAULT_DECIMAL_UNITS) {
29191
- const valueUnits = this.toString().slice(0, units * -1);
29192
- const valueDecimals = this.toString().slice(units * -1);
29193
- const length = valueDecimals.length;
29194
- const defaultDecimals = Array.from({ length: units - length }).fill("0").join("");
29195
- const integerPortion = valueUnits ? `${valueUnits}.` : "0.";
29196
- return `${integerPortion}${defaultDecimals}${valueDecimals}`;
29198
+ const valueString = this.toString();
29199
+ const valueLength = valueString.length;
29200
+ if (valueLength <= units) {
29201
+ const paddedZeros = "0".repeat(units - valueLength);
29202
+ return `0.${paddedZeros}${valueString}`;
29203
+ }
29204
+ const integerPart = valueString.slice(0, valueLength - units);
29205
+ const fractionalPart = valueString.slice(valueLength - units);
29206
+ return `${integerPart}.${fractionalPart}`;
29197
29207
  }
29198
29208
  // END ANCHOR: HELPERS
29199
29209
  // ANCHOR: OVERRIDES to accept better inputs
@@ -32038,6 +32048,15 @@ If you are attempting to transform a hex value, please make sure it is being pas
32038
32048
  );
32039
32049
  }
32040
32050
  }
32051
+ /**
32052
+ * Takes an B256 Address and returns back an checksum address.
32053
+ * The implementation follows the ERC-55 https://github.com/ethereum/ercs/blob/master/ERCS/erc-55.md.
32054
+ *
32055
+ * @returns A new `ChecksumAddress` instance
32056
+ */
32057
+ toChecksum() {
32058
+ return Address.toChecksum(this.toB256());
32059
+ }
32041
32060
  /**
32042
32061
  * Returns the `bech32Address` property
32043
32062
  *
@@ -32071,12 +32090,12 @@ If you are attempting to transform a hex value, please make sure it is being pas
32071
32090
  return this.toB256();
32072
32091
  }
32073
32092
  /**
32074
- * Converts and returns the `bech32Address` property as a string
32093
+ * returns the address `checksum` as a string
32075
32094
  *
32076
32095
  * @returns The `bech32Address` property as a string
32077
32096
  */
32078
32097
  toString() {
32079
- return this.bech32Address;
32098
+ return this.toChecksum();
32080
32099
  }
32081
32100
  /**
32082
32101
  * Converts and returns the `bech32Address` property as a string
@@ -32108,12 +32127,12 @@ If you are attempting to transform a hex value, please make sure it is being pas
32108
32127
  };
32109
32128
  }
32110
32129
  /**
32111
- * Returns the value of the `bech32Address` property
32130
+ * returns the address `checksum` as a string
32112
32131
  *
32113
32132
  * @returns The value of `bech32Address` property
32114
32133
  */
32115
32134
  valueOf() {
32116
- return this.bech32Address;
32135
+ return this.toChecksum();
32117
32136
  }
32118
32137
  /**
32119
32138
  * Compares this the `bech32Address` property to another for direct equality
@@ -32220,6 +32239,38 @@ If you are attempting to transform a hex value, please make sure it is being pas
32220
32239
  const paddedAddress = padFirst12BytesOfEvmAddress(evmAddress);
32221
32240
  return new Address(toBech32(paddedAddress));
32222
32241
  }
32242
+ /**
32243
+ * Takes an ChecksumAddress and validates if it is a valid checksum address.
32244
+ *
32245
+ * @returns A `boolean` instance indicating if the address is valid.
32246
+ */
32247
+ static isChecksumValid(address) {
32248
+ let addressParsed = address;
32249
+ if (!address.startsWith("0x")) {
32250
+ addressParsed = `0x${address}`;
32251
+ }
32252
+ if (addressParsed.trim().length !== 66) {
32253
+ return false;
32254
+ }
32255
+ return Address.toChecksum(hexlify(addressParsed)) === addressParsed;
32256
+ }
32257
+ /** @hidden */
32258
+ static toChecksum(address) {
32259
+ if (!isB256(address)) {
32260
+ throw new Error("Invalid B256 Address");
32261
+ }
32262
+ const addressHex = hexlify(address).toLowerCase().slice(2);
32263
+ const checksum = sha256(addressHex);
32264
+ let ret2 = "0x";
32265
+ for (let i = 0; i < 32; ++i) {
32266
+ const byte = checksum[i];
32267
+ const ha = addressHex.charAt(i * 2);
32268
+ const hb = addressHex.charAt(i * 2 + 1);
32269
+ ret2 += (byte & 240) >= 128 ? ha.toUpperCase() : ha;
32270
+ ret2 += (byte & 15) >= 8 ? hb.toUpperCase() : hb;
32271
+ }
32272
+ return ret2;
32273
+ }
32223
32274
  };
32224
32275
 
32225
32276
  // ../transactions/dist/index.mjs
@@ -37289,6 +37340,26 @@ ${DryRunSuccessStatusFragmentDoc}`;
37289
37340
  }
37290
37341
  ${DryRunTransactionStatusFragmentDoc}
37291
37342
  ${ReceiptFragmentDoc}`;
37343
+ var BlockFragmentDoc = lib_default2`
37344
+ fragment blockFragment on Block {
37345
+ id
37346
+ height
37347
+ header {
37348
+ time
37349
+ daHeight
37350
+ stateTransitionBytecodeVersion
37351
+ transactionsCount
37352
+ transactionsRoot
37353
+ messageOutboxRoot
37354
+ eventInboxRoot
37355
+ prevRoot
37356
+ applicationHash
37357
+ }
37358
+ transactions {
37359
+ id
37360
+ }
37361
+ }
37362
+ `;
37292
37363
  var CoinFragmentDoc = lib_default2`
37293
37364
  fragment coinFragment on Coin {
37294
37365
  type: __typename
@@ -37368,33 +37439,6 @@ ${ReceiptFragmentDoc}`;
37368
37439
  nonce
37369
37440
  amount
37370
37441
  data
37371
- }
37372
- `;
37373
- var BalanceFragmentDoc = lib_default2`
37374
- fragment balanceFragment on Balance {
37375
- owner
37376
- amount
37377
- assetId
37378
- }
37379
- `;
37380
- var BlockFragmentDoc = lib_default2`
37381
- fragment blockFragment on Block {
37382
- id
37383
- height
37384
- header {
37385
- time
37386
- daHeight
37387
- stateTransitionBytecodeVersion
37388
- transactionsCount
37389
- transactionsRoot
37390
- messageOutboxRoot
37391
- eventInboxRoot
37392
- prevRoot
37393
- applicationHash
37394
- }
37395
- transactions {
37396
- id
37397
- }
37398
37442
  }
37399
37443
  `;
37400
37444
  var TxParametersFragmentDoc = lib_default2`
@@ -37454,167 +37498,6 @@ ${ReceiptFragmentDoc}`;
37454
37498
  `;
37455
37499
  var GasCostsFragmentDoc = lib_default2`
37456
37500
  fragment GasCostsFragment on GasCosts {
37457
- version
37458
- add
37459
- addi
37460
- aloc
37461
- and
37462
- andi
37463
- bal
37464
- bhei
37465
- bhsh
37466
- burn
37467
- cb
37468
- cfei
37469
- cfsi
37470
- div
37471
- divi
37472
- ecr1
37473
- eck1
37474
- ed19
37475
- eq
37476
- exp
37477
- expi
37478
- flag
37479
- gm
37480
- gt
37481
- gtf
37482
- ji
37483
- jmp
37484
- jne
37485
- jnei
37486
- jnzi
37487
- jmpf
37488
- jmpb
37489
- jnzf
37490
- jnzb
37491
- jnef
37492
- jneb
37493
- lb
37494
- log
37495
- lt
37496
- lw
37497
- mint
37498
- mlog
37499
- modOp
37500
- modi
37501
- moveOp
37502
- movi
37503
- mroo
37504
- mul
37505
- muli
37506
- mldv
37507
- noop
37508
- not
37509
- or
37510
- ori
37511
- poph
37512
- popl
37513
- pshh
37514
- pshl
37515
- ret
37516
- rvrt
37517
- sb
37518
- sll
37519
- slli
37520
- srl
37521
- srli
37522
- srw
37523
- sub
37524
- subi
37525
- sw
37526
- sww
37527
- time
37528
- tr
37529
- tro
37530
- wdcm
37531
- wqcm
37532
- wdop
37533
- wqop
37534
- wdml
37535
- wqml
37536
- wddv
37537
- wqdv
37538
- wdmd
37539
- wqmd
37540
- wdam
37541
- wqam
37542
- wdmm
37543
- wqmm
37544
- xor
37545
- xori
37546
- alocDependentCost {
37547
- ...DependentCostFragment
37548
- }
37549
- bldd {
37550
- ...DependentCostFragment
37551
- }
37552
- bsiz {
37553
- ...DependentCostFragment
37554
- }
37555
- cfe {
37556
- ...DependentCostFragment
37557
- }
37558
- cfeiDependentCost {
37559
- ...DependentCostFragment
37560
- }
37561
- call {
37562
- ...DependentCostFragment
37563
- }
37564
- ccp {
37565
- ...DependentCostFragment
37566
- }
37567
- croo {
37568
- ...DependentCostFragment
37569
- }
37570
- csiz {
37571
- ...DependentCostFragment
37572
- }
37573
- ed19DependentCost {
37574
- ...DependentCostFragment
37575
- }
37576
- k256 {
37577
- ...DependentCostFragment
37578
- }
37579
- ldc {
37580
- ...DependentCostFragment
37581
- }
37582
- logd {
37583
- ...DependentCostFragment
37584
- }
37585
- mcl {
37586
- ...DependentCostFragment
37587
- }
37588
- mcli {
37589
- ...DependentCostFragment
37590
- }
37591
- mcp {
37592
- ...DependentCostFragment
37593
- }
37594
- mcpi {
37595
- ...DependentCostFragment
37596
- }
37597
- meq {
37598
- ...DependentCostFragment
37599
- }
37600
- retd {
37601
- ...DependentCostFragment
37602
- }
37603
- s256 {
37604
- ...DependentCostFragment
37605
- }
37606
- scwq {
37607
- ...DependentCostFragment
37608
- }
37609
- smo {
37610
- ...DependentCostFragment
37611
- }
37612
- srwq {
37613
- ...DependentCostFragment
37614
- }
37615
- swwq {
37616
- ...DependentCostFragment
37617
- }
37618
37501
  contractRoot {
37619
37502
  ...DependentCostFragment
37620
37503
  }
@@ -37624,6 +37507,10 @@ ${ReceiptFragmentDoc}`;
37624
37507
  vmInitialization {
37625
37508
  ...DependentCostFragment
37626
37509
  }
37510
+ s256 {
37511
+ ...DependentCostFragment
37512
+ }
37513
+ ecr1
37627
37514
  newStoragePerByte
37628
37515
  }
37629
37516
  ${DependentCostFragmentDoc}`;
@@ -37660,16 +37547,12 @@ ${GasCostsFragmentDoc}`;
37660
37547
  var ChainInfoFragmentDoc = lib_default2`
37661
37548
  fragment chainInfoFragment on ChainInfo {
37662
37549
  name
37663
- latestBlock {
37664
- ...blockFragment
37665
- }
37666
37550
  daHeight
37667
37551
  consensusParameters {
37668
37552
  ...consensusParametersFragment
37669
37553
  }
37670
37554
  }
37671
- ${BlockFragmentDoc}
37672
- ${ConsensusParametersFragmentDoc}`;
37555
+ ${ConsensusParametersFragmentDoc}`;
37673
37556
  var ContractBalanceFragmentDoc = lib_default2`
37674
37557
  fragment contractBalanceFragment on ContractBalance {
37675
37558
  contract
@@ -37700,6 +37583,12 @@ ${ConsensusParametersFragmentDoc}`;
37700
37583
  blockHeight
37701
37584
  failure
37702
37585
  }
37586
+ }
37587
+ `;
37588
+ var TransactionRawPayloadFragmentDoc = lib_default2`
37589
+ fragment transactionRawPayload on Transaction {
37590
+ id
37591
+ rawPayload
37703
37592
  }
37704
37593
  `;
37705
37594
  var GetVersionDocument = lib_default2`
@@ -37723,6 +37612,17 @@ ${ConsensusParametersFragmentDoc}`;
37723
37612
  }
37724
37613
  }
37725
37614
  ${ChainInfoFragmentDoc}`;
37615
+ var GetChainAndNodeInfoDocument = lib_default2`
37616
+ query getChainAndNodeInfo {
37617
+ chain {
37618
+ ...chainInfoFragment
37619
+ }
37620
+ nodeInfo {
37621
+ ...nodeInfoFragment
37622
+ }
37623
+ }
37624
+ ${ChainInfoFragmentDoc}
37625
+ ${NodeInfoFragmentDoc}`;
37726
37626
  var GetTransactionDocument = lib_default2`
37727
37627
  query getTransaction($transactionId: TransactionId!) {
37728
37628
  transaction(id: $transactionId) {
@@ -37780,6 +37680,24 @@ ${TransactionFragmentDoc}`;
37780
37680
  }
37781
37681
  }
37782
37682
  ${TransactionEstimatePredicatesFragmentDoc}`;
37683
+ var GetLatestBlockDocument = lib_default2`
37684
+ query getLatestBlock {
37685
+ chain {
37686
+ latestBlock {
37687
+ ...blockFragment
37688
+ }
37689
+ }
37690
+ }
37691
+ ${BlockFragmentDoc}`;
37692
+ var GetLatestBlockHeightDocument = lib_default2`
37693
+ query getLatestBlockHeight {
37694
+ chain {
37695
+ latestBlock {
37696
+ height
37697
+ }
37698
+ }
37699
+ }
37700
+ `;
37783
37701
  var GetBlockDocument = lib_default2`
37784
37702
  query getBlock($blockId: BlockId, $height: U32) {
37785
37703
  block(id: $blockId, height: $height) {
@@ -37792,12 +37710,12 @@ ${TransactionFragmentDoc}`;
37792
37710
  block(id: $blockId, height: $blockHeight) {
37793
37711
  ...blockFragment
37794
37712
  transactions {
37795
- ...transactionFragment
37713
+ ...transactionRawPayload
37796
37714
  }
37797
37715
  }
37798
37716
  }
37799
37717
  ${BlockFragmentDoc}
37800
- ${TransactionFragmentDoc}`;
37718
+ ${TransactionRawPayloadFragmentDoc}`;
37801
37719
  var GetBlocksDocument = lib_default2`
37802
37720
  query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
37803
37721
  blocks(after: $after, before: $before, first: $first, last: $last) {
@@ -37872,10 +37790,10 @@ ${MessageCoinFragmentDoc}`;
37872
37790
  var GetBalanceDocument = lib_default2`
37873
37791
  query getBalance($owner: Address!, $assetId: AssetId!) {
37874
37792
  balance(owner: $owner, assetId: $assetId) {
37875
- ...balanceFragment
37793
+ amount
37876
37794
  }
37877
37795
  }
37878
- ${BalanceFragmentDoc}`;
37796
+ `;
37879
37797
  var GetLatestGasPriceDocument = lib_default2`
37880
37798
  query getLatestGasPrice {
37881
37799
  latestGasPrice {
@@ -37904,13 +37822,13 @@ ${MessageCoinFragmentDoc}`;
37904
37822
  }
37905
37823
  edges {
37906
37824
  node {
37907
- ...balanceFragment
37825
+ assetId
37826
+ amount
37908
37827
  }
37909
37828
  }
37910
37829
  }
37911
37830
  }
37912
- ${PageInfoFragmentDoc}
37913
- ${BalanceFragmentDoc}`;
37831
+ ${PageInfoFragmentDoc}`;
37914
37832
  var GetMessagesDocument = lib_default2`
37915
37833
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
37916
37834
  messages(
@@ -37991,6 +37909,19 @@ ${MessageFragmentDoc}`;
37991
37909
  }
37992
37910
  }
37993
37911
  ${MessageFragmentDoc}`;
37912
+ var IsUserAccountDocument = lib_default2`
37913
+ query isUserAccount($blobId: BlobId!, $contractId: ContractId!, $transactionId: TransactionId!) {
37914
+ blob(id: $blobId) {
37915
+ id
37916
+ }
37917
+ contract(id: $contractId) {
37918
+ id
37919
+ }
37920
+ transaction(id: $transactionId) {
37921
+ id
37922
+ }
37923
+ }
37924
+ `;
37994
37925
  var SubmitAndAwaitDocument = lib_default2`
37995
37926
  subscription submitAndAwait($encodedTransaction: HexString!) {
37996
37927
  submitAndAwait(tx: $encodedTransaction) {
@@ -38023,6 +37954,9 @@ ${MessageFragmentDoc}`;
38023
37954
  getChain(variables, options) {
38024
37955
  return requester(GetChainDocument, variables, options);
38025
37956
  },
37957
+ getChainAndNodeInfo(variables, options) {
37958
+ return requester(GetChainAndNodeInfoDocument, variables, options);
37959
+ },
38026
37960
  getTransaction(variables, options) {
38027
37961
  return requester(GetTransactionDocument, variables, options);
38028
37962
  },
@@ -38038,6 +37972,12 @@ ${MessageFragmentDoc}`;
38038
37972
  estimatePredicates(variables, options) {
38039
37973
  return requester(EstimatePredicatesDocument, variables, options);
38040
37974
  },
37975
+ getLatestBlock(variables, options) {
37976
+ return requester(GetLatestBlockDocument, variables, options);
37977
+ },
37978
+ getLatestBlockHeight(variables, options) {
37979
+ return requester(GetLatestBlockHeightDocument, variables, options);
37980
+ },
38041
37981
  getBlock(variables, options) {
38042
37982
  return requester(GetBlockDocument, variables, options);
38043
37983
  },
@@ -38098,6 +38038,9 @@ ${MessageFragmentDoc}`;
38098
38038
  getMessageByNonce(variables, options) {
38099
38039
  return requester(GetMessageByNonceDocument, variables, options);
38100
38040
  },
38041
+ isUserAccount(variables, options) {
38042
+ return requester(IsUserAccountDocument, variables, options);
38043
+ },
38101
38044
  submitAndAwait(variables, options) {
38102
38045
  return requester(SubmitAndAwaitDocument, variables, options);
38103
38046
  },
@@ -41385,10 +41328,11 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41385
41328
  // src/providers/provider.ts
41386
41329
  var MAX_RETRIES = 10;
41387
41330
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
41331
+ var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
41388
41332
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
41389
41333
  var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
41390
41334
  var processGqlChain = (chain) => {
41391
- const { name, daHeight, consensusParameters, latestBlock } = chain;
41335
+ const { name, daHeight, consensusParameters } = chain;
41392
41336
  const {
41393
41337
  contractParams,
41394
41338
  feeParams,
@@ -41439,14 +41383,6 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41439
41383
  maxScriptDataLength: bn(scriptParams.maxScriptDataLength)
41440
41384
  },
41441
41385
  gasCosts
41442
- },
41443
- latestBlock: {
41444
- id: latestBlock.id,
41445
- height: bn(latestBlock.height),
41446
- time: latestBlock.header.time,
41447
- transactions: latestBlock.transactions.map((i) => ({
41448
- id: i.id
41449
- }))
41450
41386
  }
41451
41387
  };
41452
41388
  };
@@ -41477,14 +41413,17 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41477
41413
  retryOptions: void 0,
41478
41414
  headers: void 0
41479
41415
  });
41480
- const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
41416
+ const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
41481
41417
  this.url = rawUrl;
41482
41418
  this.urlWithoutAuth = urlWithoutAuth;
41483
- this.options = { ...this.options, ...options };
41484
41419
  this.url = url;
41485
- if (headers) {
41486
- this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
41487
- }
41420
+ const { FUELS } = versions;
41421
+ const headers = { ...authHeaders, ...options.headers, Source: `ts-sdk-${FUELS}` };
41422
+ this.options = {
41423
+ ...this.options,
41424
+ ...options,
41425
+ headers
41426
+ };
41488
41427
  this.operations = this.createOperations();
41489
41428
  const { resourceCacheTTL } = this.options;
41490
41429
  if (isDefined(resourceCacheTTL)) {
@@ -41623,9 +41562,25 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41623
41562
  * @returns A promise that resolves to the Chain and NodeInfo.
41624
41563
  */
41625
41564
  async fetchChainAndNodeInfo() {
41626
- const nodeInfo = await this.fetchNode();
41627
- _Provider.ensureClientVersionIsSupported(nodeInfo);
41628
- const chain = await this.fetchChain();
41565
+ let nodeInfo;
41566
+ let chain;
41567
+ try {
41568
+ nodeInfo = this.getNode();
41569
+ chain = this.getChain();
41570
+ } catch (error) {
41571
+ const data = await this.operations.getChainAndNodeInfo();
41572
+ nodeInfo = {
41573
+ maxDepth: bn(data.nodeInfo.maxDepth),
41574
+ maxTx: bn(data.nodeInfo.maxTx),
41575
+ nodeVersion: data.nodeInfo.nodeVersion,
41576
+ utxoValidation: data.nodeInfo.utxoValidation,
41577
+ vmBacktrace: data.nodeInfo.vmBacktrace
41578
+ };
41579
+ _Provider.ensureClientVersionIsSupported(nodeInfo);
41580
+ chain = processGqlChain(data.chain);
41581
+ _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
41582
+ _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
41583
+ }
41629
41584
  return {
41630
41585
  chain,
41631
41586
  nodeInfo
@@ -41717,8 +41672,12 @@ Supported fuel-core version: ${supportedVersion}.`
41717
41672
  * @returns A promise that resolves to the latest block number.
41718
41673
  */
41719
41674
  async getBlockNumber() {
41720
- const { chain } = await this.operations.getChain();
41721
- return bn(chain.latestBlock.height, 10);
41675
+ const {
41676
+ chain: {
41677
+ latestBlock: { height }
41678
+ }
41679
+ } = await this.operations.getLatestBlockHeight();
41680
+ return bn(height);
41722
41681
  }
41723
41682
  /**
41724
41683
  * Returns the node information for the current provider network.
@@ -42265,17 +42224,18 @@ Supported fuel-core version: ${supportedVersion}.`
42265
42224
  * @returns A promise that resolves to the block or null.
42266
42225
  */
42267
42226
  async getBlock(idOrHeight) {
42268
- let variables;
42269
- if (typeof idOrHeight === "number") {
42270
- variables = { height: bn(idOrHeight).toString(10) };
42271
- } else if (idOrHeight === "latest") {
42272
- variables = { height: (await this.getBlockNumber()).toString(10) };
42273
- } else if (idOrHeight.length === 66) {
42274
- variables = { blockId: idOrHeight };
42227
+ let block2;
42228
+ if (idOrHeight === "latest") {
42229
+ const {
42230
+ chain: { latestBlock }
42231
+ } = await this.operations.getLatestBlock();
42232
+ block2 = latestBlock;
42275
42233
  } else {
42276
- variables = { blockId: bn(idOrHeight).toString(10) };
42234
+ const isblockId = typeof idOrHeight === "string" && idOrHeight.length === 66;
42235
+ const variables = isblockId ? { blockId: idOrHeight } : { height: bn(idOrHeight).toString(10) };
42236
+ const response = await this.operations.getBlock(variables);
42237
+ block2 = response.block;
42277
42238
  }
42278
- const { block: block2 } = await this.operations.getBlock(variables);
42279
42239
  if (!block2) {
42280
42240
  return null;
42281
42241
  }
@@ -42401,7 +42361,12 @@ Supported fuel-core version: ${supportedVersion}.`
42401
42361
  async getTransactions(paginationArgs) {
42402
42362
  const {
42403
42363
  transactions: { edges, pageInfo }
42404
- } = await this.operations.getTransactions(paginationArgs);
42364
+ } = await this.operations.getTransactions({
42365
+ ...this.validatePaginationArgs({
42366
+ inputArgs: paginationArgs,
42367
+ paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
42368
+ })
42369
+ });
42405
42370
  const coder = new TransactionCoder();
42406
42371
  const transactions = edges.map(({ node: { rawPayload } }) => {
42407
42372
  try {
@@ -42657,6 +42622,40 @@ Supported fuel-core version: ${supportedVersion}.`
42657
42622
  });
42658
42623
  return bn(latestBlockHeight);
42659
42624
  }
42625
+ /**
42626
+ * Check if the given ID is an account.
42627
+ *
42628
+ * @param id - The ID to check.
42629
+ * @returns A promise that resolves to the result of the check.
42630
+ */
42631
+ async isUserAccount(id) {
42632
+ const { contract, blob, transaction } = await this.operations.isUserAccount({
42633
+ blobId: id,
42634
+ contractId: id,
42635
+ transactionId: id
42636
+ });
42637
+ if (contract || blob || transaction) {
42638
+ return false;
42639
+ }
42640
+ return true;
42641
+ }
42642
+ async getAddressType(id) {
42643
+ const { contract, blob, transaction } = await this.operations.isUserAccount({
42644
+ blobId: id,
42645
+ contractId: id,
42646
+ transactionId: id
42647
+ });
42648
+ if (contract) {
42649
+ return "Contract";
42650
+ }
42651
+ if (blob) {
42652
+ return "Blob";
42653
+ }
42654
+ if (transaction) {
42655
+ return "Transaction";
42656
+ }
42657
+ return "Account";
42658
+ }
42660
42659
  /**
42661
42660
  * Get the transaction response for the given transaction ID.
42662
42661
  *