@fuel-ts/account 0.0.0-rc-1895-20240404023124 → 0.0.0-rc-1976-20240404063407
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 -182
- 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 -183
- 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
@@ -31975,7 +31975,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31975
31975
|
ErrorCode2["ABI_TYPES_AND_VALUES_MISMATCH"] = "abi-types-and-values-mismatch";
|
31976
31976
|
ErrorCode2["ABI_MAIN_METHOD_MISSING"] = "abi-main-method-missing";
|
31977
31977
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
31978
|
-
ErrorCode2["FRAGMENT_NOT_FOUND"] = "fragment-not-found";
|
31979
31978
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
31980
31979
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
31981
31980
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
@@ -31990,14 +31989,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31990
31989
|
ErrorCode2["INVALID_BECH32_ADDRESS"] = "invalid-bech32-address";
|
31991
31990
|
ErrorCode2["INVALID_EVM_ADDRESS"] = "invalid-evm-address";
|
31992
31991
|
ErrorCode2["INVALID_B256_ADDRESS"] = "invalid-b256-address";
|
31993
|
-
ErrorCode2["INVALID_URL"] = "invalid-url";
|
31994
31992
|
ErrorCode2["CHAIN_INFO_CACHE_EMPTY"] = "chain-info-cache-empty";
|
31995
31993
|
ErrorCode2["NODE_INFO_CACHE_EMPTY"] = "node-info-cache-empty";
|
31996
31994
|
ErrorCode2["MISSING_PROVIDER"] = "missing-provider";
|
31997
31995
|
ErrorCode2["INVALID_PROVIDER"] = "invalid-provider";
|
31998
31996
|
ErrorCode2["CONNECTION_REFUSED"] = "connection-refused";
|
31999
31997
|
ErrorCode2["INVALID_PUBLIC_KEY"] = "invalid-public-key";
|
32000
|
-
ErrorCode2["INSUFFICIENT_BALANCE"] = "insufficient-balance";
|
32001
31998
|
ErrorCode2["WALLET_MANAGER_ERROR"] = "wallet-manager-error";
|
32002
31999
|
ErrorCode2["HD_WALLET_ERROR"] = "hd-wallet-error";
|
32003
32000
|
ErrorCode2["MISSING_CONNECTOR"] = "missing-connector";
|
@@ -32014,7 +32011,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32014
32011
|
ErrorCode2["ELEMENT_NOT_FOUND"] = "element-not-found";
|
32015
32012
|
ErrorCode2["MISSING_REQUIRED_PARAMETER"] = "missing-required-parameter";
|
32016
32013
|
ErrorCode2["INVALID_REQUEST"] = "invalid-request";
|
32017
|
-
ErrorCode2["UNEXPECTED_HEX_VALUE"] = "unexpected-hex-value";
|
32018
32014
|
ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
|
32019
32015
|
ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
|
32020
32016
|
ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
|
@@ -32038,7 +32034,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32038
32034
|
ErrorCode2["INVALID_PASSWORD"] = "invalid-password";
|
32039
32035
|
ErrorCode2["ACCOUNT_REQUIRED"] = "account-required";
|
32040
32036
|
ErrorCode2["UNLOCKED_WALLET_REQUIRED"] = "unlocked-wallet-required";
|
32041
|
-
ErrorCode2["LATEST_BLOCK_UNAVAILABLE"] = "latest-block-unavailable";
|
32042
32037
|
ErrorCode2["ERROR_BUILDING_BLOCK_EXPLORER_URL"] = "error-building-block-explorer-url";
|
32043
32038
|
ErrorCode2["UNSUPPORTED_FUEL_CLIENT_VERSION"] = "unsupported-fuel-client-version";
|
32044
32039
|
ErrorCode2["VITEPRESS_PLUGIN_ERROR"] = "vitepress-plugin-error";
|
@@ -32050,7 +32045,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32050
32045
|
})(ErrorCode || {});
|
32051
32046
|
var _FuelError = class extends Error {
|
32052
32047
|
VERSIONS = versions;
|
32053
|
-
metadata;
|
32054
32048
|
static parse(e) {
|
32055
32049
|
const error = e;
|
32056
32050
|
if (error.code === void 0) {
|
@@ -32070,15 +32064,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32070
32064
|
return new _FuelError(error.code, error.message);
|
32071
32065
|
}
|
32072
32066
|
code;
|
32073
|
-
constructor(code, message
|
32067
|
+
constructor(code, message) {
|
32074
32068
|
super(message);
|
32075
32069
|
this.code = code;
|
32076
32070
|
this.name = "FuelError";
|
32077
|
-
this.metadata = metadata;
|
32078
32071
|
}
|
32079
32072
|
toObject() {
|
32080
|
-
const { code, name, message,
|
32081
|
-
return { code, name, message,
|
32073
|
+
const { code, name, message, VERSIONS } = this;
|
32074
|
+
return { code, name, message, VERSIONS };
|
32082
32075
|
}
|
32083
32076
|
};
|
32084
32077
|
var FuelError = _FuelError;
|
@@ -32490,7 +32483,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32490
32483
|
fee_params: {
|
32491
32484
|
gas_price_factor: 92,
|
32492
32485
|
gas_per_byte: 4
|
32493
|
-
}
|
32486
|
+
},
|
32487
|
+
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32494
32488
|
},
|
32495
32489
|
gas_costs: {
|
32496
32490
|
add: 1,
|
@@ -34759,10 +34753,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34759
34753
|
}
|
34760
34754
|
};
|
34761
34755
|
|
34762
|
-
// ../address/dist/configs.mjs
|
34763
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34764
|
-
var BaseAssetId = ZeroBytes32;
|
34765
|
-
|
34766
34756
|
// ../math/dist/index.mjs
|
34767
34757
|
var import_bn = __toESM(require_bn(), 1);
|
34768
34758
|
var DEFAULT_PRECISION = 9;
|
@@ -34993,11 +34983,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34993
34983
|
let max2;
|
34994
34984
|
if (Array.isArray(coinQuantityLike)) {
|
34995
34985
|
amount = coinQuantityLike[0];
|
34996
|
-
assetId = coinQuantityLike[1]
|
34997
|
-
max2 = coinQuantityLike[2]
|
34986
|
+
assetId = coinQuantityLike[1];
|
34987
|
+
max2 = coinQuantityLike[2];
|
34998
34988
|
} else {
|
34999
34989
|
amount = coinQuantityLike.amount;
|
35000
|
-
assetId = coinQuantityLike.assetId
|
34990
|
+
assetId = coinQuantityLike.assetId;
|
35001
34991
|
max2 = coinQuantityLike.max ?? void 0;
|
35002
34992
|
}
|
35003
34993
|
const bnAmount = bn(amount);
|
@@ -36689,16 +36679,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36689
36679
|
}
|
36690
36680
|
decodeFunctionData(functionFragment, data) {
|
36691
36681
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
36692
|
-
if (!fragment) {
|
36693
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
36694
|
-
}
|
36695
36682
|
return fragment.decodeArguments(data);
|
36696
36683
|
}
|
36697
36684
|
encodeFunctionData(functionFragment, values, offset = 0) {
|
36698
36685
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
36699
|
-
if (!fragment) {
|
36700
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
36701
|
-
}
|
36702
36686
|
return fragment.encodeArguments(values, offset);
|
36703
36687
|
}
|
36704
36688
|
// Decode the result of a function call
|
@@ -42295,6 +42279,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42295
42279
|
}
|
42296
42280
|
};
|
42297
42281
|
|
42282
|
+
// ../address/dist/configs.mjs
|
42283
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42284
|
+
|
42298
42285
|
// src/providers/transaction-request/input.ts
|
42299
42286
|
var inputify = (value) => {
|
42300
42287
|
const { type: type3 } = value;
|
@@ -42426,60 +42413,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42426
42413
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42427
42414
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42428
42415
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42429
|
-
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42430
42416
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42431
|
-
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42432
|
-
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42433
|
-
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42434
|
-
var PANIC_REASONS = [
|
42435
|
-
"UnknownPanicReason",
|
42436
|
-
"Revert",
|
42437
|
-
"OutOfGas",
|
42438
|
-
"TransactionValidity",
|
42439
|
-
"MemoryOverflow",
|
42440
|
-
"ArithmeticOverflow",
|
42441
|
-
"ContractNotFound",
|
42442
|
-
"MemoryOwnership",
|
42443
|
-
"NotEnoughBalance",
|
42444
|
-
"ExpectedInternalContext",
|
42445
|
-
"AssetIdNotFound",
|
42446
|
-
"InputNotFound",
|
42447
|
-
"OutputNotFound",
|
42448
|
-
"WitnessNotFound",
|
42449
|
-
"TransactionMaturity",
|
42450
|
-
"InvalidMetadataIdentifier",
|
42451
|
-
"MalformedCallStructure",
|
42452
|
-
"ReservedRegisterNotWritable",
|
42453
|
-
"InvalidFlags",
|
42454
|
-
"InvalidImmediateValue",
|
42455
|
-
"ExpectedCoinInput",
|
42456
|
-
"EcalError",
|
42457
|
-
"MemoryWriteOverlap",
|
42458
|
-
"ContractNotInInputs",
|
42459
|
-
"InternalBalanceOverflow",
|
42460
|
-
"ContractMaxSize",
|
42461
|
-
"ExpectedUnallocatedStack",
|
42462
|
-
"MaxStaticContractsReached",
|
42463
|
-
"TransferAmountCannotBeZero",
|
42464
|
-
"ExpectedOutputVariable",
|
42465
|
-
"ExpectedParentInternalContext",
|
42466
|
-
"PredicateReturnedNonOne",
|
42467
|
-
"ContractIdAlreadyDeployed",
|
42468
|
-
"ContractMismatch",
|
42469
|
-
"MessageDataTooLong",
|
42470
|
-
"ArithmeticError",
|
42471
|
-
"ContractInstructionNotAllowed",
|
42472
|
-
"TransferZeroCoins",
|
42473
|
-
"InvalidInstruction",
|
42474
|
-
"MemoryNotExecutable",
|
42475
|
-
"PolicyIsNotSet",
|
42476
|
-
"PolicyNotFound",
|
42477
|
-
"TooManyReceipts",
|
42478
|
-
"BalanceOverflow",
|
42479
|
-
"InvalidBlockHeight",
|
42480
|
-
"TooManySlots"
|
42481
|
-
];
|
42482
|
-
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42483
42417
|
|
42484
42418
|
// src/providers/utils/receipts.ts
|
42485
42419
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42792,74 +42726,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42792
42726
|
});
|
42793
42727
|
}
|
42794
42728
|
|
42795
|
-
// src/providers/utils/extract-tx-error.ts
|
42796
|
-
var assemblePanicError = (status) => {
|
42797
|
-
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42798
|
-
const reason = status.reason;
|
42799
|
-
if (PANIC_REASONS.includes(status.reason)) {
|
42800
|
-
errorMessage = `${errorMessage}
|
42801
|
-
|
42802
|
-
You can read more about this error at:
|
42803
|
-
|
42804
|
-
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42805
|
-
}
|
42806
|
-
return { errorMessage, reason };
|
42807
|
-
};
|
42808
|
-
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42809
|
-
var assembleRevertError = (receipts, logs) => {
|
42810
|
-
let errorMessage = "The transaction reverted with an unknown reason.";
|
42811
|
-
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42812
|
-
let reason = "";
|
42813
|
-
if (revertReceipt) {
|
42814
|
-
const reasonHex = bn(revertReceipt.val).toHex();
|
42815
|
-
switch (reasonHex) {
|
42816
|
-
case FAILED_REQUIRE_SIGNAL: {
|
42817
|
-
reason = "require";
|
42818
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42819
|
-
break;
|
42820
|
-
}
|
42821
|
-
case FAILED_ASSERT_EQ_SIGNAL: {
|
42822
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42823
|
-
reason = "assert_eq";
|
42824
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42825
|
-
break;
|
42826
|
-
}
|
42827
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
42828
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42829
|
-
reason = "assert_ne";
|
42830
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42831
|
-
break;
|
42832
|
-
}
|
42833
|
-
case FAILED_ASSERT_SIGNAL:
|
42834
|
-
reason = "assert";
|
42835
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42836
|
-
break;
|
42837
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42838
|
-
reason = "MissingOutputChange";
|
42839
|
-
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42840
|
-
break;
|
42841
|
-
default:
|
42842
|
-
reason = "unknown";
|
42843
|
-
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42844
|
-
}
|
42845
|
-
}
|
42846
|
-
return { errorMessage, reason };
|
42847
|
-
};
|
42848
|
-
var extractTxError = (params) => {
|
42849
|
-
const { receipts, status, logs } = params;
|
42850
|
-
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42851
|
-
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42852
|
-
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42853
|
-
const metadata = {
|
42854
|
-
logs,
|
42855
|
-
receipts,
|
42856
|
-
panic: isPanic,
|
42857
|
-
revert: isRevert,
|
42858
|
-
reason
|
42859
|
-
};
|
42860
|
-
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42861
|
-
};
|
42862
|
-
|
42863
42729
|
// src/providers/transaction-request/errors.ts
|
42864
42730
|
var NoWitnessAtIndexError = class extends Error {
|
42865
42731
|
constructor(index) {
|
@@ -42895,6 +42761,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42895
42761
|
outputs = [];
|
42896
42762
|
/** List of witnesses */
|
42897
42763
|
witnesses = [];
|
42764
|
+
/** Base asset ID - should be fetched from the chain */
|
42765
|
+
baseAssetId = ZeroBytes32;
|
42898
42766
|
/**
|
42899
42767
|
* Constructor for initializing a base transaction request.
|
42900
42768
|
*
|
@@ -42907,7 +42775,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42907
42775
|
witnessLimit,
|
42908
42776
|
inputs,
|
42909
42777
|
outputs,
|
42910
|
-
witnesses
|
42778
|
+
witnesses,
|
42779
|
+
baseAssetId
|
42911
42780
|
} = {}) {
|
42912
42781
|
this.gasPrice = bn(gasPrice);
|
42913
42782
|
this.maturity = maturity ?? 0;
|
@@ -42916,6 +42785,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42916
42785
|
this.inputs = inputs ?? [];
|
42917
42786
|
this.outputs = outputs ?? [];
|
42918
42787
|
this.witnesses = witnesses ?? [];
|
42788
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42919
42789
|
}
|
42920
42790
|
static getPolicyMeta(req) {
|
42921
42791
|
let policyTypes = 0;
|
@@ -43140,11 +43010,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43140
43010
|
*
|
43141
43011
|
* @param message - Message resource.
|
43142
43012
|
* @param predicate - Predicate bytes.
|
43143
|
-
* @param predicateData - Predicate data bytes.
|
43144
43013
|
*/
|
43145
43014
|
addMessageInput(message, predicate) {
|
43146
43015
|
const { recipient, sender, amount } = message;
|
43147
|
-
const assetId = BaseAssetId;
|
43148
43016
|
let witnessIndex;
|
43149
43017
|
if (predicate) {
|
43150
43018
|
witnessIndex = 0;
|
@@ -43165,7 +43033,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43165
43033
|
predicateData: predicate?.predicateDataBytes
|
43166
43034
|
};
|
43167
43035
|
this.pushInput(input);
|
43168
|
-
this.addChangeOutput(recipient,
|
43036
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
43169
43037
|
}
|
43170
43038
|
/**
|
43171
43039
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43226,12 +43094,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43226
43094
|
* @param amount - Amount of coin.
|
43227
43095
|
* @param assetId - Asset ID of coin.
|
43228
43096
|
*/
|
43229
|
-
addCoinOutput(to, amount, assetId
|
43097
|
+
addCoinOutput(to, amount, assetId) {
|
43230
43098
|
this.pushOutput({
|
43231
43099
|
type: OutputType.Coin,
|
43232
43100
|
to: addressify(to).toB256(),
|
43233
43101
|
amount,
|
43234
|
-
assetId
|
43102
|
+
assetId: assetId ?? this.baseAssetId
|
43235
43103
|
});
|
43236
43104
|
return this;
|
43237
43105
|
}
|
@@ -43258,7 +43126,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43258
43126
|
* @param to - Address of the owner.
|
43259
43127
|
* @param assetId - Asset ID of coin.
|
43260
43128
|
*/
|
43261
|
-
addChangeOutput(to, assetId
|
43129
|
+
addChangeOutput(to, assetId) {
|
43262
43130
|
const changeOutput = this.getChangeOutputs().find(
|
43263
43131
|
(output3) => hexlify(output3.assetId) === assetId
|
43264
43132
|
);
|
@@ -43266,7 +43134,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43266
43134
|
this.pushOutput({
|
43267
43135
|
type: OutputType.Change,
|
43268
43136
|
to: addressify(to).toB256(),
|
43269
|
-
assetId
|
43137
|
+
assetId: assetId ?? this.baseAssetId
|
43270
43138
|
});
|
43271
43139
|
}
|
43272
43140
|
}
|
@@ -43348,7 +43216,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43348
43216
|
]);
|
43349
43217
|
}
|
43350
43218
|
};
|
43351
|
-
updateAssetInput(
|
43219
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
43352
43220
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43353
43221
|
}
|
43354
43222
|
/**
|
@@ -44617,26 +44485,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44617
44485
|
gqlTransaction: this.gqlTransaction,
|
44618
44486
|
...transactionSummary
|
44619
44487
|
};
|
44620
|
-
let logs = [];
|
44621
44488
|
if (this.abis) {
|
44622
|
-
logs = getDecodedLogs(
|
44489
|
+
const logs = getDecodedLogs(
|
44623
44490
|
transactionSummary.receipts,
|
44624
44491
|
this.abis.main,
|
44625
44492
|
this.abis.otherContractsAbis
|
44626
44493
|
);
|
44627
44494
|
transactionResult.logs = logs;
|
44628
44495
|
}
|
44629
|
-
if (transactionResult.isStatusFailure) {
|
44630
|
-
const {
|
44631
|
-
receipts,
|
44632
|
-
gqlTransaction: { status }
|
44633
|
-
} = transactionResult;
|
44634
|
-
throw extractTxError({
|
44635
|
-
receipts,
|
44636
|
-
status,
|
44637
|
-
logs
|
44638
|
-
});
|
44639
|
-
}
|
44640
44496
|
return transactionResult;
|
44641
44497
|
}
|
44642
44498
|
/**
|
@@ -44645,7 +44501,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44645
44501
|
* @param contractsAbiMap - The contracts ABI map.
|
44646
44502
|
*/
|
44647
44503
|
async wait(contractsAbiMap) {
|
44648
|
-
|
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;
|
44649
44512
|
}
|
44650
44513
|
};
|
44651
44514
|
|
@@ -44724,6 +44587,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44724
44587
|
gasPerByte: bn(feeParams.gasPerByte),
|
44725
44588
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44726
44589
|
chainId: bn(consensusParameters.chainId),
|
44590
|
+
baseAssetId: consensusParameters.baseAssetId,
|
44727
44591
|
gasCosts
|
44728
44592
|
},
|
44729
44593
|
gasCosts,
|
@@ -44966,6 +44830,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44966
44830
|
} = this.getChain();
|
44967
44831
|
return chainId.toNumber();
|
44968
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
|
+
}
|
44969
44844
|
/**
|
44970
44845
|
* Submits a transaction to the chain to be executed.
|
44971
44846
|
*
|
@@ -45827,8 +45702,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45827
45702
|
* @param assetId - The asset ID to check the balance for.
|
45828
45703
|
* @returns A promise that resolves to the balance amount.
|
45829
45704
|
*/
|
45830
|
-
async getBalance(assetId
|
45831
|
-
const
|
45705
|
+
async getBalance(assetId) {
|
45706
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
45707
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45832
45708
|
return amount;
|
45833
45709
|
}
|
45834
45710
|
/**
|
@@ -45866,9 +45742,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45866
45742
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45867
45743
|
*/
|
45868
45744
|
async fund(request, coinQuantities, fee) {
|
45745
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
45869
45746
|
const updatedQuantities = addAmountToAsset({
|
45870
45747
|
amount: bn(fee),
|
45871
|
-
assetId:
|
45748
|
+
assetId: baseAssetId,
|
45872
45749
|
coinQuantities
|
45873
45750
|
});
|
45874
45751
|
const quantitiesDict = {};
|
@@ -45892,8 +45769,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45892
45769
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45893
45770
|
cachedUtxos.push(input.id);
|
45894
45771
|
}
|
45895
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45896
|
-
quantitiesDict[
|
45772
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
45773
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
45897
45774
|
cachedMessages.push(input.nonce);
|
45898
45775
|
}
|
45899
45776
|
}
|
@@ -45925,11 +45802,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45925
45802
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45926
45803
|
* @returns A promise that resolves to the prepared transaction request.
|
45927
45804
|
*/
|
45928
|
-
async createTransfer(destination, amount, assetId
|
45805
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45929
45806
|
const { minGasPrice } = this.provider.getGasConfig();
|
45807
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45930
45808
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45931
45809
|
const request = new ScriptTransactionRequest(params);
|
45932
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45810
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
45933
45811
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45934
45812
|
estimateTxDependencies: true,
|
45935
45813
|
resourcesOwner: this
|
@@ -45955,14 +45833,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45955
45833
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45956
45834
|
* @returns A promise that resolves to the transaction response.
|
45957
45835
|
*/
|
45958
|
-
async transfer(destination, amount, assetId
|
45836
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
45959
45837
|
if (bn(amount).lte(0)) {
|
45960
45838
|
throw new FuelError(
|
45961
45839
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45962
45840
|
"Transfer amount must be a positive number."
|
45963
45841
|
);
|
45964
45842
|
}
|
45965
|
-
const
|
45843
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45844
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45966
45845
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45967
45846
|
}
|
45968
45847
|
/**
|
@@ -45974,7 +45853,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45974
45853
|
* @param txParams - The optional transaction parameters.
|
45975
45854
|
* @returns A promise that resolves to the transaction response.
|
45976
45855
|
*/
|
45977
|
-
async transferToContract(contractId, amount, assetId
|
45856
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
45978
45857
|
if (bn(amount).lte(0)) {
|
45979
45858
|
throw new FuelError(
|
45980
45859
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45983,11 +45862,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45983
45862
|
}
|
45984
45863
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45985
45864
|
const { minGasPrice } = this.provider.getGasConfig();
|
45865
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45986
45866
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45987
45867
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45988
45868
|
hexlifiedContractId: contractAddress.toB256(),
|
45989
45869
|
amountToTransfer: bn(amount),
|
45990
|
-
assetId
|
45870
|
+
assetId: assetIdToTransfer
|
45991
45871
|
});
|
45992
45872
|
const request = new ScriptTransactionRequest({
|
45993
45873
|
...params,
|
@@ -45997,7 +45877,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45997
45877
|
request.addContractInputAndOutput(contractAddress);
|
45998
45878
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
45999
45879
|
request,
|
46000
|
-
[{ amount: bn(amount), assetId: String(
|
45880
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
46001
45881
|
);
|
46002
45882
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46003
45883
|
this.validateGas({
|
@@ -46019,6 +45899,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46019
45899
|
*/
|
46020
45900
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46021
45901
|
const { minGasPrice } = this.provider.getGasConfig();
|
45902
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
46022
45903
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46023
45904
|
const recipientDataArray = arrayify(
|
46024
45905
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46033,7 +45914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46033
45914
|
]);
|
46034
45915
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46035
45916
|
const request = new ScriptTransactionRequest(params);
|
46036
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
45917
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
46037
45918
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46038
45919
|
request,
|
46039
45920
|
forwardingQuantities
|
@@ -50595,7 +50476,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50595
50476
|
{
|
50596
50477
|
owner: signer.address.toHexString(),
|
50597
50478
|
amount: toHex(1e9),
|
50598
|
-
asset_id:
|
50479
|
+
asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes32
|
50599
50480
|
}
|
50600
50481
|
]
|
50601
50482
|
}
|
@@ -50661,9 +50542,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50661
50542
|
})
|
50662
50543
|
);
|
50663
50544
|
var generateWallets = async (count, provider) => {
|
50545
|
+
const baseAssetId = provider.getBaseAssetId();
|
50664
50546
|
const wallets = [];
|
50665
50547
|
for (let i = 0; i < count; i += 1) {
|
50666
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50548
|
+
const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
|
50667
50549
|
wallets.push(wallet);
|
50668
50550
|
}
|
50669
50551
|
return wallets;
|