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