@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/index.js
CHANGED
@@ -184,14 +184,12 @@ module.exports = __toCommonJS(src_exports);
|
|
184
184
|
|
185
185
|
// src/account.ts
|
186
186
|
var import_address4 = require("@fuel-ts/address");
|
187
|
-
var import_configs12 = require("@fuel-ts/address/configs");
|
188
187
|
var import_errors16 = require("@fuel-ts/errors");
|
189
188
|
var import_interfaces = require("@fuel-ts/interfaces");
|
190
189
|
var import_math18 = require("@fuel-ts/math");
|
191
190
|
var import_utils28 = require("@fuel-ts/utils");
|
192
191
|
|
193
192
|
// src/providers/coin-quantity.ts
|
194
|
-
var import_configs = require("@fuel-ts/address/configs");
|
195
193
|
var import_math = require("@fuel-ts/math");
|
196
194
|
var import_utils = require("@fuel-ts/utils");
|
197
195
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -200,11 +198,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
200
198
|
let max2;
|
201
199
|
if (Array.isArray(coinQuantityLike)) {
|
202
200
|
amount = coinQuantityLike[0];
|
203
|
-
assetId = coinQuantityLike[1]
|
204
|
-
max2 = coinQuantityLike[2]
|
201
|
+
assetId = coinQuantityLike[1];
|
202
|
+
max2 = coinQuantityLike[2];
|
205
203
|
} else {
|
206
204
|
amount = coinQuantityLike.amount;
|
207
|
-
assetId = coinQuantityLike.assetId
|
205
|
+
assetId = coinQuantityLike.assetId;
|
208
206
|
max2 = coinQuantityLike.max ?? void 0;
|
209
207
|
}
|
210
208
|
const bnAmount = (0, import_math.bn)(amount);
|
@@ -1173,7 +1171,7 @@ var MemoryCache = class {
|
|
1173
1171
|
};
|
1174
1172
|
|
1175
1173
|
// src/providers/transaction-request/input.ts
|
1176
|
-
var
|
1174
|
+
var import_configs = require("@fuel-ts/address/configs");
|
1177
1175
|
var import_errors3 = require("@fuel-ts/errors");
|
1178
1176
|
var import_math2 = require("@fuel-ts/math");
|
1179
1177
|
var import_transactions = require("@fuel-ts/transactions");
|
@@ -1207,10 +1205,10 @@ var inputify = (value) => {
|
|
1207
1205
|
case import_transactions.InputType.Contract: {
|
1208
1206
|
return {
|
1209
1207
|
type: import_transactions.InputType.Contract,
|
1210
|
-
txID:
|
1208
|
+
txID: import_configs.ZeroBytes32,
|
1211
1209
|
outputIndex: 0,
|
1212
|
-
balanceRoot:
|
1213
|
-
stateRoot:
|
1210
|
+
balanceRoot: import_configs.ZeroBytes32,
|
1211
|
+
stateRoot: import_configs.ZeroBytes32,
|
1214
1212
|
txPointer: {
|
1215
1213
|
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1216
1214
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
@@ -1248,7 +1246,7 @@ var inputify = (value) => {
|
|
1248
1246
|
};
|
1249
1247
|
|
1250
1248
|
// src/providers/transaction-request/output.ts
|
1251
|
-
var
|
1249
|
+
var import_configs2 = require("@fuel-ts/address/configs");
|
1252
1250
|
var import_errors4 = require("@fuel-ts/errors");
|
1253
1251
|
var import_math3 = require("@fuel-ts/math");
|
1254
1252
|
var import_transactions2 = require("@fuel-ts/transactions");
|
@@ -1268,8 +1266,8 @@ var outputify = (value) => {
|
|
1268
1266
|
return {
|
1269
1267
|
type: import_transactions2.OutputType.Contract,
|
1270
1268
|
inputIndex: value.inputIndex,
|
1271
|
-
balanceRoot:
|
1272
|
-
stateRoot:
|
1269
|
+
balanceRoot: import_configs2.ZeroBytes32,
|
1270
|
+
stateRoot: import_configs2.ZeroBytes32
|
1273
1271
|
};
|
1274
1272
|
}
|
1275
1273
|
case import_transactions2.OutputType.Change: {
|
@@ -1283,9 +1281,9 @@ var outputify = (value) => {
|
|
1283
1281
|
case import_transactions2.OutputType.Variable: {
|
1284
1282
|
return {
|
1285
1283
|
type: import_transactions2.OutputType.Variable,
|
1286
|
-
to:
|
1284
|
+
to: import_configs2.ZeroBytes32,
|
1287
1285
|
amount: (0, import_math3.bn)(0),
|
1288
|
-
assetId:
|
1286
|
+
assetId: import_configs2.ZeroBytes32
|
1289
1287
|
};
|
1290
1288
|
}
|
1291
1289
|
case import_transactions2.OutputType.ContractCreated: {
|
@@ -1306,7 +1304,7 @@ var outputify = (value) => {
|
|
1306
1304
|
|
1307
1305
|
// src/providers/transaction-request/transaction-request.ts
|
1308
1306
|
var import_address = require("@fuel-ts/address");
|
1309
|
-
var
|
1307
|
+
var import_configs6 = require("@fuel-ts/address/configs");
|
1310
1308
|
var import_math7 = require("@fuel-ts/math");
|
1311
1309
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1312
1310
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1318,13 +1316,13 @@ var isCoin = (resource) => "id" in resource;
|
|
1318
1316
|
var isMessage = (resource) => "recipient" in resource;
|
1319
1317
|
|
1320
1318
|
// src/providers/utils/receipts.ts
|
1321
|
-
var
|
1319
|
+
var import_configs3 = require("@fuel-ts/address/configs");
|
1322
1320
|
var import_errors5 = require("@fuel-ts/errors");
|
1323
1321
|
var import_math4 = require("@fuel-ts/math");
|
1324
1322
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1325
|
-
var
|
1323
|
+
var import_configs4 = require("@fuel-ts/transactions/configs");
|
1326
1324
|
var import_utils5 = require("@fuel-ts/utils");
|
1327
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") ===
|
1325
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1328
1326
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1329
1327
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
1330
1328
|
(memo, receipt) => {
|
@@ -1341,7 +1339,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
1341
1339
|
missingOutputContractIds: []
|
1342
1340
|
}
|
1343
1341
|
);
|
1344
|
-
var hexOrZero = (hex) => hex ||
|
1342
|
+
var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
|
1345
1343
|
function assembleReceiptByType(receipt) {
|
1346
1344
|
const { receiptType } = receipt;
|
1347
1345
|
switch (receiptType) {
|
@@ -1705,16 +1703,16 @@ function sleep(time) {
|
|
1705
1703
|
var import_errors7 = require("@fuel-ts/errors");
|
1706
1704
|
var import_math6 = require("@fuel-ts/math");
|
1707
1705
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1708
|
-
var
|
1706
|
+
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1709
1707
|
var assemblePanicError = (status) => {
|
1710
1708
|
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1711
1709
|
const reason = status.reason;
|
1712
|
-
if (
|
1710
|
+
if (import_configs5.PANIC_REASONS.includes(status.reason)) {
|
1713
1711
|
errorMessage = `${errorMessage}
|
1714
1712
|
|
1715
1713
|
You can read more about this error at:
|
1716
1714
|
|
1717
|
-
${
|
1715
|
+
${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
|
1718
1716
|
}
|
1719
1717
|
return { errorMessage, reason };
|
1720
1718
|
};
|
@@ -1726,28 +1724,28 @@ var assembleRevertError = (receipts, logs) => {
|
|
1726
1724
|
if (revertReceipt) {
|
1727
1725
|
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1728
1726
|
switch (reasonHex) {
|
1729
|
-
case
|
1727
|
+
case import_configs5.FAILED_REQUIRE_SIGNAL: {
|
1730
1728
|
reason = "require";
|
1731
1729
|
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1732
1730
|
break;
|
1733
1731
|
}
|
1734
|
-
case
|
1732
|
+
case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
|
1735
1733
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1736
1734
|
reason = "assert_eq";
|
1737
1735
|
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1738
1736
|
break;
|
1739
1737
|
}
|
1740
|
-
case
|
1738
|
+
case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
|
1741
1739
|
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1742
1740
|
reason = "assert_ne";
|
1743
1741
|
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1744
1742
|
break;
|
1745
1743
|
}
|
1746
|
-
case
|
1744
|
+
case import_configs5.FAILED_ASSERT_SIGNAL:
|
1747
1745
|
reason = "assert";
|
1748
1746
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1749
1747
|
break;
|
1750
|
-
case
|
1748
|
+
case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1751
1749
|
reason = "MissingOutputChange";
|
1752
1750
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1753
1751
|
break;
|
@@ -1821,6 +1819,8 @@ var BaseTransactionRequest = class {
|
|
1821
1819
|
outputs = [];
|
1822
1820
|
/** List of witnesses */
|
1823
1821
|
witnesses = [];
|
1822
|
+
/** Base asset ID - should be fetched from the chain */
|
1823
|
+
baseAssetId = import_configs6.ZeroBytes32;
|
1824
1824
|
/**
|
1825
1825
|
* Constructor for initializing a base transaction request.
|
1826
1826
|
*
|
@@ -1833,7 +1833,8 @@ var BaseTransactionRequest = class {
|
|
1833
1833
|
witnessLimit,
|
1834
1834
|
inputs,
|
1835
1835
|
outputs,
|
1836
|
-
witnesses
|
1836
|
+
witnesses,
|
1837
|
+
baseAssetId
|
1837
1838
|
} = {}) {
|
1838
1839
|
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1839
1840
|
this.maturity = maturity ?? 0;
|
@@ -1842,6 +1843,7 @@ var BaseTransactionRequest = class {
|
|
1842
1843
|
this.inputs = inputs ?? [];
|
1843
1844
|
this.outputs = outputs ?? [];
|
1844
1845
|
this.witnesses = witnesses ?? [];
|
1846
|
+
this.baseAssetId = baseAssetId ?? import_configs6.ZeroBytes32;
|
1845
1847
|
}
|
1846
1848
|
static getPolicyMeta(req) {
|
1847
1849
|
let policyTypes = 0;
|
@@ -1934,7 +1936,7 @@ var BaseTransactionRequest = class {
|
|
1934
1936
|
* @returns The index of the created witness.
|
1935
1937
|
*/
|
1936
1938
|
addEmptyWitness() {
|
1937
|
-
this.addWitness((0, import_utils9.concat)([
|
1939
|
+
this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1938
1940
|
return this.witnesses.length - 1;
|
1939
1941
|
}
|
1940
1942
|
/**
|
@@ -2066,11 +2068,9 @@ var BaseTransactionRequest = class {
|
|
2066
2068
|
*
|
2067
2069
|
* @param message - Message resource.
|
2068
2070
|
* @param predicate - Predicate bytes.
|
2069
|
-
* @param predicateData - Predicate data bytes.
|
2070
2071
|
*/
|
2071
2072
|
addMessageInput(message, predicate) {
|
2072
2073
|
const { recipient, sender, amount } = message;
|
2073
|
-
const assetId = import_configs7.BaseAssetId;
|
2074
2074
|
let witnessIndex;
|
2075
2075
|
if (predicate) {
|
2076
2076
|
witnessIndex = 0;
|
@@ -2091,7 +2091,7 @@ var BaseTransactionRequest = class {
|
|
2091
2091
|
predicateData: predicate?.predicateDataBytes
|
2092
2092
|
};
|
2093
2093
|
this.pushInput(input);
|
2094
|
-
this.addChangeOutput(recipient,
|
2094
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
2095
2095
|
}
|
2096
2096
|
/**
|
2097
2097
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2152,12 +2152,12 @@ var BaseTransactionRequest = class {
|
|
2152
2152
|
* @param amount - Amount of coin.
|
2153
2153
|
* @param assetId - Asset ID of coin.
|
2154
2154
|
*/
|
2155
|
-
addCoinOutput(to, amount, assetId
|
2155
|
+
addCoinOutput(to, amount, assetId) {
|
2156
2156
|
this.pushOutput({
|
2157
2157
|
type: import_transactions6.OutputType.Coin,
|
2158
2158
|
to: (0, import_address.addressify)(to).toB256(),
|
2159
2159
|
amount,
|
2160
|
-
assetId
|
2160
|
+
assetId: assetId ?? this.baseAssetId
|
2161
2161
|
});
|
2162
2162
|
return this;
|
2163
2163
|
}
|
@@ -2184,7 +2184,7 @@ var BaseTransactionRequest = class {
|
|
2184
2184
|
* @param to - Address of the owner.
|
2185
2185
|
* @param assetId - Asset ID of coin.
|
2186
2186
|
*/
|
2187
|
-
addChangeOutput(to, assetId
|
2187
|
+
addChangeOutput(to, assetId) {
|
2188
2188
|
const changeOutput = this.getChangeOutputs().find(
|
2189
2189
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
2190
2190
|
);
|
@@ -2192,7 +2192,7 @@ var BaseTransactionRequest = class {
|
|
2192
2192
|
this.pushOutput({
|
2193
2193
|
type: import_transactions6.OutputType.Change,
|
2194
2194
|
to: (0, import_address.addressify)(to).toB256(),
|
2195
|
-
assetId
|
2195
|
+
assetId: assetId ?? this.baseAssetId
|
2196
2196
|
});
|
2197
2197
|
}
|
2198
2198
|
}
|
@@ -2246,7 +2246,7 @@ var BaseTransactionRequest = class {
|
|
2246
2246
|
let idCounter = 0;
|
2247
2247
|
const generateId = () => {
|
2248
2248
|
const counterString = String(idCounter++);
|
2249
|
-
const id =
|
2249
|
+
const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2250
2250
|
return id;
|
2251
2251
|
};
|
2252
2252
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2274,7 +2274,7 @@ var BaseTransactionRequest = class {
|
|
2274
2274
|
]);
|
2275
2275
|
}
|
2276
2276
|
};
|
2277
|
-
updateAssetInput(
|
2277
|
+
updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
|
2278
2278
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2279
2279
|
}
|
2280
2280
|
/**
|
@@ -2324,13 +2324,13 @@ var BaseTransactionRequest = class {
|
|
2324
2324
|
};
|
2325
2325
|
|
2326
2326
|
// src/providers/transaction-request/create-transaction-request.ts
|
2327
|
-
var
|
2327
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2328
2328
|
var import_math9 = require("@fuel-ts/math");
|
2329
2329
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2330
2330
|
var import_utils13 = require("@fuel-ts/utils");
|
2331
2331
|
|
2332
2332
|
// src/providers/transaction-request/hash-transaction.ts
|
2333
|
-
var
|
2333
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
2334
2334
|
var import_hasher = require("@fuel-ts/hasher");
|
2335
2335
|
var import_math8 = require("@fuel-ts/math");
|
2336
2336
|
var import_transactions7 = require("@fuel-ts/transactions");
|
@@ -2339,7 +2339,7 @@ var import_ramda2 = require("ramda");
|
|
2339
2339
|
function hashTransaction(transactionRequest, chainId) {
|
2340
2340
|
const transaction = transactionRequest.toTransaction();
|
2341
2341
|
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2342
|
-
transaction.receiptsRoot =
|
2342
|
+
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2343
2343
|
}
|
2344
2344
|
transaction.inputs = transaction.inputs.map((input) => {
|
2345
2345
|
const inputClone = (0, import_ramda2.clone)(input);
|
@@ -2361,10 +2361,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2361
2361
|
blockHeight: 0,
|
2362
2362
|
txIndex: 0
|
2363
2363
|
};
|
2364
|
-
inputClone.txID =
|
2364
|
+
inputClone.txID = import_configs7.ZeroBytes32;
|
2365
2365
|
inputClone.outputIndex = 0;
|
2366
|
-
inputClone.balanceRoot =
|
2367
|
-
inputClone.stateRoot =
|
2366
|
+
inputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2367
|
+
inputClone.stateRoot = import_configs7.ZeroBytes32;
|
2368
2368
|
return inputClone;
|
2369
2369
|
}
|
2370
2370
|
default:
|
@@ -2375,8 +2375,8 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2375
2375
|
const outputClone = (0, import_ramda2.clone)(output);
|
2376
2376
|
switch (outputClone.type) {
|
2377
2377
|
case import_transactions7.OutputType.Contract: {
|
2378
|
-
outputClone.balanceRoot =
|
2379
|
-
outputClone.stateRoot =
|
2378
|
+
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2379
|
+
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2380
2380
|
return outputClone;
|
2381
2381
|
}
|
2382
2382
|
case import_transactions7.OutputType.Change: {
|
@@ -2384,9 +2384,9 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2384
2384
|
return outputClone;
|
2385
2385
|
}
|
2386
2386
|
case import_transactions7.OutputType.Variable: {
|
2387
|
-
outputClone.to =
|
2387
|
+
outputClone.to = import_configs7.ZeroBytes32;
|
2388
2388
|
outputClone.amount = (0, import_math8.bn)(0);
|
2389
|
-
outputClone.assetId =
|
2389
|
+
outputClone.assetId = import_configs7.ZeroBytes32;
|
2390
2390
|
return outputClone;
|
2391
2391
|
}
|
2392
2392
|
default:
|
@@ -2452,7 +2452,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2452
2452
|
} = {}) {
|
2453
2453
|
super(rest);
|
2454
2454
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2455
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2455
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2456
2456
|
this.storageSlots = [...storageSlots ?? []];
|
2457
2457
|
}
|
2458
2458
|
/**
|
@@ -2470,7 +2470,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2470
2470
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2471
2471
|
bytecodeWitnessIndex,
|
2472
2472
|
storageSlotsCount: storageSlots.length,
|
2473
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2473
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2474
2474
|
storageSlots
|
2475
2475
|
};
|
2476
2476
|
}
|
@@ -2520,7 +2520,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2520
2520
|
// src/providers/transaction-request/script-transaction-request.ts
|
2521
2521
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2522
2522
|
var import_address2 = require("@fuel-ts/address");
|
2523
|
-
var
|
2523
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2524
2524
|
var import_math10 = require("@fuel-ts/math");
|
2525
2525
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2526
2526
|
var import_utils15 = require("@fuel-ts/utils");
|
@@ -2594,7 +2594,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2594
2594
|
...super.getBaseTransaction(),
|
2595
2595
|
scriptLength: script.length,
|
2596
2596
|
scriptDataLength: scriptData.length,
|
2597
|
-
receiptsRoot:
|
2597
|
+
receiptsRoot: import_configs9.ZeroBytes32,
|
2598
2598
|
script: (0, import_utils15.hexlify)(script),
|
2599
2599
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2600
2600
|
};
|
@@ -2826,7 +2826,7 @@ var calculateTransactionFee = (params) => {
|
|
2826
2826
|
};
|
2827
2827
|
|
2828
2828
|
// src/providers/transaction-summary/operations.ts
|
2829
|
-
var
|
2829
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2830
2830
|
var import_errors11 = require("@fuel-ts/errors");
|
2831
2831
|
var import_math13 = require("@fuel-ts/math");
|
2832
2832
|
var import_transactions14 = require("@fuel-ts/transactions");
|
@@ -3171,7 +3171,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3171
3171
|
const { to: toAddress, assetId, amount } = receipt;
|
3172
3172
|
let { from: fromAddress } = receipt;
|
3173
3173
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3174
|
-
if (
|
3174
|
+
if (import_configs10.ZeroBytes32 === fromAddress) {
|
3175
3175
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3176
3176
|
fromAddress = change?.to || fromAddress;
|
3177
3177
|
}
|
@@ -3748,6 +3748,7 @@ var processGqlChain = (chain) => {
|
|
3748
3748
|
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3749
3749
|
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3750
3750
|
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3751
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3751
3752
|
gasCosts
|
3752
3753
|
},
|
3753
3754
|
gasCosts,
|
@@ -3990,6 +3991,17 @@ var _Provider = class {
|
|
3990
3991
|
} = this.getChain();
|
3991
3992
|
return chainId.toNumber();
|
3992
3993
|
}
|
3994
|
+
/**
|
3995
|
+
* Returns the base asset ID
|
3996
|
+
*
|
3997
|
+
* @returns A promise that resolves to the base asset ID
|
3998
|
+
*/
|
3999
|
+
getBaseAssetId() {
|
4000
|
+
const {
|
4001
|
+
consensusParameters: { baseAssetId }
|
4002
|
+
} = this.getChain();
|
4003
|
+
return baseAssetId;
|
4004
|
+
}
|
3993
4005
|
/**
|
3994
4006
|
* Submits a transaction to the chain to be executed.
|
3995
4007
|
*
|
@@ -5026,8 +5038,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5026
5038
|
* @param assetId - The asset ID to check the balance for.
|
5027
5039
|
* @returns A promise that resolves to the balance amount.
|
5028
5040
|
*/
|
5029
|
-
async getBalance(assetId
|
5030
|
-
const
|
5041
|
+
async getBalance(assetId) {
|
5042
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
5043
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
5031
5044
|
return amount;
|
5032
5045
|
}
|
5033
5046
|
/**
|
@@ -5065,9 +5078,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5065
5078
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5066
5079
|
*/
|
5067
5080
|
async fund(request, coinQuantities, fee) {
|
5081
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5068
5082
|
const updatedQuantities = addAmountToAsset({
|
5069
5083
|
amount: (0, import_math18.bn)(fee),
|
5070
|
-
assetId:
|
5084
|
+
assetId: baseAssetId,
|
5071
5085
|
coinQuantities
|
5072
5086
|
});
|
5073
5087
|
const quantitiesDict = {};
|
@@ -5091,8 +5105,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5091
5105
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
5092
5106
|
cachedUtxos.push(input.id);
|
5093
5107
|
}
|
5094
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
5095
|
-
quantitiesDict[
|
5108
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
5109
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
5096
5110
|
cachedMessages.push(input.nonce);
|
5097
5111
|
}
|
5098
5112
|
}
|
@@ -5124,11 +5138,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5124
5138
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5125
5139
|
* @returns A promise that resolves to the prepared transaction request.
|
5126
5140
|
*/
|
5127
|
-
async createTransfer(destination, amount, assetId
|
5141
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5128
5142
|
const { minGasPrice } = this.provider.getGasConfig();
|
5143
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5129
5144
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5130
5145
|
const request = new ScriptTransactionRequest(params);
|
5131
|
-
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount,
|
5146
|
+
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5132
5147
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5133
5148
|
estimateTxDependencies: true,
|
5134
5149
|
resourcesOwner: this
|
@@ -5154,14 +5169,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5154
5169
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5155
5170
|
* @returns A promise that resolves to the transaction response.
|
5156
5171
|
*/
|
5157
|
-
async transfer(destination, amount, assetId
|
5172
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
5158
5173
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
5159
5174
|
throw new import_errors16.FuelError(
|
5160
5175
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5161
5176
|
"Transfer amount must be a positive number."
|
5162
5177
|
);
|
5163
5178
|
}
|
5164
|
-
const
|
5179
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5180
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5165
5181
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5166
5182
|
}
|
5167
5183
|
/**
|
@@ -5173,7 +5189,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5173
5189
|
* @param txParams - The optional transaction parameters.
|
5174
5190
|
* @returns A promise that resolves to the transaction response.
|
5175
5191
|
*/
|
5176
|
-
async transferToContract(contractId, amount, assetId
|
5192
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5177
5193
|
if ((0, import_math18.bn)(amount).lte(0)) {
|
5178
5194
|
throw new import_errors16.FuelError(
|
5179
5195
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -5182,11 +5198,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5182
5198
|
}
|
5183
5199
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
5184
5200
|
const { minGasPrice } = this.provider.getGasConfig();
|
5201
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5185
5202
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5186
5203
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5187
5204
|
hexlifiedContractId: contractAddress.toB256(),
|
5188
5205
|
amountToTransfer: (0, import_math18.bn)(amount),
|
5189
|
-
assetId
|
5206
|
+
assetId: assetIdToTransfer
|
5190
5207
|
});
|
5191
5208
|
const request = new ScriptTransactionRequest({
|
5192
5209
|
...params,
|
@@ -5196,7 +5213,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5196
5213
|
request.addContractInputAndOutput(contractAddress);
|
5197
5214
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5198
5215
|
request,
|
5199
|
-
[{ amount: (0, import_math18.bn)(amount), assetId: String(
|
5216
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5200
5217
|
);
|
5201
5218
|
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
5202
5219
|
this.validateGas({
|
@@ -5218,6 +5235,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5218
5235
|
*/
|
5219
5236
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5220
5237
|
const { minGasPrice } = this.provider.getGasConfig();
|
5238
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5221
5239
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5222
5240
|
const recipientDataArray = (0, import_utils28.arrayify)(
|
5223
5241
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -5232,7 +5250,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5232
5250
|
]);
|
5233
5251
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5234
5252
|
const request = new ScriptTransactionRequest(params);
|
5235
|
-
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId:
|
5253
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
|
5236
5254
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5237
5255
|
request,
|
5238
5256
|
forwardingQuantities
|
@@ -8795,7 +8813,6 @@ var StorageAbstract = class {
|
|
8795
8813
|
// src/predicate/predicate.ts
|
8796
8814
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
8797
8815
|
var import_address10 = require("@fuel-ts/address");
|
8798
|
-
var import_configs13 = require("@fuel-ts/address/configs");
|
8799
8816
|
var import_errors25 = require("@fuel-ts/errors");
|
8800
8817
|
var import_transactions20 = require("@fuel-ts/transactions");
|
8801
8818
|
var import_utils37 = require("@fuel-ts/utils");
|
@@ -8874,8 +8891,9 @@ var Predicate = class extends Account {
|
|
8874
8891
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8875
8892
|
* @returns A promise that resolves to the prepared transaction request.
|
8876
8893
|
*/
|
8877
|
-
async createTransfer(destination, amount, assetId
|
8878
|
-
const
|
8894
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8895
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
8896
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8879
8897
|
return this.populateTransactionPredicateData(request);
|
8880
8898
|
}
|
8881
8899
|
/**
|