@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
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":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;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gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAyCzB,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,6 +29083,7 @@ 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;
|
29086
29087
|
static parse(e) {
|
29087
29088
|
const error = e;
|
29088
29089
|
if (error.code === void 0) {
|
@@ -29102,14 +29103,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29102
29103
|
return new _FuelError(error.code, error.message);
|
29103
29104
|
}
|
29104
29105
|
code;
|
29105
|
-
constructor(code, message) {
|
29106
|
+
constructor(code, message, metadata = {}) {
|
29106
29107
|
super(message);
|
29107
29108
|
this.code = code;
|
29108
29109
|
this.name = "FuelError";
|
29110
|
+
this.metadata = metadata;
|
29109
29111
|
}
|
29110
29112
|
toObject() {
|
29111
|
-
const { code, name, message, VERSIONS } = this;
|
29112
|
-
return { code, name, message, VERSIONS };
|
29113
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
29114
|
+
return { code, name, message, metadata, VERSIONS };
|
29113
29115
|
}
|
29114
29116
|
};
|
29115
29117
|
var FuelError = _FuelError;
|
@@ -31269,6 +31271,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31269
31271
|
}
|
31270
31272
|
};
|
31271
31273
|
|
31274
|
+
// ../address/dist/configs.mjs
|
31275
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31276
|
+
var BaseAssetId = ZeroBytes32;
|
31277
|
+
|
31272
31278
|
// ../math/dist/index.mjs
|
31273
31279
|
var import_bn = __toESM(require_bn(), 1);
|
31274
31280
|
var DEFAULT_PRECISION = 9;
|
@@ -31499,11 +31505,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31499
31505
|
let max2;
|
31500
31506
|
if (Array.isArray(coinQuantityLike)) {
|
31501
31507
|
amount = coinQuantityLike[0];
|
31502
|
-
assetId = coinQuantityLike[1];
|
31503
|
-
max2 = coinQuantityLike[2];
|
31508
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31509
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31504
31510
|
} else {
|
31505
31511
|
amount = coinQuantityLike.amount;
|
31506
|
-
assetId = coinQuantityLike.assetId;
|
31512
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31507
31513
|
max2 = coinQuantityLike.max ?? void 0;
|
31508
31514
|
}
|
31509
31515
|
const bnAmount = bn(amount);
|
@@ -38813,9 +38819,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38813
38819
|
}
|
38814
38820
|
};
|
38815
38821
|
|
38816
|
-
// ../address/dist/configs.mjs
|
38817
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38818
|
-
|
38819
38822
|
// src/providers/transaction-request/input.ts
|
38820
38823
|
var inputify = (value) => {
|
38821
38824
|
const { type: type3 } = value;
|
@@ -38950,7 +38953,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38950
38953
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
38951
38954
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
38952
38955
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
38956
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
38953
38957
|
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";
|
38954
39010
|
|
38955
39011
|
// src/providers/utils/receipts.ts
|
38956
39012
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -39324,6 +39380,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39324
39380
|
});
|
39325
39381
|
}
|
39326
39382
|
|
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
|
+
|
39327
39451
|
// src/providers/transaction-request/errors.ts
|
39328
39452
|
var ChangeOutputCollisionError = class extends Error {
|
39329
39453
|
name = "ChangeOutputCollisionError";
|
@@ -39371,8 +39495,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39371
39495
|
outputs = [];
|
39372
39496
|
/** List of witnesses */
|
39373
39497
|
witnesses = [];
|
39374
|
-
/** Base asset ID - should be fetched from the chain */
|
39375
|
-
baseAssetId = ZeroBytes32;
|
39376
39498
|
/**
|
39377
39499
|
* Constructor for initializing a base transaction request.
|
39378
39500
|
*
|
@@ -39385,8 +39507,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39385
39507
|
witnessLimit,
|
39386
39508
|
inputs,
|
39387
39509
|
outputs,
|
39388
|
-
witnesses
|
39389
|
-
baseAssetId
|
39510
|
+
witnesses
|
39390
39511
|
} = {}) {
|
39391
39512
|
this.gasPrice = bn(gasPrice);
|
39392
39513
|
this.maturity = maturity ?? 0;
|
@@ -39395,7 +39516,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39395
39516
|
this.inputs = inputs ?? [];
|
39396
39517
|
this.outputs = outputs ?? [];
|
39397
39518
|
this.witnesses = witnesses ?? [];
|
39398
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39399
39519
|
}
|
39400
39520
|
static getPolicyMeta(req) {
|
39401
39521
|
let policyTypes = 0;
|
@@ -39620,9 +39740,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39620
39740
|
*
|
39621
39741
|
* @param message - Message resource.
|
39622
39742
|
* @param predicate - Predicate bytes.
|
39743
|
+
* @param predicateData - Predicate data bytes.
|
39623
39744
|
*/
|
39624
39745
|
addMessageInput(message, predicate) {
|
39625
39746
|
const { recipient, sender, amount } = message;
|
39747
|
+
const assetId = BaseAssetId;
|
39626
39748
|
let witnessIndex;
|
39627
39749
|
if (predicate) {
|
39628
39750
|
witnessIndex = 0;
|
@@ -39643,7 +39765,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39643
39765
|
predicateData: predicate?.predicateDataBytes
|
39644
39766
|
};
|
39645
39767
|
this.pushInput(input);
|
39646
|
-
this.addChangeOutput(recipient,
|
39768
|
+
this.addChangeOutput(recipient, assetId);
|
39647
39769
|
}
|
39648
39770
|
/**
|
39649
39771
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39704,12 +39826,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39704
39826
|
* @param amount - Amount of coin.
|
39705
39827
|
* @param assetId - Asset ID of coin.
|
39706
39828
|
*/
|
39707
|
-
addCoinOutput(to, amount, assetId) {
|
39829
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39708
39830
|
this.pushOutput({
|
39709
39831
|
type: OutputType.Coin,
|
39710
39832
|
to: addressify(to).toB256(),
|
39711
39833
|
amount,
|
39712
|
-
assetId
|
39834
|
+
assetId
|
39713
39835
|
});
|
39714
39836
|
return this;
|
39715
39837
|
}
|
@@ -39736,7 +39858,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39736
39858
|
* @param to - Address of the owner.
|
39737
39859
|
* @param assetId - Asset ID of coin.
|
39738
39860
|
*/
|
39739
|
-
addChangeOutput(to, assetId) {
|
39861
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39740
39862
|
const changeOutput = this.getChangeOutputs().find(
|
39741
39863
|
(output3) => hexlify(output3.assetId) === assetId
|
39742
39864
|
);
|
@@ -39744,7 +39866,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39744
39866
|
this.pushOutput({
|
39745
39867
|
type: OutputType.Change,
|
39746
39868
|
to: addressify(to).toB256(),
|
39747
|
-
assetId
|
39869
|
+
assetId
|
39748
39870
|
});
|
39749
39871
|
}
|
39750
39872
|
}
|
@@ -39826,7 +39948,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39826
39948
|
]);
|
39827
39949
|
}
|
39828
39950
|
};
|
39829
|
-
updateAssetInput(
|
39951
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
39830
39952
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39831
39953
|
}
|
39832
39954
|
/**
|
@@ -41142,14 +41264,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41142
41264
|
gqlTransaction: this.gqlTransaction,
|
41143
41265
|
...transactionSummary
|
41144
41266
|
};
|
41267
|
+
let logs = [];
|
41145
41268
|
if (this.abis) {
|
41146
|
-
|
41269
|
+
logs = getDecodedLogs(
|
41147
41270
|
transactionSummary.receipts,
|
41148
41271
|
this.abis.main,
|
41149
41272
|
this.abis.otherContractsAbis
|
41150
41273
|
);
|
41151
41274
|
transactionResult.logs = logs;
|
41152
41275
|
}
|
41276
|
+
if (transactionResult.isStatusFailure) {
|
41277
|
+
const {
|
41278
|
+
receipts,
|
41279
|
+
gqlTransaction: { status }
|
41280
|
+
} = transactionResult;
|
41281
|
+
throw extractTxError({
|
41282
|
+
receipts,
|
41283
|
+
status,
|
41284
|
+
logs
|
41285
|
+
});
|
41286
|
+
}
|
41153
41287
|
return transactionResult;
|
41154
41288
|
}
|
41155
41289
|
/**
|
@@ -41158,14 +41292,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41158
41292
|
* @param contractsAbiMap - The contracts ABI map.
|
41159
41293
|
*/
|
41160
41294
|
async wait(contractsAbiMap) {
|
41161
|
-
|
41162
|
-
if (result.isStatusFailure) {
|
41163
|
-
throw new FuelError(
|
41164
|
-
ErrorCode.TRANSACTION_FAILED,
|
41165
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
41166
|
-
);
|
41167
|
-
}
|
41168
|
-
return result;
|
41295
|
+
return this.waitForResult(contractsAbiMap);
|
41169
41296
|
}
|
41170
41297
|
};
|
41171
41298
|
|
@@ -41244,7 +41371,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41244
41371
|
gasPerByte: bn(feeParams.gasPerByte),
|
41245
41372
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41246
41373
|
chainId: bn(consensusParameters.chainId),
|
41247
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41248
41374
|
gasCosts
|
41249
41375
|
},
|
41250
41376
|
gasCosts,
|
@@ -41487,17 +41613,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41487
41613
|
} = this.getChain();
|
41488
41614
|
return chainId.toNumber();
|
41489
41615
|
}
|
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
|
-
}
|
41501
41616
|
/**
|
41502
41617
|
* Submits a transaction to the chain to be executed.
|
41503
41618
|
*
|
@@ -42527,9 +42642,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42527
42642
|
* @param assetId - The asset ID to check the balance for.
|
42528
42643
|
* @returns A promise that resolves to the balance amount.
|
42529
42644
|
*/
|
42530
|
-
async getBalance(assetId) {
|
42531
|
-
const
|
42532
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42645
|
+
async getBalance(assetId = BaseAssetId) {
|
42646
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42533
42647
|
return amount;
|
42534
42648
|
}
|
42535
42649
|
/**
|
@@ -42567,10 +42681,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42567
42681
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42568
42682
|
*/
|
42569
42683
|
async fund(request, coinQuantities, fee) {
|
42570
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42571
42684
|
const updatedQuantities = addAmountToAsset({
|
42572
42685
|
amount: bn(fee),
|
42573
|
-
assetId:
|
42686
|
+
assetId: BaseAssetId,
|
42574
42687
|
coinQuantities
|
42575
42688
|
});
|
42576
42689
|
const quantitiesDict = {};
|
@@ -42594,8 +42707,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42594
42707
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42595
42708
|
cachedUtxos.push(input.id);
|
42596
42709
|
}
|
42597
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42598
|
-
quantitiesDict[
|
42710
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42711
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42599
42712
|
cachedMessages.push(input.nonce);
|
42600
42713
|
}
|
42601
42714
|
}
|
@@ -42627,12 +42740,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42627
42740
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42628
42741
|
* @returns A promise that resolves to the prepared transaction request.
|
42629
42742
|
*/
|
42630
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42743
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42631
42744
|
const { minGasPrice } = this.provider.getGasConfig();
|
42632
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42633
42745
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42634
42746
|
const request = new ScriptTransactionRequest(params);
|
42635
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42747
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42636
42748
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42637
42749
|
estimateTxDependencies: true,
|
42638
42750
|
resourcesOwner: this
|
@@ -42658,15 +42770,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42658
42770
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42659
42771
|
* @returns A promise that resolves to the transaction response.
|
42660
42772
|
*/
|
42661
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42773
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42662
42774
|
if (bn(amount).lte(0)) {
|
42663
42775
|
throw new FuelError(
|
42664
42776
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42665
42777
|
"Transfer amount must be a positive number."
|
42666
42778
|
);
|
42667
42779
|
}
|
42668
|
-
const
|
42669
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42780
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42670
42781
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42671
42782
|
}
|
42672
42783
|
/**
|
@@ -42678,7 +42789,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42678
42789
|
* @param txParams - The optional transaction parameters.
|
42679
42790
|
* @returns A promise that resolves to the transaction response.
|
42680
42791
|
*/
|
42681
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42792
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42682
42793
|
if (bn(amount).lte(0)) {
|
42683
42794
|
throw new FuelError(
|
42684
42795
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42687,12 +42798,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42687
42798
|
}
|
42688
42799
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42689
42800
|
const { minGasPrice } = this.provider.getGasConfig();
|
42690
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42691
42801
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42692
42802
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42693
42803
|
hexlifiedContractId: contractAddress.toB256(),
|
42694
42804
|
amountToTransfer: bn(amount),
|
42695
|
-
assetId
|
42805
|
+
assetId
|
42696
42806
|
});
|
42697
42807
|
const request = new ScriptTransactionRequest({
|
42698
42808
|
...params,
|
@@ -42702,7 +42812,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42702
42812
|
request.addContractInputAndOutput(contractAddress);
|
42703
42813
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42704
42814
|
request,
|
42705
|
-
[{ amount: bn(amount), assetId: String(
|
42815
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42706
42816
|
);
|
42707
42817
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42708
42818
|
this.validateGas({
|
@@ -42724,7 +42834,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42724
42834
|
*/
|
42725
42835
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42726
42836
|
const { minGasPrice } = this.provider.getGasConfig();
|
42727
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42728
42837
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42729
42838
|
const recipientDataArray = arrayify(
|
42730
42839
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42739,7 +42848,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42739
42848
|
]);
|
42740
42849
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42741
42850
|
const request = new ScriptTransactionRequest(params);
|
42742
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42851
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42743
42852
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42744
42853
|
request,
|
42745
42854
|
forwardingQuantities
|
@@ -47703,9 +47812,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47703
47812
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47704
47813
|
* @returns A promise that resolves to the prepared transaction request.
|
47705
47814
|
*/
|
47706
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47707
|
-
const
|
47708
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47815
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47816
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47709
47817
|
return this.populateTransactionPredicateData(request);
|
47710
47818
|
}
|
47711
47819
|
/**
|