@fuel-ts/account 0.0.0-rc-1976-20240404063407 → 0.0.0-rc-1895-20240404064636
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
@@ -32045,6 +32045,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32045
32045
|
})(ErrorCode || {});
|
32046
32046
|
var _FuelError = class extends Error {
|
32047
32047
|
VERSIONS = versions;
|
32048
|
+
metadata;
|
32048
32049
|
static parse(e) {
|
32049
32050
|
const error = e;
|
32050
32051
|
if (error.code === void 0) {
|
@@ -32064,14 +32065,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32064
32065
|
return new _FuelError(error.code, error.message);
|
32065
32066
|
}
|
32066
32067
|
code;
|
32067
|
-
constructor(code, message) {
|
32068
|
+
constructor(code, message, metadata = {}) {
|
32068
32069
|
super(message);
|
32069
32070
|
this.code = code;
|
32070
32071
|
this.name = "FuelError";
|
32072
|
+
this.metadata = metadata;
|
32071
32073
|
}
|
32072
32074
|
toObject() {
|
32073
|
-
const { code, name, message, VERSIONS } = this;
|
32074
|
-
return { code, name, message, VERSIONS };
|
32075
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
32076
|
+
return { code, name, message, metadata, VERSIONS };
|
32075
32077
|
}
|
32076
32078
|
};
|
32077
32079
|
var FuelError = _FuelError;
|
@@ -32483,8 +32485,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32483
32485
|
fee_params: {
|
32484
32486
|
gas_price_factor: 92,
|
32485
32487
|
gas_per_byte: 4
|
32486
|
-
}
|
32487
|
-
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32488
|
+
}
|
32488
32489
|
},
|
32489
32490
|
gas_costs: {
|
32490
32491
|
add: 1,
|
@@ -34753,6 +34754,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34753
34754
|
}
|
34754
34755
|
};
|
34755
34756
|
|
34757
|
+
// ../address/dist/configs.mjs
|
34758
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34759
|
+
var BaseAssetId = ZeroBytes32;
|
34760
|
+
|
34756
34761
|
// ../math/dist/index.mjs
|
34757
34762
|
var import_bn = __toESM(require_bn(), 1);
|
34758
34763
|
var DEFAULT_PRECISION = 9;
|
@@ -34983,11 +34988,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34983
34988
|
let max2;
|
34984
34989
|
if (Array.isArray(coinQuantityLike)) {
|
34985
34990
|
amount = coinQuantityLike[0];
|
34986
|
-
assetId = coinQuantityLike[1];
|
34987
|
-
max2 = coinQuantityLike[2];
|
34991
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
34992
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
34988
34993
|
} else {
|
34989
34994
|
amount = coinQuantityLike.amount;
|
34990
|
-
assetId = coinQuantityLike.assetId;
|
34995
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
34991
34996
|
max2 = coinQuantityLike.max ?? void 0;
|
34992
34997
|
}
|
34993
34998
|
const bnAmount = bn(amount);
|
@@ -42279,9 +42284,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42279
42284
|
}
|
42280
42285
|
};
|
42281
42286
|
|
42282
|
-
// ../address/dist/configs.mjs
|
42283
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42284
|
-
|
42285
42287
|
// src/providers/transaction-request/input.ts
|
42286
42288
|
var inputify = (value) => {
|
42287
42289
|
const { type: type3 } = value;
|
@@ -42413,7 +42415,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42413
42415
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42414
42416
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42415
42417
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42418
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42416
42419
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42420
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42421
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42422
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42423
|
+
var PANIC_REASONS = [
|
42424
|
+
"UnknownPanicReason",
|
42425
|
+
"Revert",
|
42426
|
+
"OutOfGas",
|
42427
|
+
"TransactionValidity",
|
42428
|
+
"MemoryOverflow",
|
42429
|
+
"ArithmeticOverflow",
|
42430
|
+
"ContractNotFound",
|
42431
|
+
"MemoryOwnership",
|
42432
|
+
"NotEnoughBalance",
|
42433
|
+
"ExpectedInternalContext",
|
42434
|
+
"AssetIdNotFound",
|
42435
|
+
"InputNotFound",
|
42436
|
+
"OutputNotFound",
|
42437
|
+
"WitnessNotFound",
|
42438
|
+
"TransactionMaturity",
|
42439
|
+
"InvalidMetadataIdentifier",
|
42440
|
+
"MalformedCallStructure",
|
42441
|
+
"ReservedRegisterNotWritable",
|
42442
|
+
"InvalidFlags",
|
42443
|
+
"InvalidImmediateValue",
|
42444
|
+
"ExpectedCoinInput",
|
42445
|
+
"EcalError",
|
42446
|
+
"MemoryWriteOverlap",
|
42447
|
+
"ContractNotInInputs",
|
42448
|
+
"InternalBalanceOverflow",
|
42449
|
+
"ContractMaxSize",
|
42450
|
+
"ExpectedUnallocatedStack",
|
42451
|
+
"MaxStaticContractsReached",
|
42452
|
+
"TransferAmountCannotBeZero",
|
42453
|
+
"ExpectedOutputVariable",
|
42454
|
+
"ExpectedParentInternalContext",
|
42455
|
+
"PredicateReturnedNonOne",
|
42456
|
+
"ContractIdAlreadyDeployed",
|
42457
|
+
"ContractMismatch",
|
42458
|
+
"MessageDataTooLong",
|
42459
|
+
"ArithmeticError",
|
42460
|
+
"ContractInstructionNotAllowed",
|
42461
|
+
"TransferZeroCoins",
|
42462
|
+
"InvalidInstruction",
|
42463
|
+
"MemoryNotExecutable",
|
42464
|
+
"PolicyIsNotSet",
|
42465
|
+
"PolicyNotFound",
|
42466
|
+
"TooManyReceipts",
|
42467
|
+
"BalanceOverflow",
|
42468
|
+
"InvalidBlockHeight",
|
42469
|
+
"TooManySlots"
|
42470
|
+
];
|
42471
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42417
42472
|
|
42418
42473
|
// src/providers/utils/receipts.ts
|
42419
42474
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42726,6 +42781,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42726
42781
|
});
|
42727
42782
|
}
|
42728
42783
|
|
42784
|
+
// src/providers/utils/extract-tx-error.ts
|
42785
|
+
var assemblePanicError = (status) => {
|
42786
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42787
|
+
const reason = status.reason;
|
42788
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42789
|
+
errorMessage = `${errorMessage}
|
42790
|
+
|
42791
|
+
You can read more about this error at:
|
42792
|
+
|
42793
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42794
|
+
}
|
42795
|
+
return { errorMessage, reason };
|
42796
|
+
};
|
42797
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42798
|
+
var assembleRevertError = (receipts, logs) => {
|
42799
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42800
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42801
|
+
let reason = "";
|
42802
|
+
if (revertReceipt) {
|
42803
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42804
|
+
switch (reasonHex) {
|
42805
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42806
|
+
reason = "require";
|
42807
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42808
|
+
break;
|
42809
|
+
}
|
42810
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42811
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42812
|
+
reason = "assert_eq";
|
42813
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42814
|
+
break;
|
42815
|
+
}
|
42816
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42817
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42818
|
+
reason = "assert_ne";
|
42819
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42820
|
+
break;
|
42821
|
+
}
|
42822
|
+
case FAILED_ASSERT_SIGNAL:
|
42823
|
+
reason = "assert";
|
42824
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42825
|
+
break;
|
42826
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42827
|
+
reason = "MissingOutputChange";
|
42828
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42829
|
+
break;
|
42830
|
+
default:
|
42831
|
+
reason = "unknown";
|
42832
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42833
|
+
}
|
42834
|
+
}
|
42835
|
+
return { errorMessage, reason };
|
42836
|
+
};
|
42837
|
+
var extractTxError = (params) => {
|
42838
|
+
const { receipts, status, logs } = params;
|
42839
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42840
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42841
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42842
|
+
const metadata = {
|
42843
|
+
logs,
|
42844
|
+
receipts,
|
42845
|
+
panic: isPanic,
|
42846
|
+
revert: isRevert,
|
42847
|
+
reason
|
42848
|
+
};
|
42849
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42850
|
+
};
|
42851
|
+
|
42729
42852
|
// src/providers/transaction-request/errors.ts
|
42730
42853
|
var NoWitnessAtIndexError = class extends Error {
|
42731
42854
|
constructor(index) {
|
@@ -42761,8 +42884,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42761
42884
|
outputs = [];
|
42762
42885
|
/** List of witnesses */
|
42763
42886
|
witnesses = [];
|
42764
|
-
/** Base asset ID - should be fetched from the chain */
|
42765
|
-
baseAssetId = ZeroBytes32;
|
42766
42887
|
/**
|
42767
42888
|
* Constructor for initializing a base transaction request.
|
42768
42889
|
*
|
@@ -42775,8 +42896,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42775
42896
|
witnessLimit,
|
42776
42897
|
inputs,
|
42777
42898
|
outputs,
|
42778
|
-
witnesses
|
42779
|
-
baseAssetId
|
42899
|
+
witnesses
|
42780
42900
|
} = {}) {
|
42781
42901
|
this.gasPrice = bn(gasPrice);
|
42782
42902
|
this.maturity = maturity ?? 0;
|
@@ -42785,7 +42905,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42785
42905
|
this.inputs = inputs ?? [];
|
42786
42906
|
this.outputs = outputs ?? [];
|
42787
42907
|
this.witnesses = witnesses ?? [];
|
42788
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42789
42908
|
}
|
42790
42909
|
static getPolicyMeta(req) {
|
42791
42910
|
let policyTypes = 0;
|
@@ -43010,9 +43129,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43010
43129
|
*
|
43011
43130
|
* @param message - Message resource.
|
43012
43131
|
* @param predicate - Predicate bytes.
|
43132
|
+
* @param predicateData - Predicate data bytes.
|
43013
43133
|
*/
|
43014
43134
|
addMessageInput(message, predicate) {
|
43015
43135
|
const { recipient, sender, amount } = message;
|
43136
|
+
const assetId = BaseAssetId;
|
43016
43137
|
let witnessIndex;
|
43017
43138
|
if (predicate) {
|
43018
43139
|
witnessIndex = 0;
|
@@ -43033,7 +43154,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43033
43154
|
predicateData: predicate?.predicateDataBytes
|
43034
43155
|
};
|
43035
43156
|
this.pushInput(input);
|
43036
|
-
this.addChangeOutput(recipient,
|
43157
|
+
this.addChangeOutput(recipient, assetId);
|
43037
43158
|
}
|
43038
43159
|
/**
|
43039
43160
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43094,12 +43215,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43094
43215
|
* @param amount - Amount of coin.
|
43095
43216
|
* @param assetId - Asset ID of coin.
|
43096
43217
|
*/
|
43097
|
-
addCoinOutput(to, amount, assetId) {
|
43218
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43098
43219
|
this.pushOutput({
|
43099
43220
|
type: OutputType.Coin,
|
43100
43221
|
to: addressify(to).toB256(),
|
43101
43222
|
amount,
|
43102
|
-
assetId
|
43223
|
+
assetId
|
43103
43224
|
});
|
43104
43225
|
return this;
|
43105
43226
|
}
|
@@ -43126,7 +43247,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43126
43247
|
* @param to - Address of the owner.
|
43127
43248
|
* @param assetId - Asset ID of coin.
|
43128
43249
|
*/
|
43129
|
-
addChangeOutput(to, assetId) {
|
43250
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43130
43251
|
const changeOutput = this.getChangeOutputs().find(
|
43131
43252
|
(output3) => hexlify(output3.assetId) === assetId
|
43132
43253
|
);
|
@@ -43134,7 +43255,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43134
43255
|
this.pushOutput({
|
43135
43256
|
type: OutputType.Change,
|
43136
43257
|
to: addressify(to).toB256(),
|
43137
|
-
assetId
|
43258
|
+
assetId
|
43138
43259
|
});
|
43139
43260
|
}
|
43140
43261
|
}
|
@@ -43216,7 +43337,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43216
43337
|
]);
|
43217
43338
|
}
|
43218
43339
|
};
|
43219
|
-
updateAssetInput(
|
43340
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43220
43341
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43221
43342
|
}
|
43222
43343
|
/**
|
@@ -44485,14 +44606,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44485
44606
|
gqlTransaction: this.gqlTransaction,
|
44486
44607
|
...transactionSummary
|
44487
44608
|
};
|
44609
|
+
let logs = [];
|
44488
44610
|
if (this.abis) {
|
44489
|
-
|
44611
|
+
logs = getDecodedLogs(
|
44490
44612
|
transactionSummary.receipts,
|
44491
44613
|
this.abis.main,
|
44492
44614
|
this.abis.otherContractsAbis
|
44493
44615
|
);
|
44494
44616
|
transactionResult.logs = logs;
|
44495
44617
|
}
|
44618
|
+
if (transactionResult.isStatusFailure) {
|
44619
|
+
const {
|
44620
|
+
receipts,
|
44621
|
+
gqlTransaction: { status }
|
44622
|
+
} = transactionResult;
|
44623
|
+
throw extractTxError({
|
44624
|
+
receipts,
|
44625
|
+
status,
|
44626
|
+
logs
|
44627
|
+
});
|
44628
|
+
}
|
44496
44629
|
return transactionResult;
|
44497
44630
|
}
|
44498
44631
|
/**
|
@@ -44501,14 +44634,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44501
44634
|
* @param contractsAbiMap - The contracts ABI map.
|
44502
44635
|
*/
|
44503
44636
|
async wait(contractsAbiMap) {
|
44504
|
-
|
44505
|
-
if (result.isStatusFailure) {
|
44506
|
-
throw new FuelError(
|
44507
|
-
ErrorCode.TRANSACTION_FAILED,
|
44508
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44509
|
-
);
|
44510
|
-
}
|
44511
|
-
return result;
|
44637
|
+
return this.waitForResult(contractsAbiMap);
|
44512
44638
|
}
|
44513
44639
|
};
|
44514
44640
|
|
@@ -44587,7 +44713,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44587
44713
|
gasPerByte: bn(feeParams.gasPerByte),
|
44588
44714
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44589
44715
|
chainId: bn(consensusParameters.chainId),
|
44590
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44591
44716
|
gasCosts
|
44592
44717
|
},
|
44593
44718
|
gasCosts,
|
@@ -44830,17 +44955,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44830
44955
|
} = this.getChain();
|
44831
44956
|
return chainId.toNumber();
|
44832
44957
|
}
|
44833
|
-
/**
|
44834
|
-
* Returns the base asset ID
|
44835
|
-
*
|
44836
|
-
* @returns A promise that resolves to the base asset ID
|
44837
|
-
*/
|
44838
|
-
getBaseAssetId() {
|
44839
|
-
const {
|
44840
|
-
consensusParameters: { baseAssetId }
|
44841
|
-
} = this.getChain();
|
44842
|
-
return baseAssetId;
|
44843
|
-
}
|
44844
44958
|
/**
|
44845
44959
|
* Submits a transaction to the chain to be executed.
|
44846
44960
|
*
|
@@ -45702,9 +45816,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45702
45816
|
* @param assetId - The asset ID to check the balance for.
|
45703
45817
|
* @returns A promise that resolves to the balance amount.
|
45704
45818
|
*/
|
45705
|
-
async getBalance(assetId) {
|
45706
|
-
const
|
45707
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45819
|
+
async getBalance(assetId = BaseAssetId) {
|
45820
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45708
45821
|
return amount;
|
45709
45822
|
}
|
45710
45823
|
/**
|
@@ -45742,10 +45855,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45742
45855
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45743
45856
|
*/
|
45744
45857
|
async fund(request, coinQuantities, fee) {
|
45745
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45746
45858
|
const updatedQuantities = addAmountToAsset({
|
45747
45859
|
amount: bn(fee),
|
45748
|
-
assetId:
|
45860
|
+
assetId: BaseAssetId,
|
45749
45861
|
coinQuantities
|
45750
45862
|
});
|
45751
45863
|
const quantitiesDict = {};
|
@@ -45769,8 +45881,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45769
45881
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45770
45882
|
cachedUtxos.push(input.id);
|
45771
45883
|
}
|
45772
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45773
|
-
quantitiesDict[
|
45884
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45885
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45774
45886
|
cachedMessages.push(input.nonce);
|
45775
45887
|
}
|
45776
45888
|
}
|
@@ -45802,12 +45914,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45802
45914
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45803
45915
|
* @returns A promise that resolves to the prepared transaction request.
|
45804
45916
|
*/
|
45805
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45917
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45806
45918
|
const { minGasPrice } = this.provider.getGasConfig();
|
45807
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45808
45919
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45809
45920
|
const request = new ScriptTransactionRequest(params);
|
45810
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45921
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
45811
45922
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45812
45923
|
estimateTxDependencies: true,
|
45813
45924
|
resourcesOwner: this
|
@@ -45833,15 +45944,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45833
45944
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45834
45945
|
* @returns A promise that resolves to the transaction response.
|
45835
45946
|
*/
|
45836
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
45947
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45837
45948
|
if (bn(amount).lte(0)) {
|
45838
45949
|
throw new FuelError(
|
45839
45950
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45840
45951
|
"Transfer amount must be a positive number."
|
45841
45952
|
);
|
45842
45953
|
}
|
45843
|
-
const
|
45844
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45954
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
45845
45955
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45846
45956
|
}
|
45847
45957
|
/**
|
@@ -45853,7 +45963,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45853
45963
|
* @param txParams - The optional transaction parameters.
|
45854
45964
|
* @returns A promise that resolves to the transaction response.
|
45855
45965
|
*/
|
45856
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
45966
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
45857
45967
|
if (bn(amount).lte(0)) {
|
45858
45968
|
throw new FuelError(
|
45859
45969
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45862,12 +45972,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45862
45972
|
}
|
45863
45973
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45864
45974
|
const { minGasPrice } = this.provider.getGasConfig();
|
45865
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45866
45975
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45867
45976
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45868
45977
|
hexlifiedContractId: contractAddress.toB256(),
|
45869
45978
|
amountToTransfer: bn(amount),
|
45870
|
-
assetId
|
45979
|
+
assetId
|
45871
45980
|
});
|
45872
45981
|
const request = new ScriptTransactionRequest({
|
45873
45982
|
...params,
|
@@ -45877,7 +45986,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45877
45986
|
request.addContractInputAndOutput(contractAddress);
|
45878
45987
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
45879
45988
|
request,
|
45880
|
-
[{ amount: bn(amount), assetId: String(
|
45989
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
45881
45990
|
);
|
45882
45991
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
45883
45992
|
this.validateGas({
|
@@ -45899,7 +46008,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45899
46008
|
*/
|
45900
46009
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
45901
46010
|
const { minGasPrice } = this.provider.getGasConfig();
|
45902
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45903
46011
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
45904
46012
|
const recipientDataArray = arrayify(
|
45905
46013
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -45914,7 +46022,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45914
46022
|
]);
|
45915
46023
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
45916
46024
|
const request = new ScriptTransactionRequest(params);
|
45917
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46025
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
45918
46026
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
45919
46027
|
request,
|
45920
46028
|
forwardingQuantities
|
@@ -50476,7 +50584,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50476
50584
|
{
|
50477
50585
|
owner: signer.address.toHexString(),
|
50478
50586
|
amount: toHex(1e9),
|
50479
|
-
asset_id:
|
50587
|
+
asset_id: BaseAssetId
|
50480
50588
|
}
|
50481
50589
|
]
|
50482
50590
|
}
|
@@ -50542,10 +50650,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50542
50650
|
})
|
50543
50651
|
);
|
50544
50652
|
var generateWallets = async (count, provider) => {
|
50545
|
-
const baseAssetId = provider.getBaseAssetId();
|
50546
50653
|
const wallets = [];
|
50547
50654
|
for (let i = 0; i < count; i += 1) {
|
50548
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50655
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50549
50656
|
wallets.push(wallet);
|
50550
50657
|
}
|
50551
50658
|
return wallets;
|