@fuel-ts/account 0.0.0-rc-1976-20240403225009 → 0.0.0-rc-1895-20240404023124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +171 -63
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +578 -513
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +356 -286
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +0 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +36 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +172 -65
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +537 -479
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +326 -260
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
@@ -32050,6 +32050,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32050
32050
|
})(ErrorCode || {});
|
32051
32051
|
var _FuelError = class extends Error {
|
32052
32052
|
VERSIONS = versions;
|
32053
|
+
metadata;
|
32053
32054
|
static parse(e) {
|
32054
32055
|
const error = e;
|
32055
32056
|
if (error.code === void 0) {
|
@@ -32069,14 +32070,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32069
32070
|
return new _FuelError(error.code, error.message);
|
32070
32071
|
}
|
32071
32072
|
code;
|
32072
|
-
constructor(code, message) {
|
32073
|
+
constructor(code, message, metadata = {}) {
|
32073
32074
|
super(message);
|
32074
32075
|
this.code = code;
|
32075
32076
|
this.name = "FuelError";
|
32077
|
+
this.metadata = metadata;
|
32076
32078
|
}
|
32077
32079
|
toObject() {
|
32078
|
-
const { code, name, message, VERSIONS } = this;
|
32079
|
-
return { code, name, message, VERSIONS };
|
32080
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
32081
|
+
return { code, name, message, metadata, VERSIONS };
|
32080
32082
|
}
|
32081
32083
|
};
|
32082
32084
|
var FuelError = _FuelError;
|
@@ -32488,8 +32490,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32488
32490
|
fee_params: {
|
32489
32491
|
gas_price_factor: 92,
|
32490
32492
|
gas_per_byte: 4
|
32491
|
-
}
|
32492
|
-
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32493
|
+
}
|
32493
32494
|
},
|
32494
32495
|
gas_costs: {
|
32495
32496
|
add: 1,
|
@@ -34758,6 +34759,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34758
34759
|
}
|
34759
34760
|
};
|
34760
34761
|
|
34762
|
+
// ../address/dist/configs.mjs
|
34763
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34764
|
+
var BaseAssetId = ZeroBytes32;
|
34765
|
+
|
34761
34766
|
// ../math/dist/index.mjs
|
34762
34767
|
var import_bn = __toESM(require_bn(), 1);
|
34763
34768
|
var DEFAULT_PRECISION = 9;
|
@@ -34988,11 +34993,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34988
34993
|
let max2;
|
34989
34994
|
if (Array.isArray(coinQuantityLike)) {
|
34990
34995
|
amount = coinQuantityLike[0];
|
34991
|
-
assetId = coinQuantityLike[1];
|
34992
|
-
max2 = coinQuantityLike[2];
|
34996
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
34997
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
34993
34998
|
} else {
|
34994
34999
|
amount = coinQuantityLike.amount;
|
34995
|
-
assetId = coinQuantityLike.assetId;
|
35000
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
34996
35001
|
max2 = coinQuantityLike.max ?? void 0;
|
34997
35002
|
}
|
34998
35003
|
const bnAmount = bn(amount);
|
@@ -42290,9 +42295,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42290
42295
|
}
|
42291
42296
|
};
|
42292
42297
|
|
42293
|
-
// ../address/dist/configs.mjs
|
42294
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42295
|
-
|
42296
42298
|
// src/providers/transaction-request/input.ts
|
42297
42299
|
var inputify = (value) => {
|
42298
42300
|
const { type: type3 } = value;
|
@@ -42424,7 +42426,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42424
42426
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42425
42427
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42426
42428
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42429
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42427
42430
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42431
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42432
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42433
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42434
|
+
var PANIC_REASONS = [
|
42435
|
+
"UnknownPanicReason",
|
42436
|
+
"Revert",
|
42437
|
+
"OutOfGas",
|
42438
|
+
"TransactionValidity",
|
42439
|
+
"MemoryOverflow",
|
42440
|
+
"ArithmeticOverflow",
|
42441
|
+
"ContractNotFound",
|
42442
|
+
"MemoryOwnership",
|
42443
|
+
"NotEnoughBalance",
|
42444
|
+
"ExpectedInternalContext",
|
42445
|
+
"AssetIdNotFound",
|
42446
|
+
"InputNotFound",
|
42447
|
+
"OutputNotFound",
|
42448
|
+
"WitnessNotFound",
|
42449
|
+
"TransactionMaturity",
|
42450
|
+
"InvalidMetadataIdentifier",
|
42451
|
+
"MalformedCallStructure",
|
42452
|
+
"ReservedRegisterNotWritable",
|
42453
|
+
"InvalidFlags",
|
42454
|
+
"InvalidImmediateValue",
|
42455
|
+
"ExpectedCoinInput",
|
42456
|
+
"EcalError",
|
42457
|
+
"MemoryWriteOverlap",
|
42458
|
+
"ContractNotInInputs",
|
42459
|
+
"InternalBalanceOverflow",
|
42460
|
+
"ContractMaxSize",
|
42461
|
+
"ExpectedUnallocatedStack",
|
42462
|
+
"MaxStaticContractsReached",
|
42463
|
+
"TransferAmountCannotBeZero",
|
42464
|
+
"ExpectedOutputVariable",
|
42465
|
+
"ExpectedParentInternalContext",
|
42466
|
+
"PredicateReturnedNonOne",
|
42467
|
+
"ContractIdAlreadyDeployed",
|
42468
|
+
"ContractMismatch",
|
42469
|
+
"MessageDataTooLong",
|
42470
|
+
"ArithmeticError",
|
42471
|
+
"ContractInstructionNotAllowed",
|
42472
|
+
"TransferZeroCoins",
|
42473
|
+
"InvalidInstruction",
|
42474
|
+
"MemoryNotExecutable",
|
42475
|
+
"PolicyIsNotSet",
|
42476
|
+
"PolicyNotFound",
|
42477
|
+
"TooManyReceipts",
|
42478
|
+
"BalanceOverflow",
|
42479
|
+
"InvalidBlockHeight",
|
42480
|
+
"TooManySlots"
|
42481
|
+
];
|
42482
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42428
42483
|
|
42429
42484
|
// src/providers/utils/receipts.ts
|
42430
42485
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42737,6 +42792,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42737
42792
|
});
|
42738
42793
|
}
|
42739
42794
|
|
42795
|
+
// src/providers/utils/extract-tx-error.ts
|
42796
|
+
var assemblePanicError = (status) => {
|
42797
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42798
|
+
const reason = status.reason;
|
42799
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42800
|
+
errorMessage = `${errorMessage}
|
42801
|
+
|
42802
|
+
You can read more about this error at:
|
42803
|
+
|
42804
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42805
|
+
}
|
42806
|
+
return { errorMessage, reason };
|
42807
|
+
};
|
42808
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42809
|
+
var assembleRevertError = (receipts, logs) => {
|
42810
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42811
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42812
|
+
let reason = "";
|
42813
|
+
if (revertReceipt) {
|
42814
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42815
|
+
switch (reasonHex) {
|
42816
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42817
|
+
reason = "require";
|
42818
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42819
|
+
break;
|
42820
|
+
}
|
42821
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42822
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42823
|
+
reason = "assert_eq";
|
42824
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42825
|
+
break;
|
42826
|
+
}
|
42827
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42828
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42829
|
+
reason = "assert_ne";
|
42830
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42831
|
+
break;
|
42832
|
+
}
|
42833
|
+
case FAILED_ASSERT_SIGNAL:
|
42834
|
+
reason = "assert";
|
42835
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42836
|
+
break;
|
42837
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42838
|
+
reason = "MissingOutputChange";
|
42839
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42840
|
+
break;
|
42841
|
+
default:
|
42842
|
+
reason = "unknown";
|
42843
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42844
|
+
}
|
42845
|
+
}
|
42846
|
+
return { errorMessage, reason };
|
42847
|
+
};
|
42848
|
+
var extractTxError = (params) => {
|
42849
|
+
const { receipts, status, logs } = params;
|
42850
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42851
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42852
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42853
|
+
const metadata = {
|
42854
|
+
logs,
|
42855
|
+
receipts,
|
42856
|
+
panic: isPanic,
|
42857
|
+
revert: isRevert,
|
42858
|
+
reason
|
42859
|
+
};
|
42860
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42861
|
+
};
|
42862
|
+
|
42740
42863
|
// src/providers/transaction-request/errors.ts
|
42741
42864
|
var NoWitnessAtIndexError = class extends Error {
|
42742
42865
|
constructor(index) {
|
@@ -42772,8 +42895,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42772
42895
|
outputs = [];
|
42773
42896
|
/** List of witnesses */
|
42774
42897
|
witnesses = [];
|
42775
|
-
/** Base asset ID - should be fetched from the chain */
|
42776
|
-
baseAssetId = ZeroBytes32;
|
42777
42898
|
/**
|
42778
42899
|
* Constructor for initializing a base transaction request.
|
42779
42900
|
*
|
@@ -42786,8 +42907,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42786
42907
|
witnessLimit,
|
42787
42908
|
inputs,
|
42788
42909
|
outputs,
|
42789
|
-
witnesses
|
42790
|
-
baseAssetId
|
42910
|
+
witnesses
|
42791
42911
|
} = {}) {
|
42792
42912
|
this.gasPrice = bn(gasPrice);
|
42793
42913
|
this.maturity = maturity ?? 0;
|
@@ -42796,7 +42916,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42796
42916
|
this.inputs = inputs ?? [];
|
42797
42917
|
this.outputs = outputs ?? [];
|
42798
42918
|
this.witnesses = witnesses ?? [];
|
42799
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42800
42919
|
}
|
42801
42920
|
static getPolicyMeta(req) {
|
42802
42921
|
let policyTypes = 0;
|
@@ -43021,9 +43140,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43021
43140
|
*
|
43022
43141
|
* @param message - Message resource.
|
43023
43142
|
* @param predicate - Predicate bytes.
|
43143
|
+
* @param predicateData - Predicate data bytes.
|
43024
43144
|
*/
|
43025
43145
|
addMessageInput(message, predicate) {
|
43026
43146
|
const { recipient, sender, amount } = message;
|
43147
|
+
const assetId = BaseAssetId;
|
43027
43148
|
let witnessIndex;
|
43028
43149
|
if (predicate) {
|
43029
43150
|
witnessIndex = 0;
|
@@ -43044,7 +43165,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43044
43165
|
predicateData: predicate?.predicateDataBytes
|
43045
43166
|
};
|
43046
43167
|
this.pushInput(input);
|
43047
|
-
this.addChangeOutput(recipient,
|
43168
|
+
this.addChangeOutput(recipient, assetId);
|
43048
43169
|
}
|
43049
43170
|
/**
|
43050
43171
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43105,12 +43226,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43105
43226
|
* @param amount - Amount of coin.
|
43106
43227
|
* @param assetId - Asset ID of coin.
|
43107
43228
|
*/
|
43108
|
-
addCoinOutput(to, amount, assetId) {
|
43229
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43109
43230
|
this.pushOutput({
|
43110
43231
|
type: OutputType.Coin,
|
43111
43232
|
to: addressify(to).toB256(),
|
43112
43233
|
amount,
|
43113
|
-
assetId
|
43234
|
+
assetId
|
43114
43235
|
});
|
43115
43236
|
return this;
|
43116
43237
|
}
|
@@ -43137,7 +43258,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43137
43258
|
* @param to - Address of the owner.
|
43138
43259
|
* @param assetId - Asset ID of coin.
|
43139
43260
|
*/
|
43140
|
-
addChangeOutput(to, assetId) {
|
43261
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43141
43262
|
const changeOutput = this.getChangeOutputs().find(
|
43142
43263
|
(output3) => hexlify(output3.assetId) === assetId
|
43143
43264
|
);
|
@@ -43145,7 +43266,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43145
43266
|
this.pushOutput({
|
43146
43267
|
type: OutputType.Change,
|
43147
43268
|
to: addressify(to).toB256(),
|
43148
|
-
assetId
|
43269
|
+
assetId
|
43149
43270
|
});
|
43150
43271
|
}
|
43151
43272
|
}
|
@@ -43227,7 +43348,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43227
43348
|
]);
|
43228
43349
|
}
|
43229
43350
|
};
|
43230
|
-
updateAssetInput(
|
43351
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43231
43352
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43232
43353
|
}
|
43233
43354
|
/**
|
@@ -44496,14 +44617,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44496
44617
|
gqlTransaction: this.gqlTransaction,
|
44497
44618
|
...transactionSummary
|
44498
44619
|
};
|
44620
|
+
let logs = [];
|
44499
44621
|
if (this.abis) {
|
44500
|
-
|
44622
|
+
logs = getDecodedLogs(
|
44501
44623
|
transactionSummary.receipts,
|
44502
44624
|
this.abis.main,
|
44503
44625
|
this.abis.otherContractsAbis
|
44504
44626
|
);
|
44505
44627
|
transactionResult.logs = logs;
|
44506
44628
|
}
|
44629
|
+
if (transactionResult.isStatusFailure) {
|
44630
|
+
const {
|
44631
|
+
receipts,
|
44632
|
+
gqlTransaction: { status }
|
44633
|
+
} = transactionResult;
|
44634
|
+
throw extractTxError({
|
44635
|
+
receipts,
|
44636
|
+
status,
|
44637
|
+
logs
|
44638
|
+
});
|
44639
|
+
}
|
44507
44640
|
return transactionResult;
|
44508
44641
|
}
|
44509
44642
|
/**
|
@@ -44512,14 +44645,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44512
44645
|
* @param contractsAbiMap - The contracts ABI map.
|
44513
44646
|
*/
|
44514
44647
|
async wait(contractsAbiMap) {
|
44515
|
-
|
44516
|
-
if (result.isStatusFailure) {
|
44517
|
-
throw new FuelError(
|
44518
|
-
ErrorCode.TRANSACTION_FAILED,
|
44519
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44520
|
-
);
|
44521
|
-
}
|
44522
|
-
return result;
|
44648
|
+
return this.waitForResult(contractsAbiMap);
|
44523
44649
|
}
|
44524
44650
|
};
|
44525
44651
|
|
@@ -44598,7 +44724,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44598
44724
|
gasPerByte: bn(feeParams.gasPerByte),
|
44599
44725
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44600
44726
|
chainId: bn(consensusParameters.chainId),
|
44601
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44602
44727
|
gasCosts
|
44603
44728
|
},
|
44604
44729
|
gasCosts,
|
@@ -44841,17 +44966,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44841
44966
|
} = this.getChain();
|
44842
44967
|
return chainId.toNumber();
|
44843
44968
|
}
|
44844
|
-
/**
|
44845
|
-
* Returns the base asset ID
|
44846
|
-
*
|
44847
|
-
* @returns A promise that resolves to the base asset ID
|
44848
|
-
*/
|
44849
|
-
getBaseAssetId() {
|
44850
|
-
const {
|
44851
|
-
consensusParameters: { baseAssetId }
|
44852
|
-
} = this.getChain();
|
44853
|
-
return baseAssetId;
|
44854
|
-
}
|
44855
44969
|
/**
|
44856
44970
|
* Submits a transaction to the chain to be executed.
|
44857
44971
|
*
|
@@ -45713,9 +45827,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45713
45827
|
* @param assetId - The asset ID to check the balance for.
|
45714
45828
|
* @returns A promise that resolves to the balance amount.
|
45715
45829
|
*/
|
45716
|
-
async getBalance(assetId) {
|
45717
|
-
const
|
45718
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45830
|
+
async getBalance(assetId = BaseAssetId) {
|
45831
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45719
45832
|
return amount;
|
45720
45833
|
}
|
45721
45834
|
/**
|
@@ -45753,10 +45866,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45753
45866
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45754
45867
|
*/
|
45755
45868
|
async fund(request, coinQuantities, fee) {
|
45756
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45757
45869
|
const updatedQuantities = addAmountToAsset({
|
45758
45870
|
amount: bn(fee),
|
45759
|
-
assetId:
|
45871
|
+
assetId: BaseAssetId,
|
45760
45872
|
coinQuantities
|
45761
45873
|
});
|
45762
45874
|
const quantitiesDict = {};
|
@@ -45780,8 +45892,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45780
45892
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45781
45893
|
cachedUtxos.push(input.id);
|
45782
45894
|
}
|
45783
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45784
|
-
quantitiesDict[
|
45895
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45896
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45785
45897
|
cachedMessages.push(input.nonce);
|
45786
45898
|
}
|
45787
45899
|
}
|
@@ -45813,12 +45925,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45813
45925
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45814
45926
|
* @returns A promise that resolves to the prepared transaction request.
|
45815
45927
|
*/
|
45816
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45928
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45817
45929
|
const { minGasPrice } = this.provider.getGasConfig();
|
45818
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45819
45930
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45820
45931
|
const request = new ScriptTransactionRequest(params);
|
45821
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45932
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
45822
45933
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45823
45934
|
estimateTxDependencies: true,
|
45824
45935
|
resourcesOwner: this
|
@@ -45844,15 +45955,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45844
45955
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45845
45956
|
* @returns A promise that resolves to the transaction response.
|
45846
45957
|
*/
|
45847
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
45958
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45848
45959
|
if (bn(amount).lte(0)) {
|
45849
45960
|
throw new FuelError(
|
45850
45961
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45851
45962
|
"Transfer amount must be a positive number."
|
45852
45963
|
);
|
45853
45964
|
}
|
45854
|
-
const
|
45855
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45965
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
45856
45966
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45857
45967
|
}
|
45858
45968
|
/**
|
@@ -45864,7 +45974,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45864
45974
|
* @param txParams - The optional transaction parameters.
|
45865
45975
|
* @returns A promise that resolves to the transaction response.
|
45866
45976
|
*/
|
45867
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
45977
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
45868
45978
|
if (bn(amount).lte(0)) {
|
45869
45979
|
throw new FuelError(
|
45870
45980
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45873,12 +45983,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45873
45983
|
}
|
45874
45984
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45875
45985
|
const { minGasPrice } = this.provider.getGasConfig();
|
45876
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45877
45986
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45878
45987
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45879
45988
|
hexlifiedContractId: contractAddress.toB256(),
|
45880
45989
|
amountToTransfer: bn(amount),
|
45881
|
-
assetId
|
45990
|
+
assetId
|
45882
45991
|
});
|
45883
45992
|
const request = new ScriptTransactionRequest({
|
45884
45993
|
...params,
|
@@ -45888,7 +45997,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45888
45997
|
request.addContractInputAndOutput(contractAddress);
|
45889
45998
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
45890
45999
|
request,
|
45891
|
-
[{ amount: bn(amount), assetId: String(
|
46000
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
45892
46001
|
);
|
45893
46002
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
45894
46003
|
this.validateGas({
|
@@ -45910,7 +46019,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45910
46019
|
*/
|
45911
46020
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
45912
46021
|
const { minGasPrice } = this.provider.getGasConfig();
|
45913
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45914
46022
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
45915
46023
|
const recipientDataArray = arrayify(
|
45916
46024
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -45925,7 +46033,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45925
46033
|
]);
|
45926
46034
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
45927
46035
|
const request = new ScriptTransactionRequest(params);
|
45928
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46036
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
45929
46037
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
45930
46038
|
request,
|
45931
46039
|
forwardingQuantities
|
@@ -50487,7 +50595,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50487
50595
|
{
|
50488
50596
|
owner: signer.address.toHexString(),
|
50489
50597
|
amount: toHex(1e9),
|
50490
|
-
asset_id:
|
50598
|
+
asset_id: BaseAssetId
|
50491
50599
|
}
|
50492
50600
|
]
|
50493
50601
|
}
|
@@ -50553,10 +50661,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50553
50661
|
})
|
50554
50662
|
);
|
50555
50663
|
var generateWallets = async (count, provider) => {
|
50556
|
-
const baseAssetId = provider.getBaseAssetId();
|
50557
50664
|
const wallets = [];
|
50558
50665
|
for (let i = 0; i < count; i += 1) {
|
50559
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50666
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50560
50667
|
wallets.push(wallet);
|
50561
50668
|
}
|
50562
50669
|
return wallets;
|