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