@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-1976-20240411153008
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 +135 -104
- 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 +138 -89
- 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);
|
@@ -1156,7 +1154,7 @@ var outputify = (value) => {
|
|
1156
1154
|
|
1157
1155
|
// src/providers/transaction-request/transaction-request.ts
|
1158
1156
|
import { Address, addressify } from "@fuel-ts/address";
|
1159
|
-
import {
|
1157
|
+
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1160
1158
|
import { bn as bn7 } from "@fuel-ts/math";
|
1161
1159
|
import {
|
1162
1160
|
PolicyType,
|
@@ -1690,6 +1688,8 @@ var BaseTransactionRequest = class {
|
|
1690
1688
|
outputs = [];
|
1691
1689
|
/** List of witnesses */
|
1692
1690
|
witnesses = [];
|
1691
|
+
/** Base asset ID - should be fetched from the chain */
|
1692
|
+
baseAssetId;
|
1693
1693
|
/**
|
1694
1694
|
* Constructor for initializing a base transaction request.
|
1695
1695
|
*
|
@@ -1702,8 +1702,9 @@ var BaseTransactionRequest = class {
|
|
1702
1702
|
witnessLimit,
|
1703
1703
|
inputs,
|
1704
1704
|
outputs,
|
1705
|
-
witnesses
|
1706
|
-
|
1705
|
+
witnesses,
|
1706
|
+
baseAssetId
|
1707
|
+
}) {
|
1707
1708
|
this.gasPrice = bn7(gasPrice);
|
1708
1709
|
this.maturity = maturity ?? 0;
|
1709
1710
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
@@ -1711,6 +1712,7 @@ var BaseTransactionRequest = class {
|
|
1711
1712
|
this.inputs = inputs ?? [];
|
1712
1713
|
this.outputs = outputs ?? [];
|
1713
1714
|
this.witnesses = witnesses ?? [];
|
1715
|
+
this.baseAssetId = baseAssetId;
|
1714
1716
|
}
|
1715
1717
|
static getPolicyMeta(req) {
|
1716
1718
|
let policyTypes = 0;
|
@@ -1904,8 +1906,8 @@ var BaseTransactionRequest = class {
|
|
1904
1906
|
* @param predicate - Predicate bytes.
|
1905
1907
|
* @param predicateData - Predicate data bytes.
|
1906
1908
|
*/
|
1907
|
-
addCoinInput(coin) {
|
1908
|
-
const { assetId, owner, amount
|
1909
|
+
addCoinInput(coin, predicate) {
|
1910
|
+
const { assetId, owner, amount } = coin;
|
1909
1911
|
let witnessIndex;
|
1910
1912
|
if (predicate) {
|
1911
1913
|
witnessIndex = 0;
|
@@ -1916,14 +1918,14 @@ var BaseTransactionRequest = class {
|
|
1916
1918
|
}
|
1917
1919
|
}
|
1918
1920
|
const input = {
|
1919
|
-
|
1921
|
+
...coin,
|
1920
1922
|
type: InputType2.Coin,
|
1921
1923
|
owner: owner.toB256(),
|
1922
1924
|
amount,
|
1923
1925
|
assetId,
|
1924
1926
|
txPointer: "0x00000000000000000000000000000000",
|
1925
1927
|
witnessIndex,
|
1926
|
-
predicate
|
1928
|
+
predicate: predicate?.bytes
|
1927
1929
|
};
|
1928
1930
|
this.pushInput(input);
|
1929
1931
|
this.addChangeOutput(owner, assetId);
|
@@ -1934,11 +1936,9 @@ var BaseTransactionRequest = class {
|
|
1934
1936
|
*
|
1935
1937
|
* @param message - Message resource.
|
1936
1938
|
* @param predicate - Predicate bytes.
|
1937
|
-
* @param predicateData - Predicate data bytes.
|
1938
1939
|
*/
|
1939
|
-
addMessageInput(message) {
|
1940
|
-
const { recipient, sender, amount
|
1941
|
-
const assetId = BaseAssetId2;
|
1940
|
+
addMessageInput(message, predicate) {
|
1941
|
+
const { recipient, sender, amount } = message;
|
1942
1942
|
let witnessIndex;
|
1943
1943
|
if (predicate) {
|
1944
1944
|
witnessIndex = 0;
|
@@ -1949,16 +1949,16 @@ var BaseTransactionRequest = class {
|
|
1949
1949
|
}
|
1950
1950
|
}
|
1951
1951
|
const input = {
|
1952
|
-
|
1952
|
+
...message,
|
1953
1953
|
type: InputType2.Message,
|
1954
1954
|
sender: sender.toB256(),
|
1955
1955
|
recipient: recipient.toB256(),
|
1956
1956
|
amount,
|
1957
1957
|
witnessIndex,
|
1958
|
-
predicate
|
1958
|
+
predicate: predicate?.bytes
|
1959
1959
|
};
|
1960
1960
|
this.pushInput(input);
|
1961
|
-
this.addChangeOutput(recipient,
|
1961
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
1962
1962
|
}
|
1963
1963
|
/**
|
1964
1964
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -1986,6 +1986,32 @@ var BaseTransactionRequest = class {
|
|
1986
1986
|
resources.forEach((resource) => this.addResource(resource));
|
1987
1987
|
return this;
|
1988
1988
|
}
|
1989
|
+
/**
|
1990
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1991
|
+
* outputs from the related assetIds.
|
1992
|
+
*
|
1993
|
+
* @param resources - The resources to add.
|
1994
|
+
* @returns This transaction.
|
1995
|
+
*/
|
1996
|
+
addPredicateResource(resource, predicate) {
|
1997
|
+
if (isCoin(resource)) {
|
1998
|
+
this.addCoinInput(resource, predicate);
|
1999
|
+
} else {
|
2000
|
+
this.addMessageInput(resource, predicate);
|
2001
|
+
}
|
2002
|
+
return this;
|
2003
|
+
}
|
2004
|
+
/**
|
2005
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2006
|
+
* from the related assetIds.
|
2007
|
+
*
|
2008
|
+
* @param resources - The resources to add.
|
2009
|
+
* @returns This transaction.
|
2010
|
+
*/
|
2011
|
+
addPredicateResources(resources, predicate) {
|
2012
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2013
|
+
return this;
|
2014
|
+
}
|
1989
2015
|
/**
|
1990
2016
|
* Adds a coin output to the transaction.
|
1991
2017
|
*
|
@@ -1993,12 +2019,12 @@ var BaseTransactionRequest = class {
|
|
1993
2019
|
* @param amount - Amount of coin.
|
1994
2020
|
* @param assetId - Asset ID of coin.
|
1995
2021
|
*/
|
1996
|
-
addCoinOutput(to, amount, assetId
|
2022
|
+
addCoinOutput(to, amount, assetId) {
|
1997
2023
|
this.pushOutput({
|
1998
2024
|
type: OutputType2.Coin,
|
1999
2025
|
to: addressify(to).toB256(),
|
2000
2026
|
amount,
|
2001
|
-
assetId
|
2027
|
+
assetId: assetId ?? this.baseAssetId
|
2002
2028
|
});
|
2003
2029
|
return this;
|
2004
2030
|
}
|
@@ -2025,7 +2051,7 @@ var BaseTransactionRequest = class {
|
|
2025
2051
|
* @param to - Address of the owner.
|
2026
2052
|
* @param assetId - Asset ID of coin.
|
2027
2053
|
*/
|
2028
|
-
addChangeOutput(to, assetId
|
2054
|
+
addChangeOutput(to, assetId) {
|
2029
2055
|
const changeOutput = this.getChangeOutputs().find(
|
2030
2056
|
(output) => hexlify7(output.assetId) === assetId
|
2031
2057
|
);
|
@@ -2033,7 +2059,7 @@ var BaseTransactionRequest = class {
|
|
2033
2059
|
this.pushOutput({
|
2034
2060
|
type: OutputType2.Change,
|
2035
2061
|
to: addressify(to).toB256(),
|
2036
|
-
assetId
|
2062
|
+
assetId: assetId ?? this.baseAssetId
|
2037
2063
|
});
|
2038
2064
|
}
|
2039
2065
|
}
|
@@ -2115,7 +2141,7 @@ var BaseTransactionRequest = class {
|
|
2115
2141
|
]);
|
2116
2142
|
}
|
2117
2143
|
};
|
2118
|
-
updateAssetInput(
|
2144
|
+
updateAssetInput(this.baseAssetId, bn7(1e11));
|
2119
2145
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2120
2146
|
}
|
2121
2147
|
/**
|
@@ -2285,12 +2311,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2285
2311
|
*
|
2286
2312
|
* @param createTransactionRequestLike - The initial values for the instance
|
2287
2313
|
*/
|
2288
|
-
constructor({
|
2289
|
-
bytecodeWitnessIndex,
|
2290
|
-
salt,
|
2291
|
-
storageSlots,
|
2292
|
-
...rest
|
2293
|
-
} = {}) {
|
2314
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
2294
2315
|
super(rest);
|
2295
2316
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2296
2317
|
this.salt = hexlify9(salt ?? ZeroBytes326);
|
@@ -2414,7 +2435,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2414
2435
|
*
|
2415
2436
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
2416
2437
|
*/
|
2417
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
2438
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
2418
2439
|
super(rest);
|
2419
2440
|
this.gasLimit = bn10(gasLimit);
|
2420
2441
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
@@ -3589,6 +3610,7 @@ var processGqlChain = (chain) => {
|
|
3589
3610
|
gasPerByte: bn15(feeParams.gasPerByte),
|
3590
3611
|
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3591
3612
|
chainId: bn15(consensusParameters.chainId),
|
3613
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3592
3614
|
gasCosts
|
3593
3615
|
},
|
3594
3616
|
gasCosts,
|
@@ -3831,6 +3853,17 @@ var _Provider = class {
|
|
3831
3853
|
} = this.getChain();
|
3832
3854
|
return chainId.toNumber();
|
3833
3855
|
}
|
3856
|
+
/**
|
3857
|
+
* Returns the base asset ID
|
3858
|
+
*
|
3859
|
+
* @returns A promise that resolves to the base asset ID
|
3860
|
+
*/
|
3861
|
+
getBaseAssetId() {
|
3862
|
+
const {
|
3863
|
+
consensusParameters: { baseAssetId }
|
3864
|
+
} = this.getChain();
|
3865
|
+
return baseAssetId;
|
3866
|
+
}
|
3834
3867
|
/**
|
3835
3868
|
* Submits a transaction to the chain to be executed.
|
3836
3869
|
*
|
@@ -4867,8 +4900,9 @@ var Account = class extends AbstractAccount {
|
|
4867
4900
|
* @param assetId - The asset ID to check the balance for.
|
4868
4901
|
* @returns A promise that resolves to the balance amount.
|
4869
4902
|
*/
|
4870
|
-
async getBalance(assetId
|
4871
|
-
const
|
4903
|
+
async getBalance(assetId) {
|
4904
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
4905
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
4872
4906
|
return amount;
|
4873
4907
|
}
|
4874
4908
|
/**
|
@@ -4906,9 +4940,10 @@ var Account = class extends AbstractAccount {
|
|
4906
4940
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4907
4941
|
*/
|
4908
4942
|
async fund(request, coinQuantities, fee) {
|
4943
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
4909
4944
|
const updatedQuantities = addAmountToAsset({
|
4910
4945
|
amount: bn17(fee),
|
4911
|
-
assetId:
|
4946
|
+
assetId: baseAssetId,
|
4912
4947
|
coinQuantities
|
4913
4948
|
});
|
4914
4949
|
const quantitiesDict = {};
|
@@ -4932,8 +4967,8 @@ var Account = class extends AbstractAccount {
|
|
4932
4967
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4933
4968
|
cachedUtxos.push(input.id);
|
4934
4969
|
}
|
4935
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4936
|
-
quantitiesDict[
|
4970
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
4971
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
4937
4972
|
cachedMessages.push(input.nonce);
|
4938
4973
|
}
|
4939
4974
|
}
|
@@ -4965,11 +5000,13 @@ var Account = class extends AbstractAccount {
|
|
4965
5000
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4966
5001
|
* @returns A promise that resolves to the prepared transaction request.
|
4967
5002
|
*/
|
4968
|
-
async createTransfer(destination, amount, assetId
|
5003
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4969
5004
|
const { minGasPrice } = this.provider.getGasConfig();
|
4970
|
-
const
|
5005
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5006
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5007
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
4971
5008
|
const request = new ScriptTransactionRequest(params);
|
4972
|
-
request.addCoinOutput(Address3.fromAddressOrString(destination), amount,
|
5009
|
+
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4973
5010
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4974
5011
|
estimateTxDependencies: true,
|
4975
5012
|
resourcesOwner: this
|
@@ -4995,14 +5032,15 @@ var Account = class extends AbstractAccount {
|
|
4995
5032
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4996
5033
|
* @returns A promise that resolves to the transaction response.
|
4997
5034
|
*/
|
4998
|
-
async transfer(destination, amount, assetId
|
5035
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
4999
5036
|
if (bn17(amount).lte(0)) {
|
5000
5037
|
throw new FuelError15(
|
5001
5038
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5002
5039
|
"Transfer amount must be a positive number."
|
5003
5040
|
);
|
5004
5041
|
}
|
5005
|
-
const
|
5042
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5043
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5006
5044
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5007
5045
|
}
|
5008
5046
|
/**
|
@@ -5014,7 +5052,7 @@ var Account = class extends AbstractAccount {
|
|
5014
5052
|
* @param txParams - The optional transaction parameters.
|
5015
5053
|
* @returns A promise that resolves to the transaction response.
|
5016
5054
|
*/
|
5017
|
-
async transferToContract(contractId, amount, assetId
|
5055
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5018
5056
|
if (bn17(amount).lte(0)) {
|
5019
5057
|
throw new FuelError15(
|
5020
5058
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
@@ -5023,11 +5061,13 @@ var Account = class extends AbstractAccount {
|
|
5023
5061
|
}
|
5024
5062
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5025
5063
|
const { minGasPrice } = this.provider.getGasConfig();
|
5026
|
-
const
|
5064
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5065
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5066
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
5027
5067
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5028
5068
|
hexlifiedContractId: contractAddress.toB256(),
|
5029
5069
|
amountToTransfer: bn17(amount),
|
5030
|
-
assetId
|
5070
|
+
assetId: assetIdToTransfer
|
5031
5071
|
});
|
5032
5072
|
const request = new ScriptTransactionRequest({
|
5033
5073
|
...params,
|
@@ -5037,7 +5077,7 @@ var Account = class extends AbstractAccount {
|
|
5037
5077
|
request.addContractInputAndOutput(contractAddress);
|
5038
5078
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5039
5079
|
request,
|
5040
|
-
[{ amount: bn17(amount), assetId: String(
|
5080
|
+
[{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
|
5041
5081
|
);
|
5042
5082
|
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5043
5083
|
this.validateGas({
|
@@ -5059,6 +5099,7 @@ var Account = class extends AbstractAccount {
|
|
5059
5099
|
*/
|
5060
5100
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5061
5101
|
const { minGasPrice } = this.provider.getGasConfig();
|
5102
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5062
5103
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5063
5104
|
const recipientDataArray = arrayify14(
|
5064
5105
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -5071,9 +5112,14 @@ var Account = class extends AbstractAccount {
|
|
5071
5112
|
...recipientDataArray,
|
5072
5113
|
...amountDataArray
|
5073
5114
|
]);
|
5074
|
-
const params = {
|
5115
|
+
const params = {
|
5116
|
+
script,
|
5117
|
+
gasPrice: minGasPrice,
|
5118
|
+
baseAssetId,
|
5119
|
+
...txParams
|
5120
|
+
};
|
5075
5121
|
const request = new ScriptTransactionRequest(params);
|
5076
|
-
const forwardingQuantities = [{ amount: bn17(amount), assetId:
|
5122
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
|
5077
5123
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5078
5124
|
request,
|
5079
5125
|
forwardingQuantities
|
@@ -8650,7 +8696,6 @@ import {
|
|
8650
8696
|
SCRIPT_FIXED_SIZE
|
8651
8697
|
} from "@fuel-ts/abi-coder";
|
8652
8698
|
import { Address as Address9 } from "@fuel-ts/address";
|
8653
|
-
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8654
8699
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8655
8700
|
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8656
8701
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
@@ -8715,7 +8760,6 @@ var Predicate = class extends Account {
|
|
8715
8760
|
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8716
8761
|
input.predicate = this.bytes;
|
8717
8762
|
input.predicateData = this.getPredicateData(policies.length);
|
8718
|
-
input.witnessIndex = 0;
|
8719
8763
|
}
|
8720
8764
|
});
|
8721
8765
|
return request;
|
@@ -8729,8 +8773,9 @@ var Predicate = class extends Account {
|
|
8729
8773
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8730
8774
|
* @returns A promise that resolves to the prepared transaction request.
|
8731
8775
|
*/
|
8732
|
-
async createTransfer(destination, amount, assetId
|
8733
|
-
const
|
8776
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8777
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
8778
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8734
8779
|
return this.populateTransactionPredicateData(request);
|
8735
8780
|
}
|
8736
8781
|
/**
|
@@ -8753,20 +8798,6 @@ var Predicate = class extends Account {
|
|
8753
8798
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8754
8799
|
return super.simulateTransaction(transactionRequest);
|
8755
8800
|
}
|
8756
|
-
/**
|
8757
|
-
* Retrieves resources satisfying the spend query for the account.
|
8758
|
-
*
|
8759
|
-
* @param quantities - IDs of coins to exclude.
|
8760
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8761
|
-
* @returns A promise that resolves to an array of Resources.
|
8762
|
-
*/
|
8763
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8764
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8765
|
-
return resources.map((resource) => ({
|
8766
|
-
...resource,
|
8767
|
-
predicate: hexlify19(this.bytes)
|
8768
|
-
}));
|
8769
|
-
}
|
8770
8801
|
getPredicateData(policiesLength) {
|
8771
8802
|
if (!this.predicateData.length) {
|
8772
8803
|
return new Uint8Array();
|