@fuel-ts/account 0.0.0-rc-2037-20240412171107 → 0.0.0-rc-1976-20240415100843
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 +98 -65
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +134 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -65
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +1 -9
- 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/coin.d.ts +1 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.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/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 +25 -4
- 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 +102 -51
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +137 -88
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +99 -50
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
@@ -29,14 +29,12 @@ var __privateMethod = (obj, member, method) => {
|
|
29
29
|
|
30
30
|
// src/account.ts
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
|
-
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
33
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
34
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
34
|
import { bn as bn17 } from "@fuel-ts/math";
|
36
35
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
37
36
|
|
38
37
|
// src/providers/coin-quantity.ts
|
39
|
-
import { BaseAssetId } from "@fuel-ts/address/configs";
|
40
38
|
import { bn } from "@fuel-ts/math";
|
41
39
|
import { hexlify } from "@fuel-ts/utils";
|
42
40
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -45,11 +43,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
45
43
|
let max2;
|
46
44
|
if (Array.isArray(coinQuantityLike)) {
|
47
45
|
amount = coinQuantityLike[0];
|
48
|
-
assetId = coinQuantityLike[1]
|
49
|
-
max2 = coinQuantityLike[2]
|
46
|
+
assetId = coinQuantityLike[1];
|
47
|
+
max2 = coinQuantityLike[2];
|
50
48
|
} else {
|
51
49
|
amount = coinQuantityLike.amount;
|
52
|
-
assetId = coinQuantityLike.assetId
|
50
|
+
assetId = coinQuantityLike.assetId;
|
53
51
|
max2 = coinQuantityLike.max ?? void 0;
|
54
52
|
}
|
55
53
|
const bnAmount = bn(amount);
|
@@ -1158,7 +1156,7 @@ var outputify = (value) => {
|
|
1158
1156
|
// src/providers/transaction-request/transaction-request.ts
|
1159
1157
|
import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
1160
1158
|
import { Address, addressify } from "@fuel-ts/address";
|
1161
|
-
import {
|
1159
|
+
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1162
1160
|
import { randomBytes } from "@fuel-ts/crypto";
|
1163
1161
|
import { bn as bn7 } from "@fuel-ts/math";
|
1164
1162
|
import {
|
@@ -1693,6 +1691,8 @@ var BaseTransactionRequest = class {
|
|
1693
1691
|
outputs = [];
|
1694
1692
|
/** List of witnesses */
|
1695
1693
|
witnesses = [];
|
1694
|
+
/** Base asset ID - should be fetched from the chain */
|
1695
|
+
baseAssetId;
|
1696
1696
|
/**
|
1697
1697
|
* Constructor for initializing a base transaction request.
|
1698
1698
|
*
|
@@ -1705,8 +1705,9 @@ var BaseTransactionRequest = class {
|
|
1705
1705
|
witnessLimit,
|
1706
1706
|
inputs,
|
1707
1707
|
outputs,
|
1708
|
-
witnesses
|
1709
|
-
|
1708
|
+
witnesses,
|
1709
|
+
baseAssetId
|
1710
|
+
}) {
|
1710
1711
|
this.gasPrice = bn7(gasPrice);
|
1711
1712
|
this.maturity = maturity ?? 0;
|
1712
1713
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
@@ -1714,6 +1715,7 @@ var BaseTransactionRequest = class {
|
|
1714
1715
|
this.inputs = inputs ?? [];
|
1715
1716
|
this.outputs = outputs ?? [];
|
1716
1717
|
this.witnesses = witnesses ?? [];
|
1718
|
+
this.baseAssetId = baseAssetId;
|
1717
1719
|
}
|
1718
1720
|
static getPolicyMeta(req) {
|
1719
1721
|
let policyTypes = 0;
|
@@ -1907,8 +1909,8 @@ var BaseTransactionRequest = class {
|
|
1907
1909
|
* @param predicate - Predicate bytes.
|
1908
1910
|
* @param predicateData - Predicate data bytes.
|
1909
1911
|
*/
|
1910
|
-
addCoinInput(coin) {
|
1911
|
-
const { assetId, owner, amount
|
1912
|
+
addCoinInput(coin, predicate) {
|
1913
|
+
const { assetId, owner, amount } = coin;
|
1912
1914
|
let witnessIndex;
|
1913
1915
|
if (predicate) {
|
1914
1916
|
witnessIndex = 0;
|
@@ -1919,14 +1921,14 @@ var BaseTransactionRequest = class {
|
|
1919
1921
|
}
|
1920
1922
|
}
|
1921
1923
|
const input = {
|
1922
|
-
|
1924
|
+
...coin,
|
1923
1925
|
type: InputType2.Coin,
|
1924
1926
|
owner: owner.toB256(),
|
1925
1927
|
amount,
|
1926
1928
|
assetId,
|
1927
1929
|
txPointer: "0x00000000000000000000000000000000",
|
1928
1930
|
witnessIndex,
|
1929
|
-
predicate
|
1931
|
+
predicate: predicate?.bytes
|
1930
1932
|
};
|
1931
1933
|
this.pushInput(input);
|
1932
1934
|
this.addChangeOutput(owner, assetId);
|
@@ -1937,11 +1939,9 @@ var BaseTransactionRequest = class {
|
|
1937
1939
|
*
|
1938
1940
|
* @param message - Message resource.
|
1939
1941
|
* @param predicate - Predicate bytes.
|
1940
|
-
* @param predicateData - Predicate data bytes.
|
1941
1942
|
*/
|
1942
|
-
addMessageInput(message) {
|
1943
|
-
const { recipient, sender, amount
|
1944
|
-
const assetId = BaseAssetId2;
|
1943
|
+
addMessageInput(message, predicate) {
|
1944
|
+
const { recipient, sender, amount } = message;
|
1945
1945
|
let witnessIndex;
|
1946
1946
|
if (predicate) {
|
1947
1947
|
witnessIndex = 0;
|
@@ -1952,16 +1952,16 @@ var BaseTransactionRequest = class {
|
|
1952
1952
|
}
|
1953
1953
|
}
|
1954
1954
|
const input = {
|
1955
|
-
|
1955
|
+
...message,
|
1956
1956
|
type: InputType2.Message,
|
1957
1957
|
sender: sender.toB256(),
|
1958
1958
|
recipient: recipient.toB256(),
|
1959
1959
|
amount,
|
1960
1960
|
witnessIndex,
|
1961
|
-
predicate
|
1961
|
+
predicate: predicate?.bytes
|
1962
1962
|
};
|
1963
1963
|
this.pushInput(input);
|
1964
|
-
this.addChangeOutput(recipient,
|
1964
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
1965
1965
|
}
|
1966
1966
|
/**
|
1967
1967
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -1989,6 +1989,32 @@ var BaseTransactionRequest = class {
|
|
1989
1989
|
resources.forEach((resource) => this.addResource(resource));
|
1990
1990
|
return this;
|
1991
1991
|
}
|
1992
|
+
/**
|
1993
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1994
|
+
* outputs from the related assetIds.
|
1995
|
+
*
|
1996
|
+
* @param resources - The resources to add.
|
1997
|
+
* @returns This transaction.
|
1998
|
+
*/
|
1999
|
+
addPredicateResource(resource, predicate) {
|
2000
|
+
if (isCoin(resource)) {
|
2001
|
+
this.addCoinInput(resource, predicate);
|
2002
|
+
} else {
|
2003
|
+
this.addMessageInput(resource, predicate);
|
2004
|
+
}
|
2005
|
+
return this;
|
2006
|
+
}
|
2007
|
+
/**
|
2008
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2009
|
+
* from the related assetIds.
|
2010
|
+
*
|
2011
|
+
* @param resources - The resources to add.
|
2012
|
+
* @returns This transaction.
|
2013
|
+
*/
|
2014
|
+
addPredicateResources(resources, predicate) {
|
2015
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2016
|
+
return this;
|
2017
|
+
}
|
1992
2018
|
/**
|
1993
2019
|
* Adds a coin output to the transaction.
|
1994
2020
|
*
|
@@ -1996,12 +2022,12 @@ var BaseTransactionRequest = class {
|
|
1996
2022
|
* @param amount - Amount of coin.
|
1997
2023
|
* @param assetId - Asset ID of coin.
|
1998
2024
|
*/
|
1999
|
-
addCoinOutput(to, amount, assetId
|
2025
|
+
addCoinOutput(to, amount, assetId) {
|
2000
2026
|
this.pushOutput({
|
2001
2027
|
type: OutputType2.Coin,
|
2002
2028
|
to: addressify(to).toB256(),
|
2003
2029
|
amount,
|
2004
|
-
assetId
|
2030
|
+
assetId: assetId ?? this.baseAssetId
|
2005
2031
|
});
|
2006
2032
|
return this;
|
2007
2033
|
}
|
@@ -2028,7 +2054,7 @@ var BaseTransactionRequest = class {
|
|
2028
2054
|
* @param to - Address of the owner.
|
2029
2055
|
* @param assetId - Asset ID of coin.
|
2030
2056
|
*/
|
2031
|
-
addChangeOutput(to, assetId
|
2057
|
+
addChangeOutput(to, assetId) {
|
2032
2058
|
const changeOutput = this.getChangeOutputs().find(
|
2033
2059
|
(output) => hexlify7(output.assetId) === assetId
|
2034
2060
|
);
|
@@ -2036,7 +2062,7 @@ var BaseTransactionRequest = class {
|
|
2036
2062
|
this.pushOutput({
|
2037
2063
|
type: OutputType2.Change,
|
2038
2064
|
to: addressify(to).toB256(),
|
2039
|
-
assetId
|
2065
|
+
assetId: assetId ?? this.baseAssetId
|
2040
2066
|
});
|
2041
2067
|
}
|
2042
2068
|
}
|
@@ -2112,7 +2138,7 @@ var BaseTransactionRequest = class {
|
|
2112
2138
|
]);
|
2113
2139
|
}
|
2114
2140
|
};
|
2115
|
-
updateAssetInput(
|
2141
|
+
updateAssetInput(this.baseAssetId, bn7(1e11));
|
2116
2142
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2117
2143
|
}
|
2118
2144
|
/**
|
@@ -2282,12 +2308,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2282
2308
|
*
|
2283
2309
|
* @param createTransactionRequestLike - The initial values for the instance
|
2284
2310
|
*/
|
2285
|
-
constructor({
|
2286
|
-
bytecodeWitnessIndex,
|
2287
|
-
salt,
|
2288
|
-
storageSlots,
|
2289
|
-
...rest
|
2290
|
-
} = {}) {
|
2311
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
2291
2312
|
super(rest);
|
2292
2313
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2293
2314
|
this.salt = hexlify9(salt ?? ZeroBytes326);
|
@@ -2411,7 +2432,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2411
2432
|
*
|
2412
2433
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
2413
2434
|
*/
|
2414
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
2435
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
2415
2436
|
super(rest);
|
2416
2437
|
this.gasLimit = bn10(gasLimit);
|
2417
2438
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
@@ -3586,6 +3607,7 @@ var processGqlChain = (chain) => {
|
|
3586
3607
|
gasPerByte: bn15(feeParams.gasPerByte),
|
3587
3608
|
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3588
3609
|
chainId: bn15(consensusParameters.chainId),
|
3610
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3589
3611
|
gasCosts
|
3590
3612
|
},
|
3591
3613
|
gasCosts,
|
@@ -3828,6 +3850,17 @@ var _Provider = class {
|
|
3828
3850
|
} = this.getChain();
|
3829
3851
|
return chainId.toNumber();
|
3830
3852
|
}
|
3853
|
+
/**
|
3854
|
+
* Returns the base asset ID
|
3855
|
+
*
|
3856
|
+
* @returns A promise that resolves to the base asset ID
|
3857
|
+
*/
|
3858
|
+
getBaseAssetId() {
|
3859
|
+
const {
|
3860
|
+
consensusParameters: { baseAssetId }
|
3861
|
+
} = this.getChain();
|
3862
|
+
return baseAssetId;
|
3863
|
+
}
|
3831
3864
|
/**
|
3832
3865
|
* Submits a transaction to the chain to be executed.
|
3833
3866
|
*
|
@@ -4891,8 +4924,9 @@ var Account = class extends AbstractAccount {
|
|
4891
4924
|
* @param assetId - The asset ID to check the balance for.
|
4892
4925
|
* @returns A promise that resolves to the balance amount.
|
4893
4926
|
*/
|
4894
|
-
async getBalance(assetId
|
4895
|
-
const
|
4927
|
+
async getBalance(assetId) {
|
4928
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
4929
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
4896
4930
|
return amount;
|
4897
4931
|
}
|
4898
4932
|
/**
|
@@ -4930,9 +4964,10 @@ var Account = class extends AbstractAccount {
|
|
4930
4964
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4931
4965
|
*/
|
4932
4966
|
async fund(request, coinQuantities, fee) {
|
4967
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
4933
4968
|
const updatedQuantities = addAmountToAsset({
|
4934
4969
|
amount: bn17(fee),
|
4935
|
-
assetId:
|
4970
|
+
assetId: baseAssetId,
|
4936
4971
|
coinQuantities
|
4937
4972
|
});
|
4938
4973
|
const quantitiesDict = {};
|
@@ -4956,8 +4991,8 @@ var Account = class extends AbstractAccount {
|
|
4956
4991
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4957
4992
|
cachedUtxos.push(input.id);
|
4958
4993
|
}
|
4959
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4960
|
-
quantitiesDict[
|
4994
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
4995
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
4961
4996
|
cachedMessages.push(input.nonce);
|
4962
4997
|
}
|
4963
4998
|
}
|
@@ -4989,11 +5024,13 @@ var Account = class extends AbstractAccount {
|
|
4989
5024
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4990
5025
|
* @returns A promise that resolves to the prepared transaction request.
|
4991
5026
|
*/
|
4992
|
-
async createTransfer(destination, amount, assetId
|
5027
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4993
5028
|
const { minGasPrice } = this.provider.getGasConfig();
|
4994
|
-
const
|
5029
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5030
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5031
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
4995
5032
|
const request = new ScriptTransactionRequest(params);
|
4996
|
-
request.addCoinOutput(Address3.fromAddressOrString(destination), amount,
|
5033
|
+
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4997
5034
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4998
5035
|
estimateTxDependencies: true,
|
4999
5036
|
resourcesOwner: this
|
@@ -5019,14 +5056,15 @@ var Account = class extends AbstractAccount {
|
|
5019
5056
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5020
5057
|
* @returns A promise that resolves to the transaction response.
|
5021
5058
|
*/
|
5022
|
-
async transfer(destination, amount, assetId
|
5059
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
5023
5060
|
if (bn17(amount).lte(0)) {
|
5024
5061
|
throw new FuelError15(
|
5025
5062
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5026
5063
|
"Transfer amount must be a positive number."
|
5027
5064
|
);
|
5028
5065
|
}
|
5029
|
-
const
|
5066
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5067
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5030
5068
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5031
5069
|
}
|
5032
5070
|
/**
|
@@ -5038,7 +5076,7 @@ var Account = class extends AbstractAccount {
|
|
5038
5076
|
* @param txParams - The optional transaction parameters.
|
5039
5077
|
* @returns A promise that resolves to the transaction response.
|
5040
5078
|
*/
|
5041
|
-
async transferToContract(contractId, amount, assetId
|
5079
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5042
5080
|
if (bn17(amount).lte(0)) {
|
5043
5081
|
throw new FuelError15(
|
5044
5082
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
@@ -5047,11 +5085,13 @@ var Account = class extends AbstractAccount {
|
|
5047
5085
|
}
|
5048
5086
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5049
5087
|
const { minGasPrice } = this.provider.getGasConfig();
|
5050
|
-
const
|
5088
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5089
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5090
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
5051
5091
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5052
5092
|
hexlifiedContractId: contractAddress.toB256(),
|
5053
5093
|
amountToTransfer: bn17(amount),
|
5054
|
-
assetId
|
5094
|
+
assetId: assetIdToTransfer
|
5055
5095
|
});
|
5056
5096
|
const request = new ScriptTransactionRequest({
|
5057
5097
|
...params,
|
@@ -5061,7 +5101,7 @@ var Account = class extends AbstractAccount {
|
|
5061
5101
|
request.addContractInputAndOutput(contractAddress);
|
5062
5102
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5063
5103
|
request,
|
5064
|
-
[{ amount: bn17(amount), assetId: String(
|
5104
|
+
[{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
|
5065
5105
|
);
|
5066
5106
|
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5067
5107
|
this.validateGas({
|
@@ -5083,6 +5123,7 @@ var Account = class extends AbstractAccount {
|
|
5083
5123
|
*/
|
5084
5124
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5085
5125
|
const { minGasPrice } = this.provider.getGasConfig();
|
5126
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5086
5127
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5087
5128
|
const recipientDataArray = arrayify14(
|
5088
5129
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -5095,9 +5136,14 @@ var Account = class extends AbstractAccount {
|
|
5095
5136
|
...recipientDataArray,
|
5096
5137
|
...amountDataArray
|
5097
5138
|
]);
|
5098
|
-
const params = {
|
5139
|
+
const params = {
|
5140
|
+
script,
|
5141
|
+
gasPrice: minGasPrice,
|
5142
|
+
baseAssetId,
|
5143
|
+
...txParams
|
5144
|
+
};
|
5099
5145
|
const request = new ScriptTransactionRequest(params);
|
5100
|
-
const forwardingQuantities = [{ amount: bn17(amount), assetId:
|
5146
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
|
5101
5147
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5102
5148
|
request,
|
5103
5149
|
forwardingQuantities
|
@@ -8674,7 +8720,6 @@ import {
|
|
8674
8720
|
SCRIPT_FIXED_SIZE
|
8675
8721
|
} from "@fuel-ts/abi-coder";
|
8676
8722
|
import { Address as Address9 } from "@fuel-ts/address";
|
8677
|
-
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8678
8723
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8679
8724
|
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8680
8725
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
@@ -8739,7 +8784,6 @@ var Predicate = class extends Account {
|
|
8739
8784
|
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8740
8785
|
input.predicate = this.bytes;
|
8741
8786
|
input.predicateData = this.getPredicateData(policies.length);
|
8742
|
-
input.witnessIndex = 0;
|
8743
8787
|
}
|
8744
8788
|
});
|
8745
8789
|
return request;
|
@@ -8753,8 +8797,9 @@ var Predicate = class extends Account {
|
|
8753
8797
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8754
8798
|
* @returns A promise that resolves to the prepared transaction request.
|
8755
8799
|
*/
|
8756
|
-
async createTransfer(destination, amount, assetId
|
8757
|
-
const
|
8800
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8801
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
8802
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8758
8803
|
return this.populateTransactionPredicateData(request);
|
8759
8804
|
}
|
8760
8805
|
/**
|
@@ -8777,20 +8822,6 @@ var Predicate = class extends Account {
|
|
8777
8822
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8778
8823
|
return super.simulateTransaction(transactionRequest);
|
8779
8824
|
}
|
8780
|
-
/**
|
8781
|
-
* Retrieves resources satisfying the spend query for the account.
|
8782
|
-
*
|
8783
|
-
* @param quantities - IDs of coins to exclude.
|
8784
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8785
|
-
* @returns A promise that resolves to an array of Resources.
|
8786
|
-
*/
|
8787
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8788
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8789
|
-
return resources.map((resource) => ({
|
8790
|
-
...resource,
|
8791
|
-
predicate: hexlify19(this.bytes)
|
8792
|
-
}));
|
8793
|
-
}
|
8794
8825
|
getPredicateData(policiesLength) {
|
8795
8826
|
if (!this.predicateData.length) {
|
8796
8827
|
return new Uint8Array();
|