@fuel-ts/account 0.93.0 → 0.94.1
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.
- package/README.md +9 -29
- package/dist/account.d.ts +2 -2
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts +0 -2
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +0 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +0 -6
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +0 -4
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/utils/promises.d.ts.map +1 -1
- package/dist/index.global.js +1628 -930
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +978 -603
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +706 -343
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +15 -9
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +614 -1
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +2 -3
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +12 -6
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource-cache.d.ts +14 -0
- package/dist/providers/resource-cache.d.ts.map +1 -0
- package/dist/providers/transaction-request/blob-transaction-request.d.ts +48 -0
- package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +4 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +5 -2
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +9 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +10 -5
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +4 -3
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts +6 -1
- package/dist/providers/transaction-summary/input.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -2
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +5 -2
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +6 -0
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +0 -18
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
- package/dist/test-utils/test-asset-id.d.ts +8 -0
- package/dist/test-utils/test-asset-id.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +4 -2
- package/dist/test-utils/test-message.d.ts.map +1 -1
- package/dist/test-utils/wallet-config.d.ts +3 -3
- package/dist/test-utils/wallet-config.d.ts.map +1 -1
- package/dist/test-utils.d.ts +1 -3
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.global.js +40829 -40167
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1500 -1200
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1209 -910
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/package.json +17 -19
- package/dist/providers/memory-cache.d.ts +0 -11
- package/dist/providers/memory-cache.d.ts.map +0 -1
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/generateTestWallet.d.ts +0 -4
- package/dist/test-utils/generateTestWallet.d.ts.map +0 -1
- package/dist/test-utils/seedTestWallet.d.ts +0 -4
- package/dist/test-utils/seedTestWallet.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
32
32
|
import { Address as Address3 } from "@fuel-ts/address";
|
33
33
|
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
34
|
-
import { ErrorCode as ErrorCode15, FuelError as
|
34
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
35
35
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
36
36
|
import { bn as bn19 } from "@fuel-ts/math";
|
37
37
|
import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined3 } from "@fuel-ts/utils";
|
@@ -74,14 +74,9 @@ var addAmountToCoinQuantities = (params) => {
|
|
74
74
|
|
75
75
|
// src/providers/provider.ts
|
76
76
|
import { Address as Address2 } from "@fuel-ts/address";
|
77
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
78
|
-
import { BN, bn as bn17 } from "@fuel-ts/math";
|
79
|
-
import {
|
80
|
-
InputType as InputType7,
|
81
|
-
TransactionType as TransactionType8,
|
82
|
-
InputMessageCoder,
|
83
|
-
TransactionCoder as TransactionCoder5
|
84
|
-
} from "@fuel-ts/transactions";
|
77
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
|
78
|
+
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
79
|
+
import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
85
80
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
86
81
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
87
82
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
@@ -90,14 +85,6 @@ import { clone as clone3 } from "ramda";
|
|
90
85
|
|
91
86
|
// src/providers/__generated__/operations.ts
|
92
87
|
import gql from "graphql-tag";
|
93
|
-
var TransactionStatusSubscriptionFragmentDoc = gql`
|
94
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
95
|
-
type: __typename
|
96
|
-
... on SqueezedOutStatus {
|
97
|
-
reason
|
98
|
-
}
|
99
|
-
}
|
100
|
-
`;
|
101
88
|
var SubmittedStatusFragmentDoc = gql`
|
102
89
|
fragment SubmittedStatusFragment on SubmittedStatus {
|
103
90
|
type: __typename
|
@@ -154,6 +141,47 @@ var SuccessStatusFragmentDoc = gql`
|
|
154
141
|
totalFee
|
155
142
|
}
|
156
143
|
${ReceiptFragmentDoc}`;
|
144
|
+
var MalleableTransactionFieldsFragmentDoc = gql`
|
145
|
+
fragment malleableTransactionFieldsFragment on Transaction {
|
146
|
+
receiptsRoot
|
147
|
+
inputs {
|
148
|
+
type: __typename
|
149
|
+
... on InputCoin {
|
150
|
+
txPointer
|
151
|
+
}
|
152
|
+
... on InputContract {
|
153
|
+
txPointer
|
154
|
+
}
|
155
|
+
}
|
156
|
+
outputs {
|
157
|
+
type: __typename
|
158
|
+
... on CoinOutput {
|
159
|
+
to
|
160
|
+
amount
|
161
|
+
assetId
|
162
|
+
}
|
163
|
+
... on ContractOutput {
|
164
|
+
inputIndex
|
165
|
+
balanceRoot
|
166
|
+
stateRoot
|
167
|
+
}
|
168
|
+
... on ChangeOutput {
|
169
|
+
to
|
170
|
+
amount
|
171
|
+
assetId
|
172
|
+
}
|
173
|
+
... on VariableOutput {
|
174
|
+
to
|
175
|
+
amount
|
176
|
+
assetId
|
177
|
+
}
|
178
|
+
... on ContractCreated {
|
179
|
+
contract
|
180
|
+
stateRoot
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
`;
|
157
185
|
var FailureStatusFragmentDoc = gql`
|
158
186
|
fragment FailureStatusFragment on FailureStatus {
|
159
187
|
type: __typename
|
@@ -175,6 +203,32 @@ var SqueezedOutStatusFragmentDoc = gql`
|
|
175
203
|
reason
|
176
204
|
}
|
177
205
|
`;
|
206
|
+
var TransactionStatusSubscriptionFragmentDoc = gql`
|
207
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
208
|
+
... on SubmittedStatus {
|
209
|
+
...SubmittedStatusFragment
|
210
|
+
}
|
211
|
+
... on SuccessStatus {
|
212
|
+
...SuccessStatusFragment
|
213
|
+
transaction {
|
214
|
+
...malleableTransactionFieldsFragment
|
215
|
+
}
|
216
|
+
}
|
217
|
+
... on FailureStatus {
|
218
|
+
...FailureStatusFragment
|
219
|
+
transaction {
|
220
|
+
...malleableTransactionFieldsFragment
|
221
|
+
}
|
222
|
+
}
|
223
|
+
... on SqueezedOutStatus {
|
224
|
+
...SqueezedOutStatusFragment
|
225
|
+
}
|
226
|
+
}
|
227
|
+
${SubmittedStatusFragmentDoc}
|
228
|
+
${SuccessStatusFragmentDoc}
|
229
|
+
${MalleableTransactionFieldsFragmentDoc}
|
230
|
+
${FailureStatusFragmentDoc}
|
231
|
+
${SqueezedOutStatusFragmentDoc}`;
|
178
232
|
var TransactionStatusFragmentDoc = gql`
|
179
233
|
fragment transactionStatusFragment on TransactionStatus {
|
180
234
|
... on SubmittedStatus {
|
@@ -515,6 +569,12 @@ var GasCostsFragmentDoc = gql`
|
|
515
569
|
alocDependentCost {
|
516
570
|
...DependentCostFragment
|
517
571
|
}
|
572
|
+
bldd {
|
573
|
+
...DependentCostFragment
|
574
|
+
}
|
575
|
+
bsiz {
|
576
|
+
...DependentCostFragment
|
577
|
+
}
|
518
578
|
cfe {
|
519
579
|
...DependentCostFragment
|
520
580
|
}
|
@@ -533,6 +593,9 @@ var GasCostsFragmentDoc = gql`
|
|
533
593
|
csiz {
|
534
594
|
...DependentCostFragment
|
535
595
|
}
|
596
|
+
ed19DependentCost {
|
597
|
+
...DependentCostFragment
|
598
|
+
}
|
536
599
|
k256 {
|
537
600
|
...DependentCostFragment
|
538
601
|
}
|
@@ -1064,12 +1127,11 @@ function getSdk(requester) {
|
|
1064
1127
|
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
1065
1128
|
import { print } from "graphql";
|
1066
1129
|
var _FuelGraphqlSubscriber = class {
|
1067
|
-
constructor(
|
1068
|
-
this.
|
1130
|
+
constructor(stream) {
|
1131
|
+
this.stream = stream;
|
1069
1132
|
}
|
1070
|
-
|
1071
|
-
|
1072
|
-
const { url, query, variables, fetchFn } = this.options;
|
1133
|
+
static async create(options) {
|
1134
|
+
const { url, query, variables, fetchFn } = options;
|
1073
1135
|
const response = await fetchFn(`${url}-sub`, {
|
1074
1136
|
method: "POST",
|
1075
1137
|
body: JSON.stringify({
|
@@ -1081,14 +1143,11 @@ var _FuelGraphqlSubscriber = class {
|
|
1081
1143
|
Accept: "text/event-stream"
|
1082
1144
|
}
|
1083
1145
|
});
|
1084
|
-
|
1146
|
+
return new _FuelGraphqlSubscriber(response.body.getReader());
|
1085
1147
|
}
|
1086
1148
|
events = [];
|
1087
1149
|
parsingLeftover = "";
|
1088
1150
|
async next() {
|
1089
|
-
if (!this.stream) {
|
1090
|
-
await this.setStream();
|
1091
|
-
}
|
1092
1151
|
while (true) {
|
1093
1152
|
if (this.events.length > 0) {
|
1094
1153
|
const { data, errors } = this.events.shift();
|
@@ -1139,62 +1198,65 @@ var _FuelGraphqlSubscriber = class {
|
|
1139
1198
|
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1140
1199
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1141
1200
|
|
1142
|
-
// src/providers/
|
1201
|
+
// src/providers/resource-cache.ts
|
1143
1202
|
import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1144
1203
|
import { hexlify as hexlify2 } from "@fuel-ts/utils";
|
1145
|
-
var cache =
|
1146
|
-
var
|
1147
|
-
var MemoryCache = class {
|
1204
|
+
var cache = /* @__PURE__ */ new Map();
|
1205
|
+
var ResourceCache = class {
|
1148
1206
|
ttl;
|
1149
|
-
constructor(
|
1150
|
-
this.ttl =
|
1151
|
-
if (typeof
|
1207
|
+
constructor(ttl) {
|
1208
|
+
this.ttl = ttl;
|
1209
|
+
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1152
1210
|
throw new FuelError2(
|
1153
1211
|
ErrorCode2.INVALID_TTL,
|
1154
1212
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1155
1213
|
);
|
1156
1214
|
}
|
1157
1215
|
}
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
}
|
1166
|
-
return void 0;
|
1167
|
-
}
|
1168
|
-
set(value) {
|
1169
|
-
const expiresAt = Date.now() + this.ttl;
|
1170
|
-
const key = hexlify2(value);
|
1171
|
-
cache[key] = {
|
1172
|
-
expires: expiresAt,
|
1173
|
-
value
|
1216
|
+
// Add resources to the cache
|
1217
|
+
set(transactionId, resources) {
|
1218
|
+
const currentTime = Date.now();
|
1219
|
+
const existingResources = cache.get(transactionId) || {
|
1220
|
+
utxos: /* @__PURE__ */ new Set(),
|
1221
|
+
messages: /* @__PURE__ */ new Set(),
|
1222
|
+
timestamp: currentTime
|
1174
1223
|
};
|
1175
|
-
|
1224
|
+
resources.utxos.forEach((utxo) => existingResources.utxos.add(hexlify2(utxo)));
|
1225
|
+
resources.messages.forEach((message) => existingResources.messages.add(hexlify2(message)));
|
1226
|
+
cache.set(transactionId, existingResources);
|
1176
1227
|
}
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
if (data) {
|
1181
|
-
list.push(data);
|
1182
|
-
}
|
1183
|
-
return list;
|
1184
|
-
}, []);
|
1228
|
+
// Remove resources from the cache for a given transaction ID
|
1229
|
+
unset(transactionId) {
|
1230
|
+
cache.delete(transactionId);
|
1185
1231
|
}
|
1232
|
+
// Get all cached resources and remove expired ones
|
1186
1233
|
getActiveData() {
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1234
|
+
const allResources = { utxos: [], messages: [] };
|
1235
|
+
const currentTime = Date.now();
|
1236
|
+
cache.forEach((resource, transactionId) => {
|
1237
|
+
if (currentTime - resource.timestamp < this.ttl) {
|
1238
|
+
allResources.utxos.push(...resource.utxos);
|
1239
|
+
allResources.messages.push(...resource.messages);
|
1240
|
+
} else {
|
1241
|
+
cache.delete(transactionId);
|
1242
|
+
}
|
1243
|
+
});
|
1244
|
+
return allResources;
|
1245
|
+
}
|
1246
|
+
// Check if a UTXO ID or message nonce is already cached and not expired
|
1247
|
+
isCached(key) {
|
1248
|
+
const currentTime = Date.now();
|
1249
|
+
for (const [transactionId, resourceData] of cache.entries()) {
|
1250
|
+
if (currentTime - resourceData.timestamp > this.ttl) {
|
1251
|
+
cache.delete(transactionId);
|
1252
|
+
} else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
|
1253
|
+
return true;
|
1191
1254
|
}
|
1192
|
-
|
1193
|
-
|
1255
|
+
}
|
1256
|
+
return false;
|
1194
1257
|
}
|
1195
|
-
|
1196
|
-
|
1197
|
-
delete cache[key];
|
1258
|
+
clear() {
|
1259
|
+
cache.clear();
|
1198
1260
|
}
|
1199
1261
|
};
|
1200
1262
|
|
@@ -1335,6 +1397,7 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1335
1397
|
import { Address, addressify } from "@fuel-ts/address";
|
1336
1398
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1337
1399
|
import { randomBytes } from "@fuel-ts/crypto";
|
1400
|
+
import { FuelError as FuelError8 } from "@fuel-ts/errors";
|
1338
1401
|
import { bn as bn8 } from "@fuel-ts/math";
|
1339
1402
|
import {
|
1340
1403
|
PolicyType,
|
@@ -1715,6 +1778,15 @@ function calculateMetadataGasForTxScript({
|
|
1715
1778
|
}) {
|
1716
1779
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1717
1780
|
}
|
1781
|
+
function calculateMetadataGasForTxBlob({
|
1782
|
+
gasCosts,
|
1783
|
+
txBytesSize,
|
1784
|
+
witnessBytesSize
|
1785
|
+
}) {
|
1786
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1787
|
+
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
1788
|
+
return txId.add(blobLen);
|
1789
|
+
}
|
1718
1790
|
var calculateGasFee = (params) => {
|
1719
1791
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1720
1792
|
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
@@ -2291,7 +2363,7 @@ var BaseTransactionRequest = class {
|
|
2291
2363
|
* @hidden
|
2292
2364
|
*/
|
2293
2365
|
metadataGas(_gasCosts) {
|
2294
|
-
throw new
|
2366
|
+
throw new FuelError8(FuelError8.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2295
2367
|
}
|
2296
2368
|
/**
|
2297
2369
|
* @hidden
|
@@ -2366,6 +2438,7 @@ var BaseTransactionRequest = class {
|
|
2366
2438
|
};
|
2367
2439
|
updateAssetInput(baseAssetId, bn8(1e11));
|
2368
2440
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2441
|
+
return this;
|
2369
2442
|
}
|
2370
2443
|
/**
|
2371
2444
|
* Retrieves an array of CoinQuantity for each coin output present in the transaction.
|
@@ -2412,14 +2485,11 @@ var BaseTransactionRequest = class {
|
|
2412
2485
|
}
|
2413
2486
|
});
|
2414
2487
|
}
|
2488
|
+
byteLength() {
|
2489
|
+
return this.toTransactionBytes().byteLength;
|
2490
|
+
}
|
2415
2491
|
};
|
2416
2492
|
|
2417
|
-
// src/providers/transaction-request/create-transaction-request.ts
|
2418
|
-
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2419
|
-
import { bn as bn10 } from "@fuel-ts/math";
|
2420
|
-
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2421
|
-
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2422
|
-
|
2423
2493
|
// src/providers/transaction-request/hash-transaction.ts
|
2424
2494
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2425
2495
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
@@ -2491,6 +2561,76 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2491
2561
|
return sha256(concatenatedData);
|
2492
2562
|
}
|
2493
2563
|
|
2564
|
+
// src/providers/transaction-request/blob-transaction-request.ts
|
2565
|
+
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
2566
|
+
static from(obj) {
|
2567
|
+
if (obj instanceof this) {
|
2568
|
+
return obj;
|
2569
|
+
}
|
2570
|
+
return new this(obj);
|
2571
|
+
}
|
2572
|
+
/** Type of the transaction */
|
2573
|
+
type = TransactionType.Blob;
|
2574
|
+
/** Blob ID */
|
2575
|
+
blobId;
|
2576
|
+
/** Witness index of contract bytecode to create */
|
2577
|
+
witnessIndex;
|
2578
|
+
/**
|
2579
|
+
* Creates an instance `BlobTransactionRequest`.
|
2580
|
+
*
|
2581
|
+
* @param blobTransactionRequestLike - The initial values for the instance
|
2582
|
+
*/
|
2583
|
+
constructor({ witnessIndex, blobId, ...rest }) {
|
2584
|
+
super(rest);
|
2585
|
+
this.blobId = blobId;
|
2586
|
+
this.witnessIndex = witnessIndex ?? 0;
|
2587
|
+
}
|
2588
|
+
/**
|
2589
|
+
* Converts the transaction request to a `TransactionBlob`.
|
2590
|
+
*
|
2591
|
+
* @returns The transaction create object.
|
2592
|
+
*/
|
2593
|
+
toTransaction() {
|
2594
|
+
const baseTransaction = this.getBaseTransaction();
|
2595
|
+
const { witnessIndex, blobId } = this;
|
2596
|
+
return {
|
2597
|
+
type: TransactionType.Blob,
|
2598
|
+
...baseTransaction,
|
2599
|
+
blobId,
|
2600
|
+
witnessIndex
|
2601
|
+
};
|
2602
|
+
}
|
2603
|
+
/**
|
2604
|
+
* Gets the Transaction Request by hashing the transaction.
|
2605
|
+
*
|
2606
|
+
* @param chainId - The chain ID.
|
2607
|
+
*
|
2608
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
2609
|
+
*/
|
2610
|
+
getTransactionId(chainId) {
|
2611
|
+
return hashTransaction(this, chainId);
|
2612
|
+
}
|
2613
|
+
/**
|
2614
|
+
* Calculates the metadata gas cost for a blob transaction.
|
2615
|
+
*
|
2616
|
+
* @param gasCosts - gas costs passed from the chain.
|
2617
|
+
* @returns metadata gas cost for the blob transaction.
|
2618
|
+
*/
|
2619
|
+
metadataGas(gasCosts) {
|
2620
|
+
return calculateMetadataGasForTxBlob({
|
2621
|
+
gasCosts,
|
2622
|
+
txBytesSize: this.byteSize(),
|
2623
|
+
witnessBytesSize: this.witnesses[this.witnessIndex].length
|
2624
|
+
});
|
2625
|
+
}
|
2626
|
+
};
|
2627
|
+
|
2628
|
+
// src/providers/transaction-request/create-transaction-request.ts
|
2629
|
+
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2630
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2631
|
+
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2632
|
+
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2633
|
+
|
2494
2634
|
// src/providers/transaction-request/storage-slot.ts
|
2495
2635
|
import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
|
2496
2636
|
var getStorageValue = (value) => {
|
@@ -2819,10 +2959,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2819
2959
|
};
|
2820
2960
|
|
2821
2961
|
// src/providers/transaction-request/utils.ts
|
2822
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
2962
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2823
2963
|
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2824
2964
|
var transactionRequestify = (obj) => {
|
2825
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2965
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
2826
2966
|
return obj;
|
2827
2967
|
}
|
2828
2968
|
const { type } = obj;
|
@@ -2833,20 +2973,26 @@ var transactionRequestify = (obj) => {
|
|
2833
2973
|
case TransactionType5.Create: {
|
2834
2974
|
return CreateTransactionRequest.from(obj);
|
2835
2975
|
}
|
2976
|
+
case TransactionType5.Blob: {
|
2977
|
+
return BlobTransactionRequest.from(obj);
|
2978
|
+
}
|
2836
2979
|
default: {
|
2837
|
-
throw new
|
2980
|
+
throw new FuelError9(
|
2838
2981
|
ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
|
2839
2982
|
`Unsupported transaction type: ${type}.`
|
2840
2983
|
);
|
2841
2984
|
}
|
2842
2985
|
}
|
2843
2986
|
};
|
2987
|
+
var isTransactionTypeScript = (request) => request.type === TransactionType5.Script;
|
2988
|
+
var isTransactionTypeCreate = (request) => request.type === TransactionType5.Create;
|
2989
|
+
var isTransactionTypeBlob = (request) => request.type === TransactionType5.Blob;
|
2844
2990
|
|
2845
2991
|
// src/providers/transaction-response/transaction-response.ts
|
2846
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
2992
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
|
2847
2993
|
import { bn as bn16 } from "@fuel-ts/math";
|
2848
|
-
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2849
|
-
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2994
|
+
import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
2995
|
+
import { arrayify as arrayify10, assertUnreachable } from "@fuel-ts/utils";
|
2850
2996
|
|
2851
2997
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2852
2998
|
import { bn as bn15 } from "@fuel-ts/math";
|
@@ -2925,7 +3071,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2925
3071
|
|
2926
3072
|
// src/providers/transaction-summary/operations.ts
|
2927
3073
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2928
|
-
import { ErrorCode as ErrorCode10, FuelError as
|
3074
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2929
3075
|
import { bn as bn13 } from "@fuel-ts/math";
|
2930
3076
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2931
3077
|
|
@@ -2963,7 +3109,8 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
2963
3109
|
};
|
2964
3110
|
|
2965
3111
|
// src/providers/transaction-summary/input.ts
|
2966
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3112
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError10 } from "@fuel-ts/errors";
|
3113
|
+
import { BN } from "@fuel-ts/math";
|
2967
3114
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2968
3115
|
function getInputsByTypes(inputs, types) {
|
2969
3116
|
return inputs.filter((i) => types.includes(i.type));
|
@@ -2980,17 +3127,47 @@ function getInputsMessage(inputs) {
|
|
2980
3127
|
function getInputsCoinAndMessage(inputs) {
|
2981
3128
|
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2982
3129
|
}
|
3130
|
+
function isInputCoin(input) {
|
3131
|
+
return input.type === InputType6.Coin;
|
3132
|
+
}
|
2983
3133
|
function getInputsContract(inputs) {
|
2984
3134
|
return getInputsByType(inputs, InputType6.Contract);
|
2985
3135
|
}
|
2986
|
-
function
|
3136
|
+
function findCoinInput(inputs, assetId) {
|
2987
3137
|
const coinInputs = getInputsCoin(inputs);
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
)
|
2993
|
-
|
3138
|
+
return coinInputs.find((i) => i.assetId === assetId);
|
3139
|
+
}
|
3140
|
+
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
|
3141
|
+
const aggregated = /* @__PURE__ */ new Map();
|
3142
|
+
getInputsCoinAndMessage(inputs).forEach((input) => {
|
3143
|
+
const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
|
3144
|
+
const owner = isInputCoin(input) ? input.owner : input.recipient;
|
3145
|
+
let ownersMap = aggregated.get(assetId);
|
3146
|
+
if (!ownersMap) {
|
3147
|
+
ownersMap = /* @__PURE__ */ new Map();
|
3148
|
+
aggregated.set(assetId, ownersMap);
|
3149
|
+
}
|
3150
|
+
let ownerBalance = ownersMap.get(owner);
|
3151
|
+
if (!ownerBalance) {
|
3152
|
+
ownerBalance = new BN(0);
|
3153
|
+
ownersMap.set(owner, ownerBalance);
|
3154
|
+
}
|
3155
|
+
ownersMap.set(owner, ownerBalance.add(input.amount));
|
3156
|
+
});
|
3157
|
+
return aggregated;
|
3158
|
+
}
|
3159
|
+
function findMessageInput(inputs) {
|
3160
|
+
return getInputsMessage(inputs)?.[0];
|
3161
|
+
}
|
3162
|
+
function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
3163
|
+
const coinInput = findCoinInput(inputs, assetId);
|
3164
|
+
if (coinInput) {
|
3165
|
+
return coinInput;
|
3166
|
+
}
|
3167
|
+
if (isBaseAsset) {
|
3168
|
+
return findMessageInput(inputs);
|
3169
|
+
}
|
3170
|
+
return void 0;
|
2994
3171
|
}
|
2995
3172
|
function getInputContractFromIndex(inputs, inputIndex) {
|
2996
3173
|
if (inputIndex == null) {
|
@@ -3001,7 +3178,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3001
3178
|
return void 0;
|
3002
3179
|
}
|
3003
3180
|
if (contractInput.type !== InputType6.Contract) {
|
3004
|
-
throw new
|
3181
|
+
throw new FuelError10(
|
3005
3182
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
3006
3183
|
`Contract input should be of type 'contract'.`
|
3007
3184
|
);
|
@@ -3046,6 +3223,7 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
|
3046
3223
|
TransactionTypeName2["Script"] = "Script";
|
3047
3224
|
TransactionTypeName2["Upgrade"] = "Upgrade";
|
3048
3225
|
TransactionTypeName2["Upload"] = "Upload";
|
3226
|
+
TransactionTypeName2["Blob"] = "Blob";
|
3049
3227
|
return TransactionTypeName2;
|
3050
3228
|
})(TransactionTypeName || {});
|
3051
3229
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
@@ -3091,8 +3269,10 @@ function getTransactionTypeName(transactionType) {
|
|
3091
3269
|
return "Create" /* Create */;
|
3092
3270
|
case TransactionType7.Script:
|
3093
3271
|
return "Script" /* Script */;
|
3272
|
+
case TransactionType7.Blob:
|
3273
|
+
return "Blob" /* Blob */;
|
3094
3274
|
default:
|
3095
|
-
throw new
|
3275
|
+
throw new FuelError11(
|
3096
3276
|
ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
|
3097
3277
|
`Unsupported transaction type: ${transactionType}.`
|
3098
3278
|
);
|
@@ -3117,6 +3297,9 @@ function isTypeUpgrade(transactionType) {
|
|
3117
3297
|
function isTypeUpload(transactionType) {
|
3118
3298
|
return isType(transactionType, "Upload" /* Upload */);
|
3119
3299
|
}
|
3300
|
+
function isTypeBlob(transactionType) {
|
3301
|
+
return isType(transactionType, "Blob" /* Blob */);
|
3302
|
+
}
|
3120
3303
|
function hasSameAssetId(a) {
|
3121
3304
|
return (b) => a.assetId === b.assetId;
|
3122
3305
|
}
|
@@ -3126,41 +3309,51 @@ function getReceiptsCall(receipts) {
|
|
3126
3309
|
function getReceiptsMessageOut(receipts) {
|
3127
3310
|
return getReceiptsByType(receipts, ReceiptType4.MessageOut);
|
3128
3311
|
}
|
3129
|
-
|
3312
|
+
function mergeAssets(op1, op2) {
|
3130
3313
|
const assets1 = op1.assetsSent || [];
|
3131
3314
|
const assets2 = op2.assetsSent || [];
|
3132
|
-
const
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3315
|
+
const assetMap = /* @__PURE__ */ new Map();
|
3316
|
+
assets1.forEach((asset) => {
|
3317
|
+
assetMap.set(asset.assetId, { ...asset });
|
3318
|
+
});
|
3319
|
+
assets2.forEach((asset) => {
|
3320
|
+
const existingAsset = assetMap.get(asset.assetId);
|
3321
|
+
if (existingAsset) {
|
3322
|
+
existingAsset.amount = bn13(existingAsset.amount).add(asset.amount);
|
3323
|
+
} else {
|
3324
|
+
assetMap.set(asset.assetId, { ...asset });
|
3139
3325
|
}
|
3140
|
-
const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
|
3141
|
-
return { ...asset1, amount: mergedAmount };
|
3142
3326
|
});
|
3143
|
-
return
|
3144
|
-
}
|
3327
|
+
return Array.from(assetMap.values());
|
3328
|
+
}
|
3145
3329
|
function isSameOperation(a, b) {
|
3146
3330
|
return a.name === b.name && a.from?.address === b.from?.address && a.to?.address === b.to?.address && a.from?.type === b.from?.type && a.to?.type === b.to?.type;
|
3147
3331
|
}
|
3332
|
+
function mergeAssetsSent(existing, toAdd) {
|
3333
|
+
if (!toAdd.assetsSent?.length) {
|
3334
|
+
return existing.assetsSent;
|
3335
|
+
}
|
3336
|
+
return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
|
3337
|
+
}
|
3338
|
+
function mergeCalls(existing, toAdd) {
|
3339
|
+
if (!toAdd.calls?.length) {
|
3340
|
+
return existing.calls;
|
3341
|
+
}
|
3342
|
+
return [...existing.calls || [], ...toAdd.calls];
|
3343
|
+
}
|
3344
|
+
function mergeOperations(existing, toAdd) {
|
3345
|
+
return {
|
3346
|
+
...existing,
|
3347
|
+
assetsSent: mergeAssetsSent(existing, toAdd),
|
3348
|
+
calls: mergeCalls(existing, toAdd)
|
3349
|
+
};
|
3350
|
+
}
|
3148
3351
|
function addOperation(operations, toAdd) {
|
3149
|
-
const
|
3150
|
-
|
3151
|
-
|
3152
|
-
const existentOperation = { ...allOperations[index] };
|
3153
|
-
if (toAdd.assetsSent?.length) {
|
3154
|
-
existentOperation.assetsSent = existentOperation.assetsSent?.length ? mergeAssets(existentOperation, toAdd) : toAdd.assetsSent;
|
3155
|
-
}
|
3156
|
-
if (toAdd.calls?.length) {
|
3157
|
-
existentOperation.calls = [...existentOperation.calls || [], ...toAdd.calls];
|
3158
|
-
}
|
3159
|
-
allOperations[index] = existentOperation;
|
3160
|
-
} else {
|
3161
|
-
allOperations.push(toAdd);
|
3352
|
+
const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
|
3353
|
+
if (existingIndex === -1) {
|
3354
|
+
return [...operations, toAdd];
|
3162
3355
|
}
|
3163
|
-
return
|
3356
|
+
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
3164
3357
|
}
|
3165
3358
|
function getReceiptsTransferOut(receipts) {
|
3166
3359
|
return getReceiptsByType(receipts, ReceiptType4.TransferOut);
|
@@ -3173,7 +3366,7 @@ function getWithdrawFromFuelOperations({
|
|
3173
3366
|
const messageOutReceipts = getReceiptsMessageOut(receipts);
|
3174
3367
|
const withdrawFromFuelOperations = messageOutReceipts.reduce(
|
3175
3368
|
(prevWithdrawFromFuelOps, receipt) => {
|
3176
|
-
const input = getInputFromAssetId(inputs, baseAssetId);
|
3369
|
+
const input = getInputFromAssetId(inputs, baseAssetId, true);
|
3177
3370
|
if (input) {
|
3178
3371
|
const inputAddress = getInputAccountAddress(input);
|
3179
3372
|
const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
|
@@ -3202,65 +3395,80 @@ function getWithdrawFromFuelOperations({
|
|
3202
3395
|
);
|
3203
3396
|
return withdrawFromFuelOperations;
|
3204
3397
|
}
|
3398
|
+
function getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs) {
|
3399
|
+
const abi = abiMap?.[contractInput.contractID];
|
3400
|
+
if (!abi) {
|
3401
|
+
return [];
|
3402
|
+
}
|
3403
|
+
return [
|
3404
|
+
getFunctionCall({
|
3405
|
+
abi,
|
3406
|
+
receipt,
|
3407
|
+
rawPayload,
|
3408
|
+
maxInputs
|
3409
|
+
})
|
3410
|
+
];
|
3411
|
+
}
|
3412
|
+
function getAssetsSent(receipt) {
|
3413
|
+
return receipt.amount?.isZero() ? void 0 : [
|
3414
|
+
{
|
3415
|
+
amount: receipt.amount,
|
3416
|
+
assetId: receipt.assetId
|
3417
|
+
}
|
3418
|
+
];
|
3419
|
+
}
|
3420
|
+
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3421
|
+
const assetId = receipt.assetId === ZeroBytes328 ? baseAssetId : receipt.assetId;
|
3422
|
+
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3423
|
+
if (!input) {
|
3424
|
+
return [];
|
3425
|
+
}
|
3426
|
+
const inputAddress = getInputAccountAddress(input);
|
3427
|
+
const calls = getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs);
|
3428
|
+
return [
|
3429
|
+
{
|
3430
|
+
name: "Contract call" /* contractCall */,
|
3431
|
+
from: {
|
3432
|
+
type: 1 /* account */,
|
3433
|
+
address: inputAddress
|
3434
|
+
},
|
3435
|
+
to: {
|
3436
|
+
type: 0 /* contract */,
|
3437
|
+
address: receipt.to
|
3438
|
+
},
|
3439
|
+
assetsSent: getAssetsSent(receipt),
|
3440
|
+
calls
|
3441
|
+
}
|
3442
|
+
];
|
3443
|
+
}
|
3205
3444
|
function getContractCallOperations({
|
3206
3445
|
inputs,
|
3207
3446
|
outputs,
|
3208
3447
|
receipts,
|
3209
3448
|
abiMap,
|
3210
3449
|
rawPayload,
|
3211
|
-
maxInputs
|
3450
|
+
maxInputs,
|
3451
|
+
baseAssetId
|
3212
3452
|
}) {
|
3213
3453
|
const contractCallReceipts = getReceiptsCall(receipts);
|
3214
3454
|
const contractOutputs = getOutputsContract(outputs);
|
3215
|
-
|
3455
|
+
return contractOutputs.flatMap((output) => {
|
3216
3456
|
const contractInput = getInputContractFromIndex(inputs, output.inputIndex);
|
3217
|
-
if (contractInput) {
|
3218
|
-
|
3219
|
-
if (receipt.to === contractInput.contractID) {
|
3220
|
-
const input = getInputFromAssetId(inputs, receipt.assetId);
|
3221
|
-
if (input) {
|
3222
|
-
const inputAddress = getInputAccountAddress(input);
|
3223
|
-
const calls = [];
|
3224
|
-
const abi = abiMap?.[contractInput.contractID];
|
3225
|
-
if (abi) {
|
3226
|
-
calls.push(
|
3227
|
-
getFunctionCall({
|
3228
|
-
abi,
|
3229
|
-
receipt,
|
3230
|
-
rawPayload,
|
3231
|
-
maxInputs
|
3232
|
-
})
|
3233
|
-
);
|
3234
|
-
}
|
3235
|
-
const newContractCallOps = addOperation(prevContractCallOps, {
|
3236
|
-
name: "Contract call" /* contractCall */,
|
3237
|
-
from: {
|
3238
|
-
type: 1 /* account */,
|
3239
|
-
address: inputAddress
|
3240
|
-
},
|
3241
|
-
to: {
|
3242
|
-
type: 0 /* contract */,
|
3243
|
-
address: receipt.to
|
3244
|
-
},
|
3245
|
-
// if no amount is forwarded to the contract, skip showing assetsSent
|
3246
|
-
assetsSent: receipt.amount?.isZero() ? void 0 : [
|
3247
|
-
{
|
3248
|
-
amount: receipt.amount,
|
3249
|
-
assetId: receipt.assetId
|
3250
|
-
}
|
3251
|
-
],
|
3252
|
-
calls
|
3253
|
-
});
|
3254
|
-
return newContractCallOps;
|
3255
|
-
}
|
3256
|
-
}
|
3257
|
-
return prevContractCallOps;
|
3258
|
-
}, prevOutputCallOps);
|
3259
|
-
return newCallOps;
|
3457
|
+
if (!contractInput) {
|
3458
|
+
return [];
|
3260
3459
|
}
|
3261
|
-
return
|
3262
|
-
|
3263
|
-
|
3460
|
+
return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
|
3461
|
+
(receipt) => processCallReceipt(
|
3462
|
+
receipt,
|
3463
|
+
contractInput,
|
3464
|
+
inputs,
|
3465
|
+
abiMap,
|
3466
|
+
rawPayload,
|
3467
|
+
maxInputs,
|
3468
|
+
baseAssetId
|
3469
|
+
)
|
3470
|
+
);
|
3471
|
+
});
|
3264
3472
|
}
|
3265
3473
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
3266
3474
|
const { to: toAddress, assetId, amount } = receipt;
|
@@ -3292,32 +3500,40 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3292
3500
|
function getTransferOperations({
|
3293
3501
|
inputs,
|
3294
3502
|
outputs,
|
3295
|
-
receipts
|
3503
|
+
receipts,
|
3504
|
+
baseAssetId
|
3296
3505
|
}) {
|
3297
3506
|
let operations = [];
|
3298
3507
|
const coinOutputs = getOutputsCoin(outputs);
|
3299
3508
|
const contractInputs = getInputsContract(inputs);
|
3300
3509
|
const changeOutputs = getOutputsChange(outputs);
|
3301
|
-
|
3302
|
-
|
3303
|
-
const
|
3304
|
-
|
3510
|
+
const aggregated = aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId);
|
3511
|
+
coinOutputs.forEach(({ amount, assetId, to }) => {
|
3512
|
+
const txPayers = aggregated.get(assetId) || /* @__PURE__ */ new Map();
|
3513
|
+
let selectedPayer;
|
3514
|
+
let fallbackPayer;
|
3515
|
+
for (const [address, payedAmount] of txPayers) {
|
3516
|
+
if (!fallbackPayer) {
|
3517
|
+
fallbackPayer = address;
|
3518
|
+
}
|
3519
|
+
if (payedAmount.gte(amount)) {
|
3520
|
+
selectedPayer = address;
|
3521
|
+
break;
|
3522
|
+
}
|
3523
|
+
}
|
3524
|
+
selectedPayer = selectedPayer || fallbackPayer;
|
3525
|
+
if (selectedPayer) {
|
3305
3526
|
operations = addOperation(operations, {
|
3306
3527
|
name: "Transfer asset" /* transfer */,
|
3307
3528
|
from: {
|
3308
3529
|
type: 1 /* account */,
|
3309
|
-
address:
|
3530
|
+
address: selectedPayer
|
3310
3531
|
},
|
3311
3532
|
to: {
|
3312
3533
|
type: 1 /* account */,
|
3313
3534
|
address: to
|
3314
3535
|
},
|
3315
|
-
assetsSent: [
|
3316
|
-
{
|
3317
|
-
assetId,
|
3318
|
-
amount
|
3319
|
-
}
|
3320
|
-
]
|
3536
|
+
assetsSent: [{ assetId, amount }]
|
3321
3537
|
});
|
3322
3538
|
}
|
3323
3539
|
});
|
@@ -3390,21 +3606,19 @@ function getOperations({
|
|
3390
3606
|
baseAssetId
|
3391
3607
|
}) {
|
3392
3608
|
if (isTypeCreate(transactionType)) {
|
3393
|
-
return [
|
3394
|
-
...getContractCreatedOperations({ inputs, outputs }),
|
3395
|
-
...getTransferOperations({ inputs, outputs, receipts })
|
3396
|
-
];
|
3609
|
+
return [...getContractCreatedOperations({ inputs, outputs })];
|
3397
3610
|
}
|
3398
3611
|
if (isTypeScript(transactionType)) {
|
3399
3612
|
return [
|
3400
|
-
...getTransferOperations({ inputs, outputs, receipts }),
|
3613
|
+
...getTransferOperations({ inputs, outputs, receipts, baseAssetId }),
|
3401
3614
|
...getContractCallOperations({
|
3402
3615
|
inputs,
|
3403
3616
|
outputs,
|
3404
3617
|
receipts,
|
3405
3618
|
abiMap,
|
3406
3619
|
rawPayload,
|
3407
|
-
maxInputs
|
3620
|
+
maxInputs,
|
3621
|
+
baseAssetId
|
3408
3622
|
}),
|
3409
3623
|
...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
|
3410
3624
|
];
|
@@ -3463,7 +3677,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3463
3677
|
};
|
3464
3678
|
|
3465
3679
|
// src/providers/transaction-summary/status.ts
|
3466
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
3680
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
|
3467
3681
|
import { bn as bn14 } from "@fuel-ts/math";
|
3468
3682
|
var getTransactionStatusName = (gqlStatus) => {
|
3469
3683
|
switch (gqlStatus) {
|
@@ -3476,7 +3690,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3476
3690
|
case "SqueezedOutStatus":
|
3477
3691
|
return "squeezedout" /* squeezedout */;
|
3478
3692
|
default:
|
3479
|
-
throw new
|
3693
|
+
throw new FuelError12(
|
3480
3694
|
ErrorCode11.INVALID_TRANSACTION_STATUS,
|
3481
3695
|
`Invalid transaction status: ${gqlStatus}.`
|
3482
3696
|
);
|
@@ -3598,6 +3812,7 @@ function assembleTransactionSummary(params) {
|
|
3598
3812
|
isTypeScript: isTypeScript(transaction.type),
|
3599
3813
|
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3600
3814
|
isTypeUpload: isTypeUpload(transaction.type),
|
3815
|
+
isTypeBlob: isTypeBlob(transaction.type),
|
3601
3816
|
isStatusFailure,
|
3602
3817
|
isStatusSuccess,
|
3603
3818
|
isStatusPending,
|
@@ -3623,6 +3838,36 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
3623
3838
|
}
|
3624
3839
|
|
3625
3840
|
// src/providers/transaction-response/transaction-response.ts
|
3841
|
+
function mapGqlOutputsToTxOutputs(outputs) {
|
3842
|
+
return outputs.map((o) => {
|
3843
|
+
const obj = "amount" in o ? { ...o, amount: bn16(o.amount) } : o;
|
3844
|
+
switch (obj.type) {
|
3845
|
+
case "CoinOutput":
|
3846
|
+
return { ...obj, type: OutputType7.Coin };
|
3847
|
+
case "ContractOutput":
|
3848
|
+
return {
|
3849
|
+
...obj,
|
3850
|
+
type: OutputType7.Contract,
|
3851
|
+
inputIndex: parseInt(obj.inputIndex, 10)
|
3852
|
+
};
|
3853
|
+
case "ChangeOutput":
|
3854
|
+
return {
|
3855
|
+
...obj,
|
3856
|
+
type: OutputType7.Change
|
3857
|
+
};
|
3858
|
+
case "VariableOutput":
|
3859
|
+
return { ...obj, type: OutputType7.Variable };
|
3860
|
+
case "ContractCreated":
|
3861
|
+
return {
|
3862
|
+
...obj,
|
3863
|
+
type: OutputType7.ContractCreated,
|
3864
|
+
contractId: obj.contract
|
3865
|
+
};
|
3866
|
+
default:
|
3867
|
+
return assertUnreachable(obj);
|
3868
|
+
}
|
3869
|
+
});
|
3870
|
+
}
|
3626
3871
|
var TransactionResponse = class {
|
3627
3872
|
/** Transaction ID */
|
3628
3873
|
id;
|
@@ -3632,17 +3877,20 @@ var TransactionResponse = class {
|
|
3632
3877
|
gasUsed = bn16(0);
|
3633
3878
|
/** The graphql Transaction with receipts object. */
|
3634
3879
|
gqlTransaction;
|
3880
|
+
request;
|
3881
|
+
status;
|
3635
3882
|
abis;
|
3636
3883
|
/**
|
3637
3884
|
* Constructor for `TransactionResponse`.
|
3638
3885
|
*
|
3639
|
-
* @param
|
3886
|
+
* @param tx - The transaction ID or TransactionRequest.
|
3640
3887
|
* @param provider - The provider.
|
3641
3888
|
*/
|
3642
|
-
constructor(
|
3643
|
-
this.id =
|
3889
|
+
constructor(tx, provider, abis) {
|
3890
|
+
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
3644
3891
|
this.provider = provider;
|
3645
3892
|
this.abis = abis;
|
3893
|
+
this.request = typeof tx === "string" ? void 0 : tx;
|
3646
3894
|
}
|
3647
3895
|
/**
|
3648
3896
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
@@ -3657,6 +3905,54 @@ var TransactionResponse = class {
|
|
3657
3905
|
await response.fetch();
|
3658
3906
|
return response;
|
3659
3907
|
}
|
3908
|
+
applyMalleableSubscriptionFields(transaction) {
|
3909
|
+
const status = this.status;
|
3910
|
+
if (!status) {
|
3911
|
+
return;
|
3912
|
+
}
|
3913
|
+
const tx = transaction;
|
3914
|
+
if (status.type === "SuccessStatus" || status.type === "FailureStatus") {
|
3915
|
+
tx.inputs = tx.inputs.map((input, idx) => {
|
3916
|
+
if ("txPointer" in input) {
|
3917
|
+
const correspondingInput = status.transaction.inputs?.[idx];
|
3918
|
+
return {
|
3919
|
+
...input,
|
3920
|
+
txPointer: TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
|
3921
|
+
};
|
3922
|
+
}
|
3923
|
+
return input;
|
3924
|
+
});
|
3925
|
+
tx.outputs = mapGqlOutputsToTxOutputs(status.transaction.outputs);
|
3926
|
+
if ("receiptsRoot" in status.transaction) {
|
3927
|
+
tx.receiptsRoot = status.transaction.receiptsRoot;
|
3928
|
+
}
|
3929
|
+
}
|
3930
|
+
}
|
3931
|
+
async getTransaction() {
|
3932
|
+
if (this.request) {
|
3933
|
+
const tx = this.request.toTransaction();
|
3934
|
+
this.applyMalleableSubscriptionFields(tx);
|
3935
|
+
return {
|
3936
|
+
tx,
|
3937
|
+
bytes: this.request.toTransactionBytes()
|
3938
|
+
};
|
3939
|
+
}
|
3940
|
+
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
3941
|
+
return {
|
3942
|
+
tx: this.decodeTransaction(gqlTransaction),
|
3943
|
+
bytes: arrayify10(gqlTransaction.rawPayload)
|
3944
|
+
};
|
3945
|
+
}
|
3946
|
+
getReceipts() {
|
3947
|
+
const status = this.status ?? this.gqlTransaction?.status;
|
3948
|
+
switch (status?.type) {
|
3949
|
+
case "SuccessStatus":
|
3950
|
+
case "FailureStatus":
|
3951
|
+
return status.receipts.map(processGqlReceipt);
|
3952
|
+
default:
|
3953
|
+
return [];
|
3954
|
+
}
|
3955
|
+
}
|
3660
3956
|
/**
|
3661
3957
|
* Fetch the transaction with receipts from the provider.
|
3662
3958
|
*
|
@@ -3667,11 +3963,12 @@ var TransactionResponse = class {
|
|
3667
3963
|
transactionId: this.id
|
3668
3964
|
});
|
3669
3965
|
if (!response.transaction) {
|
3670
|
-
const subscription = this.provider.operations.statusChange({
|
3966
|
+
const subscription = await this.provider.operations.statusChange({
|
3671
3967
|
transactionId: this.id
|
3672
3968
|
});
|
3673
3969
|
for await (const { statusChange } of subscription) {
|
3674
3970
|
if (statusChange) {
|
3971
|
+
this.status = statusChange;
|
3675
3972
|
break;
|
3676
3973
|
}
|
3677
3974
|
}
|
@@ -3700,28 +3997,17 @@ var TransactionResponse = class {
|
|
3700
3997
|
* @returns
|
3701
3998
|
*/
|
3702
3999
|
async getTransactionSummary(contractsAbiMap) {
|
3703
|
-
|
3704
|
-
if (!transaction) {
|
3705
|
-
transaction = await this.fetch();
|
3706
|
-
}
|
3707
|
-
const decodedTransaction = this.decodeTransaction(
|
3708
|
-
transaction
|
3709
|
-
);
|
3710
|
-
let txReceipts = [];
|
3711
|
-
if (transaction?.status && "receipts" in transaction.status) {
|
3712
|
-
txReceipts = transaction.status.receipts;
|
3713
|
-
}
|
3714
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
4000
|
+
const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
|
3715
4001
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3716
4002
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3717
4003
|
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3718
4004
|
const baseAssetId = this.provider.getBaseAssetId();
|
3719
4005
|
const transactionSummary = assembleTransactionSummary({
|
3720
4006
|
id: this.id,
|
3721
|
-
receipts,
|
3722
|
-
transaction
|
3723
|
-
transactionBytes
|
3724
|
-
gqlTransactionStatus:
|
4007
|
+
receipts: this.getReceipts(),
|
4008
|
+
transaction,
|
4009
|
+
transactionBytes,
|
4010
|
+
gqlTransactionStatus: this.status ?? this.gqlTransaction?.status,
|
3725
4011
|
gasPerByte,
|
3726
4012
|
gasPriceFactor,
|
3727
4013
|
abiMap: contractsAbiMap,
|
@@ -3738,12 +4024,14 @@ var TransactionResponse = class {
|
|
3738
4024
|
if (status && status !== "SubmittedStatus") {
|
3739
4025
|
return;
|
3740
4026
|
}
|
3741
|
-
const subscription = this.provider.operations.statusChange({
|
4027
|
+
const subscription = await this.provider.operations.statusChange({
|
3742
4028
|
transactionId: this.id
|
3743
4029
|
});
|
3744
4030
|
for await (const { statusChange } of subscription) {
|
4031
|
+
this.status = statusChange;
|
3745
4032
|
if (statusChange.type === "SqueezedOutStatus") {
|
3746
|
-
|
4033
|
+
this.unsetResourceCache();
|
4034
|
+
throw new FuelError13(
|
3747
4035
|
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
3748
4036
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3749
4037
|
);
|
@@ -3752,7 +4040,6 @@ var TransactionResponse = class {
|
|
3752
4040
|
break;
|
3753
4041
|
}
|
3754
4042
|
}
|
3755
|
-
await this.fetch();
|
3756
4043
|
}
|
3757
4044
|
/**
|
3758
4045
|
* Assembles the result of a transaction by retrieving the transaction summary,
|
@@ -3769,7 +4056,6 @@ var TransactionResponse = class {
|
|
3769
4056
|
async assembleResult(contractsAbiMap) {
|
3770
4057
|
const transactionSummary = await this.getTransactionSummary(contractsAbiMap);
|
3771
4058
|
const transactionResult = {
|
3772
|
-
gqlTransaction: this.gqlTransaction,
|
3773
4059
|
...transactionSummary
|
3774
4060
|
};
|
3775
4061
|
let logs = [];
|
@@ -3781,9 +4067,11 @@ var TransactionResponse = class {
|
|
3781
4067
|
);
|
3782
4068
|
transactionResult.logs = logs;
|
3783
4069
|
}
|
3784
|
-
const {
|
3785
|
-
|
3786
|
-
|
4070
|
+
const { receipts } = transactionResult;
|
4071
|
+
const status = this.status ?? this.gqlTransaction?.status;
|
4072
|
+
if (status?.type === "FailureStatus") {
|
4073
|
+
this.unsetResourceCache();
|
4074
|
+
const { reason } = status;
|
3787
4075
|
throw extractTxError({
|
3788
4076
|
receipts,
|
3789
4077
|
statusReason: reason,
|
@@ -3809,6 +4097,9 @@ var TransactionResponse = class {
|
|
3809
4097
|
async wait(contractsAbiMap) {
|
3810
4098
|
return this.waitForResult(contractsAbiMap);
|
3811
4099
|
}
|
4100
|
+
unsetResourceCache() {
|
4101
|
+
this.provider.cache?.unset(this.id);
|
4102
|
+
}
|
3812
4103
|
};
|
3813
4104
|
|
3814
4105
|
// src/providers/utils/auto-retry-fetch.ts
|
@@ -3852,7 +4143,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3852
4143
|
var MAX_RETRIES = 10;
|
3853
4144
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
3854
4145
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
3855
|
-
var
|
4146
|
+
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
3856
4147
|
var processGqlChain = (chain) => {
|
3857
4148
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3858
4149
|
const {
|
@@ -3935,22 +4226,22 @@ var _Provider = class {
|
|
3935
4226
|
__publicField(this, "cache");
|
3936
4227
|
__publicField(this, "options", {
|
3937
4228
|
timeout: void 0,
|
3938
|
-
|
4229
|
+
resourceCacheTTL: void 0,
|
3939
4230
|
fetch: void 0,
|
3940
4231
|
retryOptions: void 0
|
3941
4232
|
});
|
3942
4233
|
this.options = { ...this.options, ...options };
|
3943
4234
|
this.url = url;
|
3944
4235
|
this.operations = this.createOperations();
|
3945
|
-
const {
|
3946
|
-
if (isDefined2(
|
3947
|
-
if (
|
3948
|
-
this.cache = new
|
4236
|
+
const { resourceCacheTTL } = this.options;
|
4237
|
+
if (isDefined2(resourceCacheTTL)) {
|
4238
|
+
if (resourceCacheTTL !== -1) {
|
4239
|
+
this.cache = new ResourceCache(resourceCacheTTL);
|
3949
4240
|
} else {
|
3950
4241
|
this.cache = void 0;
|
3951
4242
|
}
|
3952
4243
|
} else {
|
3953
|
-
this.cache = new
|
4244
|
+
this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
|
3954
4245
|
}
|
3955
4246
|
}
|
3956
4247
|
/** @hidden */
|
@@ -3995,7 +4286,7 @@ var _Provider = class {
|
|
3995
4286
|
getChain() {
|
3996
4287
|
const chain = _Provider.chainInfoCache[this.url];
|
3997
4288
|
if (!chain) {
|
3998
|
-
throw new
|
4289
|
+
throw new FuelError14(
|
3999
4290
|
ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
|
4000
4291
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4001
4292
|
);
|
@@ -4010,7 +4301,7 @@ var _Provider = class {
|
|
4010
4301
|
getNode() {
|
4011
4302
|
const node = _Provider.nodeInfoCache[this.url];
|
4012
4303
|
if (!node) {
|
4013
|
-
throw new
|
4304
|
+
throw new FuelError14(
|
4014
4305
|
ErrorCode13.NODE_INFO_CACHE_EMPTY,
|
4015
4306
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4016
4307
|
);
|
@@ -4053,9 +4344,9 @@ var _Provider = class {
|
|
4053
4344
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
4054
4345
|
*/
|
4055
4346
|
async fetchChainAndNodeInfo() {
|
4056
|
-
const chain = await this.fetchChain();
|
4057
4347
|
const nodeInfo = await this.fetchNode();
|
4058
4348
|
_Provider.ensureClientVersionIsSupported(nodeInfo);
|
4349
|
+
const chain = await this.fetchChain();
|
4059
4350
|
return {
|
4060
4351
|
chain,
|
4061
4352
|
nodeInfo
|
@@ -4089,8 +4380,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4089
4380
|
if ("response" in response) {
|
4090
4381
|
const graphQlResponse = response.response;
|
4091
4382
|
if (Array.isArray(graphQlResponse?.errors)) {
|
4092
|
-
throw new
|
4093
|
-
|
4383
|
+
throw new FuelError14(
|
4384
|
+
FuelError14.CODES.INVALID_REQUEST,
|
4094
4385
|
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
4095
4386
|
);
|
4096
4387
|
}
|
@@ -4101,7 +4392,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4101
4392
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
4102
4393
|
const isSubscription = opDefinition?.operation === "subscription";
|
4103
4394
|
if (isSubscription) {
|
4104
|
-
return
|
4395
|
+
return FuelGraphqlSubscriber.create({
|
4105
4396
|
url: this.url,
|
4106
4397
|
query,
|
4107
4398
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
@@ -4182,6 +4473,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4182
4473
|
} = this.getChain();
|
4183
4474
|
return baseAssetId;
|
4184
4475
|
}
|
4476
|
+
validateTransaction(tx, consensusParameters) {
|
4477
|
+
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4478
|
+
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4479
|
+
throw new FuelError14(
|
4480
|
+
ErrorCode13.MAX_INPUTS_EXCEEDED,
|
4481
|
+
"The transaction exceeds the maximum allowed number of inputs."
|
4482
|
+
);
|
4483
|
+
}
|
4484
|
+
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4485
|
+
throw new FuelError14(
|
4486
|
+
ErrorCode13.MAX_OUTPUTS_EXCEEDED,
|
4487
|
+
"The transaction exceeds the maximum allowed number of outputs."
|
4488
|
+
);
|
4489
|
+
}
|
4490
|
+
}
|
4185
4491
|
/**
|
4186
4492
|
* Submits a transaction to the chain to be executed.
|
4187
4493
|
*
|
@@ -4198,16 +4504,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4198
4504
|
if (estimateTxDependencies) {
|
4199
4505
|
await this.estimateTxDependencies(transactionRequest);
|
4200
4506
|
}
|
4507
|
+
const { consensusParameters } = this.getChain();
|
4508
|
+
this.validateTransaction(transactionRequest, consensusParameters);
|
4201
4509
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
4202
4510
|
let abis;
|
4203
|
-
if (transactionRequest
|
4511
|
+
if (isTransactionTypeScript(transactionRequest)) {
|
4204
4512
|
abis = transactionRequest.abis;
|
4205
4513
|
}
|
4206
4514
|
const {
|
4207
4515
|
submit: { id: transactionId }
|
4208
4516
|
} = await this.operations.submit({ encodedTransaction });
|
4209
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
|
4210
|
-
return new TransactionResponse(
|
4517
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4518
|
+
return new TransactionResponse(transactionRequest, this, abis);
|
4211
4519
|
}
|
4212
4520
|
/**
|
4213
4521
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4244,7 +4552,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4244
4552
|
async estimatePredicates(transactionRequest) {
|
4245
4553
|
const shouldEstimatePredicates = Boolean(
|
4246
4554
|
transactionRequest.inputs.find(
|
4247
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new
|
4555
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN2(input.predicateGasUsed).isZero()
|
4248
4556
|
)
|
4249
4557
|
);
|
4250
4558
|
if (!shouldEstimatePredicates) {
|
@@ -4276,7 +4584,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4276
4584
|
* @returns A promise that resolves to the estimate transaction dependencies.
|
4277
4585
|
*/
|
4278
4586
|
async estimateTxDependencies(transactionRequest) {
|
4279
|
-
if (transactionRequest
|
4587
|
+
if (isTransactionTypeCreate(transactionRequest)) {
|
4280
4588
|
return {
|
4281
4589
|
receipts: [],
|
4282
4590
|
outputVariables: 0,
|
@@ -4298,7 +4606,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4298
4606
|
dryRunStatus = status;
|
4299
4607
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4300
4608
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4301
|
-
if (hasMissingOutputs) {
|
4609
|
+
if (hasMissingOutputs && isTransactionTypeScript(transactionRequest)) {
|
4302
4610
|
outputVariables += missingOutputVariables.length;
|
4303
4611
|
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
4304
4612
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4340,7 +4648,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4340
4648
|
const allRequests = clone3(transactionRequests);
|
4341
4649
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4342
4650
|
allRequests.forEach((req, index) => {
|
4343
|
-
if (req
|
4651
|
+
if (isTransactionTypeScript(req)) {
|
4344
4652
|
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4345
4653
|
}
|
4346
4654
|
});
|
@@ -4366,7 +4674,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4366
4674
|
);
|
4367
4675
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4368
4676
|
const request = allRequests[requestIdx];
|
4369
|
-
if (hasMissingOutputs && request
|
4677
|
+
if (hasMissingOutputs && isTransactionTypeScript(request)) {
|
4370
4678
|
result.outputVariables += missingOutputVariables.length;
|
4371
4679
|
request.addVariableOutputs(missingOutputVariables.length);
|
4372
4680
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4430,7 +4738,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4430
4738
|
tip: transactionRequest.tip
|
4431
4739
|
}).add(1);
|
4432
4740
|
let gasLimit = bn17(0);
|
4433
|
-
if (transactionRequest
|
4741
|
+
if (isTransactionTypeScript(transactionRequest)) {
|
4434
4742
|
gasLimit = transactionRequest.gasLimit;
|
4435
4743
|
if (transactionRequest.gasLimit.eq(0)) {
|
4436
4744
|
transactionRequest.gasLimit = minGas;
|
@@ -4498,14 +4806,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4498
4806
|
*/
|
4499
4807
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4500
4808
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4501
|
-
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4502
4809
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4810
|
+
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4503
4811
|
if (isScriptTransaction) {
|
4504
4812
|
txRequestClone.gasLimit = bn17(0);
|
4505
4813
|
}
|
4506
4814
|
const signedRequest = clone3(txRequestClone);
|
4507
4815
|
let addedSignatures = 0;
|
4508
|
-
if (signatureCallback &&
|
4816
|
+
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4509
4817
|
const lengthBefore = signedRequest.witnesses.length;
|
4510
4818
|
await signatureCallback(signedRequest);
|
4511
4819
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
@@ -4601,10 +4909,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4601
4909
|
utxos: excludedIds?.utxos?.map((id) => hexlify12(id)) || []
|
4602
4910
|
};
|
4603
4911
|
if (this.cache) {
|
4604
|
-
const
|
4605
|
-
|
4606
|
-
);
|
4607
|
-
excludeInput.utxos = Array.from(uniqueUtxos);
|
4912
|
+
const cached = this.cache.getActiveData();
|
4913
|
+
excludeInput.messages.push(...cached.messages);
|
4914
|
+
excludeInput.utxos.push(...cached.utxos);
|
4608
4915
|
}
|
4609
4916
|
const coinsQuery = {
|
4610
4917
|
owner: ownerAddress.toB256(),
|
@@ -4870,7 +5177,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4870
5177
|
nonce
|
4871
5178
|
};
|
4872
5179
|
if (commitBlockId && commitBlockHeight) {
|
4873
|
-
throw new
|
5180
|
+
throw new FuelError14(
|
4874
5181
|
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
4875
5182
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4876
5183
|
);
|
@@ -5039,25 +5346,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5039
5346
|
const { paginationLimit, inputArgs = {} } = params;
|
5040
5347
|
const { first, last, after, before } = inputArgs;
|
5041
5348
|
if (after && before) {
|
5042
|
-
throw new
|
5349
|
+
throw new FuelError14(
|
5043
5350
|
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
5044
5351
|
'Pagination arguments "after" and "before" cannot be used together'
|
5045
5352
|
);
|
5046
5353
|
}
|
5047
5354
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5048
|
-
throw new
|
5355
|
+
throw new FuelError14(
|
5049
5356
|
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
5050
5357
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5051
5358
|
);
|
5052
5359
|
}
|
5053
5360
|
if (first && before) {
|
5054
|
-
throw new
|
5361
|
+
throw new FuelError14(
|
5055
5362
|
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
5056
5363
|
'The use of pagination argument "first" with "before" is not supported'
|
5057
5364
|
);
|
5058
5365
|
}
|
5059
5366
|
if (last && after) {
|
5060
|
-
throw new
|
5367
|
+
throw new FuelError14(
|
5061
5368
|
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
5062
5369
|
'The use of pagination argument "last" with "after" is not supported'
|
5063
5370
|
);
|
@@ -5089,15 +5396,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5089
5396
|
};
|
5090
5397
|
var Provider = _Provider;
|
5091
5398
|
_cacheInputs = new WeakSet();
|
5092
|
-
cacheInputs_fn = function(inputs) {
|
5399
|
+
cacheInputs_fn = function(inputs, transactionId) {
|
5093
5400
|
if (!this.cache) {
|
5094
5401
|
return;
|
5095
5402
|
}
|
5096
|
-
inputs.
|
5097
|
-
|
5098
|
-
|
5099
|
-
|
5100
|
-
|
5403
|
+
const inputsToCache = inputs.reduce(
|
5404
|
+
(acc, input) => {
|
5405
|
+
if (input.type === InputType7.Coin) {
|
5406
|
+
acc.utxos.push(input.id);
|
5407
|
+
} else if (input.type === InputType7.Message) {
|
5408
|
+
acc.messages.push(input.nonce);
|
5409
|
+
}
|
5410
|
+
return acc;
|
5411
|
+
},
|
5412
|
+
{ utxos: [], messages: [] }
|
5413
|
+
);
|
5414
|
+
this.cache.set(transactionId, inputsToCache);
|
5101
5415
|
};
|
5102
5416
|
/** @hidden */
|
5103
5417
|
__publicField(Provider, "chainInfoCache", {});
|
@@ -5105,7 +5419,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5105
5419
|
__publicField(Provider, "nodeInfoCache", {});
|
5106
5420
|
|
5107
5421
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5108
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
5422
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5109
5423
|
import { bn as bn18 } from "@fuel-ts/math";
|
5110
5424
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5111
5425
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
@@ -5115,7 +5429,7 @@ async function getTransactionSummary(params) {
|
|
5115
5429
|
transactionId: id
|
5116
5430
|
});
|
5117
5431
|
if (!gqlTransaction) {
|
5118
|
-
throw new
|
5432
|
+
throw new FuelError15(
|
5119
5433
|
ErrorCode14.TRANSACTION_NOT_FOUND,
|
5120
5434
|
`Transaction not found for given id: ${id}.`
|
5121
5435
|
);
|
@@ -5154,7 +5468,6 @@ async function getTransactionSummary(params) {
|
|
5154
5468
|
baseAssetId
|
5155
5469
|
});
|
5156
5470
|
return {
|
5157
|
-
gqlTransaction,
|
5158
5471
|
...transactionInfo
|
5159
5472
|
};
|
5160
5473
|
}
|
@@ -5168,6 +5481,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5168
5481
|
const gasPrice = await provider.getLatestGasPrice();
|
5169
5482
|
const baseAssetId = provider.getBaseAssetId();
|
5170
5483
|
const transactionSummary = assembleTransactionSummary({
|
5484
|
+
id: transactionRequest.getTransactionId(provider.getChainId()),
|
5171
5485
|
receipts,
|
5172
5486
|
transaction,
|
5173
5487
|
transactionBytes,
|
@@ -5220,7 +5534,6 @@ async function getTransactionsSummaries(params) {
|
|
5220
5534
|
baseAssetId
|
5221
5535
|
});
|
5222
5536
|
const output = {
|
5223
|
-
gqlTransaction,
|
5224
5537
|
...transactionSummary
|
5225
5538
|
};
|
5226
5539
|
return output;
|
@@ -5372,13 +5685,13 @@ var mergeQuantities = (...coinQuantities) => {
|
|
5372
5685
|
|
5373
5686
|
// src/utils/formatTransferToContractScriptData.ts
|
5374
5687
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5375
|
-
import { BN as
|
5688
|
+
import { BN as BN3 } from "@fuel-ts/math";
|
5376
5689
|
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
5377
5690
|
import * as asm from "@fuels/vm-asm";
|
5378
5691
|
var formatTransferToContractScriptData = (params) => {
|
5379
5692
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5380
5693
|
const numberCoder = new BigNumberCoder2("u64");
|
5381
|
-
const encoded = numberCoder.encode(new
|
5694
|
+
const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
|
5382
5695
|
const scriptData = Uint8Array.from([
|
5383
5696
|
...arrayify13(hexlifiedContractId),
|
5384
5697
|
...encoded,
|
@@ -5407,7 +5720,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
5407
5720
|
};
|
5408
5721
|
|
5409
5722
|
// src/account.ts
|
5410
|
-
var MAX_FUNDING_ATTEMPTS =
|
5723
|
+
var MAX_FUNDING_ATTEMPTS = 5;
|
5411
5724
|
var Account = class extends AbstractAccount {
|
5412
5725
|
/**
|
5413
5726
|
* The address associated with the account.
|
@@ -5443,7 +5756,7 @@ var Account = class extends AbstractAccount {
|
|
5443
5756
|
*/
|
5444
5757
|
get provider() {
|
5445
5758
|
if (!this._provider) {
|
5446
|
-
throw new
|
5759
|
+
throw new FuelError16(ErrorCode15.MISSING_PROVIDER, "Provider not set");
|
5447
5760
|
}
|
5448
5761
|
return this._provider;
|
5449
5762
|
}
|
@@ -5520,7 +5833,7 @@ var Account = class extends AbstractAccount {
|
|
5520
5833
|
* @returns A promise that resolves to the funded transaction request.
|
5521
5834
|
*/
|
5522
5835
|
async fund(request, params) {
|
5523
|
-
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5836
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
|
5524
5837
|
const fee = request.maxFee;
|
5525
5838
|
const baseAssetId = this.provider.getBaseAssetId();
|
5526
5839
|
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
@@ -5568,10 +5881,12 @@ var Account = class extends AbstractAccount {
|
|
5568
5881
|
);
|
5569
5882
|
}
|
5570
5883
|
if (!updateMaxFee) {
|
5884
|
+
needsToBeFunded = false;
|
5571
5885
|
break;
|
5572
5886
|
}
|
5573
5887
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5574
|
-
transactionRequest: requestToReestimate2
|
5888
|
+
transactionRequest: requestToReestimate2,
|
5889
|
+
gasPrice
|
5575
5890
|
});
|
5576
5891
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5577
5892
|
request.inputs,
|
@@ -5591,6 +5906,12 @@ var Account = class extends AbstractAccount {
|
|
5591
5906
|
}
|
5592
5907
|
fundingAttempts += 1;
|
5593
5908
|
}
|
5909
|
+
if (needsToBeFunded) {
|
5910
|
+
throw new FuelError16(
|
5911
|
+
ErrorCode15.NOT_ENOUGH_FUNDS,
|
5912
|
+
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
5913
|
+
);
|
5914
|
+
}
|
5594
5915
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5595
5916
|
const requestToReestimate = clone4(request);
|
5596
5917
|
if (addedSignatures) {
|
@@ -5692,7 +6013,7 @@ var Account = class extends AbstractAccount {
|
|
5692
6013
|
*/
|
5693
6014
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5694
6015
|
if (bn19(amount).lte(0)) {
|
5695
|
-
throw new
|
6016
|
+
throw new FuelError16(
|
5696
6017
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5697
6018
|
"Transfer amount must be a positive number."
|
5698
6019
|
);
|
@@ -5773,10 +6094,34 @@ var Account = class extends AbstractAccount {
|
|
5773
6094
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
5774
6095
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
5775
6096
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
|
5776
|
-
const
|
5777
|
-
|
6097
|
+
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6098
|
+
if ("assetId" in input) {
|
6099
|
+
return input.assetId === assetId;
|
6100
|
+
}
|
6101
|
+
if ("recipient" in input) {
|
6102
|
+
return baseAssetId === assetId;
|
6103
|
+
}
|
6104
|
+
return false;
|
6105
|
+
});
|
6106
|
+
const updateAssetInput = (assetId, quantity) => {
|
6107
|
+
const assetInput = findAssetInput(assetId);
|
6108
|
+
const usedQuantity = quantity;
|
6109
|
+
if (assetInput && "amount" in assetInput) {
|
6110
|
+
assetInput.amount = usedQuantity;
|
6111
|
+
} else {
|
6112
|
+
txRequestClone.addResources(
|
6113
|
+
this.generateFakeResources([
|
6114
|
+
{
|
6115
|
+
amount: quantity,
|
6116
|
+
assetId
|
6117
|
+
}
|
6118
|
+
])
|
6119
|
+
);
|
6120
|
+
}
|
6121
|
+
};
|
6122
|
+
mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
|
6123
|
+
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
5778
6124
|
);
|
5779
|
-
txRequestClone.addResources(resources);
|
5780
6125
|
const txCost = await this.provider.getTransactionCost(txRequestClone, {
|
5781
6126
|
signatureCallback
|
5782
6127
|
});
|
@@ -5795,7 +6140,7 @@ var Account = class extends AbstractAccount {
|
|
5795
6140
|
*/
|
5796
6141
|
async signMessage(message) {
|
5797
6142
|
if (!this._connector) {
|
5798
|
-
throw new
|
6143
|
+
throw new FuelError16(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
5799
6144
|
}
|
5800
6145
|
return this._connector.signMessage(this.address.toString(), message);
|
5801
6146
|
}
|
@@ -5807,7 +6152,7 @@ var Account = class extends AbstractAccount {
|
|
5807
6152
|
*/
|
5808
6153
|
async signTransaction(transactionRequestLike) {
|
5809
6154
|
if (!this._connector) {
|
5810
|
-
throw new
|
6155
|
+
throw new FuelError16(
|
5811
6156
|
ErrorCode15.MISSING_CONNECTOR,
|
5812
6157
|
"A connector is required to sign transactions."
|
5813
6158
|
);
|
@@ -5867,7 +6212,7 @@ var Account = class extends AbstractAccount {
|
|
5867
6212
|
/** @hidden * */
|
5868
6213
|
validateTransferAmount(amount) {
|
5869
6214
|
if (bn19(amount).lte(0)) {
|
5870
|
-
throw new
|
6215
|
+
throw new FuelError16(
|
5871
6216
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5872
6217
|
"Transfer amount must be a positive number."
|
5873
6218
|
);
|
@@ -5897,7 +6242,7 @@ var Account = class extends AbstractAccount {
|
|
5897
6242
|
if (!isDefined3(setGasLimit)) {
|
5898
6243
|
request.gasLimit = gasUsed;
|
5899
6244
|
} else if (gasUsed.gt(setGasLimit)) {
|
5900
|
-
throw new
|
6245
|
+
throw new FuelError16(
|
5901
6246
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5902
6247
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5903
6248
|
);
|
@@ -5905,7 +6250,7 @@ var Account = class extends AbstractAccount {
|
|
5905
6250
|
if (!isDefined3(setMaxFee)) {
|
5906
6251
|
request.maxFee = maxFee;
|
5907
6252
|
} else if (maxFee.gt(setMaxFee)) {
|
5908
|
-
throw new
|
6253
|
+
throw new FuelError16(
|
5909
6254
|
ErrorCode15.MAX_FEE_TOO_LOW,
|
5910
6255
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5911
6256
|
);
|
@@ -6036,11 +6381,11 @@ import {
|
|
6036
6381
|
scrypt,
|
6037
6382
|
stringFromBuffer,
|
6038
6383
|
decryptJsonWalletData,
|
6039
|
-
encryptJsonWalletData
|
6384
|
+
encryptJsonWalletData,
|
6385
|
+
randomUUID
|
6040
6386
|
} from "@fuel-ts/crypto";
|
6041
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
6387
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
|
6042
6388
|
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
6043
|
-
import { v4 as uuidv4 } from "uuid";
|
6044
6389
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6045
6390
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6046
6391
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6070,7 +6415,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
6070
6415
|
const macHashUint8Array = keccak256(data);
|
6071
6416
|
const mac = stringFromBuffer(macHashUint8Array, "hex");
|
6072
6417
|
const keystore = {
|
6073
|
-
id:
|
6418
|
+
id: randomUUID(),
|
6074
6419
|
version: 3,
|
6075
6420
|
address: removeHexPrefix(ownerAddress.toHexString()),
|
6076
6421
|
crypto: {
|
@@ -6116,7 +6461,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6116
6461
|
const macHashUint8Array = keccak256(data);
|
6117
6462
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6118
6463
|
if (mac !== macHash) {
|
6119
|
-
throw new
|
6464
|
+
throw new FuelError17(
|
6120
6465
|
ErrorCode16.INVALID_PASSWORD,
|
6121
6466
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6122
6467
|
);
|
@@ -6247,14 +6592,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6247
6592
|
|
6248
6593
|
// src/hdwallet/hdwallet.ts
|
6249
6594
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6250
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
6595
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6251
6596
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6252
6597
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6253
6598
|
import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6254
6599
|
|
6255
6600
|
// src/mnemonic/mnemonic.ts
|
6256
6601
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6257
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
6602
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
|
6258
6603
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6259
6604
|
import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6260
6605
|
|
@@ -8317,7 +8662,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8317
8662
|
})(Language || {});
|
8318
8663
|
|
8319
8664
|
// src/mnemonic/utils.ts
|
8320
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
8665
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
8321
8666
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8322
8667
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
8323
8668
|
function getLowerMask(bits) {
|
@@ -8366,7 +8711,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8366
8711
|
for (let i = 0; i < words.length; i += 1) {
|
8367
8712
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8368
8713
|
if (index === -1) {
|
8369
|
-
throw new
|
8714
|
+
throw new FuelError18(
|
8370
8715
|
ErrorCode17.INVALID_MNEMONIC,
|
8371
8716
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8372
8717
|
);
|
@@ -8383,7 +8728,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8383
8728
|
const checksumMask = getUpperMask(checksumBits);
|
8384
8729
|
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8385
8730
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8386
|
-
throw new
|
8731
|
+
throw new FuelError18(
|
8387
8732
|
ErrorCode17.INVALID_CHECKSUM,
|
8388
8733
|
"Checksum validation failed for the provided mnemonic."
|
8389
8734
|
);
|
@@ -8398,7 +8743,7 @@ var TestnetPRV = "0x04358394";
|
|
8398
8743
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8399
8744
|
function assertWordList(wordlist) {
|
8400
8745
|
if (wordlist.length !== 2048) {
|
8401
|
-
throw new
|
8746
|
+
throw new FuelError19(
|
8402
8747
|
ErrorCode18.INVALID_WORD_LIST,
|
8403
8748
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8404
8749
|
);
|
@@ -8406,7 +8751,7 @@ function assertWordList(wordlist) {
|
|
8406
8751
|
}
|
8407
8752
|
function assertEntropy(entropy) {
|
8408
8753
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8409
|
-
throw new
|
8754
|
+
throw new FuelError19(
|
8410
8755
|
ErrorCode18.INVALID_ENTROPY,
|
8411
8756
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8412
8757
|
);
|
@@ -8417,7 +8762,7 @@ function assertMnemonic(words) {
|
|
8417
8762
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8418
8763
|
", "
|
8419
8764
|
)}] words, but got ${words.length}.`;
|
8420
|
-
throw new
|
8765
|
+
throw new FuelError19(ErrorCode18.INVALID_MNEMONIC, errorMsg);
|
8421
8766
|
}
|
8422
8767
|
}
|
8423
8768
|
var Mnemonic = class {
|
@@ -8535,7 +8880,7 @@ var Mnemonic = class {
|
|
8535
8880
|
static masterKeysFromSeed(seed) {
|
8536
8881
|
const seedArray = arrayify17(seed);
|
8537
8882
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8538
|
-
throw new
|
8883
|
+
throw new FuelError19(
|
8539
8884
|
ErrorCode18.INVALID_SEED,
|
8540
8885
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8541
8886
|
);
|
@@ -8613,7 +8958,7 @@ function isValidExtendedKey(extendedKey) {
|
|
8613
8958
|
function parsePath(path, depth = 0) {
|
8614
8959
|
const components = path.split("/");
|
8615
8960
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
8616
|
-
throw new
|
8961
|
+
throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
|
8617
8962
|
}
|
8618
8963
|
if (components[0] === "m") {
|
8619
8964
|
components.shift();
|
@@ -8642,7 +8987,7 @@ var HDWallet = class {
|
|
8642
8987
|
this.privateKey = hexlify18(config.privateKey);
|
8643
8988
|
} else {
|
8644
8989
|
if (!config.publicKey) {
|
8645
|
-
throw new
|
8990
|
+
throw new FuelError20(
|
8646
8991
|
ErrorCode19.HD_WALLET_ERROR,
|
8647
8992
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8648
8993
|
);
|
@@ -8672,7 +9017,7 @@ var HDWallet = class {
|
|
8672
9017
|
const data = new Uint8Array(37);
|
8673
9018
|
if (index & HARDENED_INDEX) {
|
8674
9019
|
if (!privateKey) {
|
8675
|
-
throw new
|
9020
|
+
throw new FuelError20(
|
8676
9021
|
ErrorCode19.HD_WALLET_ERROR,
|
8677
9022
|
"Cannot derive a hardened index without a private Key."
|
8678
9023
|
);
|
@@ -8725,7 +9070,7 @@ var HDWallet = class {
|
|
8725
9070
|
*/
|
8726
9071
|
toExtendedKey(isPublic = false, testnet = false) {
|
8727
9072
|
if (this.depth >= 256) {
|
8728
|
-
throw new
|
9073
|
+
throw new FuelError20(
|
8729
9074
|
ErrorCode19.HD_WALLET_ERROR,
|
8730
9075
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
8731
9076
|
);
|
@@ -8757,10 +9102,10 @@ var HDWallet = class {
|
|
8757
9102
|
const bytes = arrayify18(decoded);
|
8758
9103
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8759
9104
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8760
|
-
throw new
|
9105
|
+
throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
8761
9106
|
}
|
8762
9107
|
if (!validChecksum) {
|
8763
|
-
throw new
|
9108
|
+
throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8764
9109
|
}
|
8765
9110
|
const depth = bytes[4];
|
8766
9111
|
const parentFingerprint = hexlify18(bytes.slice(5, 9));
|
@@ -8768,14 +9113,14 @@ var HDWallet = class {
|
|
8768
9113
|
const chainCode = hexlify18(bytes.slice(13, 45));
|
8769
9114
|
const key = bytes.slice(45, 78);
|
8770
9115
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8771
|
-
throw new
|
9116
|
+
throw new FuelError20(
|
8772
9117
|
ErrorCode19.HD_WALLET_ERROR,
|
8773
9118
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
8774
9119
|
);
|
8775
9120
|
}
|
8776
9121
|
if (isPublicExtendedKey(bytes)) {
|
8777
9122
|
if (key[0] !== 3) {
|
8778
|
-
throw new
|
9123
|
+
throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
|
8779
9124
|
}
|
8780
9125
|
return new HDWallet({
|
8781
9126
|
publicKey: key,
|
@@ -8786,7 +9131,7 @@ var HDWallet = class {
|
|
8786
9131
|
});
|
8787
9132
|
}
|
8788
9133
|
if (key[0] !== 0) {
|
8789
|
-
throw new
|
9134
|
+
throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
|
8790
9135
|
}
|
8791
9136
|
return new HDWallet({
|
8792
9137
|
privateKey: key.slice(1),
|
@@ -8954,7 +9299,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8954
9299
|
// src/wallet-manager/wallet-manager.ts
|
8955
9300
|
import { Address as Address8 } from "@fuel-ts/address";
|
8956
9301
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
8957
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
9302
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
|
8958
9303
|
import { EventEmitter } from "events";
|
8959
9304
|
|
8960
9305
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -8977,7 +9322,7 @@ var MemoryStorage = class {
|
|
8977
9322
|
|
8978
9323
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
8979
9324
|
import { Address as Address6 } from "@fuel-ts/address";
|
8980
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
9325
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
|
8981
9326
|
var _secret;
|
8982
9327
|
var MnemonicVault = class {
|
8983
9328
|
constructor(options) {
|
@@ -9033,7 +9378,7 @@ var MnemonicVault = class {
|
|
9033
9378
|
}
|
9034
9379
|
numberOfAccounts += 1;
|
9035
9380
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9036
|
-
throw new
|
9381
|
+
throw new FuelError21(
|
9037
9382
|
ErrorCode20.WALLET_MANAGER_ERROR,
|
9038
9383
|
`Account with address '${address}' not found in derived wallets.`
|
9039
9384
|
);
|
@@ -9048,7 +9393,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9048
9393
|
|
9049
9394
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9050
9395
|
import { Address as Address7 } from "@fuel-ts/address";
|
9051
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
9396
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
|
9052
9397
|
var _privateKeys;
|
9053
9398
|
var PrivateKeyVault = class {
|
9054
9399
|
/**
|
@@ -9089,7 +9434,7 @@ var PrivateKeyVault = class {
|
|
9089
9434
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9090
9435
|
);
|
9091
9436
|
if (!privateKey) {
|
9092
|
-
throw new
|
9437
|
+
throw new FuelError22(
|
9093
9438
|
ErrorCode21.WALLET_MANAGER_ERROR,
|
9094
9439
|
`No private key found for address '${address}'.`
|
9095
9440
|
);
|
@@ -9114,7 +9459,7 @@ var ERROR_MESSAGES = {
|
|
9114
9459
|
};
|
9115
9460
|
function assert(condition, message) {
|
9116
9461
|
if (!condition) {
|
9117
|
-
throw new
|
9462
|
+
throw new FuelError23(ErrorCode22.WALLET_MANAGER_ERROR, message);
|
9118
9463
|
}
|
9119
9464
|
}
|
9120
9465
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9340,25 +9685,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9340
9685
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9341
9686
|
|
9342
9687
|
// src/wallet-manager/types.ts
|
9343
|
-
import { ErrorCode as ErrorCode23, FuelError as
|
9688
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9344
9689
|
var Vault = class {
|
9345
9690
|
constructor(_options) {
|
9346
|
-
throw new
|
9691
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9347
9692
|
}
|
9348
9693
|
serialize() {
|
9349
|
-
throw new
|
9694
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9350
9695
|
}
|
9351
9696
|
getAccounts() {
|
9352
|
-
throw new
|
9697
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9353
9698
|
}
|
9354
9699
|
addAccount() {
|
9355
|
-
throw new
|
9700
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9356
9701
|
}
|
9357
9702
|
exportAccount(_address) {
|
9358
|
-
throw new
|
9703
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9359
9704
|
}
|
9360
9705
|
getWallet(_address) {
|
9361
|
-
throw new
|
9706
|
+
throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
|
9362
9707
|
}
|
9363
9708
|
};
|
9364
9709
|
__publicField(Vault, "type");
|
@@ -9368,7 +9713,7 @@ var StorageAbstract = class {
|
|
9368
9713
|
// src/predicate/predicate.ts
|
9369
9714
|
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9370
9715
|
import { Address as Address9 } from "@fuel-ts/address";
|
9371
|
-
import { ErrorCode as ErrorCode24, FuelError as
|
9716
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
|
9372
9717
|
import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
|
9373
9718
|
|
9374
9719
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9395,14 +9740,14 @@ var Predicate = class extends Account {
|
|
9395
9740
|
* @param bytecode - The bytecode of the predicate.
|
9396
9741
|
* @param abi - The JSON ABI of the predicate.
|
9397
9742
|
* @param provider - The provider used to interact with the blockchain.
|
9398
|
-
* @param
|
9743
|
+
* @param data - The predicate input data (optional).
|
9399
9744
|
* @param configurableConstants - Optional configurable constants for the predicate.
|
9400
9745
|
*/
|
9401
9746
|
constructor({
|
9402
9747
|
bytecode,
|
9403
9748
|
abi,
|
9404
9749
|
provider,
|
9405
|
-
|
9750
|
+
data,
|
9406
9751
|
configurableConstants
|
9407
9752
|
}) {
|
9408
9753
|
const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
|
@@ -9414,8 +9759,8 @@ var Predicate = class extends Account {
|
|
9414
9759
|
super(address, provider);
|
9415
9760
|
this.bytes = predicateBytes;
|
9416
9761
|
this.interface = predicateInterface;
|
9417
|
-
if (
|
9418
|
-
this.predicateData =
|
9762
|
+
if (data !== void 0 && data.length > 0) {
|
9763
|
+
this.predicateData = data;
|
9419
9764
|
}
|
9420
9765
|
}
|
9421
9766
|
/**
|
@@ -9480,7 +9825,7 @@ var Predicate = class extends Account {
|
|
9480
9825
|
if (jsonAbi) {
|
9481
9826
|
abiInterface = new Interface4(jsonAbi);
|
9482
9827
|
if (abiInterface.functions.main === void 0) {
|
9483
|
-
throw new
|
9828
|
+
throw new FuelError25(
|
9484
9829
|
ErrorCode24.ABI_MAIN_METHOD_MISSING,
|
9485
9830
|
'Cannot use ABI without "main" function.'
|
9486
9831
|
);
|
@@ -9542,23 +9887,30 @@ var Predicate = class extends Account {
|
|
9542
9887
|
const mutatedBytes = bytes;
|
9543
9888
|
try {
|
9544
9889
|
if (!abiInterface) {
|
9545
|
-
throw new
|
9890
|
+
throw new FuelError25(
|
9891
|
+
ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
|
9546
9892
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
9547
9893
|
);
|
9548
9894
|
}
|
9549
9895
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
9550
|
-
throw new
|
9896
|
+
throw new FuelError25(
|
9897
|
+
ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
|
9898
|
+
"Predicate has no configurable constants to be set"
|
9899
|
+
);
|
9551
9900
|
}
|
9552
9901
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
9553
9902
|
if (!abiInterface?.configurables[key]) {
|
9554
|
-
throw new
|
9903
|
+
throw new FuelError25(
|
9904
|
+
ErrorCode24.CONFIGURABLE_NOT_FOUND,
|
9905
|
+
`No configurable constant named '${key}' found in the Predicate`
|
9906
|
+
);
|
9555
9907
|
}
|
9556
9908
|
const { offset } = abiInterface.configurables[key];
|
9557
9909
|
const encoded = abiInterface.encodeConfigurable(key, value);
|
9558
9910
|
mutatedBytes.set(encoded, offset);
|
9559
9911
|
});
|
9560
9912
|
} catch (err) {
|
9561
|
-
throw new
|
9913
|
+
throw new FuelError25(
|
9562
9914
|
ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
|
9563
9915
|
`Error setting configurable constants: ${err.message}.`
|
9564
9916
|
);
|
@@ -9590,9 +9942,10 @@ var Predicate = class extends Account {
|
|
9590
9942
|
};
|
9591
9943
|
|
9592
9944
|
// src/connectors/fuel.ts
|
9593
|
-
import { ErrorCode as ErrorCode25, FuelError as
|
9945
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError28 } from "@fuel-ts/errors";
|
9594
9946
|
|
9595
9947
|
// src/connectors/fuel-connector.ts
|
9948
|
+
import { FuelError as FuelError26 } from "@fuel-ts/errors";
|
9596
9949
|
import { EventEmitter as EventEmitter2 } from "events";
|
9597
9950
|
|
9598
9951
|
// src/connectors/types/connector-types.ts
|
@@ -9666,7 +10019,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9666
10019
|
* @returns Always true.
|
9667
10020
|
*/
|
9668
10021
|
async ping() {
|
9669
|
-
throw new
|
10022
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9670
10023
|
}
|
9671
10024
|
/**
|
9672
10025
|
* Should return the current version of the connector
|
@@ -9675,7 +10028,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9675
10028
|
* @returns boolean - connection status.
|
9676
10029
|
*/
|
9677
10030
|
async version() {
|
9678
|
-
throw new
|
10031
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9679
10032
|
}
|
9680
10033
|
/**
|
9681
10034
|
* Should return true if the connector is connected
|
@@ -9684,7 +10037,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9684
10037
|
* @returns The connection status.
|
9685
10038
|
*/
|
9686
10039
|
async isConnected() {
|
9687
|
-
throw new
|
10040
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9688
10041
|
}
|
9689
10042
|
/**
|
9690
10043
|
* Should return all the accounts authorized for the
|
@@ -9693,7 +10046,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9693
10046
|
* @returns The accounts addresses strings
|
9694
10047
|
*/
|
9695
10048
|
async accounts() {
|
9696
|
-
throw new
|
10049
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9697
10050
|
}
|
9698
10051
|
/**
|
9699
10052
|
* Should start the connection process and return
|
@@ -9705,7 +10058,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9705
10058
|
* @returns boolean - connection status.
|
9706
10059
|
*/
|
9707
10060
|
async connect() {
|
9708
|
-
throw new
|
10061
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9709
10062
|
}
|
9710
10063
|
/**
|
9711
10064
|
* Should disconnect the current connection and
|
@@ -9715,7 +10068,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9715
10068
|
* @returns The connection status.
|
9716
10069
|
*/
|
9717
10070
|
async disconnect() {
|
9718
|
-
throw new
|
10071
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9719
10072
|
}
|
9720
10073
|
/**
|
9721
10074
|
* Should start the sign message process and return
|
@@ -9727,7 +10080,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9727
10080
|
* @returns Message signature
|
9728
10081
|
*/
|
9729
10082
|
async signMessage(_address, _message) {
|
9730
|
-
throw new
|
10083
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9731
10084
|
}
|
9732
10085
|
/**
|
9733
10086
|
* Should start the sign transaction process and return
|
@@ -9739,7 +10092,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9739
10092
|
* @returns Transaction signature
|
9740
10093
|
*/
|
9741
10094
|
async signTransaction(_address, _transaction) {
|
9742
|
-
throw new
|
10095
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9743
10096
|
}
|
9744
10097
|
/**
|
9745
10098
|
* Should start the send transaction process and return
|
@@ -9755,7 +10108,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9755
10108
|
* @returns The transaction id
|
9756
10109
|
*/
|
9757
10110
|
async sendTransaction(_address, _transaction) {
|
9758
|
-
throw new
|
10111
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9759
10112
|
}
|
9760
10113
|
/**
|
9761
10114
|
* Should return the current account selected inside the connector, if the account
|
@@ -9766,7 +10119,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9766
10119
|
* @returns The current account selected otherwise null.
|
9767
10120
|
*/
|
9768
10121
|
async currentAccount() {
|
9769
|
-
throw new
|
10122
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9770
10123
|
}
|
9771
10124
|
/**
|
9772
10125
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -9780,7 +10133,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9780
10133
|
* @returns True if the asset was added successfully
|
9781
10134
|
*/
|
9782
10135
|
async addAssets(_assets) {
|
9783
|
-
throw new
|
10136
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9784
10137
|
}
|
9785
10138
|
/**
|
9786
10139
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -9794,7 +10147,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9794
10147
|
* @returns True if the asset was added successfully
|
9795
10148
|
*/
|
9796
10149
|
async addAsset(_asset) {
|
9797
|
-
throw new
|
10150
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9798
10151
|
}
|
9799
10152
|
/**
|
9800
10153
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -9802,7 +10155,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9802
10155
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
9803
10156
|
*/
|
9804
10157
|
async assets() {
|
9805
|
-
throw new
|
10158
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9806
10159
|
}
|
9807
10160
|
/**
|
9808
10161
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -9813,7 +10166,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9813
10166
|
* @returns Return true if the network was added successfully
|
9814
10167
|
*/
|
9815
10168
|
async addNetwork(_networkUrl) {
|
9816
|
-
throw new
|
10169
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9817
10170
|
}
|
9818
10171
|
/**
|
9819
10172
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -9824,7 +10177,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9824
10177
|
* @returns Return true if the network was added successfully
|
9825
10178
|
*/
|
9826
10179
|
async selectNetwork(_network) {
|
9827
|
-
throw new
|
10180
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9828
10181
|
}
|
9829
10182
|
/**
|
9830
10183
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -9832,7 +10185,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9832
10185
|
* @returns Return all the networks added to the connector.
|
9833
10186
|
*/
|
9834
10187
|
async networks() {
|
9835
|
-
throw new
|
10188
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9836
10189
|
}
|
9837
10190
|
/**
|
9838
10191
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -9840,7 +10193,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9840
10193
|
* @returns Return the current network selected inside the connector.
|
9841
10194
|
*/
|
9842
10195
|
async currentNetwork() {
|
9843
|
-
throw new
|
10196
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9844
10197
|
}
|
9845
10198
|
/**
|
9846
10199
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -9850,7 +10203,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9850
10203
|
* @returns Return true if the ABI was added successfully.
|
9851
10204
|
*/
|
9852
10205
|
async addABI(_contractId, _abi) {
|
9853
|
-
throw new
|
10206
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9854
10207
|
}
|
9855
10208
|
/**
|
9856
10209
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -9859,7 +10212,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9859
10212
|
* @returns The ABI if it exists, otherwise return null.
|
9860
10213
|
*/
|
9861
10214
|
async getABI(_id) {
|
9862
|
-
throw new
|
10215
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9863
10216
|
}
|
9864
10217
|
/**
|
9865
10218
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -9868,7 +10221,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
9868
10221
|
* @returns Returns true if the abi exists or false if not.
|
9869
10222
|
*/
|
9870
10223
|
async hasABI(_id) {
|
9871
|
-
throw new
|
10224
|
+
throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9872
10225
|
}
|
9873
10226
|
/**
|
9874
10227
|
* Event listener for the connector.
|
@@ -9912,6 +10265,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
9912
10265
|
}
|
9913
10266
|
|
9914
10267
|
// src/connectors/utils/promises.ts
|
10268
|
+
import { FuelError as FuelError27 } from "@fuel-ts/errors";
|
9915
10269
|
function deferPromise() {
|
9916
10270
|
const defer = {};
|
9917
10271
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -9923,7 +10277,7 @@ function deferPromise() {
|
|
9923
10277
|
async function withTimeout(promise, timeout = 1050) {
|
9924
10278
|
const timeoutPromise = new Promise((resolve, reject) => {
|
9925
10279
|
setTimeout(() => {
|
9926
|
-
reject(new
|
10280
|
+
reject(new FuelError27(FuelError27.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
9927
10281
|
}, timeout);
|
9928
10282
|
});
|
9929
10283
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10010,7 +10364,8 @@ var _Fuel = class extends FuelConnector {
|
|
10010
10364
|
const hasConnector = await this.hasConnector();
|
10011
10365
|
await this.pingConnector();
|
10012
10366
|
if (!this._currentConnector || !hasConnector) {
|
10013
|
-
throw new
|
10367
|
+
throw new FuelError28(
|
10368
|
+
ErrorCode25.MISSING_CONNECTOR,
|
10014
10369
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10015
10370
|
);
|
10016
10371
|
}
|
@@ -10074,7 +10429,7 @@ var _Fuel = class extends FuelConnector {
|
|
10074
10429
|
cacheTime: PING_CACHE_TIME
|
10075
10430
|
})();
|
10076
10431
|
} catch {
|
10077
|
-
throw new
|
10432
|
+
throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Current connector is not available.");
|
10078
10433
|
}
|
10079
10434
|
}
|
10080
10435
|
/**
|
@@ -10223,7 +10578,7 @@ var _Fuel = class extends FuelConnector {
|
|
10223
10578
|
const currentNetwork = await this.currentNetwork();
|
10224
10579
|
provider = await Provider.create(currentNetwork.url);
|
10225
10580
|
} else {
|
10226
|
-
throw new
|
10581
|
+
throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
|
10227
10582
|
}
|
10228
10583
|
return provider;
|
10229
10584
|
}
|
@@ -10267,11 +10622,12 @@ export {
|
|
10267
10622
|
BLOCKS_PAGE_SIZE_LIMIT,
|
10268
10623
|
BaseTransactionRequest,
|
10269
10624
|
BaseWalletUnlocked,
|
10625
|
+
BlobTransactionRequest,
|
10270
10626
|
CHAIN_IDS,
|
10271
10627
|
ChainName,
|
10272
10628
|
ChangeOutputCollisionError,
|
10273
10629
|
CreateTransactionRequest,
|
10274
|
-
|
10630
|
+
DEFAULT_RESOURCE_CACHE_TTL,
|
10275
10631
|
Fuel,
|
10276
10632
|
FuelConnector,
|
10277
10633
|
FuelConnectorEventType,
|
@@ -10305,6 +10661,7 @@ export {
|
|
10305
10661
|
WalletUnlocked,
|
10306
10662
|
addAmountToCoinQuantities,
|
10307
10663
|
addOperation,
|
10664
|
+
aggregateInputsAmountsByAssetAndOwner,
|
10308
10665
|
assemblePanicError,
|
10309
10666
|
assembleReceiptByType,
|
10310
10667
|
assembleRevertError,
|
@@ -10315,6 +10672,7 @@ export {
|
|
10315
10672
|
cacheRequestInputsResources,
|
10316
10673
|
cacheRequestInputsResourcesFromOwner,
|
10317
10674
|
calculateGasFee,
|
10675
|
+
calculateMetadataGasForTxBlob,
|
10318
10676
|
calculateMetadataGasForTxCreate,
|
10319
10677
|
calculateMetadataGasForTxScript,
|
10320
10678
|
calculateTXFeeForSummary,
|
@@ -10373,6 +10731,7 @@ export {
|
|
10373
10731
|
hasSameAssetId,
|
10374
10732
|
inputify,
|
10375
10733
|
isCoin,
|
10734
|
+
isInputCoin,
|
10376
10735
|
isMessage,
|
10377
10736
|
isRawCoin,
|
10378
10737
|
isRawMessage,
|
@@ -10380,7 +10739,11 @@ export {
|
|
10380
10739
|
isRequestInputMessage,
|
10381
10740
|
isRequestInputResource,
|
10382
10741
|
isRequestInputResourceFromOwner,
|
10742
|
+
isTransactionTypeBlob,
|
10743
|
+
isTransactionTypeCreate,
|
10744
|
+
isTransactionTypeScript,
|
10383
10745
|
isType,
|
10746
|
+
isTypeBlob,
|
10384
10747
|
isTypeCreate,
|
10385
10748
|
isTypeMint,
|
10386
10749
|
isTypeScript,
|