@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410113328
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 +113 -90
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +132 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -84
- 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 +15 -9
- 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/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +116 -94
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +132 -128
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +91 -87
- 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;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAk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AAsB,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
@@ -29245,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29245
29245
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29246
29246
|
|
29247
29247
|
// ../crypto/dist/index.mjs
|
29248
|
-
var
|
29248
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
29249
29249
|
|
29250
29250
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29251
29251
|
var version = "6.7.1";
|
@@ -30317,6 +30317,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30317
30317
|
};
|
30318
30318
|
Object.freeze(pbkdf22);
|
30319
30319
|
|
30320
|
+
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30321
|
+
var locked5 = false;
|
30322
|
+
var _randomBytes = function(length) {
|
30323
|
+
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30324
|
+
};
|
30325
|
+
var __randomBytes = _randomBytes;
|
30326
|
+
function randomBytes3(length) {
|
30327
|
+
return __randomBytes(length);
|
30328
|
+
}
|
30329
|
+
randomBytes3._ = _randomBytes;
|
30330
|
+
randomBytes3.lock = function() {
|
30331
|
+
locked5 = true;
|
30332
|
+
};
|
30333
|
+
randomBytes3.register = function(func) {
|
30334
|
+
if (locked5) {
|
30335
|
+
throw new Error("randomBytes is locked");
|
30336
|
+
}
|
30337
|
+
__randomBytes = func;
|
30338
|
+
};
|
30339
|
+
Object.freeze(randomBytes3);
|
30340
|
+
|
30320
30341
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30321
30342
|
var BN_03 = BigInt(0);
|
30322
30343
|
var BN_36 = BigInt(36);
|
@@ -30901,8 +30922,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30901
30922
|
}
|
30902
30923
|
|
30903
30924
|
// ../crypto/dist/index.mjs
|
30904
|
-
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30905
30925
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30926
|
+
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30906
30927
|
var scrypt3 = (params) => {
|
30907
30928
|
const { password, salt, n, p, r, dklen } = params;
|
30908
30929
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30911,7 +30932,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30911
30932
|
var keccak2562 = (data) => keccak_256(data);
|
30912
30933
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30913
30934
|
var randomBytes4 = (length) => {
|
30914
|
-
const randomValues = Uint8Array.from(
|
30935
|
+
const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
|
30915
30936
|
return randomValues;
|
30916
30937
|
};
|
30917
30938
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30926,7 +30947,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30926
30947
|
const salt = randomBytes4(32);
|
30927
30948
|
const secret = keyFromPassword(password, salt);
|
30928
30949
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30929
|
-
const cipher = await
|
30950
|
+
const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
|
30930
30951
|
let cipherData = cipher.update(dataBuffer);
|
30931
30952
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30932
30953
|
return {
|
@@ -30940,7 +30961,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30940
30961
|
const salt = bufferFromString(keystore.salt);
|
30941
30962
|
const secret = keyFromPassword(password, salt);
|
30942
30963
|
const encryptedText = bufferFromString(keystore.data);
|
30943
|
-
const decipher = await
|
30964
|
+
const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
|
30944
30965
|
const decrypted = decipher.update(encryptedText);
|
30945
30966
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30946
30967
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30951,12 +30972,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30951
30972
|
}
|
30952
30973
|
};
|
30953
30974
|
async function encryptJsonWalletData(data, key, iv) {
|
30954
|
-
const cipher = await
|
30975
|
+
const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30955
30976
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30956
30977
|
return new Uint8Array(encrypted);
|
30957
30978
|
}
|
30958
30979
|
async function decryptJsonWalletData(data, key, iv) {
|
30959
|
-
const decipher =
|
30980
|
+
const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30960
30981
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30961
30982
|
return new Uint8Array(decrypted);
|
30962
30983
|
}
|
@@ -31272,6 +31293,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31293
|
}
|
31273
31294
|
};
|
31274
31295
|
|
31296
|
+
// ../address/dist/configs.mjs
|
31297
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31298
|
+
var BaseAssetId = ZeroBytes32;
|
31299
|
+
|
31275
31300
|
// ../math/dist/index.mjs
|
31276
31301
|
var import_bn = __toESM(require_bn(), 1);
|
31277
31302
|
var DEFAULT_PRECISION = 9;
|
@@ -31502,11 +31527,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31502
31527
|
let max2;
|
31503
31528
|
if (Array.isArray(coinQuantityLike)) {
|
31504
31529
|
amount = coinQuantityLike[0];
|
31505
|
-
assetId = coinQuantityLike[1];
|
31506
|
-
max2 = coinQuantityLike[2];
|
31530
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31531
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31507
31532
|
} else {
|
31508
31533
|
amount = coinQuantityLike.amount;
|
31509
|
-
assetId = coinQuantityLike.assetId;
|
31534
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31510
31535
|
max2 = coinQuantityLike.max ?? void 0;
|
31511
31536
|
}
|
31512
31537
|
const bnAmount = bn(amount);
|
@@ -38846,9 +38871,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38846
38871
|
}
|
38847
38872
|
};
|
38848
38873
|
|
38849
|
-
// ../address/dist/configs.mjs
|
38850
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38851
|
-
|
38852
38874
|
// src/providers/transaction-request/input.ts
|
38853
38875
|
var inputify = (value) => {
|
38854
38876
|
const { type: type3 } = value;
|
@@ -38859,7 +38881,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38859
38881
|
return {
|
38860
38882
|
type: InputType.Coin,
|
38861
38883
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38862
|
-
outputIndex: arrayify(value.id)
|
38884
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
|
38863
38885
|
owner: hexlify(value.owner),
|
38864
38886
|
amount: bn(value.amount),
|
38865
38887
|
assetId: hexlify(value.assetId),
|
@@ -39525,8 +39547,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39525
39547
|
outputs = [];
|
39526
39548
|
/** List of witnesses */
|
39527
39549
|
witnesses = [];
|
39528
|
-
/** Base asset ID - should be fetched from the chain */
|
39529
|
-
baseAssetId = ZeroBytes32;
|
39530
39550
|
/**
|
39531
39551
|
* Constructor for initializing a base transaction request.
|
39532
39552
|
*
|
@@ -39539,8 +39559,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39539
39559
|
witnessLimit,
|
39540
39560
|
inputs,
|
39541
39561
|
outputs,
|
39542
|
-
witnesses
|
39543
|
-
baseAssetId
|
39562
|
+
witnesses
|
39544
39563
|
} = {}) {
|
39545
39564
|
this.gasPrice = bn(gasPrice);
|
39546
39565
|
this.maturity = maturity ?? 0;
|
@@ -39549,7 +39568,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39549
39568
|
this.inputs = inputs ?? [];
|
39550
39569
|
this.outputs = outputs ?? [];
|
39551
39570
|
this.witnesses = witnesses ?? [];
|
39552
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39553
39571
|
}
|
39554
39572
|
static getPolicyMeta(req) {
|
39555
39573
|
let policyTypes = 0;
|
@@ -39774,9 +39792,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39774
39792
|
*
|
39775
39793
|
* @param message - Message resource.
|
39776
39794
|
* @param predicate - Predicate bytes.
|
39795
|
+
* @param predicateData - Predicate data bytes.
|
39777
39796
|
*/
|
39778
39797
|
addMessageInput(message, predicate) {
|
39779
39798
|
const { recipient, sender, amount } = message;
|
39799
|
+
const assetId = BaseAssetId;
|
39780
39800
|
let witnessIndex;
|
39781
39801
|
if (predicate) {
|
39782
39802
|
witnessIndex = 0;
|
@@ -39797,7 +39817,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39797
39817
|
predicateData: predicate?.predicateDataBytes
|
39798
39818
|
};
|
39799
39819
|
this.pushInput(input);
|
39800
|
-
this.addChangeOutput(recipient,
|
39820
|
+
this.addChangeOutput(recipient, assetId);
|
39801
39821
|
}
|
39802
39822
|
/**
|
39803
39823
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39858,12 +39878,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39858
39878
|
* @param amount - Amount of coin.
|
39859
39879
|
* @param assetId - Asset ID of coin.
|
39860
39880
|
*/
|
39861
|
-
addCoinOutput(to, amount, assetId) {
|
39881
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39862
39882
|
this.pushOutput({
|
39863
39883
|
type: OutputType.Coin,
|
39864
39884
|
to: addressify(to).toB256(),
|
39865
39885
|
amount,
|
39866
|
-
assetId
|
39886
|
+
assetId
|
39867
39887
|
});
|
39868
39888
|
return this;
|
39869
39889
|
}
|
@@ -39890,7 +39910,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39890
39910
|
* @param to - Address of the owner.
|
39891
39911
|
* @param assetId - Asset ID of coin.
|
39892
39912
|
*/
|
39893
|
-
addChangeOutput(to, assetId) {
|
39913
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39894
39914
|
const changeOutput = this.getChangeOutputs().find(
|
39895
39915
|
(output3) => hexlify(output3.assetId) === assetId
|
39896
39916
|
);
|
@@ -39898,7 +39918,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39898
39918
|
this.pushOutput({
|
39899
39919
|
type: OutputType.Change,
|
39900
39920
|
to: addressify(to).toB256(),
|
39901
|
-
assetId
|
39921
|
+
assetId
|
39902
39922
|
});
|
39903
39923
|
}
|
39904
39924
|
}
|
@@ -39949,12 +39969,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39949
39969
|
* @param quantities - CoinQuantity Array.
|
39950
39970
|
*/
|
39951
39971
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39952
|
-
let idCounter = 0;
|
39953
|
-
const generateId = () => {
|
39954
|
-
const counterString = String(idCounter++);
|
39955
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39956
|
-
return id;
|
39957
|
-
};
|
39958
39972
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39959
39973
|
if ("assetId" in input) {
|
39960
39974
|
return input.assetId === assetId;
|
@@ -39964,12 +39978,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39964
39978
|
const updateAssetInput = (assetId, quantity) => {
|
39965
39979
|
const assetInput = findAssetInput(assetId);
|
39966
39980
|
if (assetInput && "assetId" in assetInput) {
|
39967
|
-
assetInput.id =
|
39981
|
+
assetInput.id = hexlify(randomBytes3(33));
|
39968
39982
|
assetInput.amount = quantity;
|
39969
39983
|
} else {
|
39970
39984
|
this.addResources([
|
39971
39985
|
{
|
39972
|
-
id:
|
39986
|
+
id: hexlify(randomBytes3(33)),
|
39973
39987
|
amount: quantity,
|
39974
39988
|
assetId,
|
39975
39989
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -39980,7 +39994,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39980
39994
|
]);
|
39981
39995
|
}
|
39982
39996
|
};
|
39983
|
-
updateAssetInput(
|
39997
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
39984
39998
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39985
39999
|
}
|
39986
40000
|
/**
|
@@ -41403,7 +41417,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41403
41417
|
gasPerByte: bn(feeParams.gasPerByte),
|
41404
41418
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41405
41419
|
chainId: bn(consensusParameters.chainId),
|
41406
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41407
41420
|
gasCosts
|
41408
41421
|
},
|
41409
41422
|
gasCosts,
|
@@ -41646,17 +41659,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41646
41659
|
} = this.getChain();
|
41647
41660
|
return chainId.toNumber();
|
41648
41661
|
}
|
41649
|
-
/**
|
41650
|
-
* Returns the base asset ID
|
41651
|
-
*
|
41652
|
-
* @returns A promise that resolves to the base asset ID
|
41653
|
-
*/
|
41654
|
-
getBaseAssetId() {
|
41655
|
-
const {
|
41656
|
-
consensusParameters: { baseAssetId }
|
41657
|
-
} = this.getChain();
|
41658
|
-
return baseAssetId;
|
41659
|
-
}
|
41660
41662
|
/**
|
41661
41663
|
* Submits a transaction to the chain to be executed.
|
41662
41664
|
*
|
@@ -41807,6 +41809,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41807
41809
|
missingContractIds
|
41808
41810
|
};
|
41809
41811
|
}
|
41812
|
+
/**
|
41813
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
41814
|
+
* @param transactionRequest - The transaction request object.
|
41815
|
+
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
41816
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41817
|
+
*/
|
41818
|
+
estimateTxGasAndFee(params) {
|
41819
|
+
const { transactionRequest } = params;
|
41820
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41821
|
+
const chainInfo = this.getChain();
|
41822
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41823
|
+
transactionRequest.gasPrice = gasPrice;
|
41824
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41825
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41826
|
+
if (transactionRequest.type === TransactionType.Script) {
|
41827
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
41828
|
+
transactionRequest.gasLimit = minGas;
|
41829
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41830
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41831
|
+
);
|
41832
|
+
}
|
41833
|
+
}
|
41834
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41835
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41836
|
+
return {
|
41837
|
+
minGas,
|
41838
|
+
minFee,
|
41839
|
+
maxGas,
|
41840
|
+
maxFee
|
41841
|
+
};
|
41842
|
+
}
|
41810
41843
|
/**
|
41811
41844
|
* Executes a signed transaction without applying the states changes
|
41812
41845
|
* on the chain.
|
@@ -41854,17 +41887,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41854
41887
|
signatureCallback
|
41855
41888
|
} = {}) {
|
41856
41889
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41857
|
-
const
|
41858
|
-
const
|
41859
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41890
|
+
const { minGasPrice } = this.getGasConfig();
|
41891
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41860
41892
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41861
41893
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41862
41894
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41863
41895
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41896
|
+
if (isScriptTransaction) {
|
41897
|
+
txRequestClone.gasLimit = bn(0);
|
41898
|
+
}
|
41864
41899
|
if (estimatePredicates) {
|
41865
|
-
if (isScriptTransaction) {
|
41866
|
-
txRequestClone.gasLimit = bn(0);
|
41867
|
-
}
|
41868
41900
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41869
41901
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41870
41902
|
}
|
@@ -41873,36 +41905,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41873
41905
|
if (signatureCallback && isScriptTransaction) {
|
41874
41906
|
await signatureCallback(txRequestClone);
|
41875
41907
|
}
|
41876
|
-
|
41877
|
-
|
41908
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41909
|
+
transactionRequest: txRequestClone
|
41910
|
+
});
|
41878
41911
|
let receipts = [];
|
41879
41912
|
let missingContractIds = [];
|
41880
41913
|
let outputVariables = 0;
|
41914
|
+
let gasUsed = bn(0);
|
41881
41915
|
if (isScriptTransaction && estimateTxDependencies) {
|
41882
41916
|
txRequestClone.gasPrice = bn(0);
|
41883
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41884
41917
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41885
41918
|
receipts = result.receipts;
|
41886
41919
|
outputVariables = result.outputVariables;
|
41887
41920
|
missingContractIds = result.missingContractIds;
|
41921
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41922
|
+
txRequestClone.gasLimit = gasUsed;
|
41923
|
+
txRequestClone.gasPrice = setGasPrice;
|
41924
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41925
|
+
transactionRequest: txRequestClone
|
41926
|
+
}));
|
41888
41927
|
}
|
41889
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41890
|
-
const usedFee = calculatePriceWithFactor(
|
41891
|
-
gasUsed,
|
41892
|
-
gasPrice,
|
41893
|
-
gasPriceFactor
|
41894
|
-
).normalizeZeroToOne();
|
41895
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41896
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41897
41928
|
return {
|
41898
41929
|
requiredQuantities: allQuantities,
|
41899
41930
|
receipts,
|
41900
41931
|
gasUsed,
|
41901
41932
|
minGasPrice,
|
41902
|
-
gasPrice,
|
41933
|
+
gasPrice: setGasPrice,
|
41903
41934
|
minGas,
|
41904
41935
|
maxGas,
|
41905
|
-
usedFee,
|
41906
41936
|
minFee,
|
41907
41937
|
maxFee,
|
41908
41938
|
estimatedInputs: txRequestClone.inputs,
|
@@ -42686,9 +42716,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42686
42716
|
* @param assetId - The asset ID to check the balance for.
|
42687
42717
|
* @returns A promise that resolves to the balance amount.
|
42688
42718
|
*/
|
42689
|
-
async getBalance(assetId) {
|
42690
|
-
const
|
42691
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42719
|
+
async getBalance(assetId = BaseAssetId) {
|
42720
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42692
42721
|
return amount;
|
42693
42722
|
}
|
42694
42723
|
/**
|
@@ -42726,10 +42755,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42726
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42727
42756
|
*/
|
42728
42757
|
async fund(request, coinQuantities, fee) {
|
42729
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42730
42758
|
const updatedQuantities = addAmountToAsset({
|
42731
42759
|
amount: bn(fee),
|
42732
|
-
assetId:
|
42760
|
+
assetId: BaseAssetId,
|
42733
42761
|
coinQuantities
|
42734
42762
|
});
|
42735
42763
|
const quantitiesDict = {};
|
@@ -42753,8 +42781,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42753
42781
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42754
42782
|
cachedUtxos.push(input.id);
|
42755
42783
|
}
|
42756
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42757
|
-
quantitiesDict[
|
42784
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42785
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42758
42786
|
cachedMessages.push(input.nonce);
|
42759
42787
|
}
|
42760
42788
|
}
|
@@ -42786,12 +42814,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42786
42814
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42787
42815
|
* @returns A promise that resolves to the prepared transaction request.
|
42788
42816
|
*/
|
42789
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42817
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42790
42818
|
const { minGasPrice } = this.provider.getGasConfig();
|
42791
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42792
42819
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42793
42820
|
const request = new ScriptTransactionRequest(params);
|
42794
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42821
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42795
42822
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42796
42823
|
estimateTxDependencies: true,
|
42797
42824
|
resourcesOwner: this
|
@@ -42817,15 +42844,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42817
42844
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42818
42845
|
* @returns A promise that resolves to the transaction response.
|
42819
42846
|
*/
|
42820
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42847
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42821
42848
|
if (bn(amount).lte(0)) {
|
42822
42849
|
throw new FuelError(
|
42823
42850
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42824
42851
|
"Transfer amount must be a positive number."
|
42825
42852
|
);
|
42826
42853
|
}
|
42827
|
-
const
|
42828
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42854
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42829
42855
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42830
42856
|
}
|
42831
42857
|
/**
|
@@ -42837,7 +42863,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42837
42863
|
* @param txParams - The optional transaction parameters.
|
42838
42864
|
* @returns A promise that resolves to the transaction response.
|
42839
42865
|
*/
|
42840
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42866
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42841
42867
|
if (bn(amount).lte(0)) {
|
42842
42868
|
throw new FuelError(
|
42843
42869
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42846,12 +42872,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42846
42872
|
}
|
42847
42873
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42848
42874
|
const { minGasPrice } = this.provider.getGasConfig();
|
42849
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42850
42875
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42851
42876
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42852
42877
|
hexlifiedContractId: contractAddress.toB256(),
|
42853
42878
|
amountToTransfer: bn(amount),
|
42854
|
-
assetId
|
42879
|
+
assetId
|
42855
42880
|
});
|
42856
42881
|
const request = new ScriptTransactionRequest({
|
42857
42882
|
...params,
|
@@ -42861,7 +42886,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42861
42886
|
request.addContractInputAndOutput(contractAddress);
|
42862
42887
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42863
42888
|
request,
|
42864
|
-
[{ amount: bn(amount), assetId: String(
|
42889
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42865
42890
|
);
|
42866
42891
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42867
42892
|
this.validateGas({
|
@@ -42883,7 +42908,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42883
42908
|
*/
|
42884
42909
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42885
42910
|
const { minGasPrice } = this.provider.getGasConfig();
|
42886
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42887
42911
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42888
42912
|
const recipientDataArray = arrayify(
|
42889
42913
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42898,7 +42922,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42898
42922
|
]);
|
42899
42923
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42900
42924
|
const request = new ScriptTransactionRequest(params);
|
42901
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42925
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42902
42926
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42903
42927
|
request,
|
42904
42928
|
forwardingQuantities
|
@@ -44362,12 +44386,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44362
44386
|
};
|
44363
44387
|
|
44364
44388
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44365
|
-
var
|
44389
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44366
44390
|
var rnds8Pool = new Uint8Array(256);
|
44367
44391
|
var poolPtr = rnds8Pool.length;
|
44368
44392
|
function rng() {
|
44369
44393
|
if (poolPtr > rnds8Pool.length - 16) {
|
44370
|
-
|
44394
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44371
44395
|
poolPtr = 0;
|
44372
44396
|
}
|
44373
44397
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44383,9 +44407,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44383
44407
|
}
|
44384
44408
|
|
44385
44409
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44386
|
-
var
|
44410
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44387
44411
|
var native_default = {
|
44388
|
-
randomUUID:
|
44412
|
+
randomUUID: import_crypto17.default.randomUUID
|
44389
44413
|
};
|
44390
44414
|
|
44391
44415
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47862,9 +47886,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47862
47886
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47863
47887
|
* @returns A promise that resolves to the prepared transaction request.
|
47864
47888
|
*/
|
47865
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47866
|
-
const
|
47867
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47889
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47890
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47868
47891
|
return this.populateTransactionPredicateData(request);
|
47869
47892
|
}
|
47870
47893
|
/**
|