@fuel-ts/account 0.0.0-rc-1832-20240404143349 → 0.0.0-rc-1976-20240404171500
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 +51 -31
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +88 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -31
- package/dist/index.mjs.map +1 -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/provider.d.ts +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -2
- 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.global.js +53 -32
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +89 -70
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +50 -31
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.js
CHANGED
@@ -62,14 +62,12 @@ var import_utils31 = require("@fuel-ts/utils");
|
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
|
-
var import_configs12 = require("@fuel-ts/address/configs");
|
66
65
|
var import_errors16 = require("@fuel-ts/errors");
|
67
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
68
67
|
var import_math18 = require("@fuel-ts/math");
|
69
68
|
var import_utils28 = require("@fuel-ts/utils");
|
70
69
|
|
71
70
|
// src/providers/coin-quantity.ts
|
72
|
-
var import_configs = require("@fuel-ts/address/configs");
|
73
71
|
var import_math = require("@fuel-ts/math");
|
74
72
|
var import_utils = require("@fuel-ts/utils");
|
75
73
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -78,11 +76,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
78
76
|
let max2;
|
79
77
|
if (Array.isArray(coinQuantityLike)) {
|
80
78
|
amount = coinQuantityLike[0];
|
81
|
-
assetId = coinQuantityLike[1]
|
82
|
-
max2 = coinQuantityLike[2]
|
79
|
+
assetId = coinQuantityLike[1];
|
80
|
+
max2 = coinQuantityLike[2];
|
83
81
|
} else {
|
84
82
|
amount = coinQuantityLike.amount;
|
85
|
-
assetId = coinQuantityLike.assetId
|
83
|
+
assetId = coinQuantityLike.assetId;
|
86
84
|
max2 = coinQuantityLike.max ?? void 0;
|
87
85
|
}
|
88
86
|
const bnAmount = (0, import_math.bn)(amount);
|
@@ -1051,7 +1049,7 @@ var MemoryCache = class {
|
|
1051
1049
|
};
|
1052
1050
|
|
1053
1051
|
// src/providers/transaction-request/input.ts
|
1054
|
-
var
|
1052
|
+
var import_configs = require("@fuel-ts/address/configs");
|
1055
1053
|
var import_errors3 = require("@fuel-ts/errors");
|
1056
1054
|
var import_math2 = require("@fuel-ts/math");
|
1057
1055
|
var import_transactions = require("@fuel-ts/transactions");
|
@@ -1085,10 +1083,10 @@ var inputify = (value) => {
|
|
1085
1083
|
case import_transactions.InputType.Contract: {
|
1086
1084
|
return {
|
1087
1085
|
type: import_transactions.InputType.Contract,
|
1088
|
-
txID:
|
1086
|
+
txID: import_configs.ZeroBytes32,
|
1089
1087
|
outputIndex: 0,
|
1090
|
-
balanceRoot:
|
1091
|
-
stateRoot:
|
1088
|
+
balanceRoot: import_configs.ZeroBytes32,
|
1089
|
+
stateRoot: import_configs.ZeroBytes32,
|
1092
1090
|
txPointer: {
|
1093
1091
|
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1094
1092
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
@@ -1126,7 +1124,7 @@ var inputify = (value) => {
|
|
1126
1124
|
};
|
1127
1125
|
|
1128
1126
|
// src/providers/transaction-request/output.ts
|
1129
|
-
var
|
1127
|
+
var import_configs2 = require("@fuel-ts/address/configs");
|
1130
1128
|
var import_errors4 = require("@fuel-ts/errors");
|
1131
1129
|
var import_math3 = require("@fuel-ts/math");
|
1132
1130
|
var import_transactions2 = require("@fuel-ts/transactions");
|
@@ -1146,8 +1144,8 @@ var outputify = (value) => {
|
|
1146
1144
|
return {
|
1147
1145
|
type: import_transactions2.OutputType.Contract,
|
1148
1146
|
inputIndex: value.inputIndex,
|
1149
|
-
balanceRoot:
|
1150
|
-
stateRoot:
|
1147
|
+
balanceRoot: import_configs2.ZeroBytes32,
|
1148
|
+
stateRoot: import_configs2.ZeroBytes32
|
1151
1149
|
};
|
1152
1150
|
}
|
1153
1151
|
case import_transactions2.OutputType.Change: {
|
@@ -1161,9 +1159,9 @@ var outputify = (value) => {
|
|
1161
1159
|
case import_transactions2.OutputType.Variable: {
|
1162
1160
|
return {
|
1163
1161
|
type: import_transactions2.OutputType.Variable,
|
1164
|
-
to:
|
1162
|
+
to: import_configs2.ZeroBytes32,
|
1165
1163
|
amount: (0, import_math3.bn)(0),
|
1166
|
-
assetId:
|
1164
|
+
assetId: import_configs2.ZeroBytes32
|
1167
1165
|
};
|
1168
1166
|
}
|
1169
1167
|
case import_transactions2.OutputType.ContractCreated: {
|
@@ -1184,7 +1182,7 @@ var outputify = (value) => {
|
|
1184
1182
|
|
1185
1183
|
// src/providers/transaction-request/transaction-request.ts
|
1186
1184
|
var import_address = require("@fuel-ts/address");
|
1187
|
-
var
|
1185
|
+
var import_configs6 = require("@fuel-ts/address/configs");
|
1188
1186
|
var import_math7 = require("@fuel-ts/math");
|
1189
1187
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1190
1188
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1193,13 +1191,13 @@ var import_utils9 = require("@fuel-ts/utils");
|
|
1193
1191
|
var isCoin = (resource) => "id" in resource;
|
1194
1192
|
|
1195
1193
|
// src/providers/utils/receipts.ts
|
1196
|
-
var
|
1194
|
+
var import_configs3 = require("@fuel-ts/address/configs");
|
1197
1195
|
var import_errors5 = require("@fuel-ts/errors");
|
1198
1196
|
var import_math4 = require("@fuel-ts/math");
|
1199
1197
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1200
|
-
var
|
1198
|
+
var import_configs4 = require("@fuel-ts/transactions/configs");
|
1201
1199
|
var import_utils5 = require("@fuel-ts/utils");
|
1202
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") ===
|
1200
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1203
1201
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1204
1202
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
1205
1203
|
(memo, receipt) => {
|
@@ -1216,7 +1214,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
1216
1214
|
missingOutputContractIds: []
|
1217
1215
|
}
|
1218
1216
|
);
|
1219
|
-
var hexOrZero = (hex) => hex ||
|
1217
|
+
var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
|
1220
1218
|
function assembleReceiptByType(receipt) {
|
1221
1219
|
const { receiptType } = receipt;
|
1222
1220
|
switch (receiptType) {
|
@@ -1521,16 +1519,16 @@ function sleep(time) {
|
|
1521
1519
|
var import_errors7 = require("@fuel-ts/errors");
|
1522
1520
|
var import_math6 = require("@fuel-ts/math");
|
1523
1521
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1524
|
-
var
|
1522
|
+
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1525
1523
|
var assemblePanicError = (status) => {
|
1526
1524
|
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1527
1525
|
const reason = status.reason;
|
1528
|
-
if (
|
1526
|
+
if (import_configs5.PANIC_REASONS.includes(status.reason)) {
|
1529
1527
|
errorMessage = `${errorMessage}
|
1530
1528
|
|
1531
1529
|
You can read more about this error at:
|
1532
1530
|
|
1533
|
-
${
|
1531
|
+
${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
|
1534
1532
|
}
|
1535
1533
|
return { errorMessage, reason };
|
1536
1534
|
};
|
@@ -1542,28 +1540,28 @@ var assembleRevertError = (receipts, logs) => {
|
|
1542
1540
|
if (revertReceipt) {
|
1543
1541
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1544
1542
|
switch (reasonHex) {
|
1545
|
-
case
|
1543
|
+
case import_configs5.FAILED_REQUIRE_SIGNAL: {
|
1546
1544
|
reason = "require";
|
1547
1545
|
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1548
1546
|
break;
|
1549
1547
|
}
|
1550
|
-
case
|
1548
|
+
case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
|
1551
1549
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1552
1550
|
reason = "assert_eq";
|
1553
1551
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1554
1552
|
break;
|
1555
1553
|
}
|
1556
|
-
case
|
1554
|
+
case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
|
1557
1555
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1558
1556
|
reason = "assert_ne";
|
1559
1557
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1560
1558
|
break;
|
1561
1559
|
}
|
1562
|
-
case
|
1560
|
+
case import_configs5.FAILED_ASSERT_SIGNAL:
|
1563
1561
|
reason = "assert";
|
1564
1562
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1565
1563
|
break;
|
1566
|
-
case
|
1564
|
+
case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1567
1565
|
reason = "MissingOutputChange";
|
1568
1566
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1569
1567
|
break;
|
@@ -1625,6 +1623,8 @@ var BaseTransactionRequest = class {
|
|
1625
1623
|
outputs = [];
|
1626
1624
|
/** List of witnesses */
|
1627
1625
|
witnesses = [];
|
1626
|
+
/** Base asset ID - should be fetched from the chain */
|
1627
|
+
baseAssetId = import_configs6.ZeroBytes32;
|
1628
1628
|
/**
|
1629
1629
|
* Constructor for initializing a base transaction request.
|
1630
1630
|
*
|
@@ -1637,7 +1637,8 @@ var BaseTransactionRequest = class {
|
|
1637
1637
|
witnessLimit,
|
1638
1638
|
inputs,
|
1639
1639
|
outputs,
|
1640
|
-
witnesses
|
1640
|
+
witnesses,
|
1641
|
+
baseAssetId
|
1641
1642
|
} = {}) {
|
1642
1643
|
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1643
1644
|
this.maturity = maturity ?? 0;
|
@@ -1646,6 +1647,7 @@ var BaseTransactionRequest = class {
|
|
1646
1647
|
this.inputs = inputs ?? [];
|
1647
1648
|
this.outputs = outputs ?? [];
|
1648
1649
|
this.witnesses = witnesses ?? [];
|
1650
|
+
this.baseAssetId = baseAssetId ?? import_configs6.ZeroBytes32;
|
1649
1651
|
}
|
1650
1652
|
static getPolicyMeta(req) {
|
1651
1653
|
let policyTypes = 0;
|
@@ -1738,7 +1740,7 @@ var BaseTransactionRequest = class {
|
|
1738
1740
|
* @returns The index of the created witness.
|
1739
1741
|
*/
|
1740
1742
|
addEmptyWitness() {
|
1741
|
-
this.addWitness((0, import_utils9.concat)([
|
1743
|
+
this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1742
1744
|
return this.witnesses.length - 1;
|
1743
1745
|
}
|
1744
1746
|
/**
|
@@ -1870,11 +1872,9 @@ var BaseTransactionRequest = class {
|
|
1870
1872
|
*
|
1871
1873
|
* @param message - Message resource.
|
1872
1874
|
* @param predicate - Predicate bytes.
|
1873
|
-
* @param predicateData - Predicate data bytes.
|
1874
1875
|
*/
|
1875
1876
|
addMessageInput(message, predicate) {
|
1876
1877
|
const { recipient, sender, amount } = message;
|
1877
|
-
const assetId = import_configs7.BaseAssetId;
|
1878
1878
|
let witnessIndex;
|
1879
1879
|
if (predicate) {
|
1880
1880
|
witnessIndex = 0;
|
@@ -1895,7 +1895,7 @@ var BaseTransactionRequest = class {
|
|
1895
1895
|
predicateData: predicate?.predicateDataBytes
|
1896
1896
|
};
|
1897
1897
|
this.pushInput(input);
|
1898
|
-
this.addChangeOutput(recipient,
|
1898
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
1899
1899
|
}
|
1900
1900
|
/**
|
1901
1901
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -1956,12 +1956,12 @@ var BaseTransactionRequest = class {
|
|
1956
1956
|
* @param amount - Amount of coin.
|
1957
1957
|
* @param assetId - Asset ID of coin.
|
1958
1958
|
*/
|
1959
|
-
addCoinOutput(to, amount, assetId
|
1959
|
+
addCoinOutput(to, amount, assetId) {
|
1960
1960
|
this.pushOutput({
|
1961
1961
|
type: import_transactions6.OutputType.Coin,
|
1962
1962
|
to: (0, import_address.addressify)(to).toB256(),
|
1963
1963
|
amount,
|
1964
|
-
assetId
|
1964
|
+
assetId: assetId ?? this.baseAssetId
|
1965
1965
|
});
|
1966
1966
|
return this;
|
1967
1967
|
}
|
@@ -1988,7 +1988,7 @@ var BaseTransactionRequest = class {
|
|
1988
1988
|
* @param to - Address of the owner.
|
1989
1989
|
* @param assetId - Asset ID of coin.
|
1990
1990
|
*/
|
1991
|
-
addChangeOutput(to, assetId
|
1991
|
+
addChangeOutput(to, assetId) {
|
1992
1992
|
const changeOutput = this.getChangeOutputs().find(
|
1993
1993
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
1994
1994
|
);
|
@@ -1996,7 +1996,7 @@ var BaseTransactionRequest = class {
|
|
1996
1996
|
this.pushOutput({
|
1997
1997
|
type: import_transactions6.OutputType.Change,
|
1998
1998
|
to: (0, import_address.addressify)(to).toB256(),
|
1999
|
-
assetId
|
1999
|
+
assetId: assetId ?? this.baseAssetId
|
2000
2000
|
});
|
2001
2001
|
}
|
2002
2002
|
}
|
@@ -2050,7 +2050,7 @@ var BaseTransactionRequest = class {
|
|
2050
2050
|
let idCounter = 0;
|
2051
2051
|
const generateId = () => {
|
2052
2052
|
const counterString = String(idCounter++);
|
2053
|
-
const id =
|
2053
|
+
const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2054
2054
|
return id;
|
2055
2055
|
};
|
2056
2056
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2078,7 +2078,7 @@ var BaseTransactionRequest = class {
|
|
2078
2078
|
]);
|
2079
2079
|
}
|
2080
2080
|
};
|
2081
|
-
updateAssetInput(
|
2081
|
+
updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
|
2082
2082
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2083
2083
|
}
|
2084
2084
|
/**
|
@@ -2128,13 +2128,13 @@ var BaseTransactionRequest = class {
|
|
2128
2128
|
};
|
2129
2129
|
|
2130
2130
|
// src/providers/transaction-request/create-transaction-request.ts
|
2131
|
-
var
|
2131
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2132
2132
|
var import_math9 = require("@fuel-ts/math");
|
2133
2133
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2134
2134
|
var import_utils13 = require("@fuel-ts/utils");
|
2135
2135
|
|
2136
2136
|
// src/providers/transaction-request/hash-transaction.ts
|
2137
|
-
var
|
2137
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
2138
2138
|
var import_hasher = require("@fuel-ts/hasher");
|
2139
2139
|
var import_math8 = require("@fuel-ts/math");
|
2140
2140
|
var import_transactions7 = require("@fuel-ts/transactions");
|
@@ -2143,7 +2143,7 @@ var import_ramda2 = require("ramda");
|
|
2143
2143
|
function hashTransaction(transactionRequest, chainId) {
|
2144
2144
|
const transaction = transactionRequest.toTransaction();
|
2145
2145
|
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2146
|
-
transaction.receiptsRoot =
|
2146
|
+
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2147
2147
|
}
|
2148
2148
|
transaction.inputs = transaction.inputs.map((input) => {
|
2149
2149
|
const inputClone = (0, import_ramda2.clone)(input);
|
@@ -2165,10 +2165,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2165
2165
|
blockHeight: 0,
|
2166
2166
|
txIndex: 0
|
2167
2167
|
};
|
2168
|
-
inputClone.txID =
|
2168
|
+
inputClone.txID = import_configs7.ZeroBytes32;
|
2169
2169
|
inputClone.outputIndex = 0;
|
2170
|
-
inputClone.balanceRoot =
|
2171
|
-
inputClone.stateRoot =
|
2170
|
+
inputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2171
|
+
inputClone.stateRoot = import_configs7.ZeroBytes32;
|
2172
2172
|
return inputClone;
|
2173
2173
|
}
|
2174
2174
|
default:
|
@@ -2179,8 +2179,8 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2179
2179
|
const outputClone = (0, import_ramda2.clone)(output);
|
2180
2180
|
switch (outputClone.type) {
|
2181
2181
|
case import_transactions7.OutputType.Contract: {
|
2182
|
-
outputClone.balanceRoot =
|
2183
|
-
outputClone.stateRoot =
|
2182
|
+
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2183
|
+
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2184
2184
|
return outputClone;
|
2185
2185
|
}
|
2186
2186
|
case import_transactions7.OutputType.Change: {
|
@@ -2188,9 +2188,9 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2188
2188
|
return outputClone;
|
2189
2189
|
}
|
2190
2190
|
case import_transactions7.OutputType.Variable: {
|
2191
|
-
outputClone.to =
|
2191
|
+
outputClone.to = import_configs7.ZeroBytes32;
|
2192
2192
|
outputClone.amount = (0, import_math8.bn)(0);
|
2193
|
-
outputClone.assetId =
|
2193
|
+
outputClone.assetId = import_configs7.ZeroBytes32;
|
2194
2194
|
return outputClone;
|
2195
2195
|
}
|
2196
2196
|
default:
|
@@ -2256,7 +2256,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2256
2256
|
} = {}) {
|
2257
2257
|
super(rest);
|
2258
2258
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2259
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2259
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2260
2260
|
this.storageSlots = [...storageSlots ?? []];
|
2261
2261
|
}
|
2262
2262
|
/**
|
@@ -2274,7 +2274,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2274
2274
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2275
2275
|
bytecodeWitnessIndex,
|
2276
2276
|
storageSlotsCount: storageSlots.length,
|
2277
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2277
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2278
2278
|
storageSlots
|
2279
2279
|
};
|
2280
2280
|
}
|
@@ -2324,7 +2324,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2324
2324
|
// src/providers/transaction-request/script-transaction-request.ts
|
2325
2325
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2326
2326
|
var import_address2 = require("@fuel-ts/address");
|
2327
|
-
var
|
2327
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2328
2328
|
var import_math10 = require("@fuel-ts/math");
|
2329
2329
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2330
2330
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2398,7 +2398,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2398
2398
|
...super.getBaseTransaction(),
|
2399
2399
|
scriptLength: script.length,
|
2400
2400
|
scriptDataLength: scriptData.length,
|
2401
|
-
receiptsRoot:
|
2401
|
+
receiptsRoot: import_configs9.ZeroBytes32,
|
2402
2402
|
script: (0, import_utils15.hexlify)(script),
|
2403
2403
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2404
2404
|
};
|
@@ -2630,7 +2630,7 @@ var calculateTransactionFee = (params) => {
|
|
2630
2630
|
};
|
2631
2631
|
|
2632
2632
|
// src/providers/transaction-summary/operations.ts
|
2633
|
-
var
|
2633
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2634
2634
|
var import_errors11 = require("@fuel-ts/errors");
|
2635
2635
|
var import_math13 = require("@fuel-ts/math");
|
2636
2636
|
var import_transactions14 = require("@fuel-ts/transactions");
|
@@ -2928,7 +2928,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
2928
2928
|
const { to: toAddress, assetId, amount } = receipt;
|
2929
2929
|
let { from: fromAddress } = receipt;
|
2930
2930
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
2931
|
-
if (
|
2931
|
+
if (import_configs10.ZeroBytes32 === fromAddress) {
|
2932
2932
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
2933
2933
|
fromAddress = change?.to || fromAddress;
|
2934
2934
|
}
|
@@ -3505,6 +3505,7 @@ var processGqlChain = (chain) => {
|
|
3505
3505
|
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3506
3506
|
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3507
3507
|
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3508
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3508
3509
|
gasCosts
|
3509
3510
|
},
|
3510
3511
|
gasCosts,
|
@@ -3747,6 +3748,17 @@ var _Provider = class {
|
|
3747
3748
|
} = this.getChain();
|
3748
3749
|
return chainId.toNumber();
|
3749
3750
|
}
|
3751
|
+
/**
|
3752
|
+
* Returns the base asset ID
|
3753
|
+
*
|
3754
|
+
* @returns A promise that resolves to the base asset ID
|
3755
|
+
*/
|
3756
|
+
getBaseAssetId() {
|
3757
|
+
const {
|
3758
|
+
consensusParameters: { baseAssetId }
|
3759
|
+
} = this.getChain();
|
3760
|
+
return baseAssetId;
|
3761
|
+
}
|
3750
3762
|
/**
|
3751
3763
|
* Submits a transaction to the chain to be executed.
|
3752
3764
|
*
|
@@ -4617,8 +4629,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4617
4629
|
* @param assetId - The asset ID to check the balance for.
|
4618
4630
|
* @returns A promise that resolves to the balance amount.
|
4619
4631
|
*/
|
4620
|
-
async getBalance(assetId
|
4621
|
-
const
|
4632
|
+
async getBalance(assetId) {
|
4633
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
4634
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
4622
4635
|
return amount;
|
4623
4636
|
}
|
4624
4637
|
/**
|
@@ -4656,9 +4669,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4656
4669
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4657
4670
|
*/
|
4658
4671
|
async fund(request, coinQuantities, fee) {
|
4672
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
4659
4673
|
const updatedQuantities = addAmountToAsset({
|
4660
4674
|
amount: (0, import_math18.bn)(fee),
|
4661
|
-
assetId:
|
4675
|
+
assetId: baseAssetId,
|
4662
4676
|
coinQuantities
|
4663
4677
|
});
|
4664
4678
|
const quantitiesDict = {};
|
@@ -4682,8 +4696,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4682
4696
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4683
4697
|
cachedUtxos.push(input.id);
|
4684
4698
|
}
|
4685
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4686
|
-
quantitiesDict[
|
4699
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
4700
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
4687
4701
|
cachedMessages.push(input.nonce);
|
4688
4702
|
}
|
4689
4703
|
}
|
@@ -4715,11 +4729,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4715
4729
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4716
4730
|
* @returns A promise that resolves to the prepared transaction request.
|
4717
4731
|
*/
|
4718
|
-
async createTransfer(destination, amount, assetId
|
4732
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4719
4733
|
const { minGasPrice } = this.provider.getGasConfig();
|
4734
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4720
4735
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4721
4736
|
const request = new ScriptTransactionRequest(params);
|
4722
|
-
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount,
|
4737
|
+
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4723
4738
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4724
4739
|
estimateTxDependencies: true,
|
4725
4740
|
resourcesOwner: this
|
@@ -4745,14 +4760,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4745
4760
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4746
4761
|
* @returns A promise that resolves to the transaction response.
|
4747
4762
|
*/
|
4748
|
-
async transfer(destination, amount, assetId
|
4763
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
4749
4764
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
4750
4765
|
throw new import_errors16.FuelError(
|
4751
4766
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4752
4767
|
"Transfer amount must be a positive number."
|
4753
4768
|
);
|
4754
4769
|
}
|
4755
|
-
const
|
4770
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4771
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
4756
4772
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4757
4773
|
}
|
4758
4774
|
/**
|
@@ -4764,7 +4780,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4764
4780
|
* @param txParams - The optional transaction parameters.
|
4765
4781
|
* @returns A promise that resolves to the transaction response.
|
4766
4782
|
*/
|
4767
|
-
async transferToContract(contractId, amount, assetId
|
4783
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
4768
4784
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
4769
4785
|
throw new import_errors16.FuelError(
|
4770
4786
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -4773,11 +4789,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4773
4789
|
}
|
4774
4790
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4775
4791
|
const { minGasPrice } = this.provider.getGasConfig();
|
4792
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4776
4793
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4777
4794
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4778
4795
|
hexlifiedContractId: contractAddress.toB256(),
|
4779
4796
|
amountToTransfer: (0, import_math18.bn)(amount),
|
4780
|
-
assetId
|
4797
|
+
assetId: assetIdToTransfer
|
4781
4798
|
});
|
4782
4799
|
const request = new ScriptTransactionRequest({
|
4783
4800
|
...params,
|
@@ -4787,7 +4804,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4787
4804
|
request.addContractInputAndOutput(contractAddress);
|
4788
4805
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4789
4806
|
request,
|
4790
|
-
[{ amount: (0, import_math18.bn)(amount), assetId: String(
|
4807
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
|
4791
4808
|
);
|
4792
4809
|
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4793
4810
|
this.validateGas({
|
@@ -4809,6 +4826,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4809
4826
|
*/
|
4810
4827
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4811
4828
|
const { minGasPrice } = this.provider.getGasConfig();
|
4829
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
4812
4830
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4813
4831
|
const recipientDataArray = (0, import_utils28.arrayify)(
|
4814
4832
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -4823,7 +4841,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4823
4841
|
]);
|
4824
4842
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
4825
4843
|
const request = new ScriptTransactionRequest(params);
|
4826
|
-
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId:
|
4844
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
|
4827
4845
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4828
4846
|
request,
|
4829
4847
|
forwardingQuantities
|
@@ -7987,7 +8005,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7987
8005
|
};
|
7988
8006
|
|
7989
8007
|
// src/test-utils/launchNode.ts
|
7990
|
-
var
|
8008
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
7991
8009
|
var import_math21 = require("@fuel-ts/math");
|
7992
8010
|
var import_utils36 = require("@fuel-ts/utils");
|
7993
8011
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
@@ -8087,7 +8105,7 @@ var launchNode = async ({
|
|
8087
8105
|
{
|
8088
8106
|
owner: signer.address.toHexString(),
|
8089
8107
|
amount: (0, import_math21.toHex)(1e9),
|
8090
|
-
asset_id:
|
8108
|
+
asset_id: import_utils36.defaultChainConfig?.consensus_parameters?.base_asset_id ?? import_configs11.ZeroBytes32
|
8091
8109
|
}
|
8092
8110
|
]
|
8093
8111
|
}
|
@@ -8153,9 +8171,10 @@ var launchNode = async ({
|
|
8153
8171
|
})
|
8154
8172
|
);
|
8155
8173
|
var generateWallets = async (count, provider) => {
|
8174
|
+
const baseAssetId = provider.getBaseAssetId();
|
8156
8175
|
const wallets = [];
|
8157
8176
|
for (let i = 0; i < count; i += 1) {
|
8158
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
8177
|
+
const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
|
8159
8178
|
wallets.push(wallet);
|
8160
8179
|
}
|
8161
8180
|
return wallets;
|