@fuel-ts/account 0.0.0-rc-1895-20240404064636 → 0.0.0-rc-1976-20240404073406
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 +63 -171
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +513 -578
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +286 -356
- 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 +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -2
- 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/index.d.ts +0 -1
- 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 +65 -172
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +479 -537
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +260 -326
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/utils/extract-tx-error.d.ts +0 -36
- package/dist/providers/utils/extract-tx-error.d.ts.map +0 -1
@@ -32045,7 +32045,6 @@ 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;
|
32049
32048
|
static parse(e) {
|
32050
32049
|
const error = e;
|
32051
32050
|
if (error.code === void 0) {
|
@@ -32065,15 +32064,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32065
32064
|
return new _FuelError(error.code, error.message);
|
32066
32065
|
}
|
32067
32066
|
code;
|
32068
|
-
constructor(code, message
|
32067
|
+
constructor(code, message) {
|
32069
32068
|
super(message);
|
32070
32069
|
this.code = code;
|
32071
32070
|
this.name = "FuelError";
|
32072
|
-
this.metadata = metadata;
|
32073
32071
|
}
|
32074
32072
|
toObject() {
|
32075
|
-
const { code, name, message,
|
32076
|
-
return { code, name, message,
|
32073
|
+
const { code, name, message, VERSIONS } = this;
|
32074
|
+
return { code, name, message, VERSIONS };
|
32077
32075
|
}
|
32078
32076
|
};
|
32079
32077
|
var FuelError = _FuelError;
|
@@ -32485,7 +32483,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32485
32483
|
fee_params: {
|
32486
32484
|
gas_price_factor: 92,
|
32487
32485
|
gas_per_byte: 4
|
32488
|
-
}
|
32486
|
+
},
|
32487
|
+
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32489
32488
|
},
|
32490
32489
|
gas_costs: {
|
32491
32490
|
add: 1,
|
@@ -34754,10 +34753,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34754
34753
|
}
|
34755
34754
|
};
|
34756
34755
|
|
34757
|
-
// ../address/dist/configs.mjs
|
34758
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34759
|
-
var BaseAssetId = ZeroBytes32;
|
34760
|
-
|
34761
34756
|
// ../math/dist/index.mjs
|
34762
34757
|
var import_bn = __toESM(require_bn(), 1);
|
34763
34758
|
var DEFAULT_PRECISION = 9;
|
@@ -34988,11 +34983,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34988
34983
|
let max2;
|
34989
34984
|
if (Array.isArray(coinQuantityLike)) {
|
34990
34985
|
amount = coinQuantityLike[0];
|
34991
|
-
assetId = coinQuantityLike[1]
|
34992
|
-
max2 = coinQuantityLike[2]
|
34986
|
+
assetId = coinQuantityLike[1];
|
34987
|
+
max2 = coinQuantityLike[2];
|
34993
34988
|
} else {
|
34994
34989
|
amount = coinQuantityLike.amount;
|
34995
|
-
assetId = coinQuantityLike.assetId
|
34990
|
+
assetId = coinQuantityLike.assetId;
|
34996
34991
|
max2 = coinQuantityLike.max ?? void 0;
|
34997
34992
|
}
|
34998
34993
|
const bnAmount = bn(amount);
|
@@ -42284,6 +42279,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42284
42279
|
}
|
42285
42280
|
};
|
42286
42281
|
|
42282
|
+
// ../address/dist/configs.mjs
|
42283
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42284
|
+
|
42287
42285
|
// src/providers/transaction-request/input.ts
|
42288
42286
|
var inputify = (value) => {
|
42289
42287
|
const { type: type3 } = value;
|
@@ -42415,60 +42413,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42415
42413
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42416
42414
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42417
42415
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42418
|
-
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42419
42416
|
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";
|
42472
42417
|
|
42473
42418
|
// src/providers/utils/receipts.ts
|
42474
42419
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42781,74 +42726,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42781
42726
|
});
|
42782
42727
|
}
|
42783
42728
|
|
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
|
-
|
42852
42729
|
// src/providers/transaction-request/errors.ts
|
42853
42730
|
var NoWitnessAtIndexError = class extends Error {
|
42854
42731
|
constructor(index) {
|
@@ -42884,6 +42761,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42884
42761
|
outputs = [];
|
42885
42762
|
/** List of witnesses */
|
42886
42763
|
witnesses = [];
|
42764
|
+
/** Base asset ID - should be fetched from the chain */
|
42765
|
+
baseAssetId = ZeroBytes32;
|
42887
42766
|
/**
|
42888
42767
|
* Constructor for initializing a base transaction request.
|
42889
42768
|
*
|
@@ -42896,7 +42775,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42896
42775
|
witnessLimit,
|
42897
42776
|
inputs,
|
42898
42777
|
outputs,
|
42899
|
-
witnesses
|
42778
|
+
witnesses,
|
42779
|
+
baseAssetId
|
42900
42780
|
} = {}) {
|
42901
42781
|
this.gasPrice = bn(gasPrice);
|
42902
42782
|
this.maturity = maturity ?? 0;
|
@@ -42905,6 +42785,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42905
42785
|
this.inputs = inputs ?? [];
|
42906
42786
|
this.outputs = outputs ?? [];
|
42907
42787
|
this.witnesses = witnesses ?? [];
|
42788
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42908
42789
|
}
|
42909
42790
|
static getPolicyMeta(req) {
|
42910
42791
|
let policyTypes = 0;
|
@@ -43129,11 +43010,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43129
43010
|
*
|
43130
43011
|
* @param message - Message resource.
|
43131
43012
|
* @param predicate - Predicate bytes.
|
43132
|
-
* @param predicateData - Predicate data bytes.
|
43133
43013
|
*/
|
43134
43014
|
addMessageInput(message, predicate) {
|
43135
43015
|
const { recipient, sender, amount } = message;
|
43136
|
-
const assetId = BaseAssetId;
|
43137
43016
|
let witnessIndex;
|
43138
43017
|
if (predicate) {
|
43139
43018
|
witnessIndex = 0;
|
@@ -43154,7 +43033,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43154
43033
|
predicateData: predicate?.predicateDataBytes
|
43155
43034
|
};
|
43156
43035
|
this.pushInput(input);
|
43157
|
-
this.addChangeOutput(recipient,
|
43036
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
43158
43037
|
}
|
43159
43038
|
/**
|
43160
43039
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43215,12 +43094,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43215
43094
|
* @param amount - Amount of coin.
|
43216
43095
|
* @param assetId - Asset ID of coin.
|
43217
43096
|
*/
|
43218
|
-
addCoinOutput(to, amount, assetId
|
43097
|
+
addCoinOutput(to, amount, assetId) {
|
43219
43098
|
this.pushOutput({
|
43220
43099
|
type: OutputType.Coin,
|
43221
43100
|
to: addressify(to).toB256(),
|
43222
43101
|
amount,
|
43223
|
-
assetId
|
43102
|
+
assetId: assetId ?? this.baseAssetId
|
43224
43103
|
});
|
43225
43104
|
return this;
|
43226
43105
|
}
|
@@ -43247,7 +43126,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43247
43126
|
* @param to - Address of the owner.
|
43248
43127
|
* @param assetId - Asset ID of coin.
|
43249
43128
|
*/
|
43250
|
-
addChangeOutput(to, assetId
|
43129
|
+
addChangeOutput(to, assetId) {
|
43251
43130
|
const changeOutput = this.getChangeOutputs().find(
|
43252
43131
|
(output3) => hexlify(output3.assetId) === assetId
|
43253
43132
|
);
|
@@ -43255,7 +43134,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43255
43134
|
this.pushOutput({
|
43256
43135
|
type: OutputType.Change,
|
43257
43136
|
to: addressify(to).toB256(),
|
43258
|
-
assetId
|
43137
|
+
assetId: assetId ?? this.baseAssetId
|
43259
43138
|
});
|
43260
43139
|
}
|
43261
43140
|
}
|
@@ -43337,7 +43216,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43337
43216
|
]);
|
43338
43217
|
}
|
43339
43218
|
};
|
43340
|
-
updateAssetInput(
|
43219
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
43341
43220
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43342
43221
|
}
|
43343
43222
|
/**
|
@@ -44606,26 +44485,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44606
44485
|
gqlTransaction: this.gqlTransaction,
|
44607
44486
|
...transactionSummary
|
44608
44487
|
};
|
44609
|
-
let logs = [];
|
44610
44488
|
if (this.abis) {
|
44611
|
-
logs = getDecodedLogs(
|
44489
|
+
const logs = getDecodedLogs(
|
44612
44490
|
transactionSummary.receipts,
|
44613
44491
|
this.abis.main,
|
44614
44492
|
this.abis.otherContractsAbis
|
44615
44493
|
);
|
44616
44494
|
transactionResult.logs = logs;
|
44617
44495
|
}
|
44618
|
-
if (transactionResult.isStatusFailure) {
|
44619
|
-
const {
|
44620
|
-
receipts,
|
44621
|
-
gqlTransaction: { status }
|
44622
|
-
} = transactionResult;
|
44623
|
-
throw extractTxError({
|
44624
|
-
receipts,
|
44625
|
-
status,
|
44626
|
-
logs
|
44627
|
-
});
|
44628
|
-
}
|
44629
44496
|
return transactionResult;
|
44630
44497
|
}
|
44631
44498
|
/**
|
@@ -44634,7 +44501,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44634
44501
|
* @param contractsAbiMap - The contracts ABI map.
|
44635
44502
|
*/
|
44636
44503
|
async wait(contractsAbiMap) {
|
44637
|
-
|
44504
|
+
const result = await this.waitForResult(contractsAbiMap);
|
44505
|
+
if (result.isStatusFailure) {
|
44506
|
+
throw new FuelError(
|
44507
|
+
ErrorCode.TRANSACTION_FAILED,
|
44508
|
+
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44509
|
+
);
|
44510
|
+
}
|
44511
|
+
return result;
|
44638
44512
|
}
|
44639
44513
|
};
|
44640
44514
|
|
@@ -44713,6 +44587,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44713
44587
|
gasPerByte: bn(feeParams.gasPerByte),
|
44714
44588
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44715
44589
|
chainId: bn(consensusParameters.chainId),
|
44590
|
+
baseAssetId: consensusParameters.baseAssetId,
|
44716
44591
|
gasCosts
|
44717
44592
|
},
|
44718
44593
|
gasCosts,
|
@@ -44955,6 +44830,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44955
44830
|
} = this.getChain();
|
44956
44831
|
return chainId.toNumber();
|
44957
44832
|
}
|
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
|
+
}
|
44958
44844
|
/**
|
44959
44845
|
* Submits a transaction to the chain to be executed.
|
44960
44846
|
*
|
@@ -45816,8 +45702,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45816
45702
|
* @param assetId - The asset ID to check the balance for.
|
45817
45703
|
* @returns A promise that resolves to the balance amount.
|
45818
45704
|
*/
|
45819
|
-
async getBalance(assetId
|
45820
|
-
const
|
45705
|
+
async getBalance(assetId) {
|
45706
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
45707
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45821
45708
|
return amount;
|
45822
45709
|
}
|
45823
45710
|
/**
|
@@ -45855,9 +45742,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45855
45742
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45856
45743
|
*/
|
45857
45744
|
async fund(request, coinQuantities, fee) {
|
45745
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
45858
45746
|
const updatedQuantities = addAmountToAsset({
|
45859
45747
|
amount: bn(fee),
|
45860
|
-
assetId:
|
45748
|
+
assetId: baseAssetId,
|
45861
45749
|
coinQuantities
|
45862
45750
|
});
|
45863
45751
|
const quantitiesDict = {};
|
@@ -45881,8 +45769,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45881
45769
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45882
45770
|
cachedUtxos.push(input.id);
|
45883
45771
|
}
|
45884
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45885
|
-
quantitiesDict[
|
45772
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
45773
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
45886
45774
|
cachedMessages.push(input.nonce);
|
45887
45775
|
}
|
45888
45776
|
}
|
@@ -45914,11 +45802,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45914
45802
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45915
45803
|
* @returns A promise that resolves to the prepared transaction request.
|
45916
45804
|
*/
|
45917
|
-
async createTransfer(destination, amount, assetId
|
45805
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45918
45806
|
const { minGasPrice } = this.provider.getGasConfig();
|
45807
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45919
45808
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45920
45809
|
const request = new ScriptTransactionRequest(params);
|
45921
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45810
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
45922
45811
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45923
45812
|
estimateTxDependencies: true,
|
45924
45813
|
resourcesOwner: this
|
@@ -45944,14 +45833,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45944
45833
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45945
45834
|
* @returns A promise that resolves to the transaction response.
|
45946
45835
|
*/
|
45947
|
-
async transfer(destination, amount, assetId
|
45836
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
45948
45837
|
if (bn(amount).lte(0)) {
|
45949
45838
|
throw new FuelError(
|
45950
45839
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45951
45840
|
"Transfer amount must be a positive number."
|
45952
45841
|
);
|
45953
45842
|
}
|
45954
|
-
const
|
45843
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45844
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45955
45845
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45956
45846
|
}
|
45957
45847
|
/**
|
@@ -45963,7 +45853,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45963
45853
|
* @param txParams - The optional transaction parameters.
|
45964
45854
|
* @returns A promise that resolves to the transaction response.
|
45965
45855
|
*/
|
45966
|
-
async transferToContract(contractId, amount, assetId
|
45856
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
45967
45857
|
if (bn(amount).lte(0)) {
|
45968
45858
|
throw new FuelError(
|
45969
45859
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45972,11 +45862,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45972
45862
|
}
|
45973
45863
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45974
45864
|
const { minGasPrice } = this.provider.getGasConfig();
|
45865
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45975
45866
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45976
45867
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45977
45868
|
hexlifiedContractId: contractAddress.toB256(),
|
45978
45869
|
amountToTransfer: bn(amount),
|
45979
|
-
assetId
|
45870
|
+
assetId: assetIdToTransfer
|
45980
45871
|
});
|
45981
45872
|
const request = new ScriptTransactionRequest({
|
45982
45873
|
...params,
|
@@ -45986,7 +45877,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45986
45877
|
request.addContractInputAndOutput(contractAddress);
|
45987
45878
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
45988
45879
|
request,
|
45989
|
-
[{ amount: bn(amount), assetId: String(
|
45880
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
45990
45881
|
);
|
45991
45882
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
45992
45883
|
this.validateGas({
|
@@ -46008,6 +45899,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46008
45899
|
*/
|
46009
45900
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46010
45901
|
const { minGasPrice } = this.provider.getGasConfig();
|
45902
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
46011
45903
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46012
45904
|
const recipientDataArray = arrayify(
|
46013
45905
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46022,7 +45914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46022
45914
|
]);
|
46023
45915
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46024
45916
|
const request = new ScriptTransactionRequest(params);
|
46025
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
45917
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
46026
45918
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46027
45919
|
request,
|
46028
45920
|
forwardingQuantities
|
@@ -50584,7 +50476,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50584
50476
|
{
|
50585
50477
|
owner: signer.address.toHexString(),
|
50586
50478
|
amount: toHex(1e9),
|
50587
|
-
asset_id:
|
50479
|
+
asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes32
|
50588
50480
|
}
|
50589
50481
|
]
|
50590
50482
|
}
|
@@ -50650,9 +50542,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50650
50542
|
})
|
50651
50543
|
);
|
50652
50544
|
var generateWallets = async (count, provider) => {
|
50545
|
+
const baseAssetId = provider.getBaseAssetId();
|
50653
50546
|
const wallets = [];
|
50654
50547
|
for (let i = 0; i < count; i += 1) {
|
50655
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50548
|
+
const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
|
50656
50549
|
wallets.push(wallet);
|
50657
50550
|
}
|
50658
50551
|
return wallets;
|