@fuel-ts/account 0.94.5 → 0.94.7
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/configs.d.ts +6 -0
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +4 -4
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +7 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/local-storage.d.ts +0 -1
- package/dist/connectors/types/local-storage.d.ts.map +1 -1
- package/dist/index.global.js +2008 -1286
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1264 -413
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1137 -290
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +1 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/assets.d.ts +1 -1
- package/dist/providers/assets/assets.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
- package/dist/providers/chains.d.ts +2 -0
- package/dist/providers/chains.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +0 -2
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +8 -3
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +2 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +8 -2
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +87 -0
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts +82 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/utils.d.ts +6 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/output.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +16 -0
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts.map +1 -1
- package/dist/test-utils.global.js +2001 -1282
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1174 -340
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1059 -222
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +0 -1
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +25 -24
package/dist/test-utils.mjs
CHANGED
@@ -376,15 +376,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
376
376
|
|
377
377
|
// src/providers/provider.ts
|
378
378
|
import { Address as Address3 } from "@fuel-ts/address";
|
379
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
379
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
|
380
380
|
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
381
381
|
import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
382
|
-
import { arrayify as
|
382
|
+
import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
383
383
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
384
384
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
385
385
|
import { GraphQLClient } from "graphql-request";
|
386
386
|
import gql2 from "graphql-tag";
|
387
|
-
import { clone as
|
387
|
+
import { clone as clone8 } from "ramda";
|
388
388
|
|
389
389
|
// src/providers/__generated__/operations.ts
|
390
390
|
import gql from "graphql-tag";
|
@@ -1796,6 +1796,7 @@ function assembleReceiptByType(receipt) {
|
|
1796
1796
|
len: bn4(receipt.len),
|
1797
1797
|
digest: hexOrZero(receipt.digest),
|
1798
1798
|
pc: bn4(receipt.pc),
|
1799
|
+
data: hexOrZero(receipt.data),
|
1799
1800
|
is: bn4(receipt.is)
|
1800
1801
|
};
|
1801
1802
|
return returnDataReceipt;
|
@@ -1844,6 +1845,7 @@ function assembleReceiptByType(receipt) {
|
|
1844
1845
|
len: bn4(receipt.len),
|
1845
1846
|
digest: hexOrZero(receipt.digest),
|
1846
1847
|
pc: bn4(receipt.pc),
|
1848
|
+
data: hexOrZero(receipt.data),
|
1847
1849
|
is: bn4(receipt.is)
|
1848
1850
|
};
|
1849
1851
|
return logDataReceipt;
|
@@ -1887,6 +1889,7 @@ function assembleReceiptByType(receipt) {
|
|
1887
1889
|
const amount = bn4(receipt.amount);
|
1888
1890
|
const data = receipt.data ? arrayify3(receipt.data) : Uint8Array.from([]);
|
1889
1891
|
const digest = hexOrZero(receipt.digest);
|
1892
|
+
const len = bn4(receipt.len).toNumber();
|
1890
1893
|
const messageId = InputMessageCoder.getMessageId({
|
1891
1894
|
sender,
|
1892
1895
|
recipient,
|
@@ -1900,6 +1903,7 @@ function assembleReceiptByType(receipt) {
|
|
1900
1903
|
recipient,
|
1901
1904
|
amount,
|
1902
1905
|
nonce,
|
1906
|
+
len,
|
1903
1907
|
data,
|
1904
1908
|
digest,
|
1905
1909
|
messageId
|
@@ -2044,6 +2048,39 @@ function calculateMetadataGasForTxBlob({
|
|
2044
2048
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2045
2049
|
return txId.add(blobLen);
|
2046
2050
|
}
|
2051
|
+
function calculateMetadataGasForTxUpgrade({
|
2052
|
+
gasCosts,
|
2053
|
+
txBytesSize,
|
2054
|
+
consensusSize
|
2055
|
+
}) {
|
2056
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2057
|
+
if (consensusSize) {
|
2058
|
+
const consensusLen = resolveGasDependentCosts(consensusSize, gasCosts.s256);
|
2059
|
+
txId.add(consensusLen);
|
2060
|
+
}
|
2061
|
+
return txId;
|
2062
|
+
}
|
2063
|
+
function calculateMetadataGasForTxUpload({
|
2064
|
+
gasCosts,
|
2065
|
+
txBytesSize,
|
2066
|
+
subsectionSize,
|
2067
|
+
subsectionsSize
|
2068
|
+
}) {
|
2069
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2070
|
+
const subsectionLen = resolveGasDependentCosts(subsectionSize, gasCosts.s256);
|
2071
|
+
txId.add(subsectionLen);
|
2072
|
+
const subsectionsLen = resolveGasDependentCosts(subsectionsSize, gasCosts.stateRoot);
|
2073
|
+
txId.add(subsectionsLen);
|
2074
|
+
return txId;
|
2075
|
+
}
|
2076
|
+
function calculateMinGasForTxUpload({
|
2077
|
+
gasCosts,
|
2078
|
+
baseMinGas,
|
2079
|
+
subsectionSize
|
2080
|
+
}) {
|
2081
|
+
const additionalStoragePerByte = bn5(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2082
|
+
return bn5(baseMinGas).add(additionalStoragePerByte);
|
2083
|
+
}
|
2047
2084
|
var calculateGasFee = (params) => {
|
2048
2085
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2049
2086
|
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
@@ -3194,50 +3231,316 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3194
3231
|
}
|
3195
3232
|
};
|
3196
3233
|
|
3234
|
+
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3235
|
+
import { FuelError as FuelError10 } from "@fuel-ts/errors";
|
3236
|
+
import { hash as hash2 } from "@fuel-ts/hasher";
|
3237
|
+
import {
|
3238
|
+
TransactionType as TransactionType5,
|
3239
|
+
UpgradePurposeTypeEnum
|
3240
|
+
} from "@fuel-ts/transactions";
|
3241
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
3242
|
+
import { clone as clone6 } from "ramda";
|
3243
|
+
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3244
|
+
static from(obj) {
|
3245
|
+
if (obj instanceof UpgradeTransactionRequest) {
|
3246
|
+
return obj;
|
3247
|
+
}
|
3248
|
+
return new this(clone6(obj));
|
3249
|
+
}
|
3250
|
+
/** The type of transaction */
|
3251
|
+
type = TransactionType5.Upgrade;
|
3252
|
+
/** The upgrade purpose */
|
3253
|
+
upgradePurpose;
|
3254
|
+
/** Witness index of consensus */
|
3255
|
+
bytecodeWitnessIndex;
|
3256
|
+
/**
|
3257
|
+
* Creates an instance `UpgradeTransactionRequest`.
|
3258
|
+
*
|
3259
|
+
* @param upgradeTransactionRequestLike - The initial values for the instance
|
3260
|
+
*/
|
3261
|
+
constructor({
|
3262
|
+
upgradePurpose,
|
3263
|
+
bytecodeWitnessIndex,
|
3264
|
+
...rest
|
3265
|
+
} = {}) {
|
3266
|
+
super(rest);
|
3267
|
+
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
3268
|
+
this.upgradePurpose = upgradePurpose ?? {
|
3269
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3270
|
+
checksum: "0x"
|
3271
|
+
};
|
3272
|
+
}
|
3273
|
+
/**
|
3274
|
+
* Adds a consensus parameters upgrade purpose.
|
3275
|
+
*
|
3276
|
+
* @param consensus - The consensus bytecode.
|
3277
|
+
*
|
3278
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3279
|
+
*/
|
3280
|
+
addConsensusParametersUpgradePurpose(consensus) {
|
3281
|
+
this.bytecodeWitnessIndex = this.addWitness(consensus);
|
3282
|
+
this.upgradePurpose = {
|
3283
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3284
|
+
checksum: hash2(consensus)
|
3285
|
+
};
|
3286
|
+
return this;
|
3287
|
+
}
|
3288
|
+
/**
|
3289
|
+
* Adds a state transition upgrade purpose.
|
3290
|
+
*
|
3291
|
+
* @param bytecodeRoot - The Merkle root of the state transition.
|
3292
|
+
*
|
3293
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3294
|
+
*/
|
3295
|
+
addStateTransitionUpgradePurpose(bytecodeRoot) {
|
3296
|
+
this.upgradePurpose = {
|
3297
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3298
|
+
data: hexlify14(bytecodeRoot)
|
3299
|
+
};
|
3300
|
+
return this;
|
3301
|
+
}
|
3302
|
+
/**
|
3303
|
+
* Adds an upgrade purpose.
|
3304
|
+
*
|
3305
|
+
* @param type - The upgrade purpose type.
|
3306
|
+
* @param data - The bytecode or merkle root of upgrade purpose
|
3307
|
+
*
|
3308
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3309
|
+
*/
|
3310
|
+
addUpgradePurpose(type, data) {
|
3311
|
+
if (type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3312
|
+
this.addConsensusParametersUpgradePurpose(data);
|
3313
|
+
}
|
3314
|
+
if (type === UpgradePurposeTypeEnum.StateTransition) {
|
3315
|
+
this.addStateTransitionUpgradePurpose(data);
|
3316
|
+
}
|
3317
|
+
return this;
|
3318
|
+
}
|
3319
|
+
/**
|
3320
|
+
* Converts the transaction request to a `TransactionUpgrade`.
|
3321
|
+
*
|
3322
|
+
* @returns The transaction create object.
|
3323
|
+
*/
|
3324
|
+
toTransaction() {
|
3325
|
+
let upgradePurpose;
|
3326
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3327
|
+
upgradePurpose = {
|
3328
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3329
|
+
data: {
|
3330
|
+
witnessIndex: this.bytecodeWitnessIndex,
|
3331
|
+
checksum: this.upgradePurpose.checksum
|
3332
|
+
}
|
3333
|
+
};
|
3334
|
+
} else if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3335
|
+
upgradePurpose = {
|
3336
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3337
|
+
data: {
|
3338
|
+
bytecodeRoot: hexlify14(this.upgradePurpose.data)
|
3339
|
+
}
|
3340
|
+
};
|
3341
|
+
} else {
|
3342
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3343
|
+
}
|
3344
|
+
return {
|
3345
|
+
type: TransactionType5.Upgrade,
|
3346
|
+
...super.getBaseTransaction(),
|
3347
|
+
upgradePurpose
|
3348
|
+
};
|
3349
|
+
}
|
3350
|
+
/**
|
3351
|
+
* Gets the Transaction ID by hashing the transaction
|
3352
|
+
*
|
3353
|
+
* @param chainId - The chain ID.
|
3354
|
+
*
|
3355
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3356
|
+
*/
|
3357
|
+
getTransactionId(chainId) {
|
3358
|
+
return hashTransaction(this, chainId);
|
3359
|
+
}
|
3360
|
+
/**
|
3361
|
+
* Calculates the metadata gas cost for an upgrade transaction.
|
3362
|
+
*
|
3363
|
+
* @param gasCosts - gas costs passed from the chain.
|
3364
|
+
*
|
3365
|
+
* @returns metadata gas cost for the upgrade transaction.
|
3366
|
+
*/
|
3367
|
+
metadataGas(gasCosts) {
|
3368
|
+
const txBytesSize = this.byteSize();
|
3369
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3370
|
+
const witnessIndex = this.bytecodeWitnessIndex;
|
3371
|
+
const consensusSize = this.witnesses[witnessIndex].length;
|
3372
|
+
return calculateMetadataGasForTxUpgrade({
|
3373
|
+
gasCosts,
|
3374
|
+
txBytesSize,
|
3375
|
+
consensusSize
|
3376
|
+
});
|
3377
|
+
}
|
3378
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3379
|
+
return calculateMetadataGasForTxUpgrade({
|
3380
|
+
gasCosts,
|
3381
|
+
txBytesSize
|
3382
|
+
});
|
3383
|
+
}
|
3384
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3385
|
+
}
|
3386
|
+
};
|
3387
|
+
|
3388
|
+
// src/providers/transaction-request/upload-transaction-request.ts
|
3389
|
+
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
3390
|
+
import { TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
3391
|
+
import { arrayify as arrayify10, hexlify as hexlify15 } from "@fuel-ts/utils";
|
3392
|
+
import { clone as clone7 } from "ramda";
|
3393
|
+
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3394
|
+
static from(obj) {
|
3395
|
+
if (obj instanceof UploadTransactionRequest) {
|
3396
|
+
return obj;
|
3397
|
+
}
|
3398
|
+
return new this(clone7(obj));
|
3399
|
+
}
|
3400
|
+
/** Type of the transaction */
|
3401
|
+
type = TransactionType6.Upload;
|
3402
|
+
/** The witness index of the subsection of the bytecode. */
|
3403
|
+
witnessIndex;
|
3404
|
+
/** The subsection data. */
|
3405
|
+
subsection;
|
3406
|
+
/**
|
3407
|
+
* Creates an instance `UploadTransactionRequest`.
|
3408
|
+
*
|
3409
|
+
* @param uploadTransactionRequestLike - The initial values for the instance
|
3410
|
+
*/
|
3411
|
+
constructor({ witnessIndex, subsection, ...rest } = {}) {
|
3412
|
+
super(rest);
|
3413
|
+
this.witnessIndex = witnessIndex ?? 0;
|
3414
|
+
this.subsection = subsection ?? {
|
3415
|
+
proofSet: [],
|
3416
|
+
root: ZeroBytes328,
|
3417
|
+
subsectionIndex: 0,
|
3418
|
+
subsectionsNumber: 0
|
3419
|
+
};
|
3420
|
+
}
|
3421
|
+
/**
|
3422
|
+
* Adds the subsection.
|
3423
|
+
*
|
3424
|
+
* @param subsection - The subsection data.
|
3425
|
+
*/
|
3426
|
+
addSubsection(subsection) {
|
3427
|
+
const { subsection: subsectionBytecode, ...rest } = subsection;
|
3428
|
+
this.subsection = rest;
|
3429
|
+
this.witnessIndex = this.addWitness(subsectionBytecode);
|
3430
|
+
}
|
3431
|
+
/**
|
3432
|
+
* Gets the Transaction Request by hashing the transaction.
|
3433
|
+
*
|
3434
|
+
* @param chainId - The chain ID.
|
3435
|
+
*
|
3436
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3437
|
+
*/
|
3438
|
+
getTransactionId(chainId) {
|
3439
|
+
return hashTransaction(this, chainId);
|
3440
|
+
}
|
3441
|
+
/**
|
3442
|
+
* Converts the transaction request to a `TransactionUpload`.
|
3443
|
+
*
|
3444
|
+
* @returns The transaction create object.
|
3445
|
+
*/
|
3446
|
+
toTransaction() {
|
3447
|
+
const baseTransaction = this.getBaseTransaction();
|
3448
|
+
const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
|
3449
|
+
return {
|
3450
|
+
type: TransactionType6.Upload,
|
3451
|
+
...baseTransaction,
|
3452
|
+
subsectionIndex,
|
3453
|
+
subsectionsNumber,
|
3454
|
+
root: hexlify15(root),
|
3455
|
+
proofSet: proofSet.map(hexlify15),
|
3456
|
+
witnessIndex: this.witnessIndex,
|
3457
|
+
proofSetCount: proofSet.length
|
3458
|
+
};
|
3459
|
+
}
|
3460
|
+
/**
|
3461
|
+
* Calculates the metadata gas cost for an upload transaction.
|
3462
|
+
*
|
3463
|
+
* @param gasCosts - gas costs passed from the chain.
|
3464
|
+
*
|
3465
|
+
* @returns metadata gas cost for the upload transaction.
|
3466
|
+
*/
|
3467
|
+
metadataGas(gasCosts) {
|
3468
|
+
return calculateMetadataGasForTxUpload({
|
3469
|
+
gasCosts,
|
3470
|
+
txBytesSize: this.byteSize(),
|
3471
|
+
subsectionSize: arrayify10(this.witnesses[this.witnessIndex]).length,
|
3472
|
+
subsectionsSize: this.subsection.subsectionsNumber
|
3473
|
+
});
|
3474
|
+
}
|
3475
|
+
/**
|
3476
|
+
* Calculates the minimum gas for an upload transaction.
|
3477
|
+
*
|
3478
|
+
* @param chainInfo - The chain information.
|
3479
|
+
*
|
3480
|
+
* @returns the minimum gas for the upload transaction
|
3481
|
+
*/
|
3482
|
+
calculateMinGas(chainInfo) {
|
3483
|
+
const minGas = super.calculateMinGas(chainInfo);
|
3484
|
+
const { gasCosts } = chainInfo.consensusParameters;
|
3485
|
+
const bytecode = this.witnesses[this.witnessIndex] ?? ZeroBytes328;
|
3486
|
+
return calculateMinGasForTxUpload({
|
3487
|
+
gasCosts,
|
3488
|
+
baseMinGas: minGas.toNumber(),
|
3489
|
+
subsectionSize: arrayify10(bytecode).length
|
3490
|
+
});
|
3491
|
+
}
|
3492
|
+
};
|
3493
|
+
|
3197
3494
|
// src/providers/transaction-request/utils.ts
|
3198
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
3199
|
-
import { TransactionType as
|
3495
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3496
|
+
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3200
3497
|
var transactionRequestify = (obj) => {
|
3201
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
3498
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
3202
3499
|
return obj;
|
3203
3500
|
}
|
3204
3501
|
const { type } = obj;
|
3205
3502
|
switch (obj.type) {
|
3206
|
-
case
|
3503
|
+
case TransactionType7.Script: {
|
3207
3504
|
return ScriptTransactionRequest.from(obj);
|
3208
3505
|
}
|
3209
|
-
case
|
3506
|
+
case TransactionType7.Create: {
|
3210
3507
|
return CreateTransactionRequest.from(obj);
|
3211
3508
|
}
|
3212
|
-
case
|
3509
|
+
case TransactionType7.Blob: {
|
3213
3510
|
return BlobTransactionRequest.from(obj);
|
3214
3511
|
}
|
3512
|
+
case TransactionType7.Upgrade: {
|
3513
|
+
return UpgradeTransactionRequest.from(obj);
|
3514
|
+
}
|
3515
|
+
case TransactionType7.Upload: {
|
3516
|
+
return UploadTransactionRequest.from(obj);
|
3517
|
+
}
|
3215
3518
|
default: {
|
3216
|
-
throw new
|
3519
|
+
throw new FuelError11(
|
3217
3520
|
ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
|
3218
3521
|
`Unsupported transaction type: ${type}.`
|
3219
3522
|
);
|
3220
3523
|
}
|
3221
3524
|
}
|
3222
3525
|
};
|
3223
|
-
var isTransactionTypeScript = (request) => request.type ===
|
3224
|
-
var isTransactionTypeCreate = (request) => request.type ===
|
3526
|
+
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3527
|
+
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3225
3528
|
|
3226
3529
|
// src/providers/transaction-response/transaction-response.ts
|
3227
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3530
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3228
3531
|
import { bn as bn16 } from "@fuel-ts/math";
|
3229
3532
|
import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3230
|
-
import { arrayify as
|
3533
|
+
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
3231
3534
|
|
3232
3535
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3233
3536
|
import { bn as bn15 } from "@fuel-ts/math";
|
3234
3537
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
3235
|
-
import { DateTime, hexlify as
|
3538
|
+
import { DateTime, hexlify as hexlify16 } from "@fuel-ts/utils";
|
3236
3539
|
|
3237
3540
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3238
3541
|
import { bn as bn12 } from "@fuel-ts/math";
|
3239
|
-
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as
|
3240
|
-
import { arrayify as
|
3542
|
+
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3543
|
+
import { arrayify as arrayify11 } from "@fuel-ts/utils";
|
3241
3544
|
var calculateTXFeeForSummary = (params) => {
|
3242
3545
|
const {
|
3243
3546
|
gasPrice,
|
@@ -3251,17 +3554,17 @@ var calculateTXFeeForSummary = (params) => {
|
|
3251
3554
|
}
|
3252
3555
|
const gasPerByte = bn12(feeParams.gasPerByte);
|
3253
3556
|
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3254
|
-
const transactionBytes =
|
3557
|
+
const transactionBytes = arrayify11(rawPayload);
|
3255
3558
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
3256
3559
|
const { type, witnesses, inputs, policies } = transaction;
|
3257
3560
|
let metadataGas = bn12(0);
|
3258
3561
|
let gasLimit = bn12(0);
|
3259
|
-
if (type !==
|
3562
|
+
if (type !== TransactionType8.Create && type !== TransactionType8.Script) {
|
3260
3563
|
return bn12(0);
|
3261
3564
|
}
|
3262
|
-
if (type ===
|
3565
|
+
if (type === TransactionType8.Create) {
|
3263
3566
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3264
|
-
const contractBytesSize = bn12(
|
3567
|
+
const contractBytesSize = bn12(arrayify11(witnesses[bytecodeWitnessIndex].data).length);
|
3265
3568
|
metadataGas = calculateMetadataGasForTxCreate({
|
3266
3569
|
contractBytesSize,
|
3267
3570
|
gasCosts,
|
@@ -3305,10 +3608,10 @@ var calculateTXFeeForSummary = (params) => {
|
|
3305
3608
|
};
|
3306
3609
|
|
3307
3610
|
// src/providers/transaction-summary/operations.ts
|
3308
|
-
import { ZeroBytes32 as
|
3309
|
-
import { ErrorCode as ErrorCode10, FuelError as
|
3611
|
+
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3612
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3310
3613
|
import { bn as bn13 } from "@fuel-ts/math";
|
3311
|
-
import { ReceiptType as ReceiptType4, TransactionType as
|
3614
|
+
import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3312
3615
|
|
3313
3616
|
// src/providers/transaction-summary/call.ts
|
3314
3617
|
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
@@ -3344,7 +3647,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3344
3647
|
};
|
3345
3648
|
|
3346
3649
|
// src/providers/transaction-summary/input.ts
|
3347
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3650
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
|
3348
3651
|
import { BN } from "@fuel-ts/math";
|
3349
3652
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3350
3653
|
function getInputsByTypes(inputs, types) {
|
@@ -3413,7 +3716,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3413
3716
|
return void 0;
|
3414
3717
|
}
|
3415
3718
|
if (contractInput.type !== InputType6.Contract) {
|
3416
|
-
throw new
|
3719
|
+
throw new FuelError12(
|
3417
3720
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
3418
3721
|
`Contract input should be of type 'contract'.`
|
3419
3722
|
);
|
@@ -3454,16 +3757,20 @@ function getReceiptsByType(receipts, type) {
|
|
3454
3757
|
}
|
3455
3758
|
function getTransactionTypeName(transactionType) {
|
3456
3759
|
switch (transactionType) {
|
3457
|
-
case
|
3760
|
+
case TransactionType9.Mint:
|
3458
3761
|
return "Mint" /* Mint */;
|
3459
|
-
case
|
3762
|
+
case TransactionType9.Create:
|
3460
3763
|
return "Create" /* Create */;
|
3461
|
-
case
|
3764
|
+
case TransactionType9.Script:
|
3462
3765
|
return "Script" /* Script */;
|
3463
|
-
case
|
3766
|
+
case TransactionType9.Blob:
|
3464
3767
|
return "Blob" /* Blob */;
|
3768
|
+
case TransactionType9.Upgrade:
|
3769
|
+
return "Upgrade" /* Upgrade */;
|
3770
|
+
case TransactionType9.Upload:
|
3771
|
+
return "Upload" /* Upload */;
|
3465
3772
|
default:
|
3466
|
-
throw new
|
3773
|
+
throw new FuelError13(
|
3467
3774
|
ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
|
3468
3775
|
`Unsupported transaction type: ${transactionType}.`
|
3469
3776
|
);
|
@@ -3603,7 +3910,7 @@ function getAssetsSent(receipt) {
|
|
3603
3910
|
];
|
3604
3911
|
}
|
3605
3912
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3606
|
-
const assetId = receipt.assetId ===
|
3913
|
+
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
3607
3914
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3608
3915
|
if (!input) {
|
3609
3916
|
return [];
|
@@ -3659,7 +3966,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3659
3966
|
const { to: toAddress, assetId, amount } = receipt;
|
3660
3967
|
let { from: fromAddress } = receipt;
|
3661
3968
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3662
|
-
if (
|
3969
|
+
if (ZeroBytes329 === fromAddress) {
|
3663
3970
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3664
3971
|
fromAddress = change?.to || fromAddress;
|
3665
3972
|
}
|
@@ -3813,25 +4120,7 @@ function getOperations({
|
|
3813
4120
|
|
3814
4121
|
// src/providers/transaction-summary/receipt.ts
|
3815
4122
|
import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
|
3816
|
-
var processGqlReceipt = (gqlReceipt) =>
|
3817
|
-
const receipt = assembleReceiptByType(gqlReceipt);
|
3818
|
-
switch (receipt.type) {
|
3819
|
-
case ReceiptType5.ReturnData: {
|
3820
|
-
return {
|
3821
|
-
...receipt,
|
3822
|
-
data: gqlReceipt.data || "0x"
|
3823
|
-
};
|
3824
|
-
}
|
3825
|
-
case ReceiptType5.LogData: {
|
3826
|
-
return {
|
3827
|
-
...receipt,
|
3828
|
-
data: gqlReceipt.data || "0x"
|
3829
|
-
};
|
3830
|
-
}
|
3831
|
-
default:
|
3832
|
-
return receipt;
|
3833
|
-
}
|
3834
|
-
};
|
4123
|
+
var processGqlReceipt = (gqlReceipt) => assembleReceiptByType(gqlReceipt);
|
3835
4124
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3836
4125
|
const mintedAssets = [];
|
3837
4126
|
receipts.forEach((receipt) => {
|
@@ -3862,7 +4151,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3862
4151
|
};
|
3863
4152
|
|
3864
4153
|
// src/providers/transaction-summary/status.ts
|
3865
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
4154
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
3866
4155
|
import { bn as bn14 } from "@fuel-ts/math";
|
3867
4156
|
var getTransactionStatusName = (gqlStatus) => {
|
3868
4157
|
switch (gqlStatus) {
|
@@ -3875,7 +4164,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3875
4164
|
case "SqueezedOutStatus":
|
3876
4165
|
return "squeezedout" /* squeezedout */;
|
3877
4166
|
default:
|
3878
|
-
throw new
|
4167
|
+
throw new FuelError14(
|
3879
4168
|
ErrorCode11.INVALID_TRANSACTION_STATUS,
|
3880
4169
|
`Invalid transaction status: ${gqlStatus}.`
|
3881
4170
|
);
|
@@ -3945,7 +4234,7 @@ function assembleTransactionSummary(params) {
|
|
3945
4234
|
baseAssetId
|
3946
4235
|
} = params;
|
3947
4236
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3948
|
-
const rawPayload =
|
4237
|
+
const rawPayload = hexlify16(transactionBytes);
|
3949
4238
|
const operations = getOperations({
|
3950
4239
|
transactionType: transaction.type,
|
3951
4240
|
inputs: transaction.inputs || [],
|
@@ -4126,7 +4415,7 @@ var TransactionResponse = class {
|
|
4126
4415
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
4127
4416
|
return {
|
4128
4417
|
tx: this.decodeTransaction(gqlTransaction),
|
4129
|
-
bytes:
|
4418
|
+
bytes: arrayify12(gqlTransaction.rawPayload)
|
4130
4419
|
};
|
4131
4420
|
}
|
4132
4421
|
getReceipts() {
|
@@ -4171,7 +4460,7 @@ var TransactionResponse = class {
|
|
4171
4460
|
*/
|
4172
4461
|
decodeTransaction(transactionWithReceipts) {
|
4173
4462
|
return new TransactionCoder4().decode(
|
4174
|
-
|
4463
|
+
arrayify12(transactionWithReceipts.rawPayload),
|
4175
4464
|
0
|
4176
4465
|
)?.[0];
|
4177
4466
|
}
|
@@ -4218,7 +4507,7 @@ var TransactionResponse = class {
|
|
4218
4507
|
this.status = statusChange;
|
4219
4508
|
if (statusChange.type === "SqueezedOutStatus") {
|
4220
4509
|
this.unsetResourceCache();
|
4221
|
-
throw new
|
4510
|
+
throw new FuelError15(
|
4222
4511
|
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
4223
4512
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4224
4513
|
);
|
@@ -4327,18 +4616,18 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4327
4616
|
}
|
4328
4617
|
|
4329
4618
|
// src/providers/utils/handle-gql-error-message.ts
|
4330
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4619
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4331
4620
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4332
4621
|
switch (errorMessage) {
|
4333
4622
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4334
|
-
throw new
|
4623
|
+
throw new FuelError16(
|
4335
4624
|
ErrorCode13.NOT_ENOUGH_FUNDS,
|
4336
4625
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4337
4626
|
{},
|
4338
4627
|
rawError
|
4339
4628
|
);
|
4340
4629
|
default:
|
4341
|
-
throw new
|
4630
|
+
throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4342
4631
|
}
|
4343
4632
|
};
|
4344
4633
|
|
@@ -4420,21 +4709,31 @@ var _Provider = class {
|
|
4420
4709
|
* @hidden
|
4421
4710
|
*/
|
4422
4711
|
constructor(url, options = {}) {
|
4423
|
-
this.url = url;
|
4424
4712
|
/**
|
4425
4713
|
* @hidden
|
4426
4714
|
*/
|
4427
4715
|
__privateAdd(this, _cacheInputs);
|
4428
4716
|
__publicField(this, "operations");
|
4429
4717
|
__publicField(this, "cache");
|
4718
|
+
/** @hidden */
|
4719
|
+
__publicField(this, "url");
|
4720
|
+
/** @hidden */
|
4721
|
+
__publicField(this, "urlWithoutAuth");
|
4430
4722
|
__publicField(this, "options", {
|
4431
4723
|
timeout: void 0,
|
4432
4724
|
resourceCacheTTL: void 0,
|
4433
4725
|
fetch: void 0,
|
4434
|
-
retryOptions: void 0
|
4726
|
+
retryOptions: void 0,
|
4727
|
+
headers: void 0
|
4435
4728
|
});
|
4729
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4730
|
+
this.url = rawUrl;
|
4731
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4436
4732
|
this.options = { ...this.options, ...options };
|
4437
4733
|
this.url = url;
|
4734
|
+
if (headers) {
|
4735
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4736
|
+
}
|
4438
4737
|
this.operations = this.createOperations();
|
4439
4738
|
const { resourceCacheTTL } = this.options;
|
4440
4739
|
if (isDefined2(resourceCacheTTL)) {
|
@@ -4456,12 +4755,16 @@ var _Provider = class {
|
|
4456
4755
|
* @hidden
|
4457
4756
|
*/
|
4458
4757
|
static getFetchFn(options) {
|
4459
|
-
const { retryOptions, timeout } = options;
|
4758
|
+
const { retryOptions, timeout, headers } = options;
|
4460
4759
|
return autoRetryFetch(async (...args) => {
|
4461
4760
|
const url = args[0];
|
4462
4761
|
const request = args[1];
|
4463
4762
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
4464
|
-
let fullRequest = {
|
4763
|
+
let fullRequest = {
|
4764
|
+
...request,
|
4765
|
+
signal,
|
4766
|
+
headers: { ...request?.headers, ...headers }
|
4767
|
+
};
|
4465
4768
|
if (options.requestMiddleware) {
|
4466
4769
|
fullRequest = await options.requestMiddleware(fullRequest);
|
4467
4770
|
}
|
@@ -4469,15 +4772,23 @@ var _Provider = class {
|
|
4469
4772
|
}, retryOptions);
|
4470
4773
|
}
|
4471
4774
|
static extractBasicAuth(url) {
|
4472
|
-
|
4775
|
+
let parsedUrl;
|
4776
|
+
try {
|
4777
|
+
parsedUrl = new URL(url);
|
4778
|
+
} catch (error) {
|
4779
|
+
throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4780
|
+
}
|
4473
4781
|
const username = parsedUrl.username;
|
4474
4782
|
const password = parsedUrl.password;
|
4475
|
-
const
|
4783
|
+
const urlWithoutAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4476
4784
|
if (!(username && password)) {
|
4477
|
-
return { url,
|
4785
|
+
return { url, urlWithoutAuth: url, headers: void 0 };
|
4478
4786
|
}
|
4479
|
-
|
4480
|
-
|
4787
|
+
return {
|
4788
|
+
url,
|
4789
|
+
urlWithoutAuth,
|
4790
|
+
headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}` }
|
4791
|
+
};
|
4481
4792
|
}
|
4482
4793
|
/**
|
4483
4794
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
@@ -4488,17 +4799,7 @@ var _Provider = class {
|
|
4488
4799
|
* @returns A promise that resolves to a Provider instance.
|
4489
4800
|
*/
|
4490
4801
|
static async create(url, options = {}) {
|
4491
|
-
const
|
4492
|
-
const provider = new _Provider(urlToUse, {
|
4493
|
-
...options,
|
4494
|
-
requestMiddleware: async (request) => {
|
4495
|
-
if (auth && request) {
|
4496
|
-
request.headers ??= {};
|
4497
|
-
request.headers.Authorization = auth;
|
4498
|
-
}
|
4499
|
-
return options.requestMiddleware?.(request) ?? request;
|
4500
|
-
}
|
4501
|
-
});
|
4802
|
+
const provider = new _Provider(url, options);
|
4502
4803
|
await provider.fetchChainAndNodeInfo();
|
4503
4804
|
return provider;
|
4504
4805
|
}
|
@@ -4508,9 +4809,9 @@ var _Provider = class {
|
|
4508
4809
|
* @returns the chain information configuration.
|
4509
4810
|
*/
|
4510
4811
|
getChain() {
|
4511
|
-
const chain = _Provider.chainInfoCache[this.
|
4812
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4512
4813
|
if (!chain) {
|
4513
|
-
throw new
|
4814
|
+
throw new FuelError17(
|
4514
4815
|
ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
|
4515
4816
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4516
4817
|
);
|
@@ -4523,9 +4824,9 @@ var _Provider = class {
|
|
4523
4824
|
* @returns the node information configuration.
|
4524
4825
|
*/
|
4525
4826
|
getNode() {
|
4526
|
-
const node = _Provider.nodeInfoCache[this.
|
4827
|
+
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4527
4828
|
if (!node) {
|
4528
|
-
throw new
|
4829
|
+
throw new FuelError17(
|
4529
4830
|
ErrorCode14.NODE_INFO_CACHE_EMPTY,
|
4530
4831
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4531
4832
|
);
|
@@ -4557,8 +4858,11 @@ var _Provider = class {
|
|
4557
4858
|
* @param options - Additional options for the provider.
|
4558
4859
|
*/
|
4559
4860
|
async connect(url, options) {
|
4560
|
-
|
4861
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4862
|
+
this.url = rawUrl;
|
4863
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4561
4864
|
this.options = options ?? this.options;
|
4865
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4562
4866
|
this.operations = this.createOperations();
|
4563
4867
|
await this.fetchChainAndNodeInfo();
|
4564
4868
|
}
|
@@ -4598,7 +4902,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4598
4902
|
*/
|
4599
4903
|
createOperations() {
|
4600
4904
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4601
|
-
const gqlClient = new GraphQLClient(this.
|
4905
|
+
const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
|
4602
4906
|
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4603
4907
|
responseMiddleware: (response) => {
|
4604
4908
|
if ("response" in response) {
|
@@ -4616,7 +4920,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4616
4920
|
const isSubscription = opDefinition?.operation === "subscription";
|
4617
4921
|
if (isSubscription) {
|
4618
4922
|
return FuelGraphqlSubscriber.create({
|
4619
|
-
url: this.
|
4923
|
+
url: this.urlWithoutAuth,
|
4620
4924
|
query,
|
4621
4925
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4622
4926
|
variables: vars
|
@@ -4679,7 +4983,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4679
4983
|
utxoValidation: nodeInfo.utxoValidation,
|
4680
4984
|
vmBacktrace: nodeInfo.vmBacktrace
|
4681
4985
|
};
|
4682
|
-
_Provider.nodeInfoCache[this.
|
4986
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
4683
4987
|
return processedNodeInfo;
|
4684
4988
|
}
|
4685
4989
|
/**
|
@@ -4690,7 +4994,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4690
4994
|
async fetchChain() {
|
4691
4995
|
const { chain } = await this.operations.getChain();
|
4692
4996
|
const processedChain = processGqlChain(chain);
|
4693
|
-
_Provider.chainInfoCache[this.
|
4997
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
4694
4998
|
return processedChain;
|
4695
4999
|
}
|
4696
5000
|
/**
|
@@ -4718,13 +5022,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4718
5022
|
validateTransaction(tx, consensusParameters) {
|
4719
5023
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4720
5024
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4721
|
-
throw new
|
5025
|
+
throw new FuelError17(
|
4722
5026
|
ErrorCode14.MAX_INPUTS_EXCEEDED,
|
4723
5027
|
"The transaction exceeds the maximum allowed number of inputs."
|
4724
5028
|
);
|
4725
5029
|
}
|
4726
5030
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4727
|
-
throw new
|
5031
|
+
throw new FuelError17(
|
4728
5032
|
ErrorCode14.MAX_OUTPUTS_EXCEEDED,
|
4729
5033
|
"The transaction exceeds the maximum allowed number of outputs."
|
4730
5034
|
);
|
@@ -4747,7 +5051,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4747
5051
|
}
|
4748
5052
|
const { consensusParameters } = this.getChain();
|
4749
5053
|
this.validateTransaction(transactionRequest, consensusParameters);
|
4750
|
-
const encodedTransaction =
|
5054
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4751
5055
|
let abis;
|
4752
5056
|
if (isTransactionTypeScript(transactionRequest)) {
|
4753
5057
|
abis = transactionRequest.abis;
|
@@ -4771,7 +5075,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4771
5075
|
if (estimateTxDependencies) {
|
4772
5076
|
return this.estimateTxDependencies(transactionRequest);
|
4773
5077
|
}
|
4774
|
-
const encodedTransaction =
|
5078
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4775
5079
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4776
5080
|
encodedTransactions: encodedTransaction,
|
4777
5081
|
utxoValidation: utxoValidation || false
|
@@ -4791,13 +5095,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4791
5095
|
async estimatePredicates(transactionRequest) {
|
4792
5096
|
const shouldEstimatePredicates = Boolean(
|
4793
5097
|
transactionRequest.inputs.find(
|
4794
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(
|
5098
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify13(input.predicate), arrayify13("0x")) && new BN2(input.predicateGasUsed).isZero()
|
4795
5099
|
)
|
4796
5100
|
);
|
4797
5101
|
if (!shouldEstimatePredicates) {
|
4798
5102
|
return transactionRequest;
|
4799
5103
|
}
|
4800
|
-
const encodedTransaction =
|
5104
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4801
5105
|
const response = await this.operations.estimatePredicates({
|
4802
5106
|
encodedTransaction
|
4803
5107
|
});
|
@@ -4838,7 +5142,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4838
5142
|
const {
|
4839
5143
|
dryRun: [{ receipts: rawReceipts, status }]
|
4840
5144
|
} = await this.operations.dryRun({
|
4841
|
-
encodedTransactions: [
|
5145
|
+
encodedTransactions: [hexlify17(transactionRequest.toTransactionBytes())],
|
4842
5146
|
utxoValidation: false
|
4843
5147
|
});
|
4844
5148
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4884,11 +5188,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4884
5188
|
missingContractIds: [],
|
4885
5189
|
dryRunStatus: void 0
|
4886
5190
|
}));
|
4887
|
-
const allRequests =
|
5191
|
+
const allRequests = clone8(transactionRequests);
|
4888
5192
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4889
5193
|
allRequests.forEach((req, index) => {
|
4890
5194
|
if (isTransactionTypeScript(req)) {
|
4891
|
-
serializedTransactionsMap.set(index,
|
5195
|
+
serializedTransactionsMap.set(index, hexlify17(req.toTransactionBytes()));
|
4892
5196
|
}
|
4893
5197
|
});
|
4894
5198
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4924,7 +5228,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4924
5228
|
transactionRequest: request
|
4925
5229
|
});
|
4926
5230
|
request.maxFee = maxFee;
|
4927
|
-
serializedTransactionsMap.set(requestIdx,
|
5231
|
+
serializedTransactionsMap.set(requestIdx, hexlify17(request.toTransactionBytes()));
|
4928
5232
|
nextRoundTransactions.push(requestIdx);
|
4929
5233
|
}
|
4930
5234
|
}
|
@@ -4945,7 +5249,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4945
5249
|
if (estimateTxDependencies) {
|
4946
5250
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4947
5251
|
}
|
4948
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
5252
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify17(tx.toTransactionBytes()));
|
4949
5253
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4950
5254
|
encodedTransactions,
|
4951
5255
|
utxoValidation: utxoValidation || false
|
@@ -5019,7 +5323,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5019
5323
|
if (estimateTxDependencies) {
|
5020
5324
|
return this.estimateTxDependencies(transactionRequest);
|
5021
5325
|
}
|
5022
|
-
const encodedTransactions = [
|
5326
|
+
const encodedTransactions = [hexlify17(transactionRequest.toTransactionBytes())];
|
5023
5327
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5024
5328
|
encodedTransactions,
|
5025
5329
|
utxoValidation: true
|
@@ -5044,13 +5348,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5044
5348
|
* @returns A promise that resolves to the transaction cost object.
|
5045
5349
|
*/
|
5046
5350
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5047
|
-
const txRequestClone =
|
5351
|
+
const txRequestClone = clone8(transactionRequestify(transactionRequestLike));
|
5048
5352
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5049
5353
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
5050
5354
|
if (isScriptTransaction) {
|
5051
5355
|
txRequestClone.gasLimit = bn17(0);
|
5052
5356
|
}
|
5053
|
-
const signedRequest =
|
5357
|
+
const signedRequest = clone8(txRequestClone);
|
5054
5358
|
let addedSignatures = 0;
|
5055
5359
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
5056
5360
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5118,7 +5422,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5118
5422
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5119
5423
|
inputArgs: paginationArgs
|
5120
5424
|
}),
|
5121
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
5425
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify17(assetId) }
|
5122
5426
|
});
|
5123
5427
|
const coins = edges.map(({ node }) => ({
|
5124
5428
|
id: node.utxoId,
|
@@ -5144,8 +5448,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5144
5448
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5145
5449
|
const ownerAddress = Address3.fromAddressOrString(owner);
|
5146
5450
|
const excludeInput = {
|
5147
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
5148
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
5451
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify17(nonce)) || [],
|
5452
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify17(id)) || []
|
5149
5453
|
};
|
5150
5454
|
if (this.cache) {
|
5151
5455
|
const cached = this.cache.getActiveData();
|
@@ -5155,7 +5459,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5155
5459
|
const coinsQuery = {
|
5156
5460
|
owner: ownerAddress.toB256(),
|
5157
5461
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5158
|
-
assetId:
|
5462
|
+
assetId: hexlify17(assetId),
|
5159
5463
|
amount: amount.toString(10),
|
5160
5464
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5161
5465
|
})),
|
@@ -5310,7 +5614,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5310
5614
|
},
|
5311
5615
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5312
5616
|
transactions: block.transactions.map(
|
5313
|
-
(tx) => new TransactionCoder5().decode(
|
5617
|
+
(tx) => new TransactionCoder5().decode(arrayify13(tx.rawPayload), 0)?.[0]
|
5314
5618
|
)
|
5315
5619
|
};
|
5316
5620
|
}
|
@@ -5327,11 +5631,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5327
5631
|
}
|
5328
5632
|
try {
|
5329
5633
|
return new TransactionCoder5().decode(
|
5330
|
-
|
5634
|
+
arrayify13(transaction.rawPayload),
|
5331
5635
|
0
|
5332
5636
|
)?.[0];
|
5333
5637
|
} catch (error) {
|
5334
|
-
if (error instanceof
|
5638
|
+
if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5335
5639
|
console.warn("Unsupported transaction type encountered");
|
5336
5640
|
return null;
|
5337
5641
|
}
|
@@ -5350,9 +5654,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5350
5654
|
const coder = new TransactionCoder5();
|
5351
5655
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5352
5656
|
try {
|
5353
|
-
return coder.decode(
|
5657
|
+
return coder.decode(arrayify13(rawPayload), 0)[0];
|
5354
5658
|
} catch (error) {
|
5355
|
-
if (error instanceof
|
5659
|
+
if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5356
5660
|
console.warn("Unsupported transaction type encountered");
|
5357
5661
|
return null;
|
5358
5662
|
}
|
@@ -5384,7 +5688,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5384
5688
|
async getContractBalance(contractId, assetId) {
|
5385
5689
|
const { contractBalance } = await this.operations.getContractBalance({
|
5386
5690
|
contract: Address3.fromAddressOrString(contractId).toB256(),
|
5387
|
-
asset:
|
5691
|
+
asset: hexlify17(assetId)
|
5388
5692
|
});
|
5389
5693
|
return bn17(contractBalance.amount, 10);
|
5390
5694
|
}
|
@@ -5398,7 +5702,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5398
5702
|
async getBalance(owner, assetId) {
|
5399
5703
|
const { balance } = await this.operations.getBalance({
|
5400
5704
|
owner: Address3.fromAddressOrString(owner).toB256(),
|
5401
|
-
assetId:
|
5705
|
+
assetId: hexlify17(assetId)
|
5402
5706
|
});
|
5403
5707
|
return bn17(balance.amount, 10);
|
5404
5708
|
}
|
@@ -5478,7 +5782,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5478
5782
|
nonce
|
5479
5783
|
};
|
5480
5784
|
if (commitBlockId && commitBlockHeight) {
|
5481
|
-
throw new
|
5785
|
+
throw new FuelError17(
|
5482
5786
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5483
5787
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5484
5788
|
);
|
@@ -5662,25 +5966,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5662
5966
|
const { paginationLimit, inputArgs = {} } = params;
|
5663
5967
|
const { first, last, after, before } = inputArgs;
|
5664
5968
|
if (after && before) {
|
5665
|
-
throw new
|
5969
|
+
throw new FuelError17(
|
5666
5970
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5667
5971
|
'Pagination arguments "after" and "before" cannot be used together'
|
5668
5972
|
);
|
5669
5973
|
}
|
5670
5974
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5671
|
-
throw new
|
5975
|
+
throw new FuelError17(
|
5672
5976
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5673
5977
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5674
5978
|
);
|
5675
5979
|
}
|
5676
5980
|
if (first && before) {
|
5677
|
-
throw new
|
5981
|
+
throw new FuelError17(
|
5678
5982
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5679
5983
|
'The use of pagination argument "first" with "before" is not supported'
|
5680
5984
|
);
|
5681
5985
|
}
|
5682
5986
|
if (last && after) {
|
5683
|
-
throw new
|
5987
|
+
throw new FuelError17(
|
5684
5988
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5685
5989
|
'The use of pagination argument "last" with "after" is not supported'
|
5686
5990
|
);
|
@@ -5735,20 +6039,22 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5735
6039
|
__publicField(Provider, "nodeInfoCache", {});
|
5736
6040
|
|
5737
6041
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5738
|
-
import { ErrorCode as ErrorCode15, FuelError as
|
6042
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5739
6043
|
import { bn as bn18 } from "@fuel-ts/math";
|
5740
6044
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5741
|
-
import { arrayify as
|
6045
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
5742
6046
|
|
5743
6047
|
// src/providers/chains.ts
|
5744
6048
|
var CHAIN_IDS = {
|
5745
6049
|
eth: {
|
6050
|
+
mainnet: 1,
|
5746
6051
|
sepolia: 11155111,
|
5747
6052
|
foundry: 31337
|
5748
6053
|
},
|
5749
6054
|
fuel: {
|
5750
6055
|
devnet: 0,
|
5751
|
-
testnet: 0
|
6056
|
+
testnet: 0,
|
6057
|
+
mainnet: 9889
|
5752
6058
|
}
|
5753
6059
|
};
|
5754
6060
|
|
@@ -5794,6 +6100,11 @@ var rawAssets = [
|
|
5794
6100
|
chainId: CHAIN_IDS.eth.foundry,
|
5795
6101
|
decimals: 18
|
5796
6102
|
},
|
6103
|
+
{
|
6104
|
+
type: "ethereum",
|
6105
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6106
|
+
decimals: 18
|
6107
|
+
},
|
5797
6108
|
{
|
5798
6109
|
type: "fuel",
|
5799
6110
|
chainId: CHAIN_IDS.fuel.devnet,
|
@@ -5805,6 +6116,532 @@ var rawAssets = [
|
|
5805
6116
|
chainId: CHAIN_IDS.fuel.testnet,
|
5806
6117
|
decimals: 9,
|
5807
6118
|
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6119
|
+
},
|
6120
|
+
{
|
6121
|
+
type: "fuel",
|
6122
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6123
|
+
decimals: 9,
|
6124
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6125
|
+
}
|
6126
|
+
]
|
6127
|
+
},
|
6128
|
+
{
|
6129
|
+
name: "WETH",
|
6130
|
+
symbol: "WETH",
|
6131
|
+
icon: "weth.svg",
|
6132
|
+
networks: [
|
6133
|
+
{
|
6134
|
+
type: "ethereum",
|
6135
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6136
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6137
|
+
decimals: 18
|
6138
|
+
},
|
6139
|
+
{
|
6140
|
+
type: "fuel",
|
6141
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6142
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6143
|
+
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6144
|
+
decimals: 9
|
6145
|
+
}
|
6146
|
+
]
|
6147
|
+
},
|
6148
|
+
{
|
6149
|
+
name: "weETH",
|
6150
|
+
symbol: "weETH",
|
6151
|
+
icon: "weETH.webp",
|
6152
|
+
networks: [
|
6153
|
+
{
|
6154
|
+
type: "ethereum",
|
6155
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6156
|
+
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6157
|
+
decimals: 18
|
6158
|
+
},
|
6159
|
+
{
|
6160
|
+
type: "fuel",
|
6161
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6162
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6163
|
+
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6164
|
+
decimals: 9
|
6165
|
+
}
|
6166
|
+
]
|
6167
|
+
},
|
6168
|
+
{
|
6169
|
+
name: "rsETH",
|
6170
|
+
symbol: "rsETH",
|
6171
|
+
icon: "rsETH.webp",
|
6172
|
+
networks: [
|
6173
|
+
{
|
6174
|
+
type: "ethereum",
|
6175
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6176
|
+
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6177
|
+
decimals: 18
|
6178
|
+
},
|
6179
|
+
{
|
6180
|
+
type: "fuel",
|
6181
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6182
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6183
|
+
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6184
|
+
decimals: 9
|
6185
|
+
}
|
6186
|
+
]
|
6187
|
+
},
|
6188
|
+
{
|
6189
|
+
name: "rETH",
|
6190
|
+
symbol: "rETH",
|
6191
|
+
icon: "reth.svg",
|
6192
|
+
networks: [
|
6193
|
+
{
|
6194
|
+
type: "ethereum",
|
6195
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6196
|
+
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6197
|
+
decimals: 18
|
6198
|
+
},
|
6199
|
+
{
|
6200
|
+
type: "fuel",
|
6201
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6202
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6203
|
+
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6204
|
+
decimals: 9
|
6205
|
+
}
|
6206
|
+
]
|
6207
|
+
},
|
6208
|
+
{
|
6209
|
+
name: "wbETH",
|
6210
|
+
symbol: "wbETH",
|
6211
|
+
icon: "wbeth.png",
|
6212
|
+
networks: [
|
6213
|
+
{
|
6214
|
+
type: "ethereum",
|
6215
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6216
|
+
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6217
|
+
decimals: 18
|
6218
|
+
},
|
6219
|
+
{
|
6220
|
+
type: "fuel",
|
6221
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6222
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6223
|
+
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6224
|
+
decimals: 9
|
6225
|
+
}
|
6226
|
+
]
|
6227
|
+
},
|
6228
|
+
{
|
6229
|
+
name: "rstETH",
|
6230
|
+
symbol: "rstETH",
|
6231
|
+
icon: "rstETH.webp",
|
6232
|
+
networks: [
|
6233
|
+
{
|
6234
|
+
type: "ethereum",
|
6235
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6236
|
+
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6237
|
+
decimals: 18
|
6238
|
+
},
|
6239
|
+
{
|
6240
|
+
type: "fuel",
|
6241
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6242
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6243
|
+
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6244
|
+
decimals: 9
|
6245
|
+
}
|
6246
|
+
]
|
6247
|
+
},
|
6248
|
+
{
|
6249
|
+
name: "amphrETH",
|
6250
|
+
symbol: "amphrETH",
|
6251
|
+
icon: "amphrETH.png",
|
6252
|
+
networks: [
|
6253
|
+
{
|
6254
|
+
type: "ethereum",
|
6255
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6256
|
+
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6257
|
+
decimals: 18
|
6258
|
+
},
|
6259
|
+
{
|
6260
|
+
type: "fuel",
|
6261
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6262
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6263
|
+
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6264
|
+
decimals: 9
|
6265
|
+
}
|
6266
|
+
]
|
6267
|
+
},
|
6268
|
+
{
|
6269
|
+
name: "Manta mBTC",
|
6270
|
+
symbol: "Manta mBTC",
|
6271
|
+
icon: "manta-mbtc.svg",
|
6272
|
+
networks: [
|
6273
|
+
{
|
6274
|
+
type: "ethereum",
|
6275
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6276
|
+
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6277
|
+
decimals: 18
|
6278
|
+
},
|
6279
|
+
{
|
6280
|
+
type: "fuel",
|
6281
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6282
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6283
|
+
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6284
|
+
decimals: 9
|
6285
|
+
}
|
6286
|
+
]
|
6287
|
+
},
|
6288
|
+
{
|
6289
|
+
name: "Manta mETH",
|
6290
|
+
symbol: "Manta mETH",
|
6291
|
+
icon: "manta-meth.svg",
|
6292
|
+
networks: [
|
6293
|
+
{
|
6294
|
+
type: "ethereum",
|
6295
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6296
|
+
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6297
|
+
decimals: 18
|
6298
|
+
},
|
6299
|
+
{
|
6300
|
+
type: "fuel",
|
6301
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6302
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6303
|
+
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6304
|
+
decimals: 9
|
6305
|
+
}
|
6306
|
+
]
|
6307
|
+
},
|
6308
|
+
{
|
6309
|
+
name: "Manta mUSD",
|
6310
|
+
symbol: "Manta mUSD",
|
6311
|
+
icon: "manta-musd.svg",
|
6312
|
+
networks: [
|
6313
|
+
{
|
6314
|
+
type: "ethereum",
|
6315
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6316
|
+
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6317
|
+
decimals: 18
|
6318
|
+
},
|
6319
|
+
{
|
6320
|
+
type: "fuel",
|
6321
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6322
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6323
|
+
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6324
|
+
decimals: 9
|
6325
|
+
}
|
6326
|
+
]
|
6327
|
+
},
|
6328
|
+
{
|
6329
|
+
name: "pumpBTC",
|
6330
|
+
symbol: "pumpBTC",
|
6331
|
+
icon: "pumpbtc.webp",
|
6332
|
+
networks: [
|
6333
|
+
{
|
6334
|
+
type: "ethereum",
|
6335
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6336
|
+
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6337
|
+
decimals: 8
|
6338
|
+
},
|
6339
|
+
{
|
6340
|
+
type: "fuel",
|
6341
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6342
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6343
|
+
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6344
|
+
decimals: 8
|
6345
|
+
}
|
6346
|
+
]
|
6347
|
+
},
|
6348
|
+
{
|
6349
|
+
name: "FBTC",
|
6350
|
+
symbol: "FBTC",
|
6351
|
+
icon: "fbtc.svg",
|
6352
|
+
networks: [
|
6353
|
+
{
|
6354
|
+
type: "ethereum",
|
6355
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6356
|
+
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6357
|
+
decimals: 8
|
6358
|
+
},
|
6359
|
+
{
|
6360
|
+
type: "fuel",
|
6361
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6362
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6363
|
+
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6364
|
+
decimals: 8
|
6365
|
+
}
|
6366
|
+
]
|
6367
|
+
},
|
6368
|
+
{
|
6369
|
+
name: "SolvBTC",
|
6370
|
+
symbol: "SolvBTC",
|
6371
|
+
icon: "solvBTC.webp",
|
6372
|
+
networks: [
|
6373
|
+
{
|
6374
|
+
type: "ethereum",
|
6375
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6376
|
+
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6377
|
+
decimals: 18
|
6378
|
+
},
|
6379
|
+
{
|
6380
|
+
type: "fuel",
|
6381
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6382
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6383
|
+
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6384
|
+
decimals: 9
|
6385
|
+
}
|
6386
|
+
]
|
6387
|
+
},
|
6388
|
+
{
|
6389
|
+
name: "SolvBTC.BBN",
|
6390
|
+
symbol: "SolvBTC.BBN",
|
6391
|
+
icon: "SolvBTC.BBN.png",
|
6392
|
+
networks: [
|
6393
|
+
{
|
6394
|
+
type: "ethereum",
|
6395
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6396
|
+
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6397
|
+
decimals: 18
|
6398
|
+
},
|
6399
|
+
{
|
6400
|
+
type: "fuel",
|
6401
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6402
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6403
|
+
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6404
|
+
decimals: 9
|
6405
|
+
}
|
6406
|
+
]
|
6407
|
+
},
|
6408
|
+
{
|
6409
|
+
name: "Mantle mETH",
|
6410
|
+
symbol: "Mantle mETH",
|
6411
|
+
icon: "mantle-meth.svg",
|
6412
|
+
networks: [
|
6413
|
+
{
|
6414
|
+
type: "ethereum",
|
6415
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6416
|
+
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6417
|
+
decimals: 18
|
6418
|
+
},
|
6419
|
+
{
|
6420
|
+
type: "fuel",
|
6421
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6422
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6423
|
+
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6424
|
+
decimals: 9
|
6425
|
+
}
|
6426
|
+
]
|
6427
|
+
},
|
6428
|
+
{
|
6429
|
+
name: "sDAI",
|
6430
|
+
symbol: "sDAI",
|
6431
|
+
icon: "sdai.svg",
|
6432
|
+
networks: [
|
6433
|
+
{
|
6434
|
+
type: "ethereum",
|
6435
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6436
|
+
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6437
|
+
decimals: 18
|
6438
|
+
},
|
6439
|
+
{
|
6440
|
+
type: "fuel",
|
6441
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6442
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6443
|
+
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6444
|
+
decimals: 9
|
6445
|
+
}
|
6446
|
+
]
|
6447
|
+
},
|
6448
|
+
{
|
6449
|
+
name: "USDT",
|
6450
|
+
symbol: "USDT",
|
6451
|
+
icon: "usdt.svg",
|
6452
|
+
networks: [
|
6453
|
+
{
|
6454
|
+
type: "ethereum",
|
6455
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6456
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6457
|
+
decimals: 6
|
6458
|
+
},
|
6459
|
+
{
|
6460
|
+
type: "fuel",
|
6461
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6462
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6463
|
+
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6464
|
+
decimals: 6
|
6465
|
+
}
|
6466
|
+
]
|
6467
|
+
},
|
6468
|
+
{
|
6469
|
+
name: "USDC",
|
6470
|
+
symbol: "USDC",
|
6471
|
+
icon: "usdc.svg",
|
6472
|
+
networks: [
|
6473
|
+
{
|
6474
|
+
type: "ethereum",
|
6475
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6476
|
+
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6477
|
+
decimals: 6
|
6478
|
+
},
|
6479
|
+
{
|
6480
|
+
type: "fuel",
|
6481
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6482
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6483
|
+
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6484
|
+
decimals: 6
|
6485
|
+
}
|
6486
|
+
]
|
6487
|
+
},
|
6488
|
+
{
|
6489
|
+
name: "USDe",
|
6490
|
+
symbol: "USDe",
|
6491
|
+
icon: "USDe.svg",
|
6492
|
+
networks: [
|
6493
|
+
{
|
6494
|
+
type: "ethereum",
|
6495
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6496
|
+
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6497
|
+
decimals: 18
|
6498
|
+
},
|
6499
|
+
{
|
6500
|
+
type: "fuel",
|
6501
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6502
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6503
|
+
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6504
|
+
decimals: 9
|
6505
|
+
}
|
6506
|
+
]
|
6507
|
+
},
|
6508
|
+
{
|
6509
|
+
name: "sUSDe",
|
6510
|
+
symbol: "sUSDe",
|
6511
|
+
icon: "sUSDe.webp",
|
6512
|
+
networks: [
|
6513
|
+
{
|
6514
|
+
type: "ethereum",
|
6515
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6516
|
+
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6517
|
+
decimals: 18
|
6518
|
+
},
|
6519
|
+
{
|
6520
|
+
type: "fuel",
|
6521
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6522
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6523
|
+
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6524
|
+
decimals: 9
|
6525
|
+
}
|
6526
|
+
]
|
6527
|
+
},
|
6528
|
+
{
|
6529
|
+
name: "rsUSDe",
|
6530
|
+
symbol: "rsUSDe",
|
6531
|
+
icon: "rsUSDe.svg",
|
6532
|
+
networks: [
|
6533
|
+
{
|
6534
|
+
type: "ethereum",
|
6535
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6536
|
+
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6537
|
+
decimals: 18
|
6538
|
+
},
|
6539
|
+
{
|
6540
|
+
type: "fuel",
|
6541
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6542
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6543
|
+
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6544
|
+
decimals: 9
|
6545
|
+
}
|
6546
|
+
]
|
6547
|
+
},
|
6548
|
+
{
|
6549
|
+
name: "wstETH",
|
6550
|
+
symbol: "wstETH",
|
6551
|
+
icon: "wsteth.svg",
|
6552
|
+
networks: [
|
6553
|
+
{
|
6554
|
+
type: "ethereum",
|
6555
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6556
|
+
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6557
|
+
decimals: 18
|
6558
|
+
},
|
6559
|
+
{
|
6560
|
+
type: "fuel",
|
6561
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6562
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6563
|
+
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6564
|
+
decimals: 9
|
6565
|
+
}
|
6566
|
+
]
|
6567
|
+
},
|
6568
|
+
{
|
6569
|
+
name: "ezETH",
|
6570
|
+
symbol: "ezETH",
|
6571
|
+
icon: "ezeth.webp",
|
6572
|
+
networks: [
|
6573
|
+
{
|
6574
|
+
type: "ethereum",
|
6575
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6576
|
+
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6577
|
+
decimals: 18
|
6578
|
+
},
|
6579
|
+
{
|
6580
|
+
type: "fuel",
|
6581
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6582
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6583
|
+
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6584
|
+
decimals: 9
|
6585
|
+
}
|
6586
|
+
]
|
6587
|
+
},
|
6588
|
+
{
|
6589
|
+
name: "pzETH",
|
6590
|
+
symbol: "pzETH",
|
6591
|
+
icon: "pzETH.webp",
|
6592
|
+
networks: [
|
6593
|
+
{
|
6594
|
+
type: "ethereum",
|
6595
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6596
|
+
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6597
|
+
decimals: 18
|
6598
|
+
},
|
6599
|
+
{
|
6600
|
+
type: "fuel",
|
6601
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6602
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6603
|
+
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6604
|
+
decimals: 9
|
6605
|
+
}
|
6606
|
+
]
|
6607
|
+
},
|
6608
|
+
{
|
6609
|
+
name: "Re7LRT",
|
6610
|
+
symbol: "Re7LRT",
|
6611
|
+
icon: "Re7LRT.png",
|
6612
|
+
networks: [
|
6613
|
+
{
|
6614
|
+
type: "ethereum",
|
6615
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6616
|
+
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6617
|
+
decimals: 18
|
6618
|
+
},
|
6619
|
+
{
|
6620
|
+
type: "fuel",
|
6621
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6622
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6623
|
+
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6624
|
+
decimals: 9
|
6625
|
+
}
|
6626
|
+
]
|
6627
|
+
},
|
6628
|
+
{
|
6629
|
+
name: "steakLRT",
|
6630
|
+
symbol: "steakLRT",
|
6631
|
+
icon: "steakLRT.png",
|
6632
|
+
networks: [
|
6633
|
+
{
|
6634
|
+
type: "ethereum",
|
6635
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6636
|
+
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6637
|
+
decimals: 18
|
6638
|
+
},
|
6639
|
+
{
|
6640
|
+
type: "fuel",
|
6641
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6642
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6643
|
+
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6644
|
+
decimals: 9
|
5808
6645
|
}
|
5809
6646
|
]
|
5810
6647
|
}
|
@@ -5813,7 +6650,7 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5813
6650
|
|
5814
6651
|
// src/test-utils/test-asset-id.ts
|
5815
6652
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
5816
|
-
import { hexlify as
|
6653
|
+
import { hexlify as hexlify18 } from "@fuel-ts/utils";
|
5817
6654
|
var _TestAssetId = class {
|
5818
6655
|
constructor(value) {
|
5819
6656
|
this.value = value;
|
@@ -5821,7 +6658,7 @@ var _TestAssetId = class {
|
|
5821
6658
|
static random(count = 1) {
|
5822
6659
|
const assetIds = [];
|
5823
6660
|
for (let i = 0; i < count; i++) {
|
5824
|
-
assetIds.push(new _TestAssetId(
|
6661
|
+
assetIds.push(new _TestAssetId(hexlify18(randomBytes4(32))));
|
5825
6662
|
}
|
5826
6663
|
return assetIds;
|
5827
6664
|
}
|
@@ -5836,23 +6673,23 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
5836
6673
|
|
5837
6674
|
// src/test-utils/wallet-config.ts
|
5838
6675
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
5839
|
-
import { FuelError as
|
5840
|
-
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as
|
6676
|
+
import { FuelError as FuelError24 } from "@fuel-ts/errors";
|
6677
|
+
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
|
5841
6678
|
|
5842
6679
|
// src/wallet/base-wallet-unlocked.ts
|
5843
6680
|
import { hashMessage } from "@fuel-ts/hasher";
|
5844
|
-
import { hexlify as
|
6681
|
+
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
5845
6682
|
|
5846
6683
|
// src/account.ts
|
5847
6684
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
5848
6685
|
import { Address as Address4 } from "@fuel-ts/address";
|
5849
6686
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
5850
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
6687
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5851
6688
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
5852
6689
|
import { bn as bn19 } from "@fuel-ts/math";
|
5853
6690
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5854
|
-
import { arrayify as
|
5855
|
-
import { clone as
|
6691
|
+
import { arrayify as arrayify16, hexlify as hexlify19, isDefined as isDefined3 } from "@fuel-ts/utils";
|
6692
|
+
import { clone as clone9 } from "ramda";
|
5856
6693
|
|
5857
6694
|
// src/providers/utils/merge-quantities.ts
|
5858
6695
|
var mergeQuantities = (...coinQuantities) => {
|
@@ -5871,16 +6708,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
5871
6708
|
// src/utils/formatTransferToContractScriptData.ts
|
5872
6709
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5873
6710
|
import { BN as BN3 } from "@fuel-ts/math";
|
5874
|
-
import { arrayify as
|
6711
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
5875
6712
|
import * as asm from "@fuels/vm-asm";
|
5876
6713
|
var formatTransferToContractScriptData = (params) => {
|
5877
6714
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5878
6715
|
const numberCoder = new BigNumberCoder2("u64");
|
5879
6716
|
const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
|
5880
6717
|
const scriptData = Uint8Array.from([
|
5881
|
-
...
|
6718
|
+
...arrayify15(hexlifiedContractId),
|
5882
6719
|
...encoded,
|
5883
|
-
...
|
6720
|
+
...arrayify15(assetId)
|
5884
6721
|
]);
|
5885
6722
|
return scriptData;
|
5886
6723
|
};
|
@@ -5941,7 +6778,7 @@ var Account = class extends AbstractAccount {
|
|
5941
6778
|
*/
|
5942
6779
|
get provider() {
|
5943
6780
|
if (!this._provider) {
|
5944
|
-
throw new
|
6781
|
+
throw new FuelError19(ErrorCode16.MISSING_PROVIDER, "Provider not set");
|
5945
6782
|
}
|
5946
6783
|
return this._provider;
|
5947
6784
|
}
|
@@ -6059,7 +6896,7 @@ var Account = class extends AbstractAccount {
|
|
6059
6896
|
);
|
6060
6897
|
request.addResources(resources);
|
6061
6898
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6062
|
-
const requestToReestimate2 =
|
6899
|
+
const requestToReestimate2 = clone9(request);
|
6063
6900
|
if (addedSignatures) {
|
6064
6901
|
Array.from({ length: addedSignatures }).forEach(
|
6065
6902
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6092,13 +6929,13 @@ var Account = class extends AbstractAccount {
|
|
6092
6929
|
fundingAttempts += 1;
|
6093
6930
|
}
|
6094
6931
|
if (needsToBeFunded) {
|
6095
|
-
throw new
|
6932
|
+
throw new FuelError19(
|
6096
6933
|
ErrorCode16.NOT_ENOUGH_FUNDS,
|
6097
6934
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6098
6935
|
);
|
6099
6936
|
}
|
6100
6937
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6101
|
-
const requestToReestimate =
|
6938
|
+
const requestToReestimate = clone9(request);
|
6102
6939
|
if (addedSignatures) {
|
6103
6940
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6104
6941
|
}
|
@@ -6198,7 +7035,7 @@ var Account = class extends AbstractAccount {
|
|
6198
7035
|
*/
|
6199
7036
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6200
7037
|
if (bn19(amount).lte(0)) {
|
6201
|
-
throw new
|
7038
|
+
throw new FuelError19(
|
6202
7039
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6203
7040
|
"Transfer amount must be a positive number."
|
6204
7041
|
);
|
@@ -6238,14 +7075,14 @@ var Account = class extends AbstractAccount {
|
|
6238
7075
|
*/
|
6239
7076
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6240
7077
|
const recipientAddress = Address4.fromAddressOrString(recipient);
|
6241
|
-
const recipientDataArray =
|
7078
|
+
const recipientDataArray = arrayify16(
|
6242
7079
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6243
7080
|
);
|
6244
|
-
const amountDataArray =
|
7081
|
+
const amountDataArray = arrayify16(
|
6245
7082
|
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
6246
7083
|
);
|
6247
7084
|
const script = new Uint8Array([
|
6248
|
-
...
|
7085
|
+
...arrayify16(withdrawScript.bytes),
|
6249
7086
|
...recipientDataArray,
|
6250
7087
|
...amountDataArray
|
6251
7088
|
]);
|
@@ -6274,7 +7111,7 @@ var Account = class extends AbstractAccount {
|
|
6274
7111
|
* @returns A promise that resolves to the transaction cost object.
|
6275
7112
|
*/
|
6276
7113
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6277
|
-
const txRequestClone =
|
7114
|
+
const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
|
6278
7115
|
const baseAssetId = this.provider.getBaseAssetId();
|
6279
7116
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6280
7117
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
@@ -6325,7 +7162,7 @@ var Account = class extends AbstractAccount {
|
|
6325
7162
|
*/
|
6326
7163
|
async signMessage(message) {
|
6327
7164
|
if (!this._connector) {
|
6328
|
-
throw new
|
7165
|
+
throw new FuelError19(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6329
7166
|
}
|
6330
7167
|
return this._connector.signMessage(this.address.toString(), message);
|
6331
7168
|
}
|
@@ -6337,7 +7174,7 @@ var Account = class extends AbstractAccount {
|
|
6337
7174
|
*/
|
6338
7175
|
async signTransaction(transactionRequestLike) {
|
6339
7176
|
if (!this._connector) {
|
6340
|
-
throw new
|
7177
|
+
throw new FuelError19(
|
6341
7178
|
ErrorCode16.MISSING_CONNECTOR,
|
6342
7179
|
"A connector is required to sign transactions."
|
6343
7180
|
);
|
@@ -6387,7 +7224,7 @@ var Account = class extends AbstractAccount {
|
|
6387
7224
|
*/
|
6388
7225
|
generateFakeResources(coins) {
|
6389
7226
|
return coins.map((coin) => ({
|
6390
|
-
id:
|
7227
|
+
id: hexlify19(randomBytes5(UTXO_ID_LEN3)),
|
6391
7228
|
owner: this.address,
|
6392
7229
|
blockCreated: bn19(1),
|
6393
7230
|
txCreatedIdx: bn19(1),
|
@@ -6397,7 +7234,7 @@ var Account = class extends AbstractAccount {
|
|
6397
7234
|
/** @hidden * */
|
6398
7235
|
validateTransferAmount(amount) {
|
6399
7236
|
if (bn19(amount).lte(0)) {
|
6400
|
-
throw new
|
7237
|
+
throw new FuelError19(
|
6401
7238
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6402
7239
|
"Transfer amount must be a positive number."
|
6403
7240
|
);
|
@@ -6427,7 +7264,7 @@ var Account = class extends AbstractAccount {
|
|
6427
7264
|
if (!isDefined3(setGasLimit)) {
|
6428
7265
|
request.gasLimit = gasUsed;
|
6429
7266
|
} else if (gasUsed.gt(setGasLimit)) {
|
6430
|
-
throw new
|
7267
|
+
throw new FuelError19(
|
6431
7268
|
ErrorCode16.GAS_LIMIT_TOO_LOW,
|
6432
7269
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6433
7270
|
);
|
@@ -6435,7 +7272,7 @@ var Account = class extends AbstractAccount {
|
|
6435
7272
|
if (!isDefined3(setMaxFee)) {
|
6436
7273
|
request.maxFee = maxFee;
|
6437
7274
|
} else if (maxFee.gt(setMaxFee)) {
|
6438
|
-
throw new
|
7275
|
+
throw new FuelError19(
|
6439
7276
|
ErrorCode16.MAX_FEE_TOO_LOW,
|
6440
7277
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6441
7278
|
);
|
@@ -6456,8 +7293,8 @@ import {
|
|
6456
7293
|
encryptJsonWalletData,
|
6457
7294
|
randomUUID as randomUUID2
|
6458
7295
|
} from "@fuel-ts/crypto";
|
6459
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6460
|
-
import { hexlify as
|
7296
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
7297
|
+
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
6461
7298
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6462
7299
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6463
7300
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6533,13 +7370,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6533
7370
|
const macHashUint8Array = keccak256(data);
|
6534
7371
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6535
7372
|
if (mac !== macHash) {
|
6536
|
-
throw new
|
7373
|
+
throw new FuelError20(
|
6537
7374
|
ErrorCode17.INVALID_PASSWORD,
|
6538
7375
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6539
7376
|
);
|
6540
7377
|
}
|
6541
7378
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
6542
|
-
const privateKey =
|
7379
|
+
const privateKey = hexlify20(buffer);
|
6543
7380
|
return privateKey;
|
6544
7381
|
}
|
6545
7382
|
|
@@ -6584,7 +7421,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6584
7421
|
*/
|
6585
7422
|
async signMessage(message) {
|
6586
7423
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
6587
|
-
return
|
7424
|
+
return hexlify21(signedMessage);
|
6588
7425
|
}
|
6589
7426
|
/**
|
6590
7427
|
* Signs a transaction with the wallet's private key.
|
@@ -6597,7 +7434,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6597
7434
|
const chainId = this.provider.getChainId();
|
6598
7435
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6599
7436
|
const signature = await this.signer().sign(hashedTransaction);
|
6600
|
-
return
|
7437
|
+
return hexlify21(signature);
|
6601
7438
|
}
|
6602
7439
|
/**
|
6603
7440
|
* Populates a transaction with the witnesses signature.
|
@@ -6664,16 +7501,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6664
7501
|
|
6665
7502
|
// src/hdwallet/hdwallet.ts
|
6666
7503
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6667
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
7504
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
6668
7505
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6669
7506
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6670
|
-
import { arrayify as
|
7507
|
+
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6671
7508
|
|
6672
7509
|
// src/mnemonic/mnemonic.ts
|
6673
7510
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6674
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7511
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
6675
7512
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6676
|
-
import { arrayify as
|
7513
|
+
import { arrayify as arrayify18, hexlify as hexlify22, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6677
7514
|
|
6678
7515
|
// src/wordlists/words/english.ts
|
6679
7516
|
var english = [
|
@@ -8728,9 +9565,9 @@ var english = [
|
|
8728
9565
|
];
|
8729
9566
|
|
8730
9567
|
// src/mnemonic/utils.ts
|
8731
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
9568
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
8732
9569
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8733
|
-
import { arrayify as
|
9570
|
+
import { arrayify as arrayify17 } from "@fuel-ts/utils";
|
8734
9571
|
function getLowerMask(bits) {
|
8735
9572
|
return (1 << bits) - 1;
|
8736
9573
|
}
|
@@ -8765,19 +9602,19 @@ function entropyToMnemonicIndices(entropy) {
|
|
8765
9602
|
}
|
8766
9603
|
}
|
8767
9604
|
const checksumBits = entropy.length / 4;
|
8768
|
-
const checksum =
|
9605
|
+
const checksum = arrayify17(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
8769
9606
|
indices[indices.length - 1] <<= checksumBits;
|
8770
9607
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8771
9608
|
return indices;
|
8772
9609
|
}
|
8773
9610
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8774
9611
|
const size = Math.ceil(11 * words.length / 8);
|
8775
|
-
const entropy =
|
9612
|
+
const entropy = arrayify17(new Uint8Array(size));
|
8776
9613
|
let offset = 0;
|
8777
9614
|
for (let i = 0; i < words.length; i += 1) {
|
8778
9615
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8779
9616
|
if (index === -1) {
|
8780
|
-
throw new
|
9617
|
+
throw new FuelError21(
|
8781
9618
|
ErrorCode18.INVALID_MNEMONIC,
|
8782
9619
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8783
9620
|
);
|
@@ -8792,9 +9629,9 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8792
9629
|
const entropyBits = 32 * words.length / 3;
|
8793
9630
|
const checksumBits = words.length / 3;
|
8794
9631
|
const checksumMask = getUpperMask(checksumBits);
|
8795
|
-
const checksum =
|
9632
|
+
const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8796
9633
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8797
|
-
throw new
|
9634
|
+
throw new FuelError21(
|
8798
9635
|
ErrorCode18.INVALID_CHECKSUM,
|
8799
9636
|
"Checksum validation failed for the provided mnemonic."
|
8800
9637
|
);
|
@@ -8809,7 +9646,7 @@ var TestnetPRV = "0x04358394";
|
|
8809
9646
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8810
9647
|
function assertWordList(wordlist) {
|
8811
9648
|
if (wordlist.length !== 2048) {
|
8812
|
-
throw new
|
9649
|
+
throw new FuelError22(
|
8813
9650
|
ErrorCode19.INVALID_WORD_LIST,
|
8814
9651
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8815
9652
|
);
|
@@ -8817,7 +9654,7 @@ function assertWordList(wordlist) {
|
|
8817
9654
|
}
|
8818
9655
|
function assertEntropy(entropy) {
|
8819
9656
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8820
|
-
throw new
|
9657
|
+
throw new FuelError22(
|
8821
9658
|
ErrorCode19.INVALID_ENTROPY,
|
8822
9659
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8823
9660
|
);
|
@@ -8828,7 +9665,7 @@ function assertMnemonic(words) {
|
|
8828
9665
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8829
9666
|
", "
|
8830
9667
|
)}] words, but got ${words.length}.`;
|
8831
|
-
throw new
|
9668
|
+
throw new FuelError22(ErrorCode19.INVALID_MNEMONIC, errorMsg);
|
8832
9669
|
}
|
8833
9670
|
}
|
8834
9671
|
var Mnemonic = class {
|
@@ -8867,7 +9704,7 @@ var Mnemonic = class {
|
|
8867
9704
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8868
9705
|
const words = getWords(phrase);
|
8869
9706
|
assertMnemonic(words);
|
8870
|
-
return
|
9707
|
+
return hexlify22(mnemonicWordsToEntropy(words, wordlist));
|
8871
9708
|
}
|
8872
9709
|
/**
|
8873
9710
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8875,7 +9712,7 @@ var Mnemonic = class {
|
|
8875
9712
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8876
9713
|
*/
|
8877
9714
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8878
|
-
const entropyBytes =
|
9715
|
+
const entropyBytes = arrayify18(entropy);
|
8879
9716
|
assertWordList(wordlist);
|
8880
9717
|
assertEntropy(entropyBytes);
|
8881
9718
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8944,14 +9781,14 @@ var Mnemonic = class {
|
|
8944
9781
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8945
9782
|
*/
|
8946
9783
|
static masterKeysFromSeed(seed) {
|
8947
|
-
const seedArray =
|
9784
|
+
const seedArray = arrayify18(seed);
|
8948
9785
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8949
|
-
throw new
|
9786
|
+
throw new FuelError22(
|
8950
9787
|
ErrorCode19.INVALID_SEED,
|
8951
9788
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8952
9789
|
);
|
8953
9790
|
}
|
8954
|
-
return
|
9791
|
+
return arrayify18(computeHmac("sha512", MasterSecret, seedArray));
|
8955
9792
|
}
|
8956
9793
|
/**
|
8957
9794
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8962,7 +9799,7 @@ var Mnemonic = class {
|
|
8962
9799
|
*/
|
8963
9800
|
static seedToExtendedKey(seed, testnet = false) {
|
8964
9801
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8965
|
-
const prefix =
|
9802
|
+
const prefix = arrayify18(testnet ? TestnetPRV : MainnetPRV);
|
8966
9803
|
const depth = "0x00";
|
8967
9804
|
const fingerprint = "0x00000000";
|
8968
9805
|
const index = "0x00000000";
|
@@ -8992,7 +9829,7 @@ var Mnemonic = class {
|
|
8992
9829
|
* @returns A randomly generated mnemonic
|
8993
9830
|
*/
|
8994
9831
|
static generate(size = 32, extraEntropy = "") {
|
8995
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size),
|
9832
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
|
8996
9833
|
return Mnemonic.entropyToMnemonic(entropy);
|
8997
9834
|
}
|
8998
9835
|
};
|
@@ -9000,10 +9837,10 @@ var mnemonic_default = Mnemonic;
|
|
9000
9837
|
|
9001
9838
|
// src/hdwallet/hdwallet.ts
|
9002
9839
|
var HARDENED_INDEX = 2147483648;
|
9003
|
-
var MainnetPRV2 =
|
9004
|
-
var MainnetPUB =
|
9005
|
-
var TestnetPRV2 =
|
9006
|
-
var TestnetPUB =
|
9840
|
+
var MainnetPRV2 = hexlify23("0x0488ade4");
|
9841
|
+
var MainnetPUB = hexlify23("0x0488b21e");
|
9842
|
+
var TestnetPRV2 = hexlify23("0x04358394");
|
9843
|
+
var TestnetPUB = hexlify23("0x043587cf");
|
9007
9844
|
function base58check(data) {
|
9008
9845
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9009
9846
|
}
|
@@ -9014,17 +9851,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9014
9851
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9015
9852
|
}
|
9016
9853
|
function isPublicExtendedKey(extendedKey) {
|
9017
|
-
return [MainnetPUB, TestnetPUB].includes(
|
9854
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify23(extendedKey.slice(0, 4)));
|
9018
9855
|
}
|
9019
9856
|
function isValidExtendedKey(extendedKey) {
|
9020
9857
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9021
|
-
|
9858
|
+
hexlify23(extendedKey.slice(0, 4))
|
9022
9859
|
);
|
9023
9860
|
}
|
9024
9861
|
function parsePath(path2, depth = 0) {
|
9025
9862
|
const components = path2.split("/");
|
9026
9863
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9027
|
-
throw new
|
9864
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9028
9865
|
}
|
9029
9866
|
if (components[0] === "m") {
|
9030
9867
|
components.shift();
|
@@ -9036,8 +9873,8 @@ function parsePath(path2, depth = 0) {
|
|
9036
9873
|
var HDWallet = class {
|
9037
9874
|
depth = 0;
|
9038
9875
|
index = 0;
|
9039
|
-
fingerprint =
|
9040
|
-
parentFingerprint =
|
9876
|
+
fingerprint = hexlify23("0x00000000");
|
9877
|
+
parentFingerprint = hexlify23("0x00000000");
|
9041
9878
|
privateKey;
|
9042
9879
|
publicKey;
|
9043
9880
|
chainCode;
|
@@ -9049,16 +9886,16 @@ var HDWallet = class {
|
|
9049
9886
|
constructor(config) {
|
9050
9887
|
if (config.privateKey) {
|
9051
9888
|
const signer = new Signer(config.privateKey);
|
9052
|
-
this.publicKey =
|
9053
|
-
this.privateKey =
|
9889
|
+
this.publicKey = hexlify23(signer.compressedPublicKey);
|
9890
|
+
this.privateKey = hexlify23(config.privateKey);
|
9054
9891
|
} else {
|
9055
9892
|
if (!config.publicKey) {
|
9056
|
-
throw new
|
9893
|
+
throw new FuelError23(
|
9057
9894
|
ErrorCode20.HD_WALLET_ERROR,
|
9058
9895
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9059
9896
|
);
|
9060
9897
|
}
|
9061
|
-
this.publicKey =
|
9898
|
+
this.publicKey = hexlify23(config.publicKey);
|
9062
9899
|
}
|
9063
9900
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9064
9901
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -9077,23 +9914,23 @@ var HDWallet = class {
|
|
9077
9914
|
* @returns A new instance of HDWallet on the derived index
|
9078
9915
|
*/
|
9079
9916
|
deriveIndex(index) {
|
9080
|
-
const privateKey = this.privateKey &&
|
9081
|
-
const publicKey =
|
9082
|
-
const chainCode =
|
9917
|
+
const privateKey = this.privateKey && arrayify19(this.privateKey);
|
9918
|
+
const publicKey = arrayify19(this.publicKey);
|
9919
|
+
const chainCode = arrayify19(this.chainCode);
|
9083
9920
|
const data = new Uint8Array(37);
|
9084
9921
|
if (index & HARDENED_INDEX) {
|
9085
9922
|
if (!privateKey) {
|
9086
|
-
throw new
|
9923
|
+
throw new FuelError23(
|
9087
9924
|
ErrorCode20.HD_WALLET_ERROR,
|
9088
9925
|
"Cannot derive a hardened index without a private Key."
|
9089
9926
|
);
|
9090
9927
|
}
|
9091
9928
|
data.set(privateKey, 1);
|
9092
9929
|
} else {
|
9093
|
-
data.set(
|
9930
|
+
data.set(arrayify19(this.publicKey));
|
9094
9931
|
}
|
9095
9932
|
data.set(toBytes2(index, 4), 33);
|
9096
|
-
const bytes =
|
9933
|
+
const bytes = arrayify19(computeHmac2("sha512", chainCode, data));
|
9097
9934
|
const IL = bytes.slice(0, 32);
|
9098
9935
|
const IR = bytes.slice(32);
|
9099
9936
|
if (privateKey) {
|
@@ -9107,7 +9944,7 @@ var HDWallet = class {
|
|
9107
9944
|
parentFingerprint: this.fingerprint
|
9108
9945
|
});
|
9109
9946
|
}
|
9110
|
-
const signer = new Signer(
|
9947
|
+
const signer = new Signer(hexlify23(IL));
|
9111
9948
|
const Ki = signer.addPoint(publicKey);
|
9112
9949
|
return new HDWallet({
|
9113
9950
|
publicKey: Ki,
|
@@ -9136,18 +9973,18 @@ var HDWallet = class {
|
|
9136
9973
|
*/
|
9137
9974
|
toExtendedKey(isPublic = false, testnet = false) {
|
9138
9975
|
if (this.depth >= 256) {
|
9139
|
-
throw new
|
9976
|
+
throw new FuelError23(
|
9140
9977
|
ErrorCode20.HD_WALLET_ERROR,
|
9141
9978
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9142
9979
|
);
|
9143
9980
|
}
|
9144
9981
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9145
|
-
const depth =
|
9982
|
+
const depth = hexlify23(Uint8Array.from([this.depth]));
|
9146
9983
|
const parentFingerprint = this.parentFingerprint;
|
9147
9984
|
const index = toHex(this.index, 4);
|
9148
9985
|
const chainCode = this.chainCode;
|
9149
9986
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
9150
|
-
const extendedKey =
|
9987
|
+
const extendedKey = arrayify19(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9151
9988
|
return base58check(extendedKey);
|
9152
9989
|
}
|
9153
9990
|
/**
|
@@ -9159,34 +9996,34 @@ var HDWallet = class {
|
|
9159
9996
|
static fromSeed(seed) {
|
9160
9997
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9161
9998
|
return new HDWallet({
|
9162
|
-
chainCode:
|
9163
|
-
privateKey:
|
9999
|
+
chainCode: arrayify19(masterKey.slice(32)),
|
10000
|
+
privateKey: arrayify19(masterKey.slice(0, 32))
|
9164
10001
|
});
|
9165
10002
|
}
|
9166
10003
|
static fromExtendedKey(extendedKey) {
|
9167
|
-
const decoded =
|
9168
|
-
const bytes =
|
10004
|
+
const decoded = hexlify23(toBytes2(decodeBase58(extendedKey)));
|
10005
|
+
const bytes = arrayify19(decoded);
|
9169
10006
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9170
10007
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9171
|
-
throw new
|
10008
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9172
10009
|
}
|
9173
10010
|
if (!validChecksum) {
|
9174
|
-
throw new
|
10011
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9175
10012
|
}
|
9176
10013
|
const depth = bytes[4];
|
9177
|
-
const parentFingerprint =
|
9178
|
-
const index = parseInt(
|
9179
|
-
const chainCode =
|
10014
|
+
const parentFingerprint = hexlify23(bytes.slice(5, 9));
|
10015
|
+
const index = parseInt(hexlify23(bytes.slice(9, 13)).substring(2), 16);
|
10016
|
+
const chainCode = hexlify23(bytes.slice(13, 45));
|
9180
10017
|
const key = bytes.slice(45, 78);
|
9181
10018
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9182
|
-
throw new
|
10019
|
+
throw new FuelError23(
|
9183
10020
|
ErrorCode20.HD_WALLET_ERROR,
|
9184
10021
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9185
10022
|
);
|
9186
10023
|
}
|
9187
10024
|
if (isPublicExtendedKey(bytes)) {
|
9188
10025
|
if (key[0] !== 3) {
|
9189
|
-
throw new
|
10026
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
|
9190
10027
|
}
|
9191
10028
|
return new HDWallet({
|
9192
10029
|
publicKey: key,
|
@@ -9197,7 +10034,7 @@ var HDWallet = class {
|
|
9197
10034
|
});
|
9198
10035
|
}
|
9199
10036
|
if (key[0] !== 0) {
|
9200
|
-
throw new
|
10037
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
|
9201
10038
|
}
|
9202
10039
|
return new HDWallet({
|
9203
10040
|
privateKey: key.slice(1),
|
@@ -9427,7 +10264,7 @@ var WalletsConfig = class {
|
|
9427
10264
|
tx_pointer_block_height: 0,
|
9428
10265
|
tx_pointer_tx_idx: 0,
|
9429
10266
|
output_index: 0,
|
9430
|
-
tx_id:
|
10267
|
+
tx_id: hexlify24(randomBytes8(32))
|
9431
10268
|
});
|
9432
10269
|
}
|
9433
10270
|
});
|
@@ -9441,26 +10278,26 @@ var WalletsConfig = class {
|
|
9441
10278
|
amountPerCoin
|
9442
10279
|
}) {
|
9443
10280
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
9444
|
-
throw new
|
9445
|
-
|
10281
|
+
throw new FuelError24(
|
10282
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9446
10283
|
"Number of wallets must be greater than zero."
|
9447
10284
|
);
|
9448
10285
|
}
|
9449
10286
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
9450
|
-
throw new
|
9451
|
-
|
10287
|
+
throw new FuelError24(
|
10288
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9452
10289
|
"Number of assets per wallet must be greater than zero."
|
9453
10290
|
);
|
9454
10291
|
}
|
9455
10292
|
if (coinsPerAsset <= 0) {
|
9456
|
-
throw new
|
9457
|
-
|
10293
|
+
throw new FuelError24(
|
10294
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9458
10295
|
"Number of coins per asset must be greater than zero."
|
9459
10296
|
);
|
9460
10297
|
}
|
9461
10298
|
if (amountPerCoin < 0) {
|
9462
|
-
throw new
|
9463
|
-
|
10299
|
+
throw new FuelError24(
|
10300
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9464
10301
|
"Amount per coin must be greater than or equal to zero."
|
9465
10302
|
);
|
9466
10303
|
}
|
@@ -9534,7 +10371,7 @@ async function setupTestProviderAndWallets({
|
|
9534
10371
|
import { Address as Address6 } from "@fuel-ts/address";
|
9535
10372
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
9536
10373
|
import { bn as bn21 } from "@fuel-ts/math";
|
9537
|
-
import { hexlify as
|
10374
|
+
import { hexlify as hexlify25 } from "@fuel-ts/utils";
|
9538
10375
|
var TestMessage = class {
|
9539
10376
|
sender;
|
9540
10377
|
recipient;
|
@@ -9551,7 +10388,7 @@ var TestMessage = class {
|
|
9551
10388
|
constructor({
|
9552
10389
|
sender = Address6.fromRandom(),
|
9553
10390
|
recipient = Address6.fromRandom(),
|
9554
|
-
nonce =
|
10391
|
+
nonce = hexlify25(randomBytes9(32)),
|
9555
10392
|
amount = 1e6,
|
9556
10393
|
data = "",
|
9557
10394
|
// Will default to empty data in order to be a spendable message
|