@fuel-ts/account 0.0.0-rc-2034-20240410133013 → 0.0.0-rc-1976-20240410142521
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 +103 -124
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +140 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -100
- 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/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/script-transaction-request.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/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +109 -127
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +143 -143
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +102 -102
- 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,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IACnC,2BAA2B;IAC3B,MAAM,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA+CzB,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
@@ -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);
|
@@ -38875,6 +38850,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38875
38850
|
}
|
38876
38851
|
};
|
38877
38852
|
|
38853
|
+
// ../address/dist/configs.mjs
|
38854
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38855
|
+
|
38878
38856
|
// src/providers/transaction-request/input.ts
|
38879
38857
|
var inputify = (value) => {
|
38880
38858
|
const { type: type3 } = value;
|
@@ -38885,7 +38863,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38885
38863
|
return {
|
38886
38864
|
type: InputType.Coin,
|
38887
38865
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38888
|
-
outputIndex:
|
38866
|
+
outputIndex: arrayify(value.id)[32],
|
38889
38867
|
owner: hexlify(value.owner),
|
38890
38868
|
amount: bn(value.amount),
|
38891
38869
|
assetId: hexlify(value.assetId),
|
@@ -39551,6 +39529,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39551
39529
|
outputs = [];
|
39552
39530
|
/** List of witnesses */
|
39553
39531
|
witnesses = [];
|
39532
|
+
/** Base asset ID - should be fetched from the chain */
|
39533
|
+
baseAssetId;
|
39554
39534
|
/**
|
39555
39535
|
* Constructor for initializing a base transaction request.
|
39556
39536
|
*
|
@@ -39563,8 +39543,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39563
39543
|
witnessLimit,
|
39564
39544
|
inputs,
|
39565
39545
|
outputs,
|
39566
|
-
witnesses
|
39567
|
-
|
39546
|
+
witnesses,
|
39547
|
+
baseAssetId
|
39548
|
+
}) {
|
39568
39549
|
this.gasPrice = bn(gasPrice);
|
39569
39550
|
this.maturity = maturity ?? 0;
|
39570
39551
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39572,6 +39553,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39572
39553
|
this.inputs = inputs ?? [];
|
39573
39554
|
this.outputs = outputs ?? [];
|
39574
39555
|
this.witnesses = witnesses ?? [];
|
39556
|
+
this.baseAssetId = baseAssetId;
|
39575
39557
|
}
|
39576
39558
|
static getPolicyMeta(req) {
|
39577
39559
|
let policyTypes = 0;
|
@@ -39795,11 +39777,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39795
39777
|
*
|
39796
39778
|
* @param message - Message resource.
|
39797
39779
|
* @param predicate - Predicate bytes.
|
39798
|
-
* @param predicateData - Predicate data bytes.
|
39799
39780
|
*/
|
39800
39781
|
addMessageInput(message, predicate) {
|
39801
39782
|
const { recipient, sender, amount } = message;
|
39802
|
-
const assetId = BaseAssetId;
|
39803
39783
|
let witnessIndex;
|
39804
39784
|
if (predicate) {
|
39805
39785
|
witnessIndex = 0;
|
@@ -39819,7 +39799,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39819
39799
|
predicate: predicate?.bytes
|
39820
39800
|
};
|
39821
39801
|
this.pushInput(input);
|
39822
|
-
this.addChangeOutput(recipient,
|
39802
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39823
39803
|
}
|
39824
39804
|
/**
|
39825
39805
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39880,12 +39860,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39880
39860
|
* @param amount - Amount of coin.
|
39881
39861
|
* @param assetId - Asset ID of coin.
|
39882
39862
|
*/
|
39883
|
-
addCoinOutput(to, amount, assetId
|
39863
|
+
addCoinOutput(to, amount, assetId) {
|
39884
39864
|
this.pushOutput({
|
39885
39865
|
type: OutputType.Coin,
|
39886
39866
|
to: addressify(to).toB256(),
|
39887
39867
|
amount,
|
39888
|
-
assetId
|
39868
|
+
assetId: assetId ?? this.baseAssetId
|
39889
39869
|
});
|
39890
39870
|
return this;
|
39891
39871
|
}
|
@@ -39912,7 +39892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39912
39892
|
* @param to - Address of the owner.
|
39913
39893
|
* @param assetId - Asset ID of coin.
|
39914
39894
|
*/
|
39915
|
-
addChangeOutput(to, assetId
|
39895
|
+
addChangeOutput(to, assetId) {
|
39916
39896
|
const changeOutput = this.getChangeOutputs().find(
|
39917
39897
|
(output3) => hexlify(output3.assetId) === assetId
|
39918
39898
|
);
|
@@ -39920,7 +39900,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39920
39900
|
this.pushOutput({
|
39921
39901
|
type: OutputType.Change,
|
39922
39902
|
to: addressify(to).toB256(),
|
39923
|
-
assetId
|
39903
|
+
assetId: assetId ?? this.baseAssetId
|
39924
39904
|
});
|
39925
39905
|
}
|
39926
39906
|
}
|
@@ -39971,6 +39951,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39971
39951
|
* @param quantities - CoinQuantity Array.
|
39972
39952
|
*/
|
39973
39953
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39954
|
+
let idCounter = 0;
|
39955
|
+
const generateId = () => {
|
39956
|
+
const counterString = String(idCounter++);
|
39957
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39958
|
+
return id;
|
39959
|
+
};
|
39974
39960
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39975
39961
|
if ("assetId" in input) {
|
39976
39962
|
return input.assetId === assetId;
|
@@ -39980,12 +39966,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39980
39966
|
const updateAssetInput = (assetId, quantity) => {
|
39981
39967
|
const assetInput = findAssetInput(assetId);
|
39982
39968
|
if (assetInput && "assetId" in assetInput) {
|
39983
|
-
assetInput.id =
|
39969
|
+
assetInput.id = generateId();
|
39984
39970
|
assetInput.amount = quantity;
|
39985
39971
|
} else {
|
39986
39972
|
this.addResources([
|
39987
39973
|
{
|
39988
|
-
id:
|
39974
|
+
id: generateId(),
|
39989
39975
|
amount: quantity,
|
39990
39976
|
assetId,
|
39991
39977
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -39996,7 +39982,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39996
39982
|
]);
|
39997
39983
|
}
|
39998
39984
|
};
|
39999
|
-
updateAssetInput(
|
39985
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
40000
39986
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40001
39987
|
}
|
40002
39988
|
/**
|
@@ -40153,12 +40139,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40153
40139
|
*
|
40154
40140
|
* @param createTransactionRequestLike - The initial values for the instance
|
40155
40141
|
*/
|
40156
|
-
constructor({
|
40157
|
-
bytecodeWitnessIndex,
|
40158
|
-
salt,
|
40159
|
-
storageSlots,
|
40160
|
-
...rest
|
40161
|
-
} = {}) {
|
40142
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40162
40143
|
super(rest);
|
40163
40144
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40164
40145
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40273,7 +40254,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40273
40254
|
*
|
40274
40255
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40275
40256
|
*/
|
40276
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40257
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40277
40258
|
super(rest);
|
40278
40259
|
this.gasLimit = bn(gasLimit);
|
40279
40260
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41419,6 +41400,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41419
41400
|
gasPerByte: bn(feeParams.gasPerByte),
|
41420
41401
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41421
41402
|
chainId: bn(consensusParameters.chainId),
|
41403
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41422
41404
|
gasCosts
|
41423
41405
|
},
|
41424
41406
|
gasCosts,
|
@@ -41661,6 +41643,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41661
41643
|
} = this.getChain();
|
41662
41644
|
return chainId.toNumber();
|
41663
41645
|
}
|
41646
|
+
/**
|
41647
|
+
* Returns the base asset ID
|
41648
|
+
*
|
41649
|
+
* @returns A promise that resolves to the base asset ID
|
41650
|
+
*/
|
41651
|
+
getBaseAssetId() {
|
41652
|
+
const {
|
41653
|
+
consensusParameters: { baseAssetId }
|
41654
|
+
} = this.getChain();
|
41655
|
+
return baseAssetId;
|
41656
|
+
}
|
41664
41657
|
/**
|
41665
41658
|
* Submits a transaction to the chain to be executed.
|
41666
41659
|
*
|
@@ -41811,37 +41804,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41811
41804
|
missingContractIds
|
41812
41805
|
};
|
41813
41806
|
}
|
41814
|
-
/**
|
41815
|
-
* Estimates the transaction gas and fee based on the provided transaction request.
|
41816
|
-
* @param transactionRequest - The transaction request object.
|
41817
|
-
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
41818
|
-
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41819
|
-
*/
|
41820
|
-
estimateTxGasAndFee(params) {
|
41821
|
-
const { transactionRequest } = params;
|
41822
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41823
|
-
const chainInfo = this.getChain();
|
41824
|
-
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41825
|
-
transactionRequest.gasPrice = gasPrice;
|
41826
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41827
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41828
|
-
if (transactionRequest.type === TransactionType.Script) {
|
41829
|
-
if (transactionRequest.gasLimit.eq(0)) {
|
41830
|
-
transactionRequest.gasLimit = minGas;
|
41831
|
-
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41832
|
-
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41833
|
-
);
|
41834
|
-
}
|
41835
|
-
}
|
41836
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41837
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41838
|
-
return {
|
41839
|
-
minGas,
|
41840
|
-
minFee,
|
41841
|
-
maxGas,
|
41842
|
-
maxFee
|
41843
|
-
};
|
41844
|
-
}
|
41845
41807
|
/**
|
41846
41808
|
* Executes a signed transaction without applying the states changes
|
41847
41809
|
* on the chain.
|
@@ -41889,16 +41851,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41889
41851
|
signatureCallback
|
41890
41852
|
} = {}) {
|
41891
41853
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41892
|
-
const
|
41893
|
-
const
|
41854
|
+
const chainInfo = this.getChain();
|
41855
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41856
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41894
41857
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41895
41858
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41896
41859
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41897
41860
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41898
|
-
if (isScriptTransaction) {
|
41899
|
-
txRequestClone.gasLimit = bn(0);
|
41900
|
-
}
|
41901
41861
|
if (estimatePredicates) {
|
41862
|
+
if (isScriptTransaction) {
|
41863
|
+
txRequestClone.gasLimit = bn(0);
|
41864
|
+
}
|
41902
41865
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41903
41866
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41904
41867
|
}
|
@@ -41907,34 +41870,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41907
41870
|
if (signatureCallback && isScriptTransaction) {
|
41908
41871
|
await signatureCallback(txRequestClone);
|
41909
41872
|
}
|
41910
|
-
|
41911
|
-
|
41912
|
-
});
|
41873
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41874
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
41913
41875
|
let receipts = [];
|
41914
41876
|
let missingContractIds = [];
|
41915
41877
|
let outputVariables = 0;
|
41916
|
-
let gasUsed = bn(0);
|
41917
41878
|
if (isScriptTransaction && estimateTxDependencies) {
|
41918
41879
|
txRequestClone.gasPrice = bn(0);
|
41880
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41919
41881
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41920
41882
|
receipts = result.receipts;
|
41921
41883
|
outputVariables = result.outputVariables;
|
41922
41884
|
missingContractIds = result.missingContractIds;
|
41923
|
-
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41924
|
-
txRequestClone.gasLimit = gasUsed;
|
41925
|
-
txRequestClone.gasPrice = setGasPrice;
|
41926
|
-
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41927
|
-
transactionRequest: txRequestClone
|
41928
|
-
}));
|
41929
41885
|
}
|
41886
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41887
|
+
const usedFee = calculatePriceWithFactor(
|
41888
|
+
gasUsed,
|
41889
|
+
gasPrice,
|
41890
|
+
gasPriceFactor
|
41891
|
+
).normalizeZeroToOne();
|
41892
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41893
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41930
41894
|
return {
|
41931
41895
|
requiredQuantities: allQuantities,
|
41932
41896
|
receipts,
|
41933
41897
|
gasUsed,
|
41934
41898
|
minGasPrice,
|
41935
|
-
gasPrice
|
41899
|
+
gasPrice,
|
41936
41900
|
minGas,
|
41937
41901
|
maxGas,
|
41902
|
+
usedFee,
|
41938
41903
|
minFee,
|
41939
41904
|
maxFee,
|
41940
41905
|
estimatedInputs: txRequestClone.inputs,
|
@@ -42718,8 +42683,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42718
42683
|
* @param assetId - The asset ID to check the balance for.
|
42719
42684
|
* @returns A promise that resolves to the balance amount.
|
42720
42685
|
*/
|
42721
|
-
async getBalance(assetId
|
42722
|
-
const
|
42686
|
+
async getBalance(assetId) {
|
42687
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42688
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42723
42689
|
return amount;
|
42724
42690
|
}
|
42725
42691
|
/**
|
@@ -42757,9 +42723,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42757
42723
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42758
42724
|
*/
|
42759
42725
|
async fund(request, coinQuantities, fee) {
|
42726
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42760
42727
|
const updatedQuantities = addAmountToAsset({
|
42761
42728
|
amount: bn(fee),
|
42762
|
-
assetId:
|
42729
|
+
assetId: baseAssetId,
|
42763
42730
|
coinQuantities
|
42764
42731
|
});
|
42765
42732
|
const quantitiesDict = {};
|
@@ -42783,8 +42750,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42783
42750
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42784
42751
|
cachedUtxos.push(input.id);
|
42785
42752
|
}
|
42786
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42787
|
-
quantitiesDict[
|
42753
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42754
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42788
42755
|
cachedMessages.push(input.nonce);
|
42789
42756
|
}
|
42790
42757
|
}
|
@@ -42816,11 +42783,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42816
42783
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42817
42784
|
* @returns A promise that resolves to the prepared transaction request.
|
42818
42785
|
*/
|
42819
|
-
async createTransfer(destination, amount, assetId
|
42786
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42820
42787
|
const { minGasPrice } = this.provider.getGasConfig();
|
42821
|
-
const
|
42788
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42789
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42790
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42822
42791
|
const request = new ScriptTransactionRequest(params);
|
42823
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42792
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42824
42793
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42825
42794
|
estimateTxDependencies: true,
|
42826
42795
|
resourcesOwner: this
|
@@ -42846,14 +42815,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42846
42815
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42847
42816
|
* @returns A promise that resolves to the transaction response.
|
42848
42817
|
*/
|
42849
|
-
async transfer(destination, amount, assetId
|
42818
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42850
42819
|
if (bn(amount).lte(0)) {
|
42851
42820
|
throw new FuelError(
|
42852
42821
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42853
42822
|
"Transfer amount must be a positive number."
|
42854
42823
|
);
|
42855
42824
|
}
|
42856
|
-
const
|
42825
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42826
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42857
42827
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42858
42828
|
}
|
42859
42829
|
/**
|
@@ -42865,7 +42835,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42865
42835
|
* @param txParams - The optional transaction parameters.
|
42866
42836
|
* @returns A promise that resolves to the transaction response.
|
42867
42837
|
*/
|
42868
|
-
async transferToContract(contractId, amount, assetId
|
42838
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42869
42839
|
if (bn(amount).lte(0)) {
|
42870
42840
|
throw new FuelError(
|
42871
42841
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42874,11 +42844,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42874
42844
|
}
|
42875
42845
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42876
42846
|
const { minGasPrice } = this.provider.getGasConfig();
|
42877
|
-
const
|
42847
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42848
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42849
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42878
42850
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42879
42851
|
hexlifiedContractId: contractAddress.toB256(),
|
42880
42852
|
amountToTransfer: bn(amount),
|
42881
|
-
assetId
|
42853
|
+
assetId: assetIdToTransfer
|
42882
42854
|
});
|
42883
42855
|
const request = new ScriptTransactionRequest({
|
42884
42856
|
...params,
|
@@ -42888,7 +42860,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42888
42860
|
request.addContractInputAndOutput(contractAddress);
|
42889
42861
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42890
42862
|
request,
|
42891
|
-
[{ amount: bn(amount), assetId: String(
|
42863
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42892
42864
|
);
|
42893
42865
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42894
42866
|
this.validateGas({
|
@@ -42910,6 +42882,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42910
42882
|
*/
|
42911
42883
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42912
42884
|
const { minGasPrice } = this.provider.getGasConfig();
|
42885
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42913
42886
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42914
42887
|
const recipientDataArray = arrayify(
|
42915
42888
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42922,9 +42895,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42922
42895
|
...recipientDataArray,
|
42923
42896
|
...amountDataArray
|
42924
42897
|
]);
|
42925
|
-
const params = {
|
42898
|
+
const params = {
|
42899
|
+
script,
|
42900
|
+
gasPrice: minGasPrice,
|
42901
|
+
baseAssetId,
|
42902
|
+
...txParams
|
42903
|
+
};
|
42926
42904
|
const request = new ScriptTransactionRequest(params);
|
42927
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42905
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42928
42906
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42929
42907
|
request,
|
42930
42908
|
forwardingQuantities
|
@@ -44388,12 +44366,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44388
44366
|
};
|
44389
44367
|
|
44390
44368
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44391
|
-
var
|
44369
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44392
44370
|
var rnds8Pool = new Uint8Array(256);
|
44393
44371
|
var poolPtr = rnds8Pool.length;
|
44394
44372
|
function rng() {
|
44395
44373
|
if (poolPtr > rnds8Pool.length - 16) {
|
44396
|
-
|
44374
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44397
44375
|
poolPtr = 0;
|
44398
44376
|
}
|
44399
44377
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44409,9 +44387,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44409
44387
|
}
|
44410
44388
|
|
44411
44389
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44412
|
-
var
|
44390
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44413
44391
|
var native_default = {
|
44414
|
-
randomUUID:
|
44392
|
+
randomUUID: import_crypto16.default.randomUUID
|
44415
44393
|
};
|
44416
44394
|
|
44417
44395
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47887,8 +47865,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47887
47865
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47888
47866
|
* @returns A promise that resolves to the prepared transaction request.
|
47889
47867
|
*/
|
47890
|
-
async createTransfer(destination, amount, assetId
|
47891
|
-
const
|
47868
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47869
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47870
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47892
47871
|
return this.populateTransactionPredicateData(request);
|
47893
47872
|
}
|
47894
47873
|
/**
|