@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
package/dist/account.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;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,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA0CzB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
|
package/dist/index.global.js
CHANGED
@@ -29083,7 +29083,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29083
29083
|
})(ErrorCode || {});
|
29084
29084
|
var _FuelError = class extends Error {
|
29085
29085
|
VERSIONS = versions;
|
29086
|
-
metadata;
|
29087
29086
|
static parse(e) {
|
29088
29087
|
const error = e;
|
29089
29088
|
if (error.code === void 0) {
|
@@ -29103,15 +29102,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29103
29102
|
return new _FuelError(error.code, error.message);
|
29104
29103
|
}
|
29105
29104
|
code;
|
29106
|
-
constructor(code, message
|
29105
|
+
constructor(code, message) {
|
29107
29106
|
super(message);
|
29108
29107
|
this.code = code;
|
29109
29108
|
this.name = "FuelError";
|
29110
|
-
this.metadata = metadata;
|
29111
29109
|
}
|
29112
29110
|
toObject() {
|
29113
|
-
const { code, name, message,
|
29114
|
-
return { code, name, message,
|
29111
|
+
const { code, name, message, VERSIONS } = this;
|
29112
|
+
return { code, name, message, VERSIONS };
|
29115
29113
|
}
|
29116
29114
|
};
|
29117
29115
|
var FuelError = _FuelError;
|
@@ -31271,10 +31269,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31271
31269
|
}
|
31272
31270
|
};
|
31273
31271
|
|
31274
|
-
// ../address/dist/configs.mjs
|
31275
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31276
|
-
var BaseAssetId = ZeroBytes32;
|
31277
|
-
|
31278
31272
|
// ../math/dist/index.mjs
|
31279
31273
|
var import_bn = __toESM(require_bn(), 1);
|
31280
31274
|
var DEFAULT_PRECISION = 9;
|
@@ -31505,11 +31499,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31505
31499
|
let max2;
|
31506
31500
|
if (Array.isArray(coinQuantityLike)) {
|
31507
31501
|
amount = coinQuantityLike[0];
|
31508
|
-
assetId = coinQuantityLike[1]
|
31509
|
-
max2 = coinQuantityLike[2]
|
31502
|
+
assetId = coinQuantityLike[1];
|
31503
|
+
max2 = coinQuantityLike[2];
|
31510
31504
|
} else {
|
31511
31505
|
amount = coinQuantityLike.amount;
|
31512
|
-
assetId = coinQuantityLike.assetId
|
31506
|
+
assetId = coinQuantityLike.assetId;
|
31513
31507
|
max2 = coinQuantityLike.max ?? void 0;
|
31514
31508
|
}
|
31515
31509
|
const bnAmount = bn(amount);
|
@@ -38819,6 +38813,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38819
38813
|
}
|
38820
38814
|
};
|
38821
38815
|
|
38816
|
+
// ../address/dist/configs.mjs
|
38817
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38818
|
+
|
38822
38819
|
// src/providers/transaction-request/input.ts
|
38823
38820
|
var inputify = (value) => {
|
38824
38821
|
const { type: type3 } = value;
|
@@ -38953,60 +38950,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38953
38950
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
38954
38951
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
38955
38952
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
38956
|
-
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
38957
38953
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
38958
|
-
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
38959
|
-
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
38960
|
-
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
38961
|
-
var PANIC_REASONS = [
|
38962
|
-
"UnknownPanicReason",
|
38963
|
-
"Revert",
|
38964
|
-
"OutOfGas",
|
38965
|
-
"TransactionValidity",
|
38966
|
-
"MemoryOverflow",
|
38967
|
-
"ArithmeticOverflow",
|
38968
|
-
"ContractNotFound",
|
38969
|
-
"MemoryOwnership",
|
38970
|
-
"NotEnoughBalance",
|
38971
|
-
"ExpectedInternalContext",
|
38972
|
-
"AssetIdNotFound",
|
38973
|
-
"InputNotFound",
|
38974
|
-
"OutputNotFound",
|
38975
|
-
"WitnessNotFound",
|
38976
|
-
"TransactionMaturity",
|
38977
|
-
"InvalidMetadataIdentifier",
|
38978
|
-
"MalformedCallStructure",
|
38979
|
-
"ReservedRegisterNotWritable",
|
38980
|
-
"InvalidFlags",
|
38981
|
-
"InvalidImmediateValue",
|
38982
|
-
"ExpectedCoinInput",
|
38983
|
-
"EcalError",
|
38984
|
-
"MemoryWriteOverlap",
|
38985
|
-
"ContractNotInInputs",
|
38986
|
-
"InternalBalanceOverflow",
|
38987
|
-
"ContractMaxSize",
|
38988
|
-
"ExpectedUnallocatedStack",
|
38989
|
-
"MaxStaticContractsReached",
|
38990
|
-
"TransferAmountCannotBeZero",
|
38991
|
-
"ExpectedOutputVariable",
|
38992
|
-
"ExpectedParentInternalContext",
|
38993
|
-
"PredicateReturnedNonOne",
|
38994
|
-
"ContractIdAlreadyDeployed",
|
38995
|
-
"ContractMismatch",
|
38996
|
-
"MessageDataTooLong",
|
38997
|
-
"ArithmeticError",
|
38998
|
-
"ContractInstructionNotAllowed",
|
38999
|
-
"TransferZeroCoins",
|
39000
|
-
"InvalidInstruction",
|
39001
|
-
"MemoryNotExecutable",
|
39002
|
-
"PolicyIsNotSet",
|
39003
|
-
"PolicyNotFound",
|
39004
|
-
"TooManyReceipts",
|
39005
|
-
"BalanceOverflow",
|
39006
|
-
"InvalidBlockHeight",
|
39007
|
-
"TooManySlots"
|
39008
|
-
];
|
39009
|
-
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
39010
38954
|
|
39011
38955
|
// src/providers/utils/receipts.ts
|
39012
38956
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -39380,74 +39324,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39380
39324
|
});
|
39381
39325
|
}
|
39382
39326
|
|
39383
|
-
// src/providers/utils/extract-tx-error.ts
|
39384
|
-
var assemblePanicError = (status) => {
|
39385
|
-
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
39386
|
-
const reason = status.reason;
|
39387
|
-
if (PANIC_REASONS.includes(status.reason)) {
|
39388
|
-
errorMessage = `${errorMessage}
|
39389
|
-
|
39390
|
-
You can read more about this error at:
|
39391
|
-
|
39392
|
-
${PANIC_DOC_URL}#variant.${status.reason}`;
|
39393
|
-
}
|
39394
|
-
return { errorMessage, reason };
|
39395
|
-
};
|
39396
|
-
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
39397
|
-
var assembleRevertError = (receipts, logs) => {
|
39398
|
-
let errorMessage = "The transaction reverted with an unknown reason.";
|
39399
|
-
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
39400
|
-
let reason = "";
|
39401
|
-
if (revertReceipt) {
|
39402
|
-
const reasonHex = bn(revertReceipt.val).toHex();
|
39403
|
-
switch (reasonHex) {
|
39404
|
-
case FAILED_REQUIRE_SIGNAL: {
|
39405
|
-
reason = "require";
|
39406
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
39407
|
-
break;
|
39408
|
-
}
|
39409
|
-
case FAILED_ASSERT_EQ_SIGNAL: {
|
39410
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39411
|
-
reason = "assert_eq";
|
39412
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
39413
|
-
break;
|
39414
|
-
}
|
39415
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
39416
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39417
|
-
reason = "assert_ne";
|
39418
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
39419
|
-
break;
|
39420
|
-
}
|
39421
|
-
case FAILED_ASSERT_SIGNAL:
|
39422
|
-
reason = "assert";
|
39423
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
39424
|
-
break;
|
39425
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
39426
|
-
reason = "MissingOutputChange";
|
39427
|
-
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
39428
|
-
break;
|
39429
|
-
default:
|
39430
|
-
reason = "unknown";
|
39431
|
-
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
39432
|
-
}
|
39433
|
-
}
|
39434
|
-
return { errorMessage, reason };
|
39435
|
-
};
|
39436
|
-
var extractTxError = (params) => {
|
39437
|
-
const { receipts, status, logs } = params;
|
39438
|
-
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
39439
|
-
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
39440
|
-
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
39441
|
-
const metadata = {
|
39442
|
-
logs,
|
39443
|
-
receipts,
|
39444
|
-
panic: isPanic,
|
39445
|
-
revert: isRevert,
|
39446
|
-
reason
|
39447
|
-
};
|
39448
|
-
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
39449
|
-
};
|
39450
|
-
|
39451
39327
|
// src/providers/transaction-request/errors.ts
|
39452
39328
|
var ChangeOutputCollisionError = class extends Error {
|
39453
39329
|
name = "ChangeOutputCollisionError";
|
@@ -39495,6 +39371,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39495
39371
|
outputs = [];
|
39496
39372
|
/** List of witnesses */
|
39497
39373
|
witnesses = [];
|
39374
|
+
/** Base asset ID - should be fetched from the chain */
|
39375
|
+
baseAssetId = ZeroBytes32;
|
39498
39376
|
/**
|
39499
39377
|
* Constructor for initializing a base transaction request.
|
39500
39378
|
*
|
@@ -39507,7 +39385,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39507
39385
|
witnessLimit,
|
39508
39386
|
inputs,
|
39509
39387
|
outputs,
|
39510
|
-
witnesses
|
39388
|
+
witnesses,
|
39389
|
+
baseAssetId
|
39511
39390
|
} = {}) {
|
39512
39391
|
this.gasPrice = bn(gasPrice);
|
39513
39392
|
this.maturity = maturity ?? 0;
|
@@ -39516,6 +39395,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39516
39395
|
this.inputs = inputs ?? [];
|
39517
39396
|
this.outputs = outputs ?? [];
|
39518
39397
|
this.witnesses = witnesses ?? [];
|
39398
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39519
39399
|
}
|
39520
39400
|
static getPolicyMeta(req) {
|
39521
39401
|
let policyTypes = 0;
|
@@ -39740,11 +39620,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39740
39620
|
*
|
39741
39621
|
* @param message - Message resource.
|
39742
39622
|
* @param predicate - Predicate bytes.
|
39743
|
-
* @param predicateData - Predicate data bytes.
|
39744
39623
|
*/
|
39745
39624
|
addMessageInput(message, predicate) {
|
39746
39625
|
const { recipient, sender, amount } = message;
|
39747
|
-
const assetId = BaseAssetId;
|
39748
39626
|
let witnessIndex;
|
39749
39627
|
if (predicate) {
|
39750
39628
|
witnessIndex = 0;
|
@@ -39765,7 +39643,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39765
39643
|
predicateData: predicate?.predicateDataBytes
|
39766
39644
|
};
|
39767
39645
|
this.pushInput(input);
|
39768
|
-
this.addChangeOutput(recipient,
|
39646
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39769
39647
|
}
|
39770
39648
|
/**
|
39771
39649
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39826,12 +39704,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39826
39704
|
* @param amount - Amount of coin.
|
39827
39705
|
* @param assetId - Asset ID of coin.
|
39828
39706
|
*/
|
39829
|
-
addCoinOutput(to, amount, assetId
|
39707
|
+
addCoinOutput(to, amount, assetId) {
|
39830
39708
|
this.pushOutput({
|
39831
39709
|
type: OutputType.Coin,
|
39832
39710
|
to: addressify(to).toB256(),
|
39833
39711
|
amount,
|
39834
|
-
assetId
|
39712
|
+
assetId: assetId ?? this.baseAssetId
|
39835
39713
|
});
|
39836
39714
|
return this;
|
39837
39715
|
}
|
@@ -39858,7 +39736,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39858
39736
|
* @param to - Address of the owner.
|
39859
39737
|
* @param assetId - Asset ID of coin.
|
39860
39738
|
*/
|
39861
|
-
addChangeOutput(to, assetId
|
39739
|
+
addChangeOutput(to, assetId) {
|
39862
39740
|
const changeOutput = this.getChangeOutputs().find(
|
39863
39741
|
(output3) => hexlify(output3.assetId) === assetId
|
39864
39742
|
);
|
@@ -39866,7 +39744,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39866
39744
|
this.pushOutput({
|
39867
39745
|
type: OutputType.Change,
|
39868
39746
|
to: addressify(to).toB256(),
|
39869
|
-
assetId
|
39747
|
+
assetId: assetId ?? this.baseAssetId
|
39870
39748
|
});
|
39871
39749
|
}
|
39872
39750
|
}
|
@@ -39948,7 +39826,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39948
39826
|
]);
|
39949
39827
|
}
|
39950
39828
|
};
|
39951
|
-
updateAssetInput(
|
39829
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39952
39830
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39953
39831
|
}
|
39954
39832
|
/**
|
@@ -41264,26 +41142,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41264
41142
|
gqlTransaction: this.gqlTransaction,
|
41265
41143
|
...transactionSummary
|
41266
41144
|
};
|
41267
|
-
let logs = [];
|
41268
41145
|
if (this.abis) {
|
41269
|
-
logs = getDecodedLogs(
|
41146
|
+
const logs = getDecodedLogs(
|
41270
41147
|
transactionSummary.receipts,
|
41271
41148
|
this.abis.main,
|
41272
41149
|
this.abis.otherContractsAbis
|
41273
41150
|
);
|
41274
41151
|
transactionResult.logs = logs;
|
41275
41152
|
}
|
41276
|
-
if (transactionResult.isStatusFailure) {
|
41277
|
-
const {
|
41278
|
-
receipts,
|
41279
|
-
gqlTransaction: { status }
|
41280
|
-
} = transactionResult;
|
41281
|
-
throw extractTxError({
|
41282
|
-
receipts,
|
41283
|
-
status,
|
41284
|
-
logs
|
41285
|
-
});
|
41286
|
-
}
|
41287
41153
|
return transactionResult;
|
41288
41154
|
}
|
41289
41155
|
/**
|
@@ -41292,7 +41158,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41292
41158
|
* @param contractsAbiMap - The contracts ABI map.
|
41293
41159
|
*/
|
41294
41160
|
async wait(contractsAbiMap) {
|
41295
|
-
|
41161
|
+
const result = await this.waitForResult(contractsAbiMap);
|
41162
|
+
if (result.isStatusFailure) {
|
41163
|
+
throw new FuelError(
|
41164
|
+
ErrorCode.TRANSACTION_FAILED,
|
41165
|
+
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
41166
|
+
);
|
41167
|
+
}
|
41168
|
+
return result;
|
41296
41169
|
}
|
41297
41170
|
};
|
41298
41171
|
|
@@ -41371,6 +41244,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41371
41244
|
gasPerByte: bn(feeParams.gasPerByte),
|
41372
41245
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41373
41246
|
chainId: bn(consensusParameters.chainId),
|
41247
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41374
41248
|
gasCosts
|
41375
41249
|
},
|
41376
41250
|
gasCosts,
|
@@ -41613,6 +41487,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41613
41487
|
} = this.getChain();
|
41614
41488
|
return chainId.toNumber();
|
41615
41489
|
}
|
41490
|
+
/**
|
41491
|
+
* Returns the base asset ID
|
41492
|
+
*
|
41493
|
+
* @returns A promise that resolves to the base asset ID
|
41494
|
+
*/
|
41495
|
+
getBaseAssetId() {
|
41496
|
+
const {
|
41497
|
+
consensusParameters: { baseAssetId }
|
41498
|
+
} = this.getChain();
|
41499
|
+
return baseAssetId;
|
41500
|
+
}
|
41616
41501
|
/**
|
41617
41502
|
* Submits a transaction to the chain to be executed.
|
41618
41503
|
*
|
@@ -42642,8 +42527,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42642
42527
|
* @param assetId - The asset ID to check the balance for.
|
42643
42528
|
* @returns A promise that resolves to the balance amount.
|
42644
42529
|
*/
|
42645
|
-
async getBalance(assetId
|
42646
|
-
const
|
42530
|
+
async getBalance(assetId) {
|
42531
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42532
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42647
42533
|
return amount;
|
42648
42534
|
}
|
42649
42535
|
/**
|
@@ -42681,9 +42567,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42681
42567
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42682
42568
|
*/
|
42683
42569
|
async fund(request, coinQuantities, fee) {
|
42570
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42684
42571
|
const updatedQuantities = addAmountToAsset({
|
42685
42572
|
amount: bn(fee),
|
42686
|
-
assetId:
|
42573
|
+
assetId: baseAssetId,
|
42687
42574
|
coinQuantities
|
42688
42575
|
});
|
42689
42576
|
const quantitiesDict = {};
|
@@ -42707,8 +42594,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42707
42594
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42708
42595
|
cachedUtxos.push(input.id);
|
42709
42596
|
}
|
42710
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42711
|
-
quantitiesDict[
|
42597
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42598
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42712
42599
|
cachedMessages.push(input.nonce);
|
42713
42600
|
}
|
42714
42601
|
}
|
@@ -42740,11 +42627,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42740
42627
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42741
42628
|
* @returns A promise that resolves to the prepared transaction request.
|
42742
42629
|
*/
|
42743
|
-
async createTransfer(destination, amount, assetId
|
42630
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42744
42631
|
const { minGasPrice } = this.provider.getGasConfig();
|
42632
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42745
42633
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42746
42634
|
const request = new ScriptTransactionRequest(params);
|
42747
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42635
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42748
42636
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42749
42637
|
estimateTxDependencies: true,
|
42750
42638
|
resourcesOwner: this
|
@@ -42770,14 +42658,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42770
42658
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42771
42659
|
* @returns A promise that resolves to the transaction response.
|
42772
42660
|
*/
|
42773
|
-
async transfer(destination, amount, assetId
|
42661
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42774
42662
|
if (bn(amount).lte(0)) {
|
42775
42663
|
throw new FuelError(
|
42776
42664
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42777
42665
|
"Transfer amount must be a positive number."
|
42778
42666
|
);
|
42779
42667
|
}
|
42780
|
-
const
|
42668
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42669
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42781
42670
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42782
42671
|
}
|
42783
42672
|
/**
|
@@ -42789,7 +42678,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42789
42678
|
* @param txParams - The optional transaction parameters.
|
42790
42679
|
* @returns A promise that resolves to the transaction response.
|
42791
42680
|
*/
|
42792
|
-
async transferToContract(contractId, amount, assetId
|
42681
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42793
42682
|
if (bn(amount).lte(0)) {
|
42794
42683
|
throw new FuelError(
|
42795
42684
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42798,11 +42687,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42798
42687
|
}
|
42799
42688
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42800
42689
|
const { minGasPrice } = this.provider.getGasConfig();
|
42690
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42801
42691
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42802
42692
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42803
42693
|
hexlifiedContractId: contractAddress.toB256(),
|
42804
42694
|
amountToTransfer: bn(amount),
|
42805
|
-
assetId
|
42695
|
+
assetId: assetIdToTransfer
|
42806
42696
|
});
|
42807
42697
|
const request = new ScriptTransactionRequest({
|
42808
42698
|
...params,
|
@@ -42812,7 +42702,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42812
42702
|
request.addContractInputAndOutput(contractAddress);
|
42813
42703
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42814
42704
|
request,
|
42815
|
-
[{ amount: bn(amount), assetId: String(
|
42705
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42816
42706
|
);
|
42817
42707
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42818
42708
|
this.validateGas({
|
@@ -42834,6 +42724,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42834
42724
|
*/
|
42835
42725
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42836
42726
|
const { minGasPrice } = this.provider.getGasConfig();
|
42727
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42837
42728
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42838
42729
|
const recipientDataArray = arrayify(
|
42839
42730
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42848,7 +42739,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42848
42739
|
]);
|
42849
42740
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42850
42741
|
const request = new ScriptTransactionRequest(params);
|
42851
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42742
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42852
42743
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42853
42744
|
request,
|
42854
42745
|
forwardingQuantities
|
@@ -47812,8 +47703,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47812
47703
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47813
47704
|
* @returns A promise that resolves to the prepared transaction request.
|
47814
47705
|
*/
|
47815
|
-
async createTransfer(destination, amount, assetId
|
47816
|
-
const
|
47706
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47707
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47708
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47817
47709
|
return this.populateTransactionPredicateData(request);
|
47818
47710
|
}
|
47819
47711
|
/**
|