@fuel-ts/account 0.0.0-rc-2037-20240422095321 → 0.0.0-rc-2130-20240422142413
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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1407 -2588
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +154 -230
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -140
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -17
- package/dist/predicate/predicate.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 +0 -9
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +0 -1
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +20 -4
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +0 -1
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1448 -2606
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +149 -203
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +70 -121
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -16
- package/dist/providers/transaction-request/helpers.d.ts +0 -10
- package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
- package/dist/test-utils/resources.d.ts +0 -4
- package/dist/test-utils/resources.d.ts.map +0 -1
- package/dist/test-utils/transactionRequest.d.ts +0 -5
- package/dist/test-utils/transactionRequest.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -76,7 +76,7 @@ import { Address as Address2 } from "@fuel-ts/address";
|
|
76
76
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
77
77
|
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
78
78
|
import {
|
79
|
-
InputType as
|
79
|
+
InputType as InputType6,
|
80
80
|
TransactionType as TransactionType8,
|
81
81
|
InputMessageCoder,
|
82
82
|
TransactionCoder as TransactionCoder5
|
@@ -84,7 +84,6 @@ import {
|
|
84
84
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
85
85
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
86
86
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
87
|
-
import { Network } from "ethers";
|
88
87
|
import { GraphQLClient } from "graphql-request";
|
89
88
|
import { clone as clone3 } from "ramda";
|
90
89
|
|
@@ -1173,7 +1172,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1173
1172
|
import {
|
1174
1173
|
PolicyType,
|
1175
1174
|
TransactionCoder,
|
1176
|
-
InputType as
|
1175
|
+
InputType as InputType2,
|
1177
1176
|
OutputType as OutputType2,
|
1178
1177
|
TransactionType
|
1179
1178
|
} from "@fuel-ts/transactions";
|
@@ -1676,28 +1675,6 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1676
1675
|
name = "NoWitnessByOwnerError";
|
1677
1676
|
};
|
1678
1677
|
|
1679
|
-
// src/providers/transaction-request/helpers.ts
|
1680
|
-
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1681
|
-
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1682
|
-
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1683
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1684
|
-
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1685
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1686
|
-
var cacheResources = (resources) => resources.reduce(
|
1687
|
-
(cache2, resource) => {
|
1688
|
-
if (isCoin(resource)) {
|
1689
|
-
cache2.utxos.push(resource.id);
|
1690
|
-
} else {
|
1691
|
-
cache2.messages.push(resource.nonce);
|
1692
|
-
}
|
1693
|
-
return cache2;
|
1694
|
-
},
|
1695
|
-
{
|
1696
|
-
utxos: [],
|
1697
|
-
messages: []
|
1698
|
-
}
|
1699
|
-
);
|
1700
|
-
|
1701
1678
|
// src/providers/transaction-request/witness.ts
|
1702
1679
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1703
1680
|
var witnessify = (value) => {
|
@@ -1888,7 +1865,7 @@ var BaseTransactionRequest = class {
|
|
1888
1865
|
*/
|
1889
1866
|
getCoinInputs() {
|
1890
1867
|
return this.inputs.filter(
|
1891
|
-
(input) => input.type ===
|
1868
|
+
(input) => input.type === InputType2.Coin
|
1892
1869
|
);
|
1893
1870
|
}
|
1894
1871
|
/**
|
@@ -1920,9 +1897,9 @@ var BaseTransactionRequest = class {
|
|
1920
1897
|
const ownerAddress = addressify(owner);
|
1921
1898
|
const found = this.inputs.find((input) => {
|
1922
1899
|
switch (input.type) {
|
1923
|
-
case
|
1900
|
+
case InputType2.Coin:
|
1924
1901
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1925
|
-
case
|
1902
|
+
case InputType2.Message:
|
1926
1903
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1927
1904
|
default:
|
1928
1905
|
return false;
|
@@ -1938,8 +1915,8 @@ var BaseTransactionRequest = class {
|
|
1938
1915
|
* @param predicate - Predicate bytes.
|
1939
1916
|
* @param predicateData - Predicate data bytes.
|
1940
1917
|
*/
|
1941
|
-
addCoinInput(coin) {
|
1942
|
-
const { assetId, owner, amount
|
1918
|
+
addCoinInput(coin, predicate) {
|
1919
|
+
const { assetId, owner, amount } = coin;
|
1943
1920
|
let witnessIndex;
|
1944
1921
|
if (predicate) {
|
1945
1922
|
witnessIndex = 0;
|
@@ -1950,14 +1927,14 @@ var BaseTransactionRequest = class {
|
|
1950
1927
|
}
|
1951
1928
|
}
|
1952
1929
|
const input = {
|
1953
|
-
|
1954
|
-
type:
|
1930
|
+
...coin,
|
1931
|
+
type: InputType2.Coin,
|
1955
1932
|
owner: owner.toB256(),
|
1956
1933
|
amount,
|
1957
1934
|
assetId,
|
1958
1935
|
txPointer: "0x00000000000000000000000000000000",
|
1959
1936
|
witnessIndex,
|
1960
|
-
predicate
|
1937
|
+
predicate: predicate?.bytes
|
1961
1938
|
};
|
1962
1939
|
this.pushInput(input);
|
1963
1940
|
this.addChangeOutput(owner, assetId);
|
@@ -1970,8 +1947,8 @@ var BaseTransactionRequest = class {
|
|
1970
1947
|
* @param predicate - Predicate bytes.
|
1971
1948
|
* @param predicateData - Predicate data bytes.
|
1972
1949
|
*/
|
1973
|
-
addMessageInput(message) {
|
1974
|
-
const { recipient, sender, amount
|
1950
|
+
addMessageInput(message, predicate) {
|
1951
|
+
const { recipient, sender, amount } = message;
|
1975
1952
|
const assetId = BaseAssetId2;
|
1976
1953
|
let witnessIndex;
|
1977
1954
|
if (predicate) {
|
@@ -1983,13 +1960,13 @@ var BaseTransactionRequest = class {
|
|
1983
1960
|
}
|
1984
1961
|
}
|
1985
1962
|
const input = {
|
1986
|
-
|
1987
|
-
type:
|
1963
|
+
...message,
|
1964
|
+
type: InputType2.Message,
|
1988
1965
|
sender: sender.toB256(),
|
1989
1966
|
recipient: recipient.toB256(),
|
1990
1967
|
amount,
|
1991
1968
|
witnessIndex,
|
1992
|
-
predicate
|
1969
|
+
predicate: predicate?.bytes
|
1993
1970
|
};
|
1994
1971
|
this.pushInput(input);
|
1995
1972
|
this.addChangeOutput(recipient, assetId);
|
@@ -2020,6 +1997,32 @@ var BaseTransactionRequest = class {
|
|
2020
1997
|
resources.forEach((resource) => this.addResource(resource));
|
2021
1998
|
return this;
|
2022
1999
|
}
|
2000
|
+
/**
|
2001
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
2002
|
+
* outputs from the related assetIds.
|
2003
|
+
*
|
2004
|
+
* @param resources - The resources to add.
|
2005
|
+
* @returns This transaction.
|
2006
|
+
*/
|
2007
|
+
addPredicateResource(resource, predicate) {
|
2008
|
+
if (isCoin(resource)) {
|
2009
|
+
this.addCoinInput(resource, predicate);
|
2010
|
+
} else {
|
2011
|
+
this.addMessageInput(resource, predicate);
|
2012
|
+
}
|
2013
|
+
return this;
|
2014
|
+
}
|
2015
|
+
/**
|
2016
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2017
|
+
* from the related assetIds.
|
2018
|
+
*
|
2019
|
+
* @param resources - The resources to add.
|
2020
|
+
* @returns This transaction.
|
2021
|
+
*/
|
2022
|
+
addPredicateResources(resources, predicate) {
|
2023
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2024
|
+
return this;
|
2025
|
+
}
|
2023
2026
|
/**
|
2024
2027
|
* Adds a coin output to the transaction.
|
2025
2028
|
*
|
@@ -2168,20 +2171,16 @@ var BaseTransactionRequest = class {
|
|
2168
2171
|
toJSON() {
|
2169
2172
|
return normalizeJSON(this);
|
2170
2173
|
}
|
2171
|
-
removeWitness(index) {
|
2172
|
-
this.witnesses.splice(index, 1);
|
2173
|
-
this.adjustWitnessIndexes(index);
|
2174
|
-
}
|
2175
2174
|
updatePredicateInputs(inputs) {
|
2176
2175
|
this.inputs.forEach((i) => {
|
2177
2176
|
let correspondingInput;
|
2178
2177
|
switch (i.type) {
|
2179
|
-
case
|
2180
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2178
|
+
case InputType2.Coin:
|
2179
|
+
correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
|
2181
2180
|
break;
|
2182
|
-
case
|
2181
|
+
case InputType2.Message:
|
2183
2182
|
correspondingInput = inputs.find(
|
2184
|
-
(x) => x.type ===
|
2183
|
+
(x) => x.type === InputType2.Message && x.sender === i.sender
|
2185
2184
|
);
|
2186
2185
|
break;
|
2187
2186
|
default:
|
@@ -2194,13 +2193,6 @@ var BaseTransactionRequest = class {
|
|
2194
2193
|
}
|
2195
2194
|
});
|
2196
2195
|
}
|
2197
|
-
adjustWitnessIndexes(removedIndex) {
|
2198
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2199
|
-
if (input.witnessIndex > removedIndex) {
|
2200
|
-
input.witnessIndex -= 1;
|
2201
|
-
}
|
2202
|
-
});
|
2203
|
-
}
|
2204
2196
|
};
|
2205
2197
|
|
2206
2198
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2213,7 +2205,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2213
2205
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2214
2206
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2215
2207
|
import { bn as bn8 } from "@fuel-ts/math";
|
2216
|
-
import { TransactionType as TransactionType2, InputType as
|
2208
|
+
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2217
2209
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2218
2210
|
import { clone as clone2 } from "ramda";
|
2219
2211
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2224,7 +2216,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2224
2216
|
transaction.inputs = transaction.inputs.map((input) => {
|
2225
2217
|
const inputClone = clone2(input);
|
2226
2218
|
switch (inputClone.type) {
|
2227
|
-
case
|
2219
|
+
case InputType3.Coin: {
|
2228
2220
|
inputClone.txPointer = {
|
2229
2221
|
blockHeight: 0,
|
2230
2222
|
txIndex: 0
|
@@ -2232,11 +2224,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2232
2224
|
inputClone.predicateGasUsed = bn8(0);
|
2233
2225
|
return inputClone;
|
2234
2226
|
}
|
2235
|
-
case
|
2227
|
+
case InputType3.Message: {
|
2236
2228
|
inputClone.predicateGasUsed = bn8(0);
|
2237
2229
|
return inputClone;
|
2238
2230
|
}
|
2239
|
-
case
|
2231
|
+
case InputType3.Contract: {
|
2240
2232
|
inputClone.txPointer = {
|
2241
2233
|
blockHeight: 0,
|
2242
2234
|
txIndex: 0
|
@@ -2402,7 +2394,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2402
2394
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2403
2395
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2404
2396
|
import { bn as bn10 } from "@fuel-ts/math";
|
2405
|
-
import { InputType as
|
2397
|
+
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2406
2398
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2407
2399
|
|
2408
2400
|
// src/providers/transaction-request/scripts.ts
|
@@ -2486,7 +2478,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2486
2478
|
*/
|
2487
2479
|
getContractInputs() {
|
2488
2480
|
return this.inputs.filter(
|
2489
|
-
(input) => input.type ===
|
2481
|
+
(input) => input.type === InputType4.Contract
|
2490
2482
|
);
|
2491
2483
|
}
|
2492
2484
|
/**
|
@@ -2562,7 +2554,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2562
2554
|
return this;
|
2563
2555
|
}
|
2564
2556
|
const inputIndex = super.pushInput({
|
2565
|
-
type:
|
2557
|
+
type: InputType4.Contract,
|
2566
2558
|
contractId: contractAddress.toB256(),
|
2567
2559
|
txPointer: "0x00000000000000000000000000000000"
|
2568
2560
|
});
|
@@ -2757,7 +2749,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2757
2749
|
|
2758
2750
|
// src/providers/transaction-summary/input.ts
|
2759
2751
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2760
|
-
import { InputType as
|
2752
|
+
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2761
2753
|
function getInputsByTypes(inputs, types) {
|
2762
2754
|
return inputs.filter((i) => types.includes(i.type));
|
2763
2755
|
}
|
@@ -2765,16 +2757,16 @@ function getInputsByType(inputs, type) {
|
|
2765
2757
|
return inputs.filter((i) => i.type === type);
|
2766
2758
|
}
|
2767
2759
|
function getInputsCoin(inputs) {
|
2768
|
-
return getInputsByType(inputs,
|
2760
|
+
return getInputsByType(inputs, InputType5.Coin);
|
2769
2761
|
}
|
2770
2762
|
function getInputsMessage(inputs) {
|
2771
|
-
return getInputsByType(inputs,
|
2763
|
+
return getInputsByType(inputs, InputType5.Message);
|
2772
2764
|
}
|
2773
2765
|
function getInputsCoinAndMessage(inputs) {
|
2774
|
-
return getInputsByTypes(inputs, [
|
2766
|
+
return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
|
2775
2767
|
}
|
2776
2768
|
function getInputsContract(inputs) {
|
2777
|
-
return getInputsByType(inputs,
|
2769
|
+
return getInputsByType(inputs, InputType5.Contract);
|
2778
2770
|
}
|
2779
2771
|
function getInputFromAssetId(inputs, assetId) {
|
2780
2772
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2793,7 +2785,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2793
2785
|
if (!contractInput) {
|
2794
2786
|
return void 0;
|
2795
2787
|
}
|
2796
|
-
if (contractInput.type !==
|
2788
|
+
if (contractInput.type !== InputType5.Contract) {
|
2797
2789
|
throw new FuelError9(
|
2798
2790
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2799
2791
|
`Contract input should be of type 'contract'.`
|
@@ -2802,10 +2794,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2802
2794
|
return contractInput;
|
2803
2795
|
}
|
2804
2796
|
function getInputAccountAddress(input) {
|
2805
|
-
if (input.type ===
|
2797
|
+
if (input.type === InputType5.Coin) {
|
2806
2798
|
return input.owner.toString();
|
2807
2799
|
}
|
2808
|
-
if (input.type ===
|
2800
|
+
if (input.type === InputType5.Message) {
|
2809
2801
|
return input.recipient.toString();
|
2810
2802
|
}
|
2811
2803
|
return "";
|
@@ -3806,21 +3798,6 @@ var _Provider = class {
|
|
3806
3798
|
} = await this.operations.getVersion();
|
3807
3799
|
return nodeVersion;
|
3808
3800
|
}
|
3809
|
-
/**
|
3810
|
-
* @hidden
|
3811
|
-
*
|
3812
|
-
* Returns the network configuration of the connected Fuel node.
|
3813
|
-
*
|
3814
|
-
* @returns A promise that resolves to the network configuration object
|
3815
|
-
*/
|
3816
|
-
async getNetwork() {
|
3817
|
-
const {
|
3818
|
-
name,
|
3819
|
-
consensusParameters: { chainId }
|
3820
|
-
} = await this.getChain();
|
3821
|
-
const network = new Network(name, chainId.toNumber());
|
3822
|
-
return Promise.resolve(network);
|
3823
|
-
}
|
3824
3801
|
/**
|
3825
3802
|
* Returns the block number.
|
3826
3803
|
*
|
@@ -4549,7 +4526,7 @@ cacheInputs_fn = function(inputs) {
|
|
4549
4526
|
return;
|
4550
4527
|
}
|
4551
4528
|
inputs.forEach((input) => {
|
4552
|
-
if (input.type ===
|
4529
|
+
if (input.type === InputType6.Coin) {
|
4553
4530
|
this.cache?.set(input.id);
|
4554
4531
|
}
|
4555
4532
|
});
|
@@ -5555,18 +5532,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5555
5532
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5556
5533
|
|
5557
5534
|
// src/hdwallet/hdwallet.ts
|
5535
|
+
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5558
5536
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5559
5537
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5560
5538
|
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5561
|
-
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5562
|
-
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5539
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
5563
5540
|
|
5564
5541
|
// src/mnemonic/mnemonic.ts
|
5565
|
-
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
5542
|
+
import { randomBytes as randomBytes4, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
5566
5543
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5567
5544
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5568
|
-
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5569
|
-
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
5545
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4, dataSlice, encodeBase58 } from "@fuel-ts/utils";
|
5570
5546
|
|
5571
5547
|
// src/wordlists/words/english.ts
|
5572
5548
|
var english = [
|
@@ -8095,7 +8071,8 @@ var HDWallet = class {
|
|
8095
8071
|
});
|
8096
8072
|
}
|
8097
8073
|
static fromExtendedKey(extendedKey) {
|
8098
|
-
|
8074
|
+
let decoded = toHex(decodeBase58(extendedKey));
|
8075
|
+
decoded = `${decoded.substring(0, 2)}0${decoded.substring(2)}`;
|
8099
8076
|
const bytes = arrayify18(decoded);
|
8100
8077
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8101
8078
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8718,7 +8695,7 @@ import {
|
|
8718
8695
|
import { Address as Address9 } from "@fuel-ts/address";
|
8719
8696
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8720
8697
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8721
|
-
import { ByteArrayCoder } from "@fuel-ts/transactions";
|
8698
|
+
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8722
8699
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8723
8700
|
|
8724
8701
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8777,15 +8754,10 @@ var Predicate = class extends Account {
|
|
8777
8754
|
populateTransactionPredicateData(transactionRequestLike) {
|
8778
8755
|
const request = transactionRequestify(transactionRequestLike);
|
8779
8756
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8780
|
-
|
8781
|
-
|
8782
|
-
request.removeWitness(placeholderIndex);
|
8783
|
-
}
|
8784
|
-
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
8785
|
-
if (isRequestInputResourceFromOwner(input, this.address)) {
|
8757
|
+
request.inputs?.forEach((input) => {
|
8758
|
+
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8786
8759
|
input.predicate = this.bytes;
|
8787
8760
|
input.predicateData = this.getPredicateData(policies.length);
|
8788
|
-
input.witnessIndex = 0;
|
8789
8761
|
}
|
8790
8762
|
});
|
8791
8763
|
return request;
|
@@ -8823,20 +8795,6 @@ var Predicate = class extends Account {
|
|
8823
8795
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8824
8796
|
return super.simulateTransaction(transactionRequest);
|
8825
8797
|
}
|
8826
|
-
/**
|
8827
|
-
* Retrieves resources satisfying the spend query for the account.
|
8828
|
-
*
|
8829
|
-
* @param quantities - Coins to retrieve.
|
8830
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8831
|
-
* @returns A promise that resolves to an array of Resources.
|
8832
|
-
*/
|
8833
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8834
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8835
|
-
return resources.map((resource) => ({
|
8836
|
-
...resource,
|
8837
|
-
predicate: hexlify19(this.bytes)
|
8838
|
-
}));
|
8839
|
-
}
|
8840
8798
|
getPredicateData(policiesLength) {
|
8841
8799
|
if (!this.predicateData.length) {
|
8842
8800
|
return new Uint8Array();
|
@@ -8916,28 +8874,6 @@ var Predicate = class extends Account {
|
|
8916
8874
|
}
|
8917
8875
|
return mutatedBytes;
|
8918
8876
|
}
|
8919
|
-
/**
|
8920
|
-
* Returns the index of the witness placeholder that was added to this predicate.
|
8921
|
-
* If no witness placeholder was added, it returns -1.
|
8922
|
-
* @param request - The transaction request.
|
8923
|
-
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
8924
|
-
*/
|
8925
|
-
getIndexFromPlaceholderWitness(request) {
|
8926
|
-
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
8927
|
-
let index = -1;
|
8928
|
-
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
8929
|
-
if (hasEmptyPredicateInputs) {
|
8930
|
-
index = hasEmptyPredicateInputs.witnessIndex;
|
8931
|
-
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
8932
|
-
if (!allInputsAreEmpty) {
|
8933
|
-
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
8934
|
-
if (wasFilledInputAddedFirst) {
|
8935
|
-
index = -1;
|
8936
|
-
}
|
8937
|
-
}
|
8938
|
-
}
|
8939
|
-
return index;
|
8940
|
-
}
|
8941
8877
|
};
|
8942
8878
|
|
8943
8879
|
// src/connectors/fuel.ts
|
@@ -9660,7 +9596,6 @@ export {
|
|
9660
9596
|
assets,
|
9661
9597
|
buildBlockExplorerUrl,
|
9662
9598
|
cacheFor,
|
9663
|
-
cacheResources,
|
9664
9599
|
calculateMetadataGasForTxCreate,
|
9665
9600
|
calculateMetadataGasForTxScript,
|
9666
9601
|
calculatePriceWithFactor,
|
@@ -9707,7 +9642,6 @@ export {
|
|
9707
9642
|
getReceiptsMessageOut,
|
9708
9643
|
getReceiptsTransferOut,
|
9709
9644
|
getReceiptsWithMissingData,
|
9710
|
-
getRequestInputResourceOwner,
|
9711
9645
|
getTransactionStatusName,
|
9712
9646
|
getTransactionSummary,
|
9713
9647
|
getTransactionSummaryFromRequest,
|
@@ -9721,10 +9655,6 @@ export {
|
|
9721
9655
|
isMessage,
|
9722
9656
|
isRawCoin,
|
9723
9657
|
isRawMessage,
|
9724
|
-
isRequestInputCoin,
|
9725
|
-
isRequestInputMessage,
|
9726
|
-
isRequestInputResource,
|
9727
|
-
isRequestInputResourceFromOwner,
|
9728
9658
|
isType,
|
9729
9659
|
isTypeCreate,
|
9730
9660
|
isTypeMint,
|