@fuel-ts/account 0.0.0-rc-2037-20240430094729 → 0.0.0-rc-2143-20240430130957
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/index.global.js +8 -69
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +118 -192
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -107
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -9
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +1 -1
- 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 +0 -2
- 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/launchNode.d.ts +4 -2
- package/dist/test-utils/launchNode.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 +14 -63
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +117 -180
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +44 -104
- 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 -15
- 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
@@ -75,7 +75,7 @@ import { Address as Address2 } from "@fuel-ts/address";
|
|
75
75
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
76
76
|
import { BN, bn as bn16 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
|
-
InputType as
|
78
|
+
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
80
80
|
InputMessageCoder,
|
81
81
|
TransactionCoder as TransactionCoder5
|
@@ -1249,7 +1249,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1249
1249
|
import {
|
1250
1250
|
PolicyType,
|
1251
1251
|
TransactionCoder,
|
1252
|
-
InputType as
|
1252
|
+
InputType as InputType2,
|
1253
1253
|
OutputType as OutputType2,
|
1254
1254
|
TransactionType
|
1255
1255
|
} from "@fuel-ts/transactions";
|
@@ -1773,28 +1773,6 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1773
1773
|
name = "NoWitnessByOwnerError";
|
1774
1774
|
};
|
1775
1775
|
|
1776
|
-
// src/providers/transaction-request/helpers.ts
|
1777
|
-
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1778
|
-
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1779
|
-
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1780
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1781
|
-
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1782
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1783
|
-
var cacheResources = (resources) => resources.reduce(
|
1784
|
-
(cache2, resource) => {
|
1785
|
-
if (isCoin(resource)) {
|
1786
|
-
cache2.utxos.push(resource.id);
|
1787
|
-
} else {
|
1788
|
-
cache2.messages.push(resource.nonce);
|
1789
|
-
}
|
1790
|
-
return cache2;
|
1791
|
-
},
|
1792
|
-
{
|
1793
|
-
utxos: [],
|
1794
|
-
messages: []
|
1795
|
-
}
|
1796
|
-
);
|
1797
|
-
|
1798
1776
|
// src/providers/transaction-request/witness.ts
|
1799
1777
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1800
1778
|
var witnessify = (value) => {
|
@@ -1985,7 +1963,7 @@ var BaseTransactionRequest = class {
|
|
1985
1963
|
*/
|
1986
1964
|
getCoinInputs() {
|
1987
1965
|
return this.inputs.filter(
|
1988
|
-
(input) => input.type ===
|
1966
|
+
(input) => input.type === InputType2.Coin
|
1989
1967
|
);
|
1990
1968
|
}
|
1991
1969
|
/**
|
@@ -2017,9 +1995,9 @@ var BaseTransactionRequest = class {
|
|
2017
1995
|
const ownerAddress = addressify(owner);
|
2018
1996
|
const found = this.inputs.find((input) => {
|
2019
1997
|
switch (input.type) {
|
2020
|
-
case
|
1998
|
+
case InputType2.Coin:
|
2021
1999
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
2022
|
-
case
|
2000
|
+
case InputType2.Message:
|
2023
2001
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
2024
2002
|
default:
|
2025
2003
|
return false;
|
@@ -2034,7 +2012,7 @@ var BaseTransactionRequest = class {
|
|
2034
2012
|
* @param coin - Coin resource.
|
2035
2013
|
*/
|
2036
2014
|
addCoinInput(coin) {
|
2037
|
-
const { assetId, owner, amount
|
2015
|
+
const { assetId, owner, amount } = coin;
|
2038
2016
|
let witnessIndex;
|
2039
2017
|
if (coin.predicate) {
|
2040
2018
|
witnessIndex = 0;
|
@@ -2045,14 +2023,13 @@ var BaseTransactionRequest = class {
|
|
2045
2023
|
}
|
2046
2024
|
}
|
2047
2025
|
const input = {
|
2048
|
-
|
2049
|
-
type:
|
2026
|
+
...coin,
|
2027
|
+
type: InputType2.Coin,
|
2050
2028
|
owner: owner.toB256(),
|
2051
2029
|
amount,
|
2052
2030
|
assetId,
|
2053
2031
|
txPointer: "0x00000000000000000000000000000000",
|
2054
|
-
witnessIndex
|
2055
|
-
predicate
|
2032
|
+
witnessIndex
|
2056
2033
|
};
|
2057
2034
|
this.pushInput(input);
|
2058
2035
|
this.addChangeOutput(owner, assetId);
|
@@ -2064,7 +2041,7 @@ var BaseTransactionRequest = class {
|
|
2064
2041
|
* @param message - Message resource.
|
2065
2042
|
*/
|
2066
2043
|
addMessageInput(message) {
|
2067
|
-
const { recipient, sender, amount,
|
2044
|
+
const { recipient, sender, amount, assetId } = message;
|
2068
2045
|
let witnessIndex;
|
2069
2046
|
if (message.predicate) {
|
2070
2047
|
witnessIndex = 0;
|
@@ -2075,13 +2052,12 @@ var BaseTransactionRequest = class {
|
|
2075
2052
|
}
|
2076
2053
|
}
|
2077
2054
|
const input = {
|
2078
|
-
|
2079
|
-
type:
|
2055
|
+
...message,
|
2056
|
+
type: InputType2.Message,
|
2080
2057
|
sender: sender.toB256(),
|
2081
2058
|
recipient: recipient.toB256(),
|
2082
2059
|
amount,
|
2083
|
-
witnessIndex
|
2084
|
-
predicate
|
2060
|
+
witnessIndex
|
2085
2061
|
};
|
2086
2062
|
this.pushInput(input);
|
2087
2063
|
this.addChangeOutput(recipient, assetId);
|
@@ -2265,27 +2241,16 @@ var BaseTransactionRequest = class {
|
|
2265
2241
|
toJSON() {
|
2266
2242
|
return normalizeJSON(this);
|
2267
2243
|
}
|
2268
|
-
removeWitness(index) {
|
2269
|
-
this.witnesses.splice(index, 1);
|
2270
|
-
this.adjustWitnessIndexes(index);
|
2271
|
-
}
|
2272
|
-
adjustWitnessIndexes(removedIndex) {
|
2273
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2274
|
-
if (input.witnessIndex > removedIndex) {
|
2275
|
-
input.witnessIndex -= 1;
|
2276
|
-
}
|
2277
|
-
});
|
2278
|
-
}
|
2279
2244
|
updatePredicateGasUsed(inputs) {
|
2280
2245
|
this.inputs.forEach((i) => {
|
2281
2246
|
let correspondingInput;
|
2282
2247
|
switch (i.type) {
|
2283
|
-
case
|
2284
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2248
|
+
case InputType2.Coin:
|
2249
|
+
correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
|
2285
2250
|
break;
|
2286
|
-
case
|
2251
|
+
case InputType2.Message:
|
2287
2252
|
correspondingInput = inputs.find(
|
2288
|
-
(x) => x.type ===
|
2253
|
+
(x) => x.type === InputType2.Message && x.sender === i.sender
|
2289
2254
|
);
|
2290
2255
|
break;
|
2291
2256
|
default:
|
@@ -2319,7 +2284,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2319
2284
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2320
2285
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2321
2286
|
import { bn as bn8 } from "@fuel-ts/math";
|
2322
|
-
import { TransactionType as TransactionType2, InputType as
|
2287
|
+
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2323
2288
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2324
2289
|
import { clone as clone2 } from "ramda";
|
2325
2290
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2330,7 +2295,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2330
2295
|
transaction.inputs = transaction.inputs.map((input) => {
|
2331
2296
|
const inputClone = clone2(input);
|
2332
2297
|
switch (inputClone.type) {
|
2333
|
-
case
|
2298
|
+
case InputType3.Coin: {
|
2334
2299
|
inputClone.txPointer = {
|
2335
2300
|
blockHeight: 0,
|
2336
2301
|
txIndex: 0
|
@@ -2338,11 +2303,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2338
2303
|
inputClone.predicateGasUsed = bn8(0);
|
2339
2304
|
return inputClone;
|
2340
2305
|
}
|
2341
|
-
case
|
2306
|
+
case InputType3.Message: {
|
2342
2307
|
inputClone.predicateGasUsed = bn8(0);
|
2343
2308
|
return inputClone;
|
2344
2309
|
}
|
2345
|
-
case
|
2310
|
+
case InputType3.Contract: {
|
2346
2311
|
inputClone.txPointer = {
|
2347
2312
|
blockHeight: 0,
|
2348
2313
|
txIndex: 0
|
@@ -2502,7 +2467,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2502
2467
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2503
2468
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2504
2469
|
import { bn as bn10 } from "@fuel-ts/math";
|
2505
|
-
import { InputType as
|
2470
|
+
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2506
2471
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2507
2472
|
|
2508
2473
|
// src/providers/transaction-request/scripts.ts
|
@@ -2586,7 +2551,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2586
2551
|
*/
|
2587
2552
|
getContractInputs() {
|
2588
2553
|
return this.inputs.filter(
|
2589
|
-
(input) => input.type ===
|
2554
|
+
(input) => input.type === InputType4.Contract
|
2590
2555
|
);
|
2591
2556
|
}
|
2592
2557
|
/**
|
@@ -2663,7 +2628,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2663
2628
|
return this;
|
2664
2629
|
}
|
2665
2630
|
const inputIndex = super.pushInput({
|
2666
|
-
type:
|
2631
|
+
type: InputType4.Contract,
|
2667
2632
|
contractId: contractAddress.toB256(),
|
2668
2633
|
txPointer: "0x00000000000000000000000000000000"
|
2669
2634
|
});
|
@@ -2705,7 +2670,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2705
2670
|
|
2706
2671
|
// src/providers/transaction-request/utils.ts
|
2707
2672
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2708
|
-
import { TransactionType as TransactionType5, InputType as
|
2673
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2709
2674
|
var transactionRequestify = (obj) => {
|
2710
2675
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2711
2676
|
return obj;
|
@@ -2725,10 +2690,10 @@ var transactionRequestify = (obj) => {
|
|
2725
2690
|
};
|
2726
2691
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2727
2692
|
(acc, input) => {
|
2728
|
-
if (input.type ===
|
2693
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2729
2694
|
acc.utxos.push(input.id);
|
2730
2695
|
}
|
2731
|
-
if (input.type ===
|
2696
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2732
2697
|
acc.messages.push(input.nonce);
|
2733
2698
|
}
|
2734
2699
|
return acc;
|
@@ -2882,7 +2847,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2882
2847
|
|
2883
2848
|
// src/providers/transaction-summary/input.ts
|
2884
2849
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2885
|
-
import { InputType as
|
2850
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2886
2851
|
function getInputsByTypes(inputs, types) {
|
2887
2852
|
return inputs.filter((i) => types.includes(i.type));
|
2888
2853
|
}
|
@@ -2890,16 +2855,16 @@ function getInputsByType(inputs, type) {
|
|
2890
2855
|
return inputs.filter((i) => i.type === type);
|
2891
2856
|
}
|
2892
2857
|
function getInputsCoin(inputs) {
|
2893
|
-
return getInputsByType(inputs,
|
2858
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2894
2859
|
}
|
2895
2860
|
function getInputsMessage(inputs) {
|
2896
|
-
return getInputsByType(inputs,
|
2861
|
+
return getInputsByType(inputs, InputType6.Message);
|
2897
2862
|
}
|
2898
2863
|
function getInputsCoinAndMessage(inputs) {
|
2899
|
-
return getInputsByTypes(inputs, [
|
2864
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2900
2865
|
}
|
2901
2866
|
function getInputsContract(inputs) {
|
2902
|
-
return getInputsByType(inputs,
|
2867
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2903
2868
|
}
|
2904
2869
|
function getInputFromAssetId(inputs, assetId) {
|
2905
2870
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2918,7 +2883,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2918
2883
|
if (!contractInput) {
|
2919
2884
|
return void 0;
|
2920
2885
|
}
|
2921
|
-
if (contractInput.type !==
|
2886
|
+
if (contractInput.type !== InputType6.Contract) {
|
2922
2887
|
throw new FuelError9(
|
2923
2888
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2924
2889
|
`Contract input should be of type 'contract'.`
|
@@ -2927,10 +2892,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2927
2892
|
return contractInput;
|
2928
2893
|
}
|
2929
2894
|
function getInputAccountAddress(input) {
|
2930
|
-
if (input.type ===
|
2895
|
+
if (input.type === InputType6.Coin) {
|
2931
2896
|
return input.owner.toString();
|
2932
2897
|
}
|
2933
|
-
if (input.type ===
|
2898
|
+
if (input.type === InputType6.Message) {
|
2934
2899
|
return input.recipient.toString();
|
2935
2900
|
}
|
2936
2901
|
return "";
|
@@ -4812,7 +4777,7 @@ cacheInputs_fn = function(inputs) {
|
|
4812
4777
|
return;
|
4813
4778
|
}
|
4814
4779
|
inputs.forEach((input) => {
|
4815
|
-
if (input.type ===
|
4780
|
+
if (input.type === InputType7.Coin) {
|
4816
4781
|
this.cache?.set(input.id);
|
4817
4782
|
}
|
4818
4783
|
});
|
@@ -8994,7 +8959,7 @@ import {
|
|
8994
8959
|
} from "@fuel-ts/abi-coder";
|
8995
8960
|
import { Address as Address9 } from "@fuel-ts/address";
|
8996
8961
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8997
|
-
import { ByteArrayCoder } from "@fuel-ts/transactions";
|
8962
|
+
import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
|
8998
8963
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8999
8964
|
|
9000
8965
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9053,15 +9018,10 @@ var Predicate = class extends Account {
|
|
9053
9018
|
populateTransactionPredicateData(transactionRequestLike) {
|
9054
9019
|
const request = transactionRequestify(transactionRequestLike);
|
9055
9020
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9056
|
-
|
9057
|
-
|
9058
|
-
request.removeWitness(placeholderIndex);
|
9059
|
-
}
|
9060
|
-
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9061
|
-
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9021
|
+
request.inputs?.forEach((input) => {
|
9022
|
+
if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
9062
9023
|
input.predicate = hexlify19(this.bytes);
|
9063
9024
|
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
9064
|
-
input.witnessIndex = 0;
|
9065
9025
|
}
|
9066
9026
|
});
|
9067
9027
|
return request;
|
@@ -9184,28 +9144,6 @@ var Predicate = class extends Account {
|
|
9184
9144
|
}
|
9185
9145
|
return mutatedBytes;
|
9186
9146
|
}
|
9187
|
-
/**
|
9188
|
-
* Returns the index of the witness placeholder that was added to this predicate.
|
9189
|
-
* If no witness placeholder was added, it returns -1.
|
9190
|
-
* @param request - The transaction request.
|
9191
|
-
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9192
|
-
*/
|
9193
|
-
getIndexFromPlaceholderWitness(request) {
|
9194
|
-
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9195
|
-
let index = -1;
|
9196
|
-
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9197
|
-
if (hasEmptyPredicateInputs) {
|
9198
|
-
index = hasEmptyPredicateInputs.witnessIndex;
|
9199
|
-
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9200
|
-
if (!allInputsAreEmpty) {
|
9201
|
-
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9202
|
-
if (wasFilledInputAddedFirst) {
|
9203
|
-
index = -1;
|
9204
|
-
}
|
9205
|
-
}
|
9206
|
-
}
|
9207
|
-
return index;
|
9208
|
-
}
|
9209
9147
|
};
|
9210
9148
|
|
9211
9149
|
// src/connectors/fuel.ts
|
@@ -9928,7 +9866,6 @@ export {
|
|
9928
9866
|
assets,
|
9929
9867
|
buildBlockExplorerUrl,
|
9930
9868
|
cacheFor,
|
9931
|
-
cacheResources,
|
9932
9869
|
cacheTxInputsFromOwner,
|
9933
9870
|
calculateGasFee,
|
9934
9871
|
calculateMetadataGasForTxCreate,
|
@@ -9976,7 +9913,6 @@ export {
|
|
9976
9913
|
getReceiptsMessageOut,
|
9977
9914
|
getReceiptsTransferOut,
|
9978
9915
|
getReceiptsWithMissingData,
|
9979
|
-
getRequestInputResourceOwner,
|
9980
9916
|
getTransactionStatusName,
|
9981
9917
|
getTransactionSummary,
|
9982
9918
|
getTransactionSummaryFromRequest,
|
@@ -9990,10 +9926,6 @@ export {
|
|
9990
9926
|
isMessage,
|
9991
9927
|
isRawCoin,
|
9992
9928
|
isRawMessage,
|
9993
|
-
isRequestInputCoin,
|
9994
|
-
isRequestInputMessage,
|
9995
|
-
isRequestInputResource,
|
9996
|
-
isRequestInputResourceFromOwner,
|
9997
9929
|
isType,
|
9998
9930
|
isTypeCreate,
|
9999
9931
|
isTypeMint,
|