@fuel-ts/account 0.94.5 → 0.94.6
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 +3 -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 +1620 -967
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1308 -405
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1237 -338
- package/dist/index.mjs.map +1 -1
- 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 +1614 -963
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1219 -332
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1161 -271
- 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 +18 -17
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";
|
@@ -2044,6 +2044,39 @@ function calculateMetadataGasForTxBlob({
|
|
2044
2044
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2045
2045
|
return txId.add(blobLen);
|
2046
2046
|
}
|
2047
|
+
function calculateMetadataGasForTxUpgrade({
|
2048
|
+
gasCosts,
|
2049
|
+
txBytesSize,
|
2050
|
+
consensusSize
|
2051
|
+
}) {
|
2052
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2053
|
+
if (consensusSize) {
|
2054
|
+
const consensusLen = resolveGasDependentCosts(consensusSize, gasCosts.s256);
|
2055
|
+
txId.add(consensusLen);
|
2056
|
+
}
|
2057
|
+
return txId;
|
2058
|
+
}
|
2059
|
+
function calculateMetadataGasForTxUpload({
|
2060
|
+
gasCosts,
|
2061
|
+
txBytesSize,
|
2062
|
+
subsectionSize,
|
2063
|
+
subsectionsSize
|
2064
|
+
}) {
|
2065
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2066
|
+
const subsectionLen = resolveGasDependentCosts(subsectionSize, gasCosts.s256);
|
2067
|
+
txId.add(subsectionLen);
|
2068
|
+
const subsectionsLen = resolveGasDependentCosts(subsectionsSize, gasCosts.stateRoot);
|
2069
|
+
txId.add(subsectionsLen);
|
2070
|
+
return txId;
|
2071
|
+
}
|
2072
|
+
function calculateMinGasForTxUpload({
|
2073
|
+
gasCosts,
|
2074
|
+
baseMinGas,
|
2075
|
+
subsectionSize
|
2076
|
+
}) {
|
2077
|
+
const additionalStoragePerByte = bn5(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2078
|
+
return bn5(baseMinGas).add(additionalStoragePerByte);
|
2079
|
+
}
|
2047
2080
|
var calculateGasFee = (params) => {
|
2048
2081
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2049
2082
|
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
@@ -3194,50 +3227,316 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3194
3227
|
}
|
3195
3228
|
};
|
3196
3229
|
|
3230
|
+
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3231
|
+
import { FuelError as FuelError10 } from "@fuel-ts/errors";
|
3232
|
+
import { hash as hash2 } from "@fuel-ts/hasher";
|
3233
|
+
import {
|
3234
|
+
TransactionType as TransactionType5,
|
3235
|
+
UpgradePurposeTypeEnum
|
3236
|
+
} from "@fuel-ts/transactions";
|
3237
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
3238
|
+
import { clone as clone6 } from "ramda";
|
3239
|
+
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3240
|
+
static from(obj) {
|
3241
|
+
if (obj instanceof UpgradeTransactionRequest) {
|
3242
|
+
return obj;
|
3243
|
+
}
|
3244
|
+
return new this(clone6(obj));
|
3245
|
+
}
|
3246
|
+
/** The type of transaction */
|
3247
|
+
type = TransactionType5.Upgrade;
|
3248
|
+
/** The upgrade purpose */
|
3249
|
+
upgradePurpose;
|
3250
|
+
/** Witness index of consensus */
|
3251
|
+
bytecodeWitnessIndex;
|
3252
|
+
/**
|
3253
|
+
* Creates an instance `UpgradeTransactionRequest`.
|
3254
|
+
*
|
3255
|
+
* @param upgradeTransactionRequestLike - The initial values for the instance
|
3256
|
+
*/
|
3257
|
+
constructor({
|
3258
|
+
upgradePurpose,
|
3259
|
+
bytecodeWitnessIndex,
|
3260
|
+
...rest
|
3261
|
+
} = {}) {
|
3262
|
+
super(rest);
|
3263
|
+
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
3264
|
+
this.upgradePurpose = upgradePurpose ?? {
|
3265
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3266
|
+
checksum: "0x"
|
3267
|
+
};
|
3268
|
+
}
|
3269
|
+
/**
|
3270
|
+
* Adds a consensus parameters upgrade purpose.
|
3271
|
+
*
|
3272
|
+
* @param consensus - The consensus bytecode.
|
3273
|
+
*
|
3274
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3275
|
+
*/
|
3276
|
+
addConsensusParametersUpgradePurpose(consensus) {
|
3277
|
+
this.bytecodeWitnessIndex = this.addWitness(consensus);
|
3278
|
+
this.upgradePurpose = {
|
3279
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3280
|
+
checksum: hash2(consensus)
|
3281
|
+
};
|
3282
|
+
return this;
|
3283
|
+
}
|
3284
|
+
/**
|
3285
|
+
* Adds a state transition upgrade purpose.
|
3286
|
+
*
|
3287
|
+
* @param bytecodeRoot - The Merkle root of the state transition.
|
3288
|
+
*
|
3289
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3290
|
+
*/
|
3291
|
+
addStateTransitionUpgradePurpose(bytecodeRoot) {
|
3292
|
+
this.upgradePurpose = {
|
3293
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3294
|
+
data: hexlify14(bytecodeRoot)
|
3295
|
+
};
|
3296
|
+
return this;
|
3297
|
+
}
|
3298
|
+
/**
|
3299
|
+
* Adds an upgrade purpose.
|
3300
|
+
*
|
3301
|
+
* @param type - The upgrade purpose type.
|
3302
|
+
* @param data - The bytecode or merkle root of upgrade purpose
|
3303
|
+
*
|
3304
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3305
|
+
*/
|
3306
|
+
addUpgradePurpose(type, data) {
|
3307
|
+
if (type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3308
|
+
this.addConsensusParametersUpgradePurpose(data);
|
3309
|
+
}
|
3310
|
+
if (type === UpgradePurposeTypeEnum.StateTransition) {
|
3311
|
+
this.addStateTransitionUpgradePurpose(data);
|
3312
|
+
}
|
3313
|
+
return this;
|
3314
|
+
}
|
3315
|
+
/**
|
3316
|
+
* Converts the transaction request to a `TransactionUpgrade`.
|
3317
|
+
*
|
3318
|
+
* @returns The transaction create object.
|
3319
|
+
*/
|
3320
|
+
toTransaction() {
|
3321
|
+
let upgradePurpose;
|
3322
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3323
|
+
upgradePurpose = {
|
3324
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3325
|
+
data: {
|
3326
|
+
witnessIndex: this.bytecodeWitnessIndex,
|
3327
|
+
checksum: this.upgradePurpose.checksum
|
3328
|
+
}
|
3329
|
+
};
|
3330
|
+
} else if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3331
|
+
upgradePurpose = {
|
3332
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3333
|
+
data: {
|
3334
|
+
bytecodeRoot: hexlify14(this.upgradePurpose.data)
|
3335
|
+
}
|
3336
|
+
};
|
3337
|
+
} else {
|
3338
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3339
|
+
}
|
3340
|
+
return {
|
3341
|
+
type: TransactionType5.Upgrade,
|
3342
|
+
...super.getBaseTransaction(),
|
3343
|
+
upgradePurpose
|
3344
|
+
};
|
3345
|
+
}
|
3346
|
+
/**
|
3347
|
+
* Gets the Transaction ID by hashing the transaction
|
3348
|
+
*
|
3349
|
+
* @param chainId - The chain ID.
|
3350
|
+
*
|
3351
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3352
|
+
*/
|
3353
|
+
getTransactionId(chainId) {
|
3354
|
+
return hashTransaction(this, chainId);
|
3355
|
+
}
|
3356
|
+
/**
|
3357
|
+
* Calculates the metadata gas cost for an upgrade transaction.
|
3358
|
+
*
|
3359
|
+
* @param gasCosts - gas costs passed from the chain.
|
3360
|
+
*
|
3361
|
+
* @returns metadata gas cost for the upgrade transaction.
|
3362
|
+
*/
|
3363
|
+
metadataGas(gasCosts) {
|
3364
|
+
const txBytesSize = this.byteSize();
|
3365
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3366
|
+
const witnessIndex = this.bytecodeWitnessIndex;
|
3367
|
+
const consensusSize = this.witnesses[witnessIndex].length;
|
3368
|
+
return calculateMetadataGasForTxUpgrade({
|
3369
|
+
gasCosts,
|
3370
|
+
txBytesSize,
|
3371
|
+
consensusSize
|
3372
|
+
});
|
3373
|
+
}
|
3374
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3375
|
+
return calculateMetadataGasForTxUpgrade({
|
3376
|
+
gasCosts,
|
3377
|
+
txBytesSize
|
3378
|
+
});
|
3379
|
+
}
|
3380
|
+
throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3381
|
+
}
|
3382
|
+
};
|
3383
|
+
|
3384
|
+
// src/providers/transaction-request/upload-transaction-request.ts
|
3385
|
+
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
3386
|
+
import { TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
3387
|
+
import { arrayify as arrayify10, hexlify as hexlify15 } from "@fuel-ts/utils";
|
3388
|
+
import { clone as clone7 } from "ramda";
|
3389
|
+
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3390
|
+
static from(obj) {
|
3391
|
+
if (obj instanceof UploadTransactionRequest) {
|
3392
|
+
return obj;
|
3393
|
+
}
|
3394
|
+
return new this(clone7(obj));
|
3395
|
+
}
|
3396
|
+
/** Type of the transaction */
|
3397
|
+
type = TransactionType6.Upload;
|
3398
|
+
/** The witness index of the subsection of the bytecode. */
|
3399
|
+
witnessIndex;
|
3400
|
+
/** The subsection data. */
|
3401
|
+
subsection;
|
3402
|
+
/**
|
3403
|
+
* Creates an instance `UploadTransactionRequest`.
|
3404
|
+
*
|
3405
|
+
* @param uploadTransactionRequestLike - The initial values for the instance
|
3406
|
+
*/
|
3407
|
+
constructor({ witnessIndex, subsection, ...rest } = {}) {
|
3408
|
+
super(rest);
|
3409
|
+
this.witnessIndex = witnessIndex ?? 0;
|
3410
|
+
this.subsection = subsection ?? {
|
3411
|
+
proofSet: [],
|
3412
|
+
root: ZeroBytes328,
|
3413
|
+
subsectionIndex: 0,
|
3414
|
+
subsectionsNumber: 0
|
3415
|
+
};
|
3416
|
+
}
|
3417
|
+
/**
|
3418
|
+
* Adds the subsection.
|
3419
|
+
*
|
3420
|
+
* @param subsection - The subsection data.
|
3421
|
+
*/
|
3422
|
+
addSubsection(subsection) {
|
3423
|
+
const { subsection: subsectionBytecode, ...rest } = subsection;
|
3424
|
+
this.subsection = rest;
|
3425
|
+
this.witnessIndex = this.addWitness(subsectionBytecode);
|
3426
|
+
}
|
3427
|
+
/**
|
3428
|
+
* Gets the Transaction Request by hashing the transaction.
|
3429
|
+
*
|
3430
|
+
* @param chainId - The chain ID.
|
3431
|
+
*
|
3432
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3433
|
+
*/
|
3434
|
+
getTransactionId(chainId) {
|
3435
|
+
return hashTransaction(this, chainId);
|
3436
|
+
}
|
3437
|
+
/**
|
3438
|
+
* Converts the transaction request to a `TransactionUpload`.
|
3439
|
+
*
|
3440
|
+
* @returns The transaction create object.
|
3441
|
+
*/
|
3442
|
+
toTransaction() {
|
3443
|
+
const baseTransaction = this.getBaseTransaction();
|
3444
|
+
const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
|
3445
|
+
return {
|
3446
|
+
type: TransactionType6.Upload,
|
3447
|
+
...baseTransaction,
|
3448
|
+
subsectionIndex,
|
3449
|
+
subsectionsNumber,
|
3450
|
+
root: hexlify15(root),
|
3451
|
+
proofSet: proofSet.map(hexlify15),
|
3452
|
+
witnessIndex: this.witnessIndex,
|
3453
|
+
proofSetCount: proofSet.length
|
3454
|
+
};
|
3455
|
+
}
|
3456
|
+
/**
|
3457
|
+
* Calculates the metadata gas cost for an upload transaction.
|
3458
|
+
*
|
3459
|
+
* @param gasCosts - gas costs passed from the chain.
|
3460
|
+
*
|
3461
|
+
* @returns metadata gas cost for the upload transaction.
|
3462
|
+
*/
|
3463
|
+
metadataGas(gasCosts) {
|
3464
|
+
return calculateMetadataGasForTxUpload({
|
3465
|
+
gasCosts,
|
3466
|
+
txBytesSize: this.byteSize(),
|
3467
|
+
subsectionSize: arrayify10(this.witnesses[this.witnessIndex]).length,
|
3468
|
+
subsectionsSize: this.subsection.subsectionsNumber
|
3469
|
+
});
|
3470
|
+
}
|
3471
|
+
/**
|
3472
|
+
* Calculates the minimum gas for an upload transaction.
|
3473
|
+
*
|
3474
|
+
* @param chainInfo - The chain information.
|
3475
|
+
*
|
3476
|
+
* @returns the minimum gas for the upload transaction
|
3477
|
+
*/
|
3478
|
+
calculateMinGas(chainInfo) {
|
3479
|
+
const minGas = super.calculateMinGas(chainInfo);
|
3480
|
+
const { gasCosts } = chainInfo.consensusParameters;
|
3481
|
+
const bytecode = this.witnesses[this.witnessIndex] ?? ZeroBytes328;
|
3482
|
+
return calculateMinGasForTxUpload({
|
3483
|
+
gasCosts,
|
3484
|
+
baseMinGas: minGas.toNumber(),
|
3485
|
+
subsectionSize: arrayify10(bytecode).length
|
3486
|
+
});
|
3487
|
+
}
|
3488
|
+
};
|
3489
|
+
|
3197
3490
|
// src/providers/transaction-request/utils.ts
|
3198
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
3199
|
-
import { TransactionType as
|
3491
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3492
|
+
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3200
3493
|
var transactionRequestify = (obj) => {
|
3201
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
3494
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
3202
3495
|
return obj;
|
3203
3496
|
}
|
3204
3497
|
const { type } = obj;
|
3205
3498
|
switch (obj.type) {
|
3206
|
-
case
|
3499
|
+
case TransactionType7.Script: {
|
3207
3500
|
return ScriptTransactionRequest.from(obj);
|
3208
3501
|
}
|
3209
|
-
case
|
3502
|
+
case TransactionType7.Create: {
|
3210
3503
|
return CreateTransactionRequest.from(obj);
|
3211
3504
|
}
|
3212
|
-
case
|
3505
|
+
case TransactionType7.Blob: {
|
3213
3506
|
return BlobTransactionRequest.from(obj);
|
3214
3507
|
}
|
3508
|
+
case TransactionType7.Upgrade: {
|
3509
|
+
return UpgradeTransactionRequest.from(obj);
|
3510
|
+
}
|
3511
|
+
case TransactionType7.Upload: {
|
3512
|
+
return UploadTransactionRequest.from(obj);
|
3513
|
+
}
|
3215
3514
|
default: {
|
3216
|
-
throw new
|
3515
|
+
throw new FuelError11(
|
3217
3516
|
ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
|
3218
3517
|
`Unsupported transaction type: ${type}.`
|
3219
3518
|
);
|
3220
3519
|
}
|
3221
3520
|
}
|
3222
3521
|
};
|
3223
|
-
var isTransactionTypeScript = (request) => request.type ===
|
3224
|
-
var isTransactionTypeCreate = (request) => request.type ===
|
3522
|
+
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3523
|
+
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3225
3524
|
|
3226
3525
|
// src/providers/transaction-response/transaction-response.ts
|
3227
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3526
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3228
3527
|
import { bn as bn16 } from "@fuel-ts/math";
|
3229
3528
|
import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3230
|
-
import { arrayify as
|
3529
|
+
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
3231
3530
|
|
3232
3531
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3233
3532
|
import { bn as bn15 } from "@fuel-ts/math";
|
3234
3533
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
3235
|
-
import { DateTime, hexlify as
|
3534
|
+
import { DateTime, hexlify as hexlify16 } from "@fuel-ts/utils";
|
3236
3535
|
|
3237
3536
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3238
3537
|
import { bn as bn12 } from "@fuel-ts/math";
|
3239
|
-
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as
|
3240
|
-
import { arrayify as
|
3538
|
+
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3539
|
+
import { arrayify as arrayify11 } from "@fuel-ts/utils";
|
3241
3540
|
var calculateTXFeeForSummary = (params) => {
|
3242
3541
|
const {
|
3243
3542
|
gasPrice,
|
@@ -3251,17 +3550,17 @@ var calculateTXFeeForSummary = (params) => {
|
|
3251
3550
|
}
|
3252
3551
|
const gasPerByte = bn12(feeParams.gasPerByte);
|
3253
3552
|
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3254
|
-
const transactionBytes =
|
3553
|
+
const transactionBytes = arrayify11(rawPayload);
|
3255
3554
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
3256
3555
|
const { type, witnesses, inputs, policies } = transaction;
|
3257
3556
|
let metadataGas = bn12(0);
|
3258
3557
|
let gasLimit = bn12(0);
|
3259
|
-
if (type !==
|
3558
|
+
if (type !== TransactionType8.Create && type !== TransactionType8.Script) {
|
3260
3559
|
return bn12(0);
|
3261
3560
|
}
|
3262
|
-
if (type ===
|
3561
|
+
if (type === TransactionType8.Create) {
|
3263
3562
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3264
|
-
const contractBytesSize = bn12(
|
3563
|
+
const contractBytesSize = bn12(arrayify11(witnesses[bytecodeWitnessIndex].data).length);
|
3265
3564
|
metadataGas = calculateMetadataGasForTxCreate({
|
3266
3565
|
contractBytesSize,
|
3267
3566
|
gasCosts,
|
@@ -3305,10 +3604,10 @@ var calculateTXFeeForSummary = (params) => {
|
|
3305
3604
|
};
|
3306
3605
|
|
3307
3606
|
// src/providers/transaction-summary/operations.ts
|
3308
|
-
import { ZeroBytes32 as
|
3309
|
-
import { ErrorCode as ErrorCode10, FuelError as
|
3607
|
+
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3608
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3310
3609
|
import { bn as bn13 } from "@fuel-ts/math";
|
3311
|
-
import { ReceiptType as ReceiptType4, TransactionType as
|
3610
|
+
import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3312
3611
|
|
3313
3612
|
// src/providers/transaction-summary/call.ts
|
3314
3613
|
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
@@ -3344,7 +3643,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3344
3643
|
};
|
3345
3644
|
|
3346
3645
|
// src/providers/transaction-summary/input.ts
|
3347
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3646
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
|
3348
3647
|
import { BN } from "@fuel-ts/math";
|
3349
3648
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3350
3649
|
function getInputsByTypes(inputs, types) {
|
@@ -3413,7 +3712,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3413
3712
|
return void 0;
|
3414
3713
|
}
|
3415
3714
|
if (contractInput.type !== InputType6.Contract) {
|
3416
|
-
throw new
|
3715
|
+
throw new FuelError12(
|
3417
3716
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
3418
3717
|
`Contract input should be of type 'contract'.`
|
3419
3718
|
);
|
@@ -3454,16 +3753,20 @@ function getReceiptsByType(receipts, type) {
|
|
3454
3753
|
}
|
3455
3754
|
function getTransactionTypeName(transactionType) {
|
3456
3755
|
switch (transactionType) {
|
3457
|
-
case
|
3756
|
+
case TransactionType9.Mint:
|
3458
3757
|
return "Mint" /* Mint */;
|
3459
|
-
case
|
3758
|
+
case TransactionType9.Create:
|
3460
3759
|
return "Create" /* Create */;
|
3461
|
-
case
|
3760
|
+
case TransactionType9.Script:
|
3462
3761
|
return "Script" /* Script */;
|
3463
|
-
case
|
3762
|
+
case TransactionType9.Blob:
|
3464
3763
|
return "Blob" /* Blob */;
|
3764
|
+
case TransactionType9.Upgrade:
|
3765
|
+
return "Upgrade" /* Upgrade */;
|
3766
|
+
case TransactionType9.Upload:
|
3767
|
+
return "Upload" /* Upload */;
|
3465
3768
|
default:
|
3466
|
-
throw new
|
3769
|
+
throw new FuelError13(
|
3467
3770
|
ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
|
3468
3771
|
`Unsupported transaction type: ${transactionType}.`
|
3469
3772
|
);
|
@@ -3603,7 +3906,7 @@ function getAssetsSent(receipt) {
|
|
3603
3906
|
];
|
3604
3907
|
}
|
3605
3908
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3606
|
-
const assetId = receipt.assetId ===
|
3909
|
+
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
3607
3910
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3608
3911
|
if (!input) {
|
3609
3912
|
return [];
|
@@ -3659,7 +3962,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3659
3962
|
const { to: toAddress, assetId, amount } = receipt;
|
3660
3963
|
let { from: fromAddress } = receipt;
|
3661
3964
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3662
|
-
if (
|
3965
|
+
if (ZeroBytes329 === fromAddress) {
|
3663
3966
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3664
3967
|
fromAddress = change?.to || fromAddress;
|
3665
3968
|
}
|
@@ -3862,7 +4165,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3862
4165
|
};
|
3863
4166
|
|
3864
4167
|
// src/providers/transaction-summary/status.ts
|
3865
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
4168
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
3866
4169
|
import { bn as bn14 } from "@fuel-ts/math";
|
3867
4170
|
var getTransactionStatusName = (gqlStatus) => {
|
3868
4171
|
switch (gqlStatus) {
|
@@ -3875,7 +4178,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3875
4178
|
case "SqueezedOutStatus":
|
3876
4179
|
return "squeezedout" /* squeezedout */;
|
3877
4180
|
default:
|
3878
|
-
throw new
|
4181
|
+
throw new FuelError14(
|
3879
4182
|
ErrorCode11.INVALID_TRANSACTION_STATUS,
|
3880
4183
|
`Invalid transaction status: ${gqlStatus}.`
|
3881
4184
|
);
|
@@ -3945,7 +4248,7 @@ function assembleTransactionSummary(params) {
|
|
3945
4248
|
baseAssetId
|
3946
4249
|
} = params;
|
3947
4250
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3948
|
-
const rawPayload =
|
4251
|
+
const rawPayload = hexlify16(transactionBytes);
|
3949
4252
|
const operations = getOperations({
|
3950
4253
|
transactionType: transaction.type,
|
3951
4254
|
inputs: transaction.inputs || [],
|
@@ -4126,7 +4429,7 @@ var TransactionResponse = class {
|
|
4126
4429
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
4127
4430
|
return {
|
4128
4431
|
tx: this.decodeTransaction(gqlTransaction),
|
4129
|
-
bytes:
|
4432
|
+
bytes: arrayify12(gqlTransaction.rawPayload)
|
4130
4433
|
};
|
4131
4434
|
}
|
4132
4435
|
getReceipts() {
|
@@ -4171,7 +4474,7 @@ var TransactionResponse = class {
|
|
4171
4474
|
*/
|
4172
4475
|
decodeTransaction(transactionWithReceipts) {
|
4173
4476
|
return new TransactionCoder4().decode(
|
4174
|
-
|
4477
|
+
arrayify12(transactionWithReceipts.rawPayload),
|
4175
4478
|
0
|
4176
4479
|
)?.[0];
|
4177
4480
|
}
|
@@ -4218,7 +4521,7 @@ var TransactionResponse = class {
|
|
4218
4521
|
this.status = statusChange;
|
4219
4522
|
if (statusChange.type === "SqueezedOutStatus") {
|
4220
4523
|
this.unsetResourceCache();
|
4221
|
-
throw new
|
4524
|
+
throw new FuelError15(
|
4222
4525
|
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
4223
4526
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4224
4527
|
);
|
@@ -4327,18 +4630,18 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4327
4630
|
}
|
4328
4631
|
|
4329
4632
|
// src/providers/utils/handle-gql-error-message.ts
|
4330
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4633
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4331
4634
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4332
4635
|
switch (errorMessage) {
|
4333
4636
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4334
|
-
throw new
|
4637
|
+
throw new FuelError16(
|
4335
4638
|
ErrorCode13.NOT_ENOUGH_FUNDS,
|
4336
4639
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4337
4640
|
{},
|
4338
4641
|
rawError
|
4339
4642
|
);
|
4340
4643
|
default:
|
4341
|
-
throw new
|
4644
|
+
throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4342
4645
|
}
|
4343
4646
|
};
|
4344
4647
|
|
@@ -4420,21 +4723,31 @@ var _Provider = class {
|
|
4420
4723
|
* @hidden
|
4421
4724
|
*/
|
4422
4725
|
constructor(url, options = {}) {
|
4423
|
-
this.url = url;
|
4424
4726
|
/**
|
4425
4727
|
* @hidden
|
4426
4728
|
*/
|
4427
4729
|
__privateAdd(this, _cacheInputs);
|
4428
4730
|
__publicField(this, "operations");
|
4429
4731
|
__publicField(this, "cache");
|
4732
|
+
/** @hidden */
|
4733
|
+
__publicField(this, "url");
|
4734
|
+
/** @hidden */
|
4735
|
+
__publicField(this, "urlWithoutAuth");
|
4430
4736
|
__publicField(this, "options", {
|
4431
4737
|
timeout: void 0,
|
4432
4738
|
resourceCacheTTL: void 0,
|
4433
4739
|
fetch: void 0,
|
4434
|
-
retryOptions: void 0
|
4740
|
+
retryOptions: void 0,
|
4741
|
+
headers: void 0
|
4435
4742
|
});
|
4743
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4744
|
+
this.url = rawUrl;
|
4745
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4436
4746
|
this.options = { ...this.options, ...options };
|
4437
4747
|
this.url = url;
|
4748
|
+
if (headers) {
|
4749
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4750
|
+
}
|
4438
4751
|
this.operations = this.createOperations();
|
4439
4752
|
const { resourceCacheTTL } = this.options;
|
4440
4753
|
if (isDefined2(resourceCacheTTL)) {
|
@@ -4456,12 +4769,16 @@ var _Provider = class {
|
|
4456
4769
|
* @hidden
|
4457
4770
|
*/
|
4458
4771
|
static getFetchFn(options) {
|
4459
|
-
const { retryOptions, timeout } = options;
|
4772
|
+
const { retryOptions, timeout, headers } = options;
|
4460
4773
|
return autoRetryFetch(async (...args) => {
|
4461
4774
|
const url = args[0];
|
4462
4775
|
const request = args[1];
|
4463
4776
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
4464
|
-
let fullRequest = {
|
4777
|
+
let fullRequest = {
|
4778
|
+
...request,
|
4779
|
+
signal,
|
4780
|
+
headers: { ...request?.headers, ...headers }
|
4781
|
+
};
|
4465
4782
|
if (options.requestMiddleware) {
|
4466
4783
|
fullRequest = await options.requestMiddleware(fullRequest);
|
4467
4784
|
}
|
@@ -4469,15 +4786,23 @@ var _Provider = class {
|
|
4469
4786
|
}, retryOptions);
|
4470
4787
|
}
|
4471
4788
|
static extractBasicAuth(url) {
|
4472
|
-
|
4789
|
+
let parsedUrl;
|
4790
|
+
try {
|
4791
|
+
parsedUrl = new URL(url);
|
4792
|
+
} catch (error) {
|
4793
|
+
throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4794
|
+
}
|
4473
4795
|
const username = parsedUrl.username;
|
4474
4796
|
const password = parsedUrl.password;
|
4475
|
-
const
|
4797
|
+
const urlWithoutAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4476
4798
|
if (!(username && password)) {
|
4477
|
-
return { url,
|
4799
|
+
return { url, urlWithoutAuth: url, headers: void 0 };
|
4478
4800
|
}
|
4479
|
-
|
4480
|
-
|
4801
|
+
return {
|
4802
|
+
url,
|
4803
|
+
urlWithoutAuth,
|
4804
|
+
headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}` }
|
4805
|
+
};
|
4481
4806
|
}
|
4482
4807
|
/**
|
4483
4808
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
@@ -4488,17 +4813,7 @@ var _Provider = class {
|
|
4488
4813
|
* @returns A promise that resolves to a Provider instance.
|
4489
4814
|
*/
|
4490
4815
|
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
|
-
});
|
4816
|
+
const provider = new _Provider(url, options);
|
4502
4817
|
await provider.fetchChainAndNodeInfo();
|
4503
4818
|
return provider;
|
4504
4819
|
}
|
@@ -4508,9 +4823,9 @@ var _Provider = class {
|
|
4508
4823
|
* @returns the chain information configuration.
|
4509
4824
|
*/
|
4510
4825
|
getChain() {
|
4511
|
-
const chain = _Provider.chainInfoCache[this.
|
4826
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4512
4827
|
if (!chain) {
|
4513
|
-
throw new
|
4828
|
+
throw new FuelError17(
|
4514
4829
|
ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
|
4515
4830
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4516
4831
|
);
|
@@ -4523,9 +4838,9 @@ var _Provider = class {
|
|
4523
4838
|
* @returns the node information configuration.
|
4524
4839
|
*/
|
4525
4840
|
getNode() {
|
4526
|
-
const node = _Provider.nodeInfoCache[this.
|
4841
|
+
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4527
4842
|
if (!node) {
|
4528
|
-
throw new
|
4843
|
+
throw new FuelError17(
|
4529
4844
|
ErrorCode14.NODE_INFO_CACHE_EMPTY,
|
4530
4845
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4531
4846
|
);
|
@@ -4557,8 +4872,11 @@ var _Provider = class {
|
|
4557
4872
|
* @param options - Additional options for the provider.
|
4558
4873
|
*/
|
4559
4874
|
async connect(url, options) {
|
4560
|
-
|
4875
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4876
|
+
this.url = rawUrl;
|
4877
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4561
4878
|
this.options = options ?? this.options;
|
4879
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4562
4880
|
this.operations = this.createOperations();
|
4563
4881
|
await this.fetchChainAndNodeInfo();
|
4564
4882
|
}
|
@@ -4598,7 +4916,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4598
4916
|
*/
|
4599
4917
|
createOperations() {
|
4600
4918
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4601
|
-
const gqlClient = new GraphQLClient(this.
|
4919
|
+
const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
|
4602
4920
|
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4603
4921
|
responseMiddleware: (response) => {
|
4604
4922
|
if ("response" in response) {
|
@@ -4616,7 +4934,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4616
4934
|
const isSubscription = opDefinition?.operation === "subscription";
|
4617
4935
|
if (isSubscription) {
|
4618
4936
|
return FuelGraphqlSubscriber.create({
|
4619
|
-
url: this.
|
4937
|
+
url: this.urlWithoutAuth,
|
4620
4938
|
query,
|
4621
4939
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4622
4940
|
variables: vars
|
@@ -4679,7 +4997,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4679
4997
|
utxoValidation: nodeInfo.utxoValidation,
|
4680
4998
|
vmBacktrace: nodeInfo.vmBacktrace
|
4681
4999
|
};
|
4682
|
-
_Provider.nodeInfoCache[this.
|
5000
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
4683
5001
|
return processedNodeInfo;
|
4684
5002
|
}
|
4685
5003
|
/**
|
@@ -4690,7 +5008,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4690
5008
|
async fetchChain() {
|
4691
5009
|
const { chain } = await this.operations.getChain();
|
4692
5010
|
const processedChain = processGqlChain(chain);
|
4693
|
-
_Provider.chainInfoCache[this.
|
5011
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
4694
5012
|
return processedChain;
|
4695
5013
|
}
|
4696
5014
|
/**
|
@@ -4718,13 +5036,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4718
5036
|
validateTransaction(tx, consensusParameters) {
|
4719
5037
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4720
5038
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4721
|
-
throw new
|
5039
|
+
throw new FuelError17(
|
4722
5040
|
ErrorCode14.MAX_INPUTS_EXCEEDED,
|
4723
5041
|
"The transaction exceeds the maximum allowed number of inputs."
|
4724
5042
|
);
|
4725
5043
|
}
|
4726
5044
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4727
|
-
throw new
|
5045
|
+
throw new FuelError17(
|
4728
5046
|
ErrorCode14.MAX_OUTPUTS_EXCEEDED,
|
4729
5047
|
"The transaction exceeds the maximum allowed number of outputs."
|
4730
5048
|
);
|
@@ -4747,7 +5065,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4747
5065
|
}
|
4748
5066
|
const { consensusParameters } = this.getChain();
|
4749
5067
|
this.validateTransaction(transactionRequest, consensusParameters);
|
4750
|
-
const encodedTransaction =
|
5068
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4751
5069
|
let abis;
|
4752
5070
|
if (isTransactionTypeScript(transactionRequest)) {
|
4753
5071
|
abis = transactionRequest.abis;
|
@@ -4771,7 +5089,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4771
5089
|
if (estimateTxDependencies) {
|
4772
5090
|
return this.estimateTxDependencies(transactionRequest);
|
4773
5091
|
}
|
4774
|
-
const encodedTransaction =
|
5092
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4775
5093
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4776
5094
|
encodedTransactions: encodedTransaction,
|
4777
5095
|
utxoValidation: utxoValidation || false
|
@@ -4791,13 +5109,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4791
5109
|
async estimatePredicates(transactionRequest) {
|
4792
5110
|
const shouldEstimatePredicates = Boolean(
|
4793
5111
|
transactionRequest.inputs.find(
|
4794
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(
|
5112
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify13(input.predicate), arrayify13("0x")) && new BN2(input.predicateGasUsed).isZero()
|
4795
5113
|
)
|
4796
5114
|
);
|
4797
5115
|
if (!shouldEstimatePredicates) {
|
4798
5116
|
return transactionRequest;
|
4799
5117
|
}
|
4800
|
-
const encodedTransaction =
|
5118
|
+
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
4801
5119
|
const response = await this.operations.estimatePredicates({
|
4802
5120
|
encodedTransaction
|
4803
5121
|
});
|
@@ -4838,7 +5156,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4838
5156
|
const {
|
4839
5157
|
dryRun: [{ receipts: rawReceipts, status }]
|
4840
5158
|
} = await this.operations.dryRun({
|
4841
|
-
encodedTransactions: [
|
5159
|
+
encodedTransactions: [hexlify17(transactionRequest.toTransactionBytes())],
|
4842
5160
|
utxoValidation: false
|
4843
5161
|
});
|
4844
5162
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4884,11 +5202,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4884
5202
|
missingContractIds: [],
|
4885
5203
|
dryRunStatus: void 0
|
4886
5204
|
}));
|
4887
|
-
const allRequests =
|
5205
|
+
const allRequests = clone8(transactionRequests);
|
4888
5206
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4889
5207
|
allRequests.forEach((req, index) => {
|
4890
5208
|
if (isTransactionTypeScript(req)) {
|
4891
|
-
serializedTransactionsMap.set(index,
|
5209
|
+
serializedTransactionsMap.set(index, hexlify17(req.toTransactionBytes()));
|
4892
5210
|
}
|
4893
5211
|
});
|
4894
5212
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4924,7 +5242,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4924
5242
|
transactionRequest: request
|
4925
5243
|
});
|
4926
5244
|
request.maxFee = maxFee;
|
4927
|
-
serializedTransactionsMap.set(requestIdx,
|
5245
|
+
serializedTransactionsMap.set(requestIdx, hexlify17(request.toTransactionBytes()));
|
4928
5246
|
nextRoundTransactions.push(requestIdx);
|
4929
5247
|
}
|
4930
5248
|
}
|
@@ -4945,7 +5263,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4945
5263
|
if (estimateTxDependencies) {
|
4946
5264
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4947
5265
|
}
|
4948
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
5266
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify17(tx.toTransactionBytes()));
|
4949
5267
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4950
5268
|
encodedTransactions,
|
4951
5269
|
utxoValidation: utxoValidation || false
|
@@ -5019,7 +5337,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5019
5337
|
if (estimateTxDependencies) {
|
5020
5338
|
return this.estimateTxDependencies(transactionRequest);
|
5021
5339
|
}
|
5022
|
-
const encodedTransactions = [
|
5340
|
+
const encodedTransactions = [hexlify17(transactionRequest.toTransactionBytes())];
|
5023
5341
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5024
5342
|
encodedTransactions,
|
5025
5343
|
utxoValidation: true
|
@@ -5044,13 +5362,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5044
5362
|
* @returns A promise that resolves to the transaction cost object.
|
5045
5363
|
*/
|
5046
5364
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5047
|
-
const txRequestClone =
|
5365
|
+
const txRequestClone = clone8(transactionRequestify(transactionRequestLike));
|
5048
5366
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5049
5367
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
5050
5368
|
if (isScriptTransaction) {
|
5051
5369
|
txRequestClone.gasLimit = bn17(0);
|
5052
5370
|
}
|
5053
|
-
const signedRequest =
|
5371
|
+
const signedRequest = clone8(txRequestClone);
|
5054
5372
|
let addedSignatures = 0;
|
5055
5373
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
5056
5374
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5118,7 +5436,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5118
5436
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5119
5437
|
inputArgs: paginationArgs
|
5120
5438
|
}),
|
5121
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
5439
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify17(assetId) }
|
5122
5440
|
});
|
5123
5441
|
const coins = edges.map(({ node }) => ({
|
5124
5442
|
id: node.utxoId,
|
@@ -5144,8 +5462,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5144
5462
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5145
5463
|
const ownerAddress = Address3.fromAddressOrString(owner);
|
5146
5464
|
const excludeInput = {
|
5147
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
5148
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
5465
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify17(nonce)) || [],
|
5466
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify17(id)) || []
|
5149
5467
|
};
|
5150
5468
|
if (this.cache) {
|
5151
5469
|
const cached = this.cache.getActiveData();
|
@@ -5155,7 +5473,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5155
5473
|
const coinsQuery = {
|
5156
5474
|
owner: ownerAddress.toB256(),
|
5157
5475
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5158
|
-
assetId:
|
5476
|
+
assetId: hexlify17(assetId),
|
5159
5477
|
amount: amount.toString(10),
|
5160
5478
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5161
5479
|
})),
|
@@ -5310,7 +5628,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5310
5628
|
},
|
5311
5629
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5312
5630
|
transactions: block.transactions.map(
|
5313
|
-
(tx) => new TransactionCoder5().decode(
|
5631
|
+
(tx) => new TransactionCoder5().decode(arrayify13(tx.rawPayload), 0)?.[0]
|
5314
5632
|
)
|
5315
5633
|
};
|
5316
5634
|
}
|
@@ -5327,11 +5645,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5327
5645
|
}
|
5328
5646
|
try {
|
5329
5647
|
return new TransactionCoder5().decode(
|
5330
|
-
|
5648
|
+
arrayify13(transaction.rawPayload),
|
5331
5649
|
0
|
5332
5650
|
)?.[0];
|
5333
5651
|
} catch (error) {
|
5334
|
-
if (error instanceof
|
5652
|
+
if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5335
5653
|
console.warn("Unsupported transaction type encountered");
|
5336
5654
|
return null;
|
5337
5655
|
}
|
@@ -5350,9 +5668,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5350
5668
|
const coder = new TransactionCoder5();
|
5351
5669
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5352
5670
|
try {
|
5353
|
-
return coder.decode(
|
5671
|
+
return coder.decode(arrayify13(rawPayload), 0)[0];
|
5354
5672
|
} catch (error) {
|
5355
|
-
if (error instanceof
|
5673
|
+
if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5356
5674
|
console.warn("Unsupported transaction type encountered");
|
5357
5675
|
return null;
|
5358
5676
|
}
|
@@ -5384,7 +5702,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5384
5702
|
async getContractBalance(contractId, assetId) {
|
5385
5703
|
const { contractBalance } = await this.operations.getContractBalance({
|
5386
5704
|
contract: Address3.fromAddressOrString(contractId).toB256(),
|
5387
|
-
asset:
|
5705
|
+
asset: hexlify17(assetId)
|
5388
5706
|
});
|
5389
5707
|
return bn17(contractBalance.amount, 10);
|
5390
5708
|
}
|
@@ -5398,7 +5716,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5398
5716
|
async getBalance(owner, assetId) {
|
5399
5717
|
const { balance } = await this.operations.getBalance({
|
5400
5718
|
owner: Address3.fromAddressOrString(owner).toB256(),
|
5401
|
-
assetId:
|
5719
|
+
assetId: hexlify17(assetId)
|
5402
5720
|
});
|
5403
5721
|
return bn17(balance.amount, 10);
|
5404
5722
|
}
|
@@ -5478,7 +5796,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5478
5796
|
nonce
|
5479
5797
|
};
|
5480
5798
|
if (commitBlockId && commitBlockHeight) {
|
5481
|
-
throw new
|
5799
|
+
throw new FuelError17(
|
5482
5800
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5483
5801
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5484
5802
|
);
|
@@ -5662,25 +5980,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5662
5980
|
const { paginationLimit, inputArgs = {} } = params;
|
5663
5981
|
const { first, last, after, before } = inputArgs;
|
5664
5982
|
if (after && before) {
|
5665
|
-
throw new
|
5983
|
+
throw new FuelError17(
|
5666
5984
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5667
5985
|
'Pagination arguments "after" and "before" cannot be used together'
|
5668
5986
|
);
|
5669
5987
|
}
|
5670
5988
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5671
|
-
throw new
|
5989
|
+
throw new FuelError17(
|
5672
5990
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5673
5991
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5674
5992
|
);
|
5675
5993
|
}
|
5676
5994
|
if (first && before) {
|
5677
|
-
throw new
|
5995
|
+
throw new FuelError17(
|
5678
5996
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5679
5997
|
'The use of pagination argument "first" with "before" is not supported'
|
5680
5998
|
);
|
5681
5999
|
}
|
5682
6000
|
if (last && after) {
|
5683
|
-
throw new
|
6001
|
+
throw new FuelError17(
|
5684
6002
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5685
6003
|
'The use of pagination argument "last" with "after" is not supported'
|
5686
6004
|
);
|
@@ -5735,20 +6053,22 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5735
6053
|
__publicField(Provider, "nodeInfoCache", {});
|
5736
6054
|
|
5737
6055
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5738
|
-
import { ErrorCode as ErrorCode15, FuelError as
|
6056
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5739
6057
|
import { bn as bn18 } from "@fuel-ts/math";
|
5740
6058
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5741
|
-
import { arrayify as
|
6059
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
5742
6060
|
|
5743
6061
|
// src/providers/chains.ts
|
5744
6062
|
var CHAIN_IDS = {
|
5745
6063
|
eth: {
|
6064
|
+
mainnet: 1,
|
5746
6065
|
sepolia: 11155111,
|
5747
6066
|
foundry: 31337
|
5748
6067
|
},
|
5749
6068
|
fuel: {
|
5750
6069
|
devnet: 0,
|
5751
|
-
testnet: 0
|
6070
|
+
testnet: 0,
|
6071
|
+
mainnet: 9889
|
5752
6072
|
}
|
5753
6073
|
};
|
5754
6074
|
|
@@ -5794,6 +6114,11 @@ var rawAssets = [
|
|
5794
6114
|
chainId: CHAIN_IDS.eth.foundry,
|
5795
6115
|
decimals: 18
|
5796
6116
|
},
|
6117
|
+
{
|
6118
|
+
type: "ethereum",
|
6119
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6120
|
+
decimals: 18
|
6121
|
+
},
|
5797
6122
|
{
|
5798
6123
|
type: "fuel",
|
5799
6124
|
chainId: CHAIN_IDS.fuel.devnet,
|
@@ -5805,87 +6130,652 @@ var rawAssets = [
|
|
5805
6130
|
chainId: CHAIN_IDS.fuel.testnet,
|
5806
6131
|
decimals: 9,
|
5807
6132
|
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6133
|
+
},
|
6134
|
+
{
|
6135
|
+
type: "fuel",
|
6136
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6137
|
+
decimals: 9,
|
6138
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5808
6139
|
}
|
5809
6140
|
]
|
5810
|
-
}
|
5811
|
-
|
5812
|
-
|
5813
|
-
|
5814
|
-
|
5815
|
-
|
5816
|
-
|
5817
|
-
|
5818
|
-
|
5819
|
-
|
5820
|
-
|
5821
|
-
|
5822
|
-
|
5823
|
-
|
5824
|
-
|
5825
|
-
|
5826
|
-
|
5827
|
-
|
5828
|
-
}
|
5829
|
-
|
5830
|
-
|
5831
|
-
|
5832
|
-
|
5833
|
-
|
5834
|
-
|
5835
|
-
|
5836
|
-
|
5837
|
-
|
5838
|
-
|
5839
|
-
|
5840
|
-
|
5841
|
-
|
5842
|
-
|
5843
|
-
|
5844
|
-
|
5845
|
-
|
5846
|
-
|
5847
|
-
|
5848
|
-
|
5849
|
-
|
5850
|
-
|
5851
|
-
|
5852
|
-
|
5853
|
-
|
5854
|
-
|
5855
|
-
|
5856
|
-
|
5857
|
-
|
5858
|
-
|
5859
|
-
|
5860
|
-
|
5861
|
-
|
5862
|
-
|
5863
|
-
|
5864
|
-
|
5865
|
-
|
5866
|
-
|
5867
|
-
|
5868
|
-
|
5869
|
-
|
5870
|
-
|
5871
|
-
|
5872
|
-
|
5873
|
-
|
5874
|
-
|
5875
|
-
|
5876
|
-
|
5877
|
-
|
5878
|
-
|
5879
|
-
|
5880
|
-
|
5881
|
-
|
5882
|
-
|
5883
|
-
|
5884
|
-
|
5885
|
-
|
5886
|
-
|
5887
|
-
|
5888
|
-
|
6141
|
+
},
|
6142
|
+
{
|
6143
|
+
name: "WETH",
|
6144
|
+
symbol: "WETH",
|
6145
|
+
icon: "weth.svg",
|
6146
|
+
networks: [
|
6147
|
+
{
|
6148
|
+
type: "ethereum",
|
6149
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6150
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6151
|
+
decimals: 18
|
6152
|
+
},
|
6153
|
+
{
|
6154
|
+
type: "fuel",
|
6155
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6156
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6157
|
+
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6158
|
+
decimals: 18
|
6159
|
+
}
|
6160
|
+
]
|
6161
|
+
},
|
6162
|
+
{
|
6163
|
+
name: "weETH",
|
6164
|
+
symbol: "weETH",
|
6165
|
+
icon: "weETH.webp",
|
6166
|
+
networks: [
|
6167
|
+
{
|
6168
|
+
type: "ethereum",
|
6169
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6170
|
+
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6171
|
+
decimals: 18
|
6172
|
+
},
|
6173
|
+
{
|
6174
|
+
type: "fuel",
|
6175
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6176
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6177
|
+
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6178
|
+
decimals: 18
|
6179
|
+
}
|
6180
|
+
]
|
6181
|
+
},
|
6182
|
+
{
|
6183
|
+
name: "rsETH",
|
6184
|
+
symbol: "rsETH",
|
6185
|
+
icon: "rsETH.webp",
|
6186
|
+
networks: [
|
6187
|
+
{
|
6188
|
+
type: "ethereum",
|
6189
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6190
|
+
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6191
|
+
decimals: 18
|
6192
|
+
},
|
6193
|
+
{
|
6194
|
+
type: "fuel",
|
6195
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6196
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6197
|
+
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6198
|
+
decimals: 18
|
6199
|
+
}
|
6200
|
+
]
|
6201
|
+
},
|
6202
|
+
{
|
6203
|
+
name: "rETH",
|
6204
|
+
symbol: "rETH",
|
6205
|
+
icon: "reth.svg",
|
6206
|
+
networks: [
|
6207
|
+
{
|
6208
|
+
type: "ethereum",
|
6209
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6210
|
+
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6211
|
+
decimals: 18
|
6212
|
+
},
|
6213
|
+
{
|
6214
|
+
type: "fuel",
|
6215
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6216
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6217
|
+
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6218
|
+
decimals: 18
|
6219
|
+
}
|
6220
|
+
]
|
6221
|
+
},
|
6222
|
+
{
|
6223
|
+
name: "wbETH",
|
6224
|
+
symbol: "wbETH",
|
6225
|
+
icon: "wbeth.png",
|
6226
|
+
networks: [
|
6227
|
+
{
|
6228
|
+
type: "ethereum",
|
6229
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6230
|
+
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6231
|
+
decimals: 18
|
6232
|
+
},
|
6233
|
+
{
|
6234
|
+
type: "fuel",
|
6235
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6236
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6237
|
+
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6238
|
+
decimals: 18
|
6239
|
+
}
|
6240
|
+
]
|
6241
|
+
},
|
6242
|
+
{
|
6243
|
+
name: "rstETH",
|
6244
|
+
symbol: "rstETH",
|
6245
|
+
icon: "rstETH.webp",
|
6246
|
+
networks: [
|
6247
|
+
{
|
6248
|
+
type: "ethereum",
|
6249
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6250
|
+
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6251
|
+
decimals: 18
|
6252
|
+
},
|
6253
|
+
{
|
6254
|
+
type: "fuel",
|
6255
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6256
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6257
|
+
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6258
|
+
decimals: 18
|
6259
|
+
}
|
6260
|
+
]
|
6261
|
+
},
|
6262
|
+
{
|
6263
|
+
name: "amphrETH",
|
6264
|
+
symbol: "amphrETH",
|
6265
|
+
icon: "amphrETH.png",
|
6266
|
+
networks: [
|
6267
|
+
{
|
6268
|
+
type: "ethereum",
|
6269
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6270
|
+
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6271
|
+
decimals: 18
|
6272
|
+
},
|
6273
|
+
{
|
6274
|
+
type: "fuel",
|
6275
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6276
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6277
|
+
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6278
|
+
decimals: 18
|
6279
|
+
}
|
6280
|
+
]
|
6281
|
+
},
|
6282
|
+
{
|
6283
|
+
name: "Manta mBTC",
|
6284
|
+
symbol: "Manta mBTC",
|
6285
|
+
icon: "manta-mbtc.svg",
|
6286
|
+
networks: [
|
6287
|
+
{
|
6288
|
+
type: "ethereum",
|
6289
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6290
|
+
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6291
|
+
decimals: 18
|
6292
|
+
},
|
6293
|
+
{
|
6294
|
+
type: "fuel",
|
6295
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6296
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6297
|
+
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6298
|
+
decimals: 18
|
6299
|
+
}
|
6300
|
+
]
|
6301
|
+
},
|
6302
|
+
{
|
6303
|
+
name: "Manta mETH",
|
6304
|
+
symbol: "Manta mETH",
|
6305
|
+
icon: "manta-meth.svg",
|
6306
|
+
networks: [
|
6307
|
+
{
|
6308
|
+
type: "ethereum",
|
6309
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6310
|
+
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6311
|
+
decimals: 18
|
6312
|
+
},
|
6313
|
+
{
|
6314
|
+
type: "fuel",
|
6315
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6316
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6317
|
+
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6318
|
+
decimals: 18
|
6319
|
+
}
|
6320
|
+
]
|
6321
|
+
},
|
6322
|
+
{
|
6323
|
+
name: "Manta mUSD",
|
6324
|
+
symbol: "Manta mUSD",
|
6325
|
+
icon: "manta-musd.svg",
|
6326
|
+
networks: [
|
6327
|
+
{
|
6328
|
+
type: "ethereum",
|
6329
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6330
|
+
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6331
|
+
decimals: 18
|
6332
|
+
},
|
6333
|
+
{
|
6334
|
+
type: "fuel",
|
6335
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6336
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6337
|
+
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6338
|
+
decimals: 18
|
6339
|
+
}
|
6340
|
+
]
|
6341
|
+
},
|
6342
|
+
{
|
6343
|
+
name: "pumpBTC",
|
6344
|
+
symbol: "pumpBTC",
|
6345
|
+
icon: "pumpbtc.webp",
|
6346
|
+
networks: [
|
6347
|
+
{
|
6348
|
+
type: "ethereum",
|
6349
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6350
|
+
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6351
|
+
decimals: 8
|
6352
|
+
},
|
6353
|
+
{
|
6354
|
+
type: "fuel",
|
6355
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6356
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6357
|
+
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6358
|
+
decimals: 8
|
6359
|
+
}
|
6360
|
+
]
|
6361
|
+
},
|
6362
|
+
{
|
6363
|
+
name: "FBTC",
|
6364
|
+
symbol: "FBTC",
|
6365
|
+
icon: "fbtc.svg",
|
6366
|
+
networks: [
|
6367
|
+
{
|
6368
|
+
type: "ethereum",
|
6369
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6370
|
+
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6371
|
+
decimals: 8
|
6372
|
+
},
|
6373
|
+
{
|
6374
|
+
type: "fuel",
|
6375
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6376
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6377
|
+
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6378
|
+
decimals: 8
|
6379
|
+
}
|
6380
|
+
]
|
6381
|
+
},
|
6382
|
+
{
|
6383
|
+
name: "SolvBTC",
|
6384
|
+
symbol: "SolvBTC",
|
6385
|
+
icon: "solvBTC.webp",
|
6386
|
+
networks: [
|
6387
|
+
{
|
6388
|
+
type: "ethereum",
|
6389
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6390
|
+
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6391
|
+
decimals: 18
|
6392
|
+
},
|
6393
|
+
{
|
6394
|
+
type: "fuel",
|
6395
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6396
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6397
|
+
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6398
|
+
decimals: 18
|
6399
|
+
}
|
6400
|
+
]
|
6401
|
+
},
|
6402
|
+
{
|
6403
|
+
name: "SolvBTC.BBN",
|
6404
|
+
symbol: "SolvBTC.BBN",
|
6405
|
+
icon: "SolvBTC.BBN.png",
|
6406
|
+
networks: [
|
6407
|
+
{
|
6408
|
+
type: "ethereum",
|
6409
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6410
|
+
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6411
|
+
decimals: 18
|
6412
|
+
},
|
6413
|
+
{
|
6414
|
+
type: "fuel",
|
6415
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6416
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6417
|
+
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6418
|
+
decimals: 18
|
6419
|
+
}
|
6420
|
+
]
|
6421
|
+
},
|
6422
|
+
{
|
6423
|
+
name: "Mantle mETH",
|
6424
|
+
symbol: "Mantle mETH",
|
6425
|
+
icon: "mantle-meth.svg",
|
6426
|
+
networks: [
|
6427
|
+
{
|
6428
|
+
type: "ethereum",
|
6429
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6430
|
+
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6431
|
+
decimals: 18
|
6432
|
+
},
|
6433
|
+
{
|
6434
|
+
type: "fuel",
|
6435
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6436
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6437
|
+
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6438
|
+
decimals: 18
|
6439
|
+
}
|
6440
|
+
]
|
6441
|
+
},
|
6442
|
+
{
|
6443
|
+
name: "sDAI",
|
6444
|
+
symbol: "sDAI",
|
6445
|
+
icon: "sdai.svg",
|
6446
|
+
networks: [
|
6447
|
+
{
|
6448
|
+
type: "ethereum",
|
6449
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6450
|
+
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6451
|
+
decimals: 18
|
6452
|
+
},
|
6453
|
+
{
|
6454
|
+
type: "fuel",
|
6455
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6456
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6457
|
+
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6458
|
+
decimals: 18
|
6459
|
+
}
|
6460
|
+
]
|
6461
|
+
},
|
6462
|
+
{
|
6463
|
+
name: "USDT",
|
6464
|
+
symbol: "USDT",
|
6465
|
+
icon: "usdt.svg",
|
6466
|
+
networks: [
|
6467
|
+
{
|
6468
|
+
type: "ethereum",
|
6469
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6470
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6471
|
+
decimals: 6
|
6472
|
+
},
|
6473
|
+
{
|
6474
|
+
type: "fuel",
|
6475
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6476
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6477
|
+
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6478
|
+
decimals: 6
|
6479
|
+
}
|
6480
|
+
]
|
6481
|
+
},
|
6482
|
+
{
|
6483
|
+
name: "USDC",
|
6484
|
+
symbol: "USDC",
|
6485
|
+
icon: "usdc.svg",
|
6486
|
+
networks: [
|
6487
|
+
{
|
6488
|
+
type: "ethereum",
|
6489
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6490
|
+
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6491
|
+
decimals: 6
|
6492
|
+
},
|
6493
|
+
{
|
6494
|
+
type: "fuel",
|
6495
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6496
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6497
|
+
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6498
|
+
decimals: 6
|
6499
|
+
}
|
6500
|
+
]
|
6501
|
+
},
|
6502
|
+
{
|
6503
|
+
name: "USDe",
|
6504
|
+
symbol: "USDe",
|
6505
|
+
icon: "USDe.svg",
|
6506
|
+
networks: [
|
6507
|
+
{
|
6508
|
+
type: "ethereum",
|
6509
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6510
|
+
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6511
|
+
decimals: 18
|
6512
|
+
},
|
6513
|
+
{
|
6514
|
+
type: "ethereum",
|
6515
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6516
|
+
address: "0xc6387efad0f184a90b34f397c3d6fd63135ef790",
|
6517
|
+
decimals: 18
|
6518
|
+
},
|
6519
|
+
{
|
6520
|
+
type: "fuel",
|
6521
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6522
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6523
|
+
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6524
|
+
decimals: 18
|
6525
|
+
},
|
6526
|
+
{
|
6527
|
+
type: "fuel",
|
6528
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6529
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6530
|
+
assetId: "0xf5c6d72d0f2c782fa47d8e228c198a08654e9fc66ca60ad85902b1d09046a7ab",
|
6531
|
+
decimals: 18
|
6532
|
+
}
|
6533
|
+
]
|
6534
|
+
},
|
6535
|
+
{
|
6536
|
+
name: "sUSDe",
|
6537
|
+
symbol: "sUSDe",
|
6538
|
+
icon: "sUSDe.webp",
|
6539
|
+
networks: [
|
6540
|
+
{
|
6541
|
+
type: "ethereum",
|
6542
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6543
|
+
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6544
|
+
decimals: 18
|
6545
|
+
},
|
6546
|
+
{
|
6547
|
+
type: "ethereum",
|
6548
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6549
|
+
address: "0xb8f4f4eafc1d2a3c0a4d519bbf1114c311cc9b1b",
|
6550
|
+
decimals: 18
|
6551
|
+
},
|
6552
|
+
{
|
6553
|
+
type: "fuel",
|
6554
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6555
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6556
|
+
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6557
|
+
decimals: 18
|
6558
|
+
},
|
6559
|
+
{
|
6560
|
+
type: "fuel",
|
6561
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6562
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6563
|
+
assetId: "0xa86e37d385c08beddbb02c8260f9ec535d484c8ea908fc19d4e6dc8d5141fb2e",
|
6564
|
+
decimals: 18
|
6565
|
+
}
|
6566
|
+
]
|
6567
|
+
},
|
6568
|
+
{
|
6569
|
+
name: "rsUSDe",
|
6570
|
+
symbol: "rsUSDe",
|
6571
|
+
icon: "rsUSDe.svg",
|
6572
|
+
networks: [
|
6573
|
+
{
|
6574
|
+
type: "ethereum",
|
6575
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6576
|
+
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6577
|
+
decimals: 18
|
6578
|
+
},
|
6579
|
+
{
|
6580
|
+
type: "fuel",
|
6581
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6582
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6583
|
+
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6584
|
+
decimals: 18
|
6585
|
+
}
|
6586
|
+
]
|
6587
|
+
},
|
6588
|
+
{
|
6589
|
+
name: "wstETH",
|
6590
|
+
symbol: "wstETH",
|
6591
|
+
icon: "wsteth.svg",
|
6592
|
+
networks: [
|
6593
|
+
{
|
6594
|
+
type: "ethereum",
|
6595
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6596
|
+
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6597
|
+
decimals: 18
|
6598
|
+
},
|
6599
|
+
{
|
6600
|
+
type: "ethereum",
|
6601
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6602
|
+
address: "0xB82381A3fBD3FaFA77B3a7bE693342618240067b",
|
6603
|
+
decimals: 18
|
6604
|
+
},
|
6605
|
+
{
|
6606
|
+
type: "fuel",
|
6607
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6608
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6609
|
+
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6610
|
+
decimals: 18
|
6611
|
+
},
|
6612
|
+
{
|
6613
|
+
type: "fuel",
|
6614
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6615
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6616
|
+
assetId: "0x4c467e3fd4f32179e1aad3b92ebbdaa6ff6aeda5b8da5f8e64e96405eb52a7f5",
|
6617
|
+
decimals: 18
|
6618
|
+
}
|
6619
|
+
]
|
6620
|
+
},
|
6621
|
+
{
|
6622
|
+
name: "ezETH",
|
6623
|
+
symbol: "ezETH",
|
6624
|
+
icon: "ezeth.webp",
|
6625
|
+
networks: [
|
6626
|
+
{
|
6627
|
+
type: "ethereum",
|
6628
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6629
|
+
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6630
|
+
decimals: 18
|
6631
|
+
},
|
6632
|
+
{
|
6633
|
+
type: "fuel",
|
6634
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6635
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6636
|
+
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6637
|
+
decimals: 18
|
6638
|
+
}
|
6639
|
+
]
|
6640
|
+
},
|
6641
|
+
{
|
6642
|
+
name: "pzETH",
|
6643
|
+
symbol: "pzETH",
|
6644
|
+
icon: "pzETH.webp",
|
6645
|
+
networks: [
|
6646
|
+
{
|
6647
|
+
type: "ethereum",
|
6648
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6649
|
+
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6650
|
+
decimals: 18
|
6651
|
+
},
|
6652
|
+
{
|
6653
|
+
type: "fuel",
|
6654
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6655
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6656
|
+
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6657
|
+
decimals: 18
|
6658
|
+
}
|
6659
|
+
]
|
6660
|
+
},
|
6661
|
+
{
|
6662
|
+
name: "Re7LRT",
|
6663
|
+
symbol: "Re7LRT",
|
6664
|
+
icon: "Re7LRT.png",
|
6665
|
+
networks: [
|
6666
|
+
{
|
6667
|
+
type: "ethereum",
|
6668
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6669
|
+
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6670
|
+
decimals: 18
|
6671
|
+
},
|
6672
|
+
{
|
6673
|
+
type: "fuel",
|
6674
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6675
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6676
|
+
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6677
|
+
decimals: 18
|
6678
|
+
}
|
6679
|
+
]
|
6680
|
+
},
|
6681
|
+
{
|
6682
|
+
name: "steakLRT",
|
6683
|
+
symbol: "steakLRT",
|
6684
|
+
icon: "steakLRT.png",
|
6685
|
+
networks: [
|
6686
|
+
{
|
6687
|
+
type: "ethereum",
|
6688
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6689
|
+
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6690
|
+
decimals: 18
|
6691
|
+
},
|
6692
|
+
{
|
6693
|
+
type: "fuel",
|
6694
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6695
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6696
|
+
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6697
|
+
decimals: 18
|
6698
|
+
}
|
6699
|
+
]
|
6700
|
+
}
|
6701
|
+
];
|
6702
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
6703
|
+
|
6704
|
+
// src/test-utils/test-asset-id.ts
|
6705
|
+
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6706
|
+
import { hexlify as hexlify18 } from "@fuel-ts/utils";
|
6707
|
+
var _TestAssetId = class {
|
6708
|
+
constructor(value) {
|
6709
|
+
this.value = value;
|
6710
|
+
}
|
6711
|
+
static random(count = 1) {
|
6712
|
+
const assetIds = [];
|
6713
|
+
for (let i = 0; i < count; i++) {
|
6714
|
+
assetIds.push(new _TestAssetId(hexlify18(randomBytes4(32))));
|
6715
|
+
}
|
6716
|
+
return assetIds;
|
6717
|
+
}
|
6718
|
+
};
|
6719
|
+
var TestAssetId = _TestAssetId;
|
6720
|
+
__publicField(TestAssetId, "A", new _TestAssetId(
|
6721
|
+
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
6722
|
+
));
|
6723
|
+
__publicField(TestAssetId, "B", new _TestAssetId(
|
6724
|
+
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
6725
|
+
));
|
6726
|
+
|
6727
|
+
// src/test-utils/wallet-config.ts
|
6728
|
+
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6729
|
+
import { FuelError as FuelError24 } from "@fuel-ts/errors";
|
6730
|
+
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
|
6731
|
+
|
6732
|
+
// src/wallet/base-wallet-unlocked.ts
|
6733
|
+
import { hashMessage } from "@fuel-ts/hasher";
|
6734
|
+
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
6735
|
+
|
6736
|
+
// src/account.ts
|
6737
|
+
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6738
|
+
import { Address as Address4 } from "@fuel-ts/address";
|
6739
|
+
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6740
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
6741
|
+
import { AbstractAccount } from "@fuel-ts/interfaces";
|
6742
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
6743
|
+
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
6744
|
+
import { arrayify as arrayify16, hexlify as hexlify19, isDefined as isDefined3 } from "@fuel-ts/utils";
|
6745
|
+
import { clone as clone9 } from "ramda";
|
6746
|
+
|
6747
|
+
// src/providers/utils/merge-quantities.ts
|
6748
|
+
var mergeQuantities = (...coinQuantities) => {
|
6749
|
+
const resultMap = {};
|
6750
|
+
function addToMap({ amount, assetId }) {
|
6751
|
+
if (resultMap[assetId]) {
|
6752
|
+
resultMap[assetId] = resultMap[assetId].add(amount);
|
6753
|
+
} else {
|
6754
|
+
resultMap[assetId] = amount;
|
6755
|
+
}
|
6756
|
+
}
|
6757
|
+
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
6758
|
+
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
6759
|
+
};
|
6760
|
+
|
6761
|
+
// src/utils/formatTransferToContractScriptData.ts
|
6762
|
+
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
6763
|
+
import { BN as BN3 } from "@fuel-ts/math";
|
6764
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
6765
|
+
import * as asm from "@fuels/vm-asm";
|
6766
|
+
var formatTransferToContractScriptData = (params) => {
|
6767
|
+
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
6768
|
+
const numberCoder = new BigNumberCoder2("u64");
|
6769
|
+
const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
|
6770
|
+
const scriptData = Uint8Array.from([
|
6771
|
+
...arrayify15(hexlifiedContractId),
|
6772
|
+
...encoded,
|
6773
|
+
...arrayify15(assetId)
|
6774
|
+
]);
|
6775
|
+
return scriptData;
|
6776
|
+
};
|
6777
|
+
var assembleTransferToContractScript = async (params) => {
|
6778
|
+
const scriptData = formatTransferToContractScriptData(params);
|
5889
6779
|
await asm.initWasm();
|
5890
6780
|
const gtf2 = asm.gtf(16, 0, asm.GTFArgs.ScriptData);
|
5891
6781
|
const addi2 = asm.addi(17, 16, 32);
|
@@ -5941,7 +6831,7 @@ var Account = class extends AbstractAccount {
|
|
5941
6831
|
*/
|
5942
6832
|
get provider() {
|
5943
6833
|
if (!this._provider) {
|
5944
|
-
throw new
|
6834
|
+
throw new FuelError19(ErrorCode16.MISSING_PROVIDER, "Provider not set");
|
5945
6835
|
}
|
5946
6836
|
return this._provider;
|
5947
6837
|
}
|
@@ -6059,7 +6949,7 @@ var Account = class extends AbstractAccount {
|
|
6059
6949
|
);
|
6060
6950
|
request.addResources(resources);
|
6061
6951
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6062
|
-
const requestToReestimate2 =
|
6952
|
+
const requestToReestimate2 = clone9(request);
|
6063
6953
|
if (addedSignatures) {
|
6064
6954
|
Array.from({ length: addedSignatures }).forEach(
|
6065
6955
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6092,13 +6982,13 @@ var Account = class extends AbstractAccount {
|
|
6092
6982
|
fundingAttempts += 1;
|
6093
6983
|
}
|
6094
6984
|
if (needsToBeFunded) {
|
6095
|
-
throw new
|
6985
|
+
throw new FuelError19(
|
6096
6986
|
ErrorCode16.NOT_ENOUGH_FUNDS,
|
6097
6987
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6098
6988
|
);
|
6099
6989
|
}
|
6100
6990
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6101
|
-
const requestToReestimate =
|
6991
|
+
const requestToReestimate = clone9(request);
|
6102
6992
|
if (addedSignatures) {
|
6103
6993
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6104
6994
|
}
|
@@ -6198,7 +7088,7 @@ var Account = class extends AbstractAccount {
|
|
6198
7088
|
*/
|
6199
7089
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6200
7090
|
if (bn19(amount).lte(0)) {
|
6201
|
-
throw new
|
7091
|
+
throw new FuelError19(
|
6202
7092
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6203
7093
|
"Transfer amount must be a positive number."
|
6204
7094
|
);
|
@@ -6238,14 +7128,14 @@ var Account = class extends AbstractAccount {
|
|
6238
7128
|
*/
|
6239
7129
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6240
7130
|
const recipientAddress = Address4.fromAddressOrString(recipient);
|
6241
|
-
const recipientDataArray =
|
7131
|
+
const recipientDataArray = arrayify16(
|
6242
7132
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6243
7133
|
);
|
6244
|
-
const amountDataArray =
|
7134
|
+
const amountDataArray = arrayify16(
|
6245
7135
|
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
6246
7136
|
);
|
6247
7137
|
const script = new Uint8Array([
|
6248
|
-
...
|
7138
|
+
...arrayify16(withdrawScript.bytes),
|
6249
7139
|
...recipientDataArray,
|
6250
7140
|
...amountDataArray
|
6251
7141
|
]);
|
@@ -6274,7 +7164,7 @@ var Account = class extends AbstractAccount {
|
|
6274
7164
|
* @returns A promise that resolves to the transaction cost object.
|
6275
7165
|
*/
|
6276
7166
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6277
|
-
const txRequestClone =
|
7167
|
+
const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
|
6278
7168
|
const baseAssetId = this.provider.getBaseAssetId();
|
6279
7169
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6280
7170
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
@@ -6325,7 +7215,7 @@ var Account = class extends AbstractAccount {
|
|
6325
7215
|
*/
|
6326
7216
|
async signMessage(message) {
|
6327
7217
|
if (!this._connector) {
|
6328
|
-
throw new
|
7218
|
+
throw new FuelError19(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6329
7219
|
}
|
6330
7220
|
return this._connector.signMessage(this.address.toString(), message);
|
6331
7221
|
}
|
@@ -6337,7 +7227,7 @@ var Account = class extends AbstractAccount {
|
|
6337
7227
|
*/
|
6338
7228
|
async signTransaction(transactionRequestLike) {
|
6339
7229
|
if (!this._connector) {
|
6340
|
-
throw new
|
7230
|
+
throw new FuelError19(
|
6341
7231
|
ErrorCode16.MISSING_CONNECTOR,
|
6342
7232
|
"A connector is required to sign transactions."
|
6343
7233
|
);
|
@@ -6387,7 +7277,7 @@ var Account = class extends AbstractAccount {
|
|
6387
7277
|
*/
|
6388
7278
|
generateFakeResources(coins) {
|
6389
7279
|
return coins.map((coin) => ({
|
6390
|
-
id:
|
7280
|
+
id: hexlify19(randomBytes5(UTXO_ID_LEN3)),
|
6391
7281
|
owner: this.address,
|
6392
7282
|
blockCreated: bn19(1),
|
6393
7283
|
txCreatedIdx: bn19(1),
|
@@ -6397,7 +7287,7 @@ var Account = class extends AbstractAccount {
|
|
6397
7287
|
/** @hidden * */
|
6398
7288
|
validateTransferAmount(amount) {
|
6399
7289
|
if (bn19(amount).lte(0)) {
|
6400
|
-
throw new
|
7290
|
+
throw new FuelError19(
|
6401
7291
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6402
7292
|
"Transfer amount must be a positive number."
|
6403
7293
|
);
|
@@ -6427,7 +7317,7 @@ var Account = class extends AbstractAccount {
|
|
6427
7317
|
if (!isDefined3(setGasLimit)) {
|
6428
7318
|
request.gasLimit = gasUsed;
|
6429
7319
|
} else if (gasUsed.gt(setGasLimit)) {
|
6430
|
-
throw new
|
7320
|
+
throw new FuelError19(
|
6431
7321
|
ErrorCode16.GAS_LIMIT_TOO_LOW,
|
6432
7322
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6433
7323
|
);
|
@@ -6435,7 +7325,7 @@ var Account = class extends AbstractAccount {
|
|
6435
7325
|
if (!isDefined3(setMaxFee)) {
|
6436
7326
|
request.maxFee = maxFee;
|
6437
7327
|
} else if (maxFee.gt(setMaxFee)) {
|
6438
|
-
throw new
|
7328
|
+
throw new FuelError19(
|
6439
7329
|
ErrorCode16.MAX_FEE_TOO_LOW,
|
6440
7330
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6441
7331
|
);
|
@@ -6456,8 +7346,8 @@ import {
|
|
6456
7346
|
encryptJsonWalletData,
|
6457
7347
|
randomUUID as randomUUID2
|
6458
7348
|
} from "@fuel-ts/crypto";
|
6459
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6460
|
-
import { hexlify as
|
7349
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
7350
|
+
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
6461
7351
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6462
7352
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6463
7353
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6533,13 +7423,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6533
7423
|
const macHashUint8Array = keccak256(data);
|
6534
7424
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6535
7425
|
if (mac !== macHash) {
|
6536
|
-
throw new
|
7426
|
+
throw new FuelError20(
|
6537
7427
|
ErrorCode17.INVALID_PASSWORD,
|
6538
7428
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6539
7429
|
);
|
6540
7430
|
}
|
6541
7431
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
6542
|
-
const privateKey =
|
7432
|
+
const privateKey = hexlify20(buffer);
|
6543
7433
|
return privateKey;
|
6544
7434
|
}
|
6545
7435
|
|
@@ -6584,7 +7474,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6584
7474
|
*/
|
6585
7475
|
async signMessage(message) {
|
6586
7476
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
6587
|
-
return
|
7477
|
+
return hexlify21(signedMessage);
|
6588
7478
|
}
|
6589
7479
|
/**
|
6590
7480
|
* Signs a transaction with the wallet's private key.
|
@@ -6597,7 +7487,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6597
7487
|
const chainId = this.provider.getChainId();
|
6598
7488
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6599
7489
|
const signature = await this.signer().sign(hashedTransaction);
|
6600
|
-
return
|
7490
|
+
return hexlify21(signature);
|
6601
7491
|
}
|
6602
7492
|
/**
|
6603
7493
|
* Populates a transaction with the witnesses signature.
|
@@ -6664,16 +7554,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6664
7554
|
|
6665
7555
|
// src/hdwallet/hdwallet.ts
|
6666
7556
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6667
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
7557
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
6668
7558
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6669
7559
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6670
|
-
import { arrayify as
|
7560
|
+
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6671
7561
|
|
6672
7562
|
// src/mnemonic/mnemonic.ts
|
6673
7563
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6674
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7564
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
6675
7565
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6676
|
-
import { arrayify as
|
7566
|
+
import { arrayify as arrayify18, hexlify as hexlify22, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6677
7567
|
|
6678
7568
|
// src/wordlists/words/english.ts
|
6679
7569
|
var english = [
|
@@ -8728,9 +9618,9 @@ var english = [
|
|
8728
9618
|
];
|
8729
9619
|
|
8730
9620
|
// src/mnemonic/utils.ts
|
8731
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
9621
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
8732
9622
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8733
|
-
import { arrayify as
|
9623
|
+
import { arrayify as arrayify17 } from "@fuel-ts/utils";
|
8734
9624
|
function getLowerMask(bits) {
|
8735
9625
|
return (1 << bits) - 1;
|
8736
9626
|
}
|
@@ -8765,19 +9655,19 @@ function entropyToMnemonicIndices(entropy) {
|
|
8765
9655
|
}
|
8766
9656
|
}
|
8767
9657
|
const checksumBits = entropy.length / 4;
|
8768
|
-
const checksum =
|
9658
|
+
const checksum = arrayify17(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
8769
9659
|
indices[indices.length - 1] <<= checksumBits;
|
8770
9660
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8771
9661
|
return indices;
|
8772
9662
|
}
|
8773
9663
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8774
9664
|
const size = Math.ceil(11 * words.length / 8);
|
8775
|
-
const entropy =
|
9665
|
+
const entropy = arrayify17(new Uint8Array(size));
|
8776
9666
|
let offset = 0;
|
8777
9667
|
for (let i = 0; i < words.length; i += 1) {
|
8778
9668
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8779
9669
|
if (index === -1) {
|
8780
|
-
throw new
|
9670
|
+
throw new FuelError21(
|
8781
9671
|
ErrorCode18.INVALID_MNEMONIC,
|
8782
9672
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8783
9673
|
);
|
@@ -8792,9 +9682,9 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8792
9682
|
const entropyBits = 32 * words.length / 3;
|
8793
9683
|
const checksumBits = words.length / 3;
|
8794
9684
|
const checksumMask = getUpperMask(checksumBits);
|
8795
|
-
const checksum =
|
9685
|
+
const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8796
9686
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8797
|
-
throw new
|
9687
|
+
throw new FuelError21(
|
8798
9688
|
ErrorCode18.INVALID_CHECKSUM,
|
8799
9689
|
"Checksum validation failed for the provided mnemonic."
|
8800
9690
|
);
|
@@ -8809,7 +9699,7 @@ var TestnetPRV = "0x04358394";
|
|
8809
9699
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8810
9700
|
function assertWordList(wordlist) {
|
8811
9701
|
if (wordlist.length !== 2048) {
|
8812
|
-
throw new
|
9702
|
+
throw new FuelError22(
|
8813
9703
|
ErrorCode19.INVALID_WORD_LIST,
|
8814
9704
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8815
9705
|
);
|
@@ -8817,7 +9707,7 @@ function assertWordList(wordlist) {
|
|
8817
9707
|
}
|
8818
9708
|
function assertEntropy(entropy) {
|
8819
9709
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8820
|
-
throw new
|
9710
|
+
throw new FuelError22(
|
8821
9711
|
ErrorCode19.INVALID_ENTROPY,
|
8822
9712
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8823
9713
|
);
|
@@ -8828,7 +9718,7 @@ function assertMnemonic(words) {
|
|
8828
9718
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8829
9719
|
", "
|
8830
9720
|
)}] words, but got ${words.length}.`;
|
8831
|
-
throw new
|
9721
|
+
throw new FuelError22(ErrorCode19.INVALID_MNEMONIC, errorMsg);
|
8832
9722
|
}
|
8833
9723
|
}
|
8834
9724
|
var Mnemonic = class {
|
@@ -8867,7 +9757,7 @@ var Mnemonic = class {
|
|
8867
9757
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8868
9758
|
const words = getWords(phrase);
|
8869
9759
|
assertMnemonic(words);
|
8870
|
-
return
|
9760
|
+
return hexlify22(mnemonicWordsToEntropy(words, wordlist));
|
8871
9761
|
}
|
8872
9762
|
/**
|
8873
9763
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8875,7 +9765,7 @@ var Mnemonic = class {
|
|
8875
9765
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8876
9766
|
*/
|
8877
9767
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8878
|
-
const entropyBytes =
|
9768
|
+
const entropyBytes = arrayify18(entropy);
|
8879
9769
|
assertWordList(wordlist);
|
8880
9770
|
assertEntropy(entropyBytes);
|
8881
9771
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8944,14 +9834,14 @@ var Mnemonic = class {
|
|
8944
9834
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8945
9835
|
*/
|
8946
9836
|
static masterKeysFromSeed(seed) {
|
8947
|
-
const seedArray =
|
9837
|
+
const seedArray = arrayify18(seed);
|
8948
9838
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8949
|
-
throw new
|
9839
|
+
throw new FuelError22(
|
8950
9840
|
ErrorCode19.INVALID_SEED,
|
8951
9841
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8952
9842
|
);
|
8953
9843
|
}
|
8954
|
-
return
|
9844
|
+
return arrayify18(computeHmac("sha512", MasterSecret, seedArray));
|
8955
9845
|
}
|
8956
9846
|
/**
|
8957
9847
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8962,7 +9852,7 @@ var Mnemonic = class {
|
|
8962
9852
|
*/
|
8963
9853
|
static seedToExtendedKey(seed, testnet = false) {
|
8964
9854
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8965
|
-
const prefix =
|
9855
|
+
const prefix = arrayify18(testnet ? TestnetPRV : MainnetPRV);
|
8966
9856
|
const depth = "0x00";
|
8967
9857
|
const fingerprint = "0x00000000";
|
8968
9858
|
const index = "0x00000000";
|
@@ -8992,7 +9882,7 @@ var Mnemonic = class {
|
|
8992
9882
|
* @returns A randomly generated mnemonic
|
8993
9883
|
*/
|
8994
9884
|
static generate(size = 32, extraEntropy = "") {
|
8995
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size),
|
9885
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
|
8996
9886
|
return Mnemonic.entropyToMnemonic(entropy);
|
8997
9887
|
}
|
8998
9888
|
};
|
@@ -9000,10 +9890,10 @@ var mnemonic_default = Mnemonic;
|
|
9000
9890
|
|
9001
9891
|
// src/hdwallet/hdwallet.ts
|
9002
9892
|
var HARDENED_INDEX = 2147483648;
|
9003
|
-
var MainnetPRV2 =
|
9004
|
-
var MainnetPUB =
|
9005
|
-
var TestnetPRV2 =
|
9006
|
-
var TestnetPUB =
|
9893
|
+
var MainnetPRV2 = hexlify23("0x0488ade4");
|
9894
|
+
var MainnetPUB = hexlify23("0x0488b21e");
|
9895
|
+
var TestnetPRV2 = hexlify23("0x04358394");
|
9896
|
+
var TestnetPUB = hexlify23("0x043587cf");
|
9007
9897
|
function base58check(data) {
|
9008
9898
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9009
9899
|
}
|
@@ -9014,17 +9904,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9014
9904
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9015
9905
|
}
|
9016
9906
|
function isPublicExtendedKey(extendedKey) {
|
9017
|
-
return [MainnetPUB, TestnetPUB].includes(
|
9907
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify23(extendedKey.slice(0, 4)));
|
9018
9908
|
}
|
9019
9909
|
function isValidExtendedKey(extendedKey) {
|
9020
9910
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9021
|
-
|
9911
|
+
hexlify23(extendedKey.slice(0, 4))
|
9022
9912
|
);
|
9023
9913
|
}
|
9024
9914
|
function parsePath(path2, depth = 0) {
|
9025
9915
|
const components = path2.split("/");
|
9026
9916
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9027
|
-
throw new
|
9917
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9028
9918
|
}
|
9029
9919
|
if (components[0] === "m") {
|
9030
9920
|
components.shift();
|
@@ -9036,8 +9926,8 @@ function parsePath(path2, depth = 0) {
|
|
9036
9926
|
var HDWallet = class {
|
9037
9927
|
depth = 0;
|
9038
9928
|
index = 0;
|
9039
|
-
fingerprint =
|
9040
|
-
parentFingerprint =
|
9929
|
+
fingerprint = hexlify23("0x00000000");
|
9930
|
+
parentFingerprint = hexlify23("0x00000000");
|
9041
9931
|
privateKey;
|
9042
9932
|
publicKey;
|
9043
9933
|
chainCode;
|
@@ -9049,16 +9939,16 @@ var HDWallet = class {
|
|
9049
9939
|
constructor(config) {
|
9050
9940
|
if (config.privateKey) {
|
9051
9941
|
const signer = new Signer(config.privateKey);
|
9052
|
-
this.publicKey =
|
9053
|
-
this.privateKey =
|
9942
|
+
this.publicKey = hexlify23(signer.compressedPublicKey);
|
9943
|
+
this.privateKey = hexlify23(config.privateKey);
|
9054
9944
|
} else {
|
9055
9945
|
if (!config.publicKey) {
|
9056
|
-
throw new
|
9946
|
+
throw new FuelError23(
|
9057
9947
|
ErrorCode20.HD_WALLET_ERROR,
|
9058
9948
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9059
9949
|
);
|
9060
9950
|
}
|
9061
|
-
this.publicKey =
|
9951
|
+
this.publicKey = hexlify23(config.publicKey);
|
9062
9952
|
}
|
9063
9953
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9064
9954
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -9077,23 +9967,23 @@ var HDWallet = class {
|
|
9077
9967
|
* @returns A new instance of HDWallet on the derived index
|
9078
9968
|
*/
|
9079
9969
|
deriveIndex(index) {
|
9080
|
-
const privateKey = this.privateKey &&
|
9081
|
-
const publicKey =
|
9082
|
-
const chainCode =
|
9970
|
+
const privateKey = this.privateKey && arrayify19(this.privateKey);
|
9971
|
+
const publicKey = arrayify19(this.publicKey);
|
9972
|
+
const chainCode = arrayify19(this.chainCode);
|
9083
9973
|
const data = new Uint8Array(37);
|
9084
9974
|
if (index & HARDENED_INDEX) {
|
9085
9975
|
if (!privateKey) {
|
9086
|
-
throw new
|
9976
|
+
throw new FuelError23(
|
9087
9977
|
ErrorCode20.HD_WALLET_ERROR,
|
9088
9978
|
"Cannot derive a hardened index without a private Key."
|
9089
9979
|
);
|
9090
9980
|
}
|
9091
9981
|
data.set(privateKey, 1);
|
9092
9982
|
} else {
|
9093
|
-
data.set(
|
9983
|
+
data.set(arrayify19(this.publicKey));
|
9094
9984
|
}
|
9095
9985
|
data.set(toBytes2(index, 4), 33);
|
9096
|
-
const bytes =
|
9986
|
+
const bytes = arrayify19(computeHmac2("sha512", chainCode, data));
|
9097
9987
|
const IL = bytes.slice(0, 32);
|
9098
9988
|
const IR = bytes.slice(32);
|
9099
9989
|
if (privateKey) {
|
@@ -9107,7 +9997,7 @@ var HDWallet = class {
|
|
9107
9997
|
parentFingerprint: this.fingerprint
|
9108
9998
|
});
|
9109
9999
|
}
|
9110
|
-
const signer = new Signer(
|
10000
|
+
const signer = new Signer(hexlify23(IL));
|
9111
10001
|
const Ki = signer.addPoint(publicKey);
|
9112
10002
|
return new HDWallet({
|
9113
10003
|
publicKey: Ki,
|
@@ -9136,18 +10026,18 @@ var HDWallet = class {
|
|
9136
10026
|
*/
|
9137
10027
|
toExtendedKey(isPublic = false, testnet = false) {
|
9138
10028
|
if (this.depth >= 256) {
|
9139
|
-
throw new
|
10029
|
+
throw new FuelError23(
|
9140
10030
|
ErrorCode20.HD_WALLET_ERROR,
|
9141
10031
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9142
10032
|
);
|
9143
10033
|
}
|
9144
10034
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9145
|
-
const depth =
|
10035
|
+
const depth = hexlify23(Uint8Array.from([this.depth]));
|
9146
10036
|
const parentFingerprint = this.parentFingerprint;
|
9147
10037
|
const index = toHex(this.index, 4);
|
9148
10038
|
const chainCode = this.chainCode;
|
9149
10039
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
9150
|
-
const extendedKey =
|
10040
|
+
const extendedKey = arrayify19(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9151
10041
|
return base58check(extendedKey);
|
9152
10042
|
}
|
9153
10043
|
/**
|
@@ -9159,34 +10049,34 @@ var HDWallet = class {
|
|
9159
10049
|
static fromSeed(seed) {
|
9160
10050
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9161
10051
|
return new HDWallet({
|
9162
|
-
chainCode:
|
9163
|
-
privateKey:
|
10052
|
+
chainCode: arrayify19(masterKey.slice(32)),
|
10053
|
+
privateKey: arrayify19(masterKey.slice(0, 32))
|
9164
10054
|
});
|
9165
10055
|
}
|
9166
10056
|
static fromExtendedKey(extendedKey) {
|
9167
|
-
const decoded =
|
9168
|
-
const bytes =
|
10057
|
+
const decoded = hexlify23(toBytes2(decodeBase58(extendedKey)));
|
10058
|
+
const bytes = arrayify19(decoded);
|
9169
10059
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9170
10060
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9171
|
-
throw new
|
10061
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9172
10062
|
}
|
9173
10063
|
if (!validChecksum) {
|
9174
|
-
throw new
|
10064
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9175
10065
|
}
|
9176
10066
|
const depth = bytes[4];
|
9177
|
-
const parentFingerprint =
|
9178
|
-
const index = parseInt(
|
9179
|
-
const chainCode =
|
10067
|
+
const parentFingerprint = hexlify23(bytes.slice(5, 9));
|
10068
|
+
const index = parseInt(hexlify23(bytes.slice(9, 13)).substring(2), 16);
|
10069
|
+
const chainCode = hexlify23(bytes.slice(13, 45));
|
9180
10070
|
const key = bytes.slice(45, 78);
|
9181
10071
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9182
|
-
throw new
|
10072
|
+
throw new FuelError23(
|
9183
10073
|
ErrorCode20.HD_WALLET_ERROR,
|
9184
10074
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9185
10075
|
);
|
9186
10076
|
}
|
9187
10077
|
if (isPublicExtendedKey(bytes)) {
|
9188
10078
|
if (key[0] !== 3) {
|
9189
|
-
throw new
|
10079
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
|
9190
10080
|
}
|
9191
10081
|
return new HDWallet({
|
9192
10082
|
publicKey: key,
|
@@ -9197,7 +10087,7 @@ var HDWallet = class {
|
|
9197
10087
|
});
|
9198
10088
|
}
|
9199
10089
|
if (key[0] !== 0) {
|
9200
|
-
throw new
|
10090
|
+
throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
|
9201
10091
|
}
|
9202
10092
|
return new HDWallet({
|
9203
10093
|
privateKey: key.slice(1),
|
@@ -9427,7 +10317,7 @@ var WalletsConfig = class {
|
|
9427
10317
|
tx_pointer_block_height: 0,
|
9428
10318
|
tx_pointer_tx_idx: 0,
|
9429
10319
|
output_index: 0,
|
9430
|
-
tx_id:
|
10320
|
+
tx_id: hexlify24(randomBytes8(32))
|
9431
10321
|
});
|
9432
10322
|
}
|
9433
10323
|
});
|
@@ -9441,26 +10331,26 @@ var WalletsConfig = class {
|
|
9441
10331
|
amountPerCoin
|
9442
10332
|
}) {
|
9443
10333
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
9444
|
-
throw new
|
9445
|
-
|
10334
|
+
throw new FuelError24(
|
10335
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9446
10336
|
"Number of wallets must be greater than zero."
|
9447
10337
|
);
|
9448
10338
|
}
|
9449
10339
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
9450
|
-
throw new
|
9451
|
-
|
10340
|
+
throw new FuelError24(
|
10341
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9452
10342
|
"Number of assets per wallet must be greater than zero."
|
9453
10343
|
);
|
9454
10344
|
}
|
9455
10345
|
if (coinsPerAsset <= 0) {
|
9456
|
-
throw new
|
9457
|
-
|
10346
|
+
throw new FuelError24(
|
10347
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9458
10348
|
"Number of coins per asset must be greater than zero."
|
9459
10349
|
);
|
9460
10350
|
}
|
9461
10351
|
if (amountPerCoin < 0) {
|
9462
|
-
throw new
|
9463
|
-
|
10352
|
+
throw new FuelError24(
|
10353
|
+
FuelError24.CODES.INVALID_INPUT_PARAMETERS,
|
9464
10354
|
"Amount per coin must be greater than or equal to zero."
|
9465
10355
|
);
|
9466
10356
|
}
|
@@ -9534,7 +10424,7 @@ async function setupTestProviderAndWallets({
|
|
9534
10424
|
import { Address as Address6 } from "@fuel-ts/address";
|
9535
10425
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
9536
10426
|
import { bn as bn21 } from "@fuel-ts/math";
|
9537
|
-
import { hexlify as
|
10427
|
+
import { hexlify as hexlify25 } from "@fuel-ts/utils";
|
9538
10428
|
var TestMessage = class {
|
9539
10429
|
sender;
|
9540
10430
|
recipient;
|
@@ -9551,7 +10441,7 @@ var TestMessage = class {
|
|
9551
10441
|
constructor({
|
9552
10442
|
sender = Address6.fromRandom(),
|
9553
10443
|
recipient = Address6.fromRandom(),
|
9554
|
-
nonce =
|
10444
|
+
nonce = hexlify25(randomBytes9(32)),
|
9555
10445
|
amount = 1e6,
|
9556
10446
|
data = "",
|
9557
10447
|
// Will default to empty data in order to be a spendable message
|