@fuel-ts/account 0.74.0 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +2 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +1 -2
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +0 -8
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/events.d.ts +2 -36
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/connectors/types/index.d.ts +0 -2
- package/dist/connectors/types/index.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1554 -2272
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +576 -451
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +495 -385
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +38 -38
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/index.d.ts +4 -0
- package/dist/providers/assets/index.d.ts.map +1 -0
- package/dist/providers/assets/types.d.ts +36 -0
- package/dist/providers/assets/types.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +4 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -0
- package/dist/providers/assets/utils/network.d.ts +33 -0
- package/dist/providers/assets/utils/network.d.ts.map +1 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/providers/assets/utils/url.d.ts +2 -0
- package/dist/providers/assets/utils/url.d.ts.map +1 -0
- package/dist/providers/chains.d.ts +11 -0
- package/dist/providers/chains.d.ts.map +1 -0
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +13 -3
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/memory-cache.d.ts +1 -1
- package/dist/providers/memory-cache.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +18 -8
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -10
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +0 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +0 -2
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/output.d.ts +2 -2
- package/dist/providers/transaction-summary/output.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +0 -1
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +4098 -4882
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +466 -416
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +390 -352
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +1 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/package.json +16 -16
- package/dist/connectors/types/asset.d.ts +0 -2
- package/dist/connectors/types/asset.d.ts.map +0 -1
- package/dist/connectors/types/constants.d.ts +0 -7
- package/dist/connectors/types/constants.d.ts.map +0 -1
- package/dist/connectors/types/message.d.ts +0 -15
- package/dist/connectors/types/message.d.ts.map +0 -1
- package/dist/providers/transaction-summary/date.d.ts +0 -3
- package/dist/providers/transaction-summary/date.d.ts.map +0 -1
- package/dist/providers/utils/time.d.ts +0 -40
- package/dist/providers/utils/time.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -61,6 +61,7 @@ __export(src_exports, {
|
|
61
61
|
AddressType: () => AddressType,
|
62
62
|
BaseTransactionRequest: () => BaseTransactionRequest,
|
63
63
|
BaseWalletUnlocked: () => BaseWalletUnlocked,
|
64
|
+
CHAIN_IDS: () => CHAIN_IDS,
|
64
65
|
ChainName: () => ChainName,
|
65
66
|
ChangeOutputCollisionError: () => ChangeOutputCollisionError,
|
66
67
|
CreateTransactionRequest: () => CreateTransactionRequest,
|
@@ -74,7 +75,6 @@ __export(src_exports, {
|
|
74
75
|
LocalStorage: () => LocalStorage,
|
75
76
|
MNEMONIC_SIZES: () => MNEMONIC_SIZES,
|
76
77
|
MemoryStorage: () => MemoryStorage,
|
77
|
-
MessageTypes: () => MessageTypes,
|
78
78
|
Mnemonic: () => mnemonic_default,
|
79
79
|
MnemonicVault: () => MnemonicVault,
|
80
80
|
NoWitnessAtIndexError: () => NoWitnessAtIndexError,
|
@@ -99,6 +99,7 @@ __export(src_exports, {
|
|
99
99
|
addOperation: () => addOperation,
|
100
100
|
assembleReceiptByType: () => assembleReceiptByType,
|
101
101
|
assembleTransactionSummary: () => assembleTransactionSummary,
|
102
|
+
assets: () => assets,
|
102
103
|
buildBlockExplorerUrl: () => buildBlockExplorerUrl,
|
103
104
|
cacheFor: () => cacheFor,
|
104
105
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
@@ -111,15 +112,15 @@ __export(src_exports, {
|
|
111
112
|
english: () => english,
|
112
113
|
extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
|
113
114
|
extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
|
114
|
-
fromDateToTai64: () => fromDateToTai64,
|
115
|
-
fromTai64ToDate: () => fromTai64ToDate,
|
116
|
-
fromTai64ToUnix: () => fromTai64ToUnix,
|
117
|
-
fromUnixToTai64: () => fromUnixToTai64,
|
118
115
|
gasUsedByInputs: () => gasUsedByInputs,
|
116
|
+
getAssetEth: () => getAssetEth,
|
117
|
+
getAssetFuel: () => getAssetFuel,
|
118
|
+
getAssetNetwork: () => getAssetNetwork,
|
119
|
+
getAssetWithNetwork: () => getAssetWithNetwork,
|
119
120
|
getContractCallOperations: () => getContractCallOperations,
|
120
121
|
getContractCreatedOperations: () => getContractCreatedOperations,
|
121
|
-
getContractTransferOperations: () => getContractTransferOperations,
|
122
122
|
getDecodedLogs: () => getDecodedLogs,
|
123
|
+
getDefaultChainId: () => getDefaultChainId,
|
123
124
|
getGasUsedFromReceipts: () => getGasUsedFromReceipts,
|
124
125
|
getInputAccountAddress: () => getInputAccountAddress,
|
125
126
|
getInputContractFromIndex: () => getInputContractFromIndex,
|
@@ -168,9 +169,11 @@ __export(src_exports, {
|
|
168
169
|
processGqlReceipt: () => processGqlReceipt,
|
169
170
|
processGraphqlStatus: () => processGraphqlStatus,
|
170
171
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
172
|
+
resolveIconPaths: () => resolveIconPaths,
|
171
173
|
returnZeroScript: () => returnZeroScript,
|
172
174
|
sleep: () => sleep,
|
173
175
|
transactionRequestify: () => transactionRequestify,
|
176
|
+
urlJoin: () => urlJoin,
|
174
177
|
withTimeout: () => withTimeout,
|
175
178
|
withdrawScript: () => withdrawScript
|
176
179
|
});
|
@@ -178,16 +181,16 @@ module.exports = __toCommonJS(src_exports);
|
|
178
181
|
|
179
182
|
// src/account.ts
|
180
183
|
var import_address4 = require("@fuel-ts/address");
|
181
|
-
var
|
184
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
182
185
|
var import_errors15 = require("@fuel-ts/errors");
|
183
186
|
var import_interfaces = require("@fuel-ts/interfaces");
|
184
187
|
var import_math17 = require("@fuel-ts/math");
|
185
|
-
var
|
188
|
+
var import_utils27 = require("@fuel-ts/utils");
|
186
189
|
|
187
190
|
// src/providers/coin-quantity.ts
|
188
191
|
var import_configs = require("@fuel-ts/address/configs");
|
189
192
|
var import_math = require("@fuel-ts/math");
|
190
|
-
var
|
193
|
+
var import_utils = require("@fuel-ts/utils");
|
191
194
|
var coinQuantityfy = (coinQuantityLike) => {
|
192
195
|
let assetId;
|
193
196
|
let amount;
|
@@ -203,7 +206,7 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
203
206
|
}
|
204
207
|
const bnAmount = (0, import_math.bn)(amount);
|
205
208
|
return {
|
206
|
-
assetId: (0,
|
209
|
+
assetId: (0, import_utils.hexlify)(assetId),
|
207
210
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
208
211
|
max: max2 ? (0, import_math.bn)(max2) : void 0
|
209
212
|
};
|
@@ -225,8 +228,10 @@ var import_address3 = require("@fuel-ts/address");
|
|
225
228
|
var import_errors13 = require("@fuel-ts/errors");
|
226
229
|
var import_math14 = require("@fuel-ts/math");
|
227
230
|
var import_transactions17 = require("@fuel-ts/transactions");
|
231
|
+
var import_utils22 = require("@fuel-ts/utils");
|
228
232
|
var import_versions = require("@fuel-ts/versions");
|
229
|
-
var
|
233
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
234
|
+
var import_ethers2 = require("ethers");
|
230
235
|
var import_graphql_request = require("graphql-request");
|
231
236
|
var import_ramda3 = require("ramda");
|
232
237
|
|
@@ -1035,71 +1040,67 @@ function getSdk(requester) {
|
|
1035
1040
|
// src/providers/fuel-graphql-subscriber.ts
|
1036
1041
|
var import_errors = require("@fuel-ts/errors");
|
1037
1042
|
var import_graphql = require("graphql");
|
1038
|
-
var
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
this.readableStreamController.enqueue(
|
1055
|
-
new import_errors.FuelError(
|
1056
|
-
import_errors.FuelError.CODES.INVALID_REQUEST,
|
1057
|
-
errors.map((err) => err.message).join("\n\n")
|
1058
|
-
)
|
1059
|
-
);
|
1060
|
-
} else {
|
1061
|
-
this.readableStreamController.enqueue(data);
|
1062
|
-
}
|
1063
|
-
}
|
1043
|
+
var _FuelGraphqlSubscriber = class {
|
1044
|
+
constructor(options) {
|
1045
|
+
this.options = options;
|
1046
|
+
}
|
1047
|
+
stream;
|
1048
|
+
async setStream() {
|
1049
|
+
const { url, query, variables, fetchFn } = this.options;
|
1050
|
+
const response = await fetchFn(`${url}-sub`, {
|
1051
|
+
method: "POST",
|
1052
|
+
body: JSON.stringify({
|
1053
|
+
query: (0, import_graphql.print)(query),
|
1054
|
+
variables
|
1055
|
+
}),
|
1056
|
+
headers: {
|
1057
|
+
"Content-Type": "application/json",
|
1058
|
+
Accept: "text/event-stream"
|
1064
1059
|
}
|
1065
1060
|
});
|
1061
|
+
this.stream = response.body.getReader();
|
1066
1062
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
async function* fuelGraphQLSubscriber({
|
1071
|
-
url,
|
1072
|
-
variables,
|
1073
|
-
query,
|
1074
|
-
fetchFn
|
1075
|
-
}) {
|
1076
|
-
const response = await fetchFn(`${url}-sub`, {
|
1077
|
-
method: "POST",
|
1078
|
-
body: JSON.stringify({
|
1079
|
-
query: (0, import_graphql.print)(query),
|
1080
|
-
variables
|
1081
|
-
}),
|
1082
|
-
headers: {
|
1083
|
-
"Content-Type": "application/json",
|
1084
|
-
Accept: "text/event-stream"
|
1085
|
-
}
|
1086
|
-
});
|
1087
|
-
const subscriptionStreamReader = response.body.pipeThrough(new FuelSubscriptionStream()).getReader();
|
1088
|
-
while (true) {
|
1089
|
-
const { value, done } = await subscriptionStreamReader.read();
|
1090
|
-
if (value instanceof import_errors.FuelError) {
|
1091
|
-
throw value;
|
1063
|
+
async next() {
|
1064
|
+
if (!this.stream) {
|
1065
|
+
await this.setStream();
|
1092
1066
|
}
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1067
|
+
while (true) {
|
1068
|
+
const { value, done } = await this.stream.read();
|
1069
|
+
if (done) {
|
1070
|
+
return { value, done };
|
1071
|
+
}
|
1072
|
+
const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
|
1073
|
+
if (!text.startsWith("data:")) {
|
1074
|
+
continue;
|
1075
|
+
}
|
1076
|
+
const { data, errors } = JSON.parse(text.split("data:")[1]);
|
1077
|
+
if (Array.isArray(errors)) {
|
1078
|
+
throw new import_errors.FuelError(
|
1079
|
+
import_errors.FuelError.CODES.INVALID_REQUEST,
|
1080
|
+
errors.map((err) => err.message).join("\n\n")
|
1081
|
+
);
|
1082
|
+
}
|
1083
|
+
return { value: data, done: false };
|
1096
1084
|
}
|
1097
1085
|
}
|
1098
|
-
|
1086
|
+
/**
|
1087
|
+
* Gets called when `break` is called in a `for-await-of` loop.
|
1088
|
+
*/
|
1089
|
+
async return() {
|
1090
|
+
await this.stream.cancel();
|
1091
|
+
this.stream.releaseLock();
|
1092
|
+
return { done: true, value: void 0 };
|
1093
|
+
}
|
1094
|
+
[Symbol.asyncIterator]() {
|
1095
|
+
return this;
|
1096
|
+
}
|
1097
|
+
};
|
1098
|
+
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1099
|
+
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1099
1100
|
|
1100
1101
|
// src/providers/memory-cache.ts
|
1101
1102
|
var import_errors2 = require("@fuel-ts/errors");
|
1102
|
-
var
|
1103
|
+
var import_utils2 = require("@fuel-ts/utils");
|
1103
1104
|
var cache = {};
|
1104
1105
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
1105
1106
|
var MemoryCache = class {
|
@@ -1114,7 +1115,7 @@ var MemoryCache = class {
|
|
1114
1115
|
}
|
1115
1116
|
}
|
1116
1117
|
get(value, isAutoExpiring = true) {
|
1117
|
-
const key = (0,
|
1118
|
+
const key = (0, import_utils2.hexlify)(value);
|
1118
1119
|
if (cache[key]) {
|
1119
1120
|
if (!isAutoExpiring || cache[key].expires > Date.now()) {
|
1120
1121
|
return cache[key].value;
|
@@ -1125,7 +1126,7 @@ var MemoryCache = class {
|
|
1125
1126
|
}
|
1126
1127
|
set(value) {
|
1127
1128
|
const expiresAt = Date.now() + this.ttl;
|
1128
|
-
const key = (0,
|
1129
|
+
const key = (0, import_utils2.hexlify)(value);
|
1129
1130
|
cache[key] = {
|
1130
1131
|
expires: expiresAt,
|
1131
1132
|
value
|
@@ -1151,7 +1152,7 @@ var MemoryCache = class {
|
|
1151
1152
|
}, []);
|
1152
1153
|
}
|
1153
1154
|
del(value) {
|
1154
|
-
const key = (0,
|
1155
|
+
const key = (0, import_utils2.hexlify)(value);
|
1155
1156
|
delete cache[key];
|
1156
1157
|
}
|
1157
1158
|
};
|
@@ -1161,31 +1162,31 @@ var import_configs2 = require("@fuel-ts/address/configs");
|
|
1161
1162
|
var import_errors3 = require("@fuel-ts/errors");
|
1162
1163
|
var import_math2 = require("@fuel-ts/math");
|
1163
1164
|
var import_transactions = require("@fuel-ts/transactions");
|
1164
|
-
var
|
1165
|
+
var import_utils3 = require("@fuel-ts/utils");
|
1165
1166
|
var inputify = (value) => {
|
1166
1167
|
const { type } = value;
|
1167
1168
|
switch (value.type) {
|
1168
1169
|
case import_transactions.InputType.Coin: {
|
1169
|
-
const predicate = (0,
|
1170
|
-
const predicateData = (0,
|
1170
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1171
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1171
1172
|
return {
|
1172
1173
|
type: import_transactions.InputType.Coin,
|
1173
|
-
txID: (0,
|
1174
|
-
outputIndex: (0,
|
1175
|
-
owner: (0,
|
1174
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1175
|
+
outputIndex: (0, import_utils3.arrayify)(value.id)[32],
|
1176
|
+
owner: (0, import_utils3.hexlify)(value.owner),
|
1176
1177
|
amount: (0, import_math2.bn)(value.amount),
|
1177
|
-
assetId: (0,
|
1178
|
+
assetId: (0, import_utils3.hexlify)(value.assetId),
|
1178
1179
|
txPointer: {
|
1179
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1180
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1180
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1181
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1181
1182
|
},
|
1182
1183
|
witnessIndex: value.witnessIndex,
|
1183
1184
|
maturity: value.maturity ?? 0,
|
1184
1185
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1185
1186
|
predicateLength: predicate.length,
|
1186
1187
|
predicateDataLength: predicateData.length,
|
1187
|
-
predicate: (0,
|
1188
|
-
predicateData: (0,
|
1188
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1189
|
+
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1189
1190
|
};
|
1190
1191
|
}
|
1191
1192
|
case import_transactions.InputType.Contract: {
|
@@ -1196,29 +1197,29 @@ var inputify = (value) => {
|
|
1196
1197
|
balanceRoot: import_configs2.ZeroBytes32,
|
1197
1198
|
stateRoot: import_configs2.ZeroBytes32,
|
1198
1199
|
txPointer: {
|
1199
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1200
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1200
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1201
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1201
1202
|
},
|
1202
|
-
contractID: (0,
|
1203
|
+
contractID: (0, import_utils3.hexlify)(value.contractId)
|
1203
1204
|
};
|
1204
1205
|
}
|
1205
1206
|
case import_transactions.InputType.Message: {
|
1206
|
-
const predicate = (0,
|
1207
|
-
const predicateData = (0,
|
1208
|
-
const data = (0,
|
1207
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1208
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1209
|
+
const data = (0, import_utils3.arrayify)(value.data ?? "0x");
|
1209
1210
|
return {
|
1210
1211
|
type: import_transactions.InputType.Message,
|
1211
|
-
sender: (0,
|
1212
|
-
recipient: (0,
|
1212
|
+
sender: (0, import_utils3.hexlify)(value.sender),
|
1213
|
+
recipient: (0, import_utils3.hexlify)(value.recipient),
|
1213
1214
|
amount: (0, import_math2.bn)(value.amount),
|
1214
|
-
nonce: (0,
|
1215
|
+
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1215
1216
|
witnessIndex: value.witnessIndex,
|
1216
1217
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1217
1218
|
predicateLength: predicate.length,
|
1218
1219
|
predicateDataLength: predicateData.length,
|
1219
|
-
predicate: (0,
|
1220
|
-
predicateData: (0,
|
1221
|
-
data: (0,
|
1220
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1221
|
+
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1222
|
+
data: (0, import_utils3.hexlify)(data),
|
1222
1223
|
dataLength: data.length
|
1223
1224
|
};
|
1224
1225
|
}
|
@@ -1236,16 +1237,16 @@ var import_configs3 = require("@fuel-ts/address/configs");
|
|
1236
1237
|
var import_errors4 = require("@fuel-ts/errors");
|
1237
1238
|
var import_math3 = require("@fuel-ts/math");
|
1238
1239
|
var import_transactions2 = require("@fuel-ts/transactions");
|
1239
|
-
var
|
1240
|
+
var import_utils4 = require("@fuel-ts/utils");
|
1240
1241
|
var outputify = (value) => {
|
1241
1242
|
const { type } = value;
|
1242
1243
|
switch (type) {
|
1243
1244
|
case import_transactions2.OutputType.Coin: {
|
1244
1245
|
return {
|
1245
1246
|
type: import_transactions2.OutputType.Coin,
|
1246
|
-
to: (0,
|
1247
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1247
1248
|
amount: (0, import_math3.bn)(value.amount),
|
1248
|
-
assetId: (0,
|
1249
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1249
1250
|
};
|
1250
1251
|
}
|
1251
1252
|
case import_transactions2.OutputType.Contract: {
|
@@ -1259,9 +1260,9 @@ var outputify = (value) => {
|
|
1259
1260
|
case import_transactions2.OutputType.Change: {
|
1260
1261
|
return {
|
1261
1262
|
type: import_transactions2.OutputType.Change,
|
1262
|
-
to: (0,
|
1263
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1263
1264
|
amount: (0, import_math3.bn)(0),
|
1264
|
-
assetId: (0,
|
1265
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1265
1266
|
};
|
1266
1267
|
}
|
1267
1268
|
case import_transactions2.OutputType.Variable: {
|
@@ -1275,8 +1276,8 @@ var outputify = (value) => {
|
|
1275
1276
|
case import_transactions2.OutputType.ContractCreated: {
|
1276
1277
|
return {
|
1277
1278
|
type: import_transactions2.OutputType.ContractCreated,
|
1278
|
-
contractId: (0,
|
1279
|
-
stateRoot: (0,
|
1279
|
+
contractId: (0, import_utils4.hexlify)(value.contractId),
|
1280
|
+
stateRoot: (0, import_utils4.hexlify)(value.stateRoot)
|
1280
1281
|
};
|
1281
1282
|
}
|
1282
1283
|
default: {
|
@@ -1293,7 +1294,7 @@ var import_address = require("@fuel-ts/address");
|
|
1293
1294
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1294
1295
|
var import_math6 = require("@fuel-ts/math");
|
1295
1296
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1296
|
-
var
|
1297
|
+
var import_utils9 = require("@fuel-ts/utils");
|
1297
1298
|
|
1298
1299
|
// src/providers/resource.ts
|
1299
1300
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1307,7 +1308,7 @@ var import_errors5 = require("@fuel-ts/errors");
|
|
1307
1308
|
var import_math4 = require("@fuel-ts/math");
|
1308
1309
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1309
1310
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1310
|
-
var
|
1311
|
+
var import_utils5 = require("@fuel-ts/utils");
|
1311
1312
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1312
1313
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1313
1314
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1451,7 +1452,7 @@ function assembleReceiptByType(receipt) {
|
|
1451
1452
|
const recipient = hexOrZero(receipt.recipient);
|
1452
1453
|
const nonce = hexOrZero(receipt.nonce);
|
1453
1454
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1454
|
-
const data = receipt.data ? (0,
|
1455
|
+
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1455
1456
|
const digest = hexOrZero(receipt.digest);
|
1456
1457
|
const messageId = import_transactions3.ReceiptMessageOutCoder.getMessageId({
|
1457
1458
|
sender,
|
@@ -1572,7 +1573,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1572
1573
|
// src/providers/utils/gas.ts
|
1573
1574
|
var import_math5 = require("@fuel-ts/math");
|
1574
1575
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1575
|
-
var
|
1576
|
+
var import_utils6 = require("@fuel-ts/utils");
|
1576
1577
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1577
1578
|
var getGasUsedFromReceipts = (receipts) => {
|
1578
1579
|
const scriptResult = receipts.filter(
|
@@ -1597,9 +1598,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1597
1598
|
const totalGas = inputs.reduce((total, input) => {
|
1598
1599
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1599
1600
|
return total.add(
|
1600
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1601
|
-
resolveGasDependentCosts((0, import_ethers6.getBytesCopy)(input.predicate).length, gasCosts.contractRoot)
|
1602
|
-
).add((0, import_math5.bn)(input.predicateGasUsed))
|
1601
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1603
1602
|
);
|
1604
1603
|
}
|
1605
1604
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1648,13 +1647,13 @@ function calculateMetadataGasForTxScript({
|
|
1648
1647
|
}
|
1649
1648
|
|
1650
1649
|
// src/providers/utils/json.ts
|
1651
|
-
var
|
1650
|
+
var import_utils7 = require("@fuel-ts/utils");
|
1652
1651
|
var import_ramda = require("ramda");
|
1653
1652
|
function normalize(object) {
|
1654
1653
|
Object.keys(object).forEach((key) => {
|
1655
1654
|
switch (object[key]?.constructor.name) {
|
1656
1655
|
case "Uint8Array":
|
1657
|
-
object[key] = (0,
|
1656
|
+
object[key] = (0, import_utils7.hexlify)(object[key]);
|
1658
1657
|
break;
|
1659
1658
|
case "Array":
|
1660
1659
|
object[key] = normalize(object[key]);
|
@@ -1687,10 +1686,6 @@ function sleep(time) {
|
|
1687
1686
|
});
|
1688
1687
|
}
|
1689
1688
|
|
1690
|
-
// src/providers/utils/time.ts
|
1691
|
-
var fromTai64ToUnix = (tai64Timestamp) => Number(BigInt(tai64Timestamp) - BigInt(2 ** 62) - BigInt(10));
|
1692
|
-
var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
|
1693
|
-
|
1694
1689
|
// src/providers/transaction-request/errors.ts
|
1695
1690
|
var ChangeOutputCollisionError = class extends Error {
|
1696
1691
|
name = "ChangeOutputCollisionError";
|
@@ -1714,11 +1709,11 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1714
1709
|
};
|
1715
1710
|
|
1716
1711
|
// src/providers/transaction-request/witness.ts
|
1717
|
-
var
|
1712
|
+
var import_utils8 = require("@fuel-ts/utils");
|
1718
1713
|
var witnessify = (value) => {
|
1719
|
-
const data = (0,
|
1714
|
+
const data = (0, import_utils8.arrayify)(value);
|
1720
1715
|
return {
|
1721
|
-
data: (0,
|
1716
|
+
data: (0, import_utils8.hexlify)(data),
|
1722
1717
|
dataLength: data.length
|
1723
1718
|
};
|
1724
1719
|
};
|
@@ -1838,7 +1833,7 @@ var BaseTransactionRequest = class {
|
|
1838
1833
|
* Creates an empty witness without any side effects and returns the index
|
1839
1834
|
*/
|
1840
1835
|
createWitness() {
|
1841
|
-
this.witnesses.push((0,
|
1836
|
+
this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1842
1837
|
return this.witnesses.length - 1;
|
1843
1838
|
}
|
1844
1839
|
/**
|
@@ -1907,9 +1902,9 @@ var BaseTransactionRequest = class {
|
|
1907
1902
|
const found = this.inputs.find((input) => {
|
1908
1903
|
switch (input.type) {
|
1909
1904
|
case import_transactions5.InputType.Coin:
|
1910
|
-
return (0,
|
1905
|
+
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1911
1906
|
case import_transactions5.InputType.Message:
|
1912
|
-
return (0,
|
1907
|
+
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1913
1908
|
default:
|
1914
1909
|
return false;
|
1915
1910
|
}
|
@@ -2075,7 +2070,7 @@ var BaseTransactionRequest = class {
|
|
2075
2070
|
*/
|
2076
2071
|
addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
|
2077
2072
|
const changeOutput = this.getChangeOutputs().find(
|
2078
|
-
(output) => (0,
|
2073
|
+
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
2079
2074
|
);
|
2080
2075
|
if (!changeOutput) {
|
2081
2076
|
this.pushOutput({
|
@@ -2188,19 +2183,27 @@ var BaseTransactionRequest = class {
|
|
2188
2183
|
toJSON() {
|
2189
2184
|
return normalizeJSON(this);
|
2190
2185
|
}
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2186
|
+
updatePredicateInputs(inputs) {
|
2187
|
+
this.inputs.forEach((i) => {
|
2188
|
+
let correspondingInput;
|
2189
|
+
switch (i.type) {
|
2190
|
+
case import_transactions5.InputType.Coin:
|
2191
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
|
2192
|
+
break;
|
2193
|
+
case import_transactions5.InputType.Message:
|
2194
|
+
correspondingInput = inputs.find(
|
2195
|
+
(x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
|
2196
|
+
);
|
2197
|
+
break;
|
2198
|
+
default:
|
2199
|
+
return;
|
2200
|
+
}
|
2201
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2202
|
+
i.predicate = correspondingInput.predicate;
|
2203
|
+
i.predicateData = correspondingInput.predicateData;
|
2204
|
+
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2205
|
+
}
|
2206
|
+
});
|
2204
2207
|
}
|
2205
2208
|
};
|
2206
2209
|
|
@@ -2208,14 +2211,15 @@ var BaseTransactionRequest = class {
|
|
2208
2211
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2209
2212
|
var import_math8 = require("@fuel-ts/math");
|
2210
2213
|
var import_transactions7 = require("@fuel-ts/transactions");
|
2211
|
-
var
|
2214
|
+
var import_utils13 = require("@fuel-ts/utils");
|
2212
2215
|
|
2213
2216
|
// src/providers/transaction-request/hash-transaction.ts
|
2214
2217
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2215
2218
|
var import_hasher = require("@fuel-ts/hasher");
|
2216
2219
|
var import_math7 = require("@fuel-ts/math");
|
2217
2220
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2218
|
-
var
|
2221
|
+
var import_utils11 = require("@fuel-ts/utils");
|
2222
|
+
var import_ethers = require("ethers");
|
2219
2223
|
var import_ramda2 = require("ramda");
|
2220
2224
|
function hashTransaction(transactionRequest, chainId) {
|
2221
2225
|
const transaction = transactionRequest.toTransaction();
|
@@ -2277,15 +2281,15 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2277
2281
|
transaction.witnessesCount = 0;
|
2278
2282
|
transaction.witnesses = [];
|
2279
2283
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2280
|
-
const concatenatedData = (0,
|
2281
|
-
return (0,
|
2284
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
|
2285
|
+
return (0, import_ethers.sha256)(concatenatedData);
|
2282
2286
|
}
|
2283
2287
|
|
2284
2288
|
// src/providers/transaction-request/storage-slot.ts
|
2285
|
-
var
|
2289
|
+
var import_utils12 = require("@fuel-ts/utils");
|
2286
2290
|
var getStorageValue = (value) => {
|
2287
2291
|
const v = new Uint8Array(32);
|
2288
|
-
v.set((0,
|
2292
|
+
v.set((0, import_utils12.arrayify)(value));
|
2289
2293
|
return v;
|
2290
2294
|
};
|
2291
2295
|
var storageSlotify = (storageSlot) => {
|
@@ -2299,8 +2303,8 @@ var storageSlotify = (storageSlot) => {
|
|
2299
2303
|
value = storageSlot.value;
|
2300
2304
|
}
|
2301
2305
|
return {
|
2302
|
-
key: (0,
|
2303
|
-
value: (0,
|
2306
|
+
key: (0, import_utils12.hexlify)(key),
|
2307
|
+
value: (0, import_utils12.hexlify)(getStorageValue(value))
|
2304
2308
|
};
|
2305
2309
|
};
|
2306
2310
|
|
@@ -2333,7 +2337,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2333
2337
|
} = {}) {
|
2334
2338
|
super(rest);
|
2335
2339
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2336
|
-
this.salt = (0,
|
2340
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2337
2341
|
this.storageSlots = [...storageSlots ?? []];
|
2338
2342
|
}
|
2339
2343
|
/**
|
@@ -2351,7 +2355,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2351
2355
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2352
2356
|
bytecodeWitnessIndex,
|
2353
2357
|
storageSlotsCount: storageSlots.length,
|
2354
|
-
salt: this.salt ? (0,
|
2358
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2355
2359
|
storageSlots
|
2356
2360
|
};
|
2357
2361
|
}
|
@@ -2390,7 +2394,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2390
2394
|
}
|
2391
2395
|
metadataGas(gasCosts) {
|
2392
2396
|
return calculateMetadataGasForTxCreate({
|
2393
|
-
contractBytesSize: (0, import_math8.bn)((0,
|
2397
|
+
contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2394
2398
|
gasCosts,
|
2395
2399
|
stateRootSize: this.storageSlots.length,
|
2396
2400
|
txBytesSize: this.byteSize()
|
@@ -2404,17 +2408,17 @@ var import_address2 = require("@fuel-ts/address");
|
|
2404
2408
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2405
2409
|
var import_math9 = require("@fuel-ts/math");
|
2406
2410
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2407
|
-
var
|
2411
|
+
var import_utils15 = require("@fuel-ts/utils");
|
2408
2412
|
|
2409
2413
|
// src/providers/transaction-request/scripts.ts
|
2410
|
-
var
|
2414
|
+
var import_utils14 = require("@fuel-ts/utils");
|
2411
2415
|
var returnZeroScript = {
|
2412
2416
|
/*
|
2413
2417
|
Opcode::RET(REG_ZERO)
|
2414
2418
|
Opcode::NOOP
|
2415
2419
|
*/
|
2416
2420
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2417
|
-
bytes: (0,
|
2421
|
+
bytes: (0, import_utils14.arrayify)("0x24000000"),
|
2418
2422
|
encodeScriptData: () => new Uint8Array(0)
|
2419
2423
|
};
|
2420
2424
|
var withdrawScript = {
|
@@ -2428,7 +2432,7 @@ var withdrawScript = {
|
|
2428
2432
|
00000000 00000000 [amount value]
|
2429
2433
|
*/
|
2430
2434
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2431
|
-
bytes: (0,
|
2435
|
+
bytes: (0, import_utils14.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
2432
2436
|
encodeScriptData: () => new Uint8Array(0)
|
2433
2437
|
};
|
2434
2438
|
|
@@ -2456,8 +2460,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2456
2460
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2457
2461
|
super(rest);
|
2458
2462
|
this.gasLimit = (0, import_math9.bn)(gasLimit);
|
2459
|
-
this.script = (0,
|
2460
|
-
this.scriptData = (0,
|
2463
|
+
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2464
|
+
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2461
2465
|
}
|
2462
2466
|
/**
|
2463
2467
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2465,8 +2469,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2465
2469
|
* @returns The transaction script object.
|
2466
2470
|
*/
|
2467
2471
|
toTransaction() {
|
2468
|
-
const script = (0,
|
2469
|
-
const scriptData = (0,
|
2472
|
+
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2473
|
+
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2470
2474
|
return {
|
2471
2475
|
type: import_transactions8.TransactionType.Script,
|
2472
2476
|
scriptGasLimit: this.gasLimit,
|
@@ -2474,8 +2478,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2474
2478
|
scriptLength: script.length,
|
2475
2479
|
scriptDataLength: scriptData.length,
|
2476
2480
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2477
|
-
script: (0,
|
2478
|
-
scriptData: (0,
|
2481
|
+
script: (0, import_utils15.hexlify)(script),
|
2482
|
+
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2479
2483
|
};
|
2480
2484
|
}
|
2481
2485
|
/**
|
@@ -2626,15 +2630,15 @@ var transactionRequestify = (obj) => {
|
|
2626
2630
|
var import_errors12 = require("@fuel-ts/errors");
|
2627
2631
|
var import_math13 = require("@fuel-ts/math");
|
2628
2632
|
var import_transactions15 = require("@fuel-ts/transactions");
|
2629
|
-
var
|
2633
|
+
var import_utils21 = require("@fuel-ts/utils");
|
2630
2634
|
|
2631
2635
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2632
|
-
var
|
2636
|
+
var import_utils19 = require("@fuel-ts/utils");
|
2633
2637
|
|
2634
2638
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2635
2639
|
var import_math10 = require("@fuel-ts/math");
|
2636
2640
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2637
|
-
var
|
2641
|
+
var import_utils16 = require("@fuel-ts/utils");
|
2638
2642
|
var calculateTransactionFee = (params) => {
|
2639
2643
|
const {
|
2640
2644
|
gasUsed,
|
@@ -2643,7 +2647,7 @@ var calculateTransactionFee = (params) => {
|
|
2643
2647
|
} = params;
|
2644
2648
|
const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
|
2645
2649
|
const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
|
2646
|
-
const transactionBytes = (0,
|
2650
|
+
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2647
2651
|
const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
|
2648
2652
|
if (transaction.type === import_transactions10.TransactionType.Mint) {
|
2649
2653
|
return {
|
@@ -2658,7 +2662,7 @@ var calculateTransactionFee = (params) => {
|
|
2658
2662
|
let gasLimit = (0, import_math10.bn)(0);
|
2659
2663
|
if (type === import_transactions10.TransactionType.Create) {
|
2660
2664
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2661
|
-
const contractBytesSize = (0, import_math10.bn)((0,
|
2665
|
+
const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2662
2666
|
metadataGas = calculateMetadataGasForTxCreate({
|
2663
2667
|
contractBytesSize,
|
2664
2668
|
gasCosts,
|
@@ -2704,15 +2708,8 @@ var calculateTransactionFee = (params) => {
|
|
2704
2708
|
};
|
2705
2709
|
};
|
2706
2710
|
|
2707
|
-
// src/providers/transaction-summary/date.ts
|
2708
|
-
var import_tai64 = require("tai64");
|
2709
|
-
var fromTai64ToDate = (tai64Timestamp) => {
|
2710
|
-
const timestamp = import_tai64.TAI64.fromString(tai64Timestamp, 10).toUnix();
|
2711
|
-
return new Date(timestamp * 1e3);
|
2712
|
-
};
|
2713
|
-
var fromDateToTai64 = (date) => import_tai64.TAI64.fromUnix(Math.floor(date.getTime() / 1e3)).toString(10);
|
2714
|
-
|
2715
2711
|
// src/providers/transaction-summary/operations.ts
|
2712
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2716
2713
|
var import_errors10 = require("@fuel-ts/errors");
|
2717
2714
|
var import_math12 = require("@fuel-ts/math");
|
2718
2715
|
var import_transactions13 = require("@fuel-ts/transactions");
|
@@ -2857,7 +2854,6 @@ var OperationName = /* @__PURE__ */ ((OperationName2) => {
|
|
2857
2854
|
OperationName2["contractCreated"] = "Contract created";
|
2858
2855
|
OperationName2["transfer"] = "Transfer asset";
|
2859
2856
|
OperationName2["contractCall"] = "Contract call";
|
2860
|
-
OperationName2["contractTransfer"] = "Contract transfer";
|
2861
2857
|
OperationName2["receive"] = "Receive asset";
|
2862
2858
|
OperationName2["mint"] = "Mint asset";
|
2863
2859
|
OperationName2["predicatecall"] = "Predicate call";
|
@@ -2957,33 +2953,6 @@ function addOperation(operations, toAdd) {
|
|
2957
2953
|
function getReceiptsTransferOut(receipts) {
|
2958
2954
|
return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
|
2959
2955
|
}
|
2960
|
-
function getContractTransferOperations({ receipts }) {
|
2961
|
-
const transferOutReceipts = getReceiptsTransferOut(receipts);
|
2962
|
-
const contractTransferOperations = transferOutReceipts.reduce(
|
2963
|
-
(prevContractTransferOps, receipt) => {
|
2964
|
-
const newContractTransferOps = addOperation(prevContractTransferOps, {
|
2965
|
-
name: "Contract transfer" /* contractTransfer */,
|
2966
|
-
from: {
|
2967
|
-
type: 0 /* contract */,
|
2968
|
-
address: receipt.from
|
2969
|
-
},
|
2970
|
-
to: {
|
2971
|
-
type: 1 /* account */,
|
2972
|
-
address: receipt.to
|
2973
|
-
},
|
2974
|
-
assetsSent: [
|
2975
|
-
{
|
2976
|
-
amount: receipt.amount,
|
2977
|
-
assetId: receipt.assetId
|
2978
|
-
}
|
2979
|
-
]
|
2980
|
-
});
|
2981
|
-
return newContractTransferOps;
|
2982
|
-
},
|
2983
|
-
[]
|
2984
|
-
);
|
2985
|
-
return contractTransferOperations;
|
2986
|
-
}
|
2987
2956
|
function getWithdrawFromFuelOperations({
|
2988
2957
|
inputs,
|
2989
2958
|
receipts
|
@@ -3081,70 +3050,77 @@ function getContractCallOperations({
|
|
3081
3050
|
}, []);
|
3082
3051
|
return contractCallOperations;
|
3083
3052
|
}
|
3053
|
+
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
3054
|
+
const { to: toAddress, assetId, amount } = receipt;
|
3055
|
+
let { from: fromAddress } = receipt;
|
3056
|
+
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3057
|
+
if (import_configs10.ZeroBytes32 === fromAddress) {
|
3058
|
+
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3059
|
+
fromAddress = change?.to || fromAddress;
|
3060
|
+
}
|
3061
|
+
const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
|
3062
|
+
return {
|
3063
|
+
name: "Transfer asset" /* transfer */,
|
3064
|
+
from: {
|
3065
|
+
type: fromType,
|
3066
|
+
address: fromAddress
|
3067
|
+
},
|
3068
|
+
to: {
|
3069
|
+
type: toType,
|
3070
|
+
address: toAddress
|
3071
|
+
},
|
3072
|
+
assetsSent: [
|
3073
|
+
{
|
3074
|
+
assetId: assetId.toString(),
|
3075
|
+
amount
|
3076
|
+
}
|
3077
|
+
]
|
3078
|
+
};
|
3079
|
+
}
|
3084
3080
|
function getTransferOperations({
|
3085
3081
|
inputs,
|
3086
3082
|
outputs,
|
3087
3083
|
receipts
|
3088
3084
|
}) {
|
3085
|
+
let operations = [];
|
3089
3086
|
const coinOutputs = getOutputsCoin(outputs);
|
3090
|
-
const
|
3087
|
+
const contractInputs = getInputsContract(inputs);
|
3088
|
+
const changeOutputs = getOutputsChange(outputs);
|
3089
|
+
coinOutputs.forEach((output) => {
|
3090
|
+
const { amount, assetId, to } = output;
|
3091
|
+
const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
|
3092
|
+
if (changeOutput) {
|
3093
|
+
operations = addOperation(operations, {
|
3094
|
+
name: "Transfer asset" /* transfer */,
|
3095
|
+
from: {
|
3096
|
+
type: 1 /* account */,
|
3097
|
+
address: changeOutput.to
|
3098
|
+
},
|
3099
|
+
to: {
|
3100
|
+
type: 1 /* account */,
|
3101
|
+
address: to
|
3102
|
+
},
|
3103
|
+
assetsSent: [
|
3104
|
+
{
|
3105
|
+
assetId,
|
3106
|
+
amount
|
3107
|
+
}
|
3108
|
+
]
|
3109
|
+
});
|
3110
|
+
}
|
3111
|
+
});
|
3112
|
+
const transferReceipts = getReceiptsByType(
|
3091
3113
|
receipts,
|
3092
3114
|
import_transactions13.ReceiptType.Transfer
|
3093
3115
|
);
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
const inputAddress = getInputAccountAddress(utxo);
|
3103
|
-
operations = addOperation(operations, {
|
3104
|
-
name: "Transfer asset" /* transfer */,
|
3105
|
-
from: {
|
3106
|
-
type: 1 /* account */,
|
3107
|
-
address: inputAddress
|
3108
|
-
},
|
3109
|
-
to: {
|
3110
|
-
type: 0 /* contract */,
|
3111
|
-
address: contractInput.contractID
|
3112
|
-
},
|
3113
|
-
assetsSent: [
|
3114
|
-
{
|
3115
|
-
assetId: assetId.toString(),
|
3116
|
-
amount: transferReceipt.amount
|
3117
|
-
}
|
3118
|
-
]
|
3119
|
-
});
|
3120
|
-
}
|
3121
|
-
});
|
3122
|
-
} else {
|
3123
|
-
coinOutputs.forEach((output) => {
|
3124
|
-
const input = getInputFromAssetId(inputs, output.assetId);
|
3125
|
-
if (input) {
|
3126
|
-
const inputAddress = getInputAccountAddress(input);
|
3127
|
-
const operationToAdd = {
|
3128
|
-
name: "Transfer asset" /* transfer */,
|
3129
|
-
from: {
|
3130
|
-
type: 1 /* account */,
|
3131
|
-
address: inputAddress
|
3132
|
-
},
|
3133
|
-
to: {
|
3134
|
-
type: 1 /* account */,
|
3135
|
-
address: output.to.toString()
|
3136
|
-
},
|
3137
|
-
assetsSent: [
|
3138
|
-
{
|
3139
|
-
assetId: output.assetId.toString(),
|
3140
|
-
amount: output.amount
|
3141
|
-
}
|
3142
|
-
]
|
3143
|
-
};
|
3144
|
-
operations = addOperation(operations, operationToAdd);
|
3145
|
-
}
|
3146
|
-
});
|
3147
|
-
}
|
3116
|
+
const transferOutReceipts = getReceiptsByType(
|
3117
|
+
receipts,
|
3118
|
+
import_transactions13.ReceiptType.TransferOut
|
3119
|
+
);
|
3120
|
+
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3121
|
+
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
3122
|
+
operations = addOperation(operations, operation);
|
3123
|
+
});
|
3148
3124
|
return operations;
|
3149
3125
|
}
|
3150
3126
|
function getPayProducerOperations(outputs) {
|
@@ -3217,7 +3193,6 @@ function getOperations({
|
|
3217
3193
|
rawPayload,
|
3218
3194
|
maxInputs
|
3219
3195
|
}),
|
3220
|
-
...getContractTransferOperations({ receipts }),
|
3221
3196
|
...getWithdrawFromFuelOperations({ inputs, receipts })
|
3222
3197
|
];
|
3223
3198
|
}
|
@@ -3346,7 +3321,7 @@ function assembleTransactionSummary(params) {
|
|
3346
3321
|
gasCosts
|
3347
3322
|
} = params;
|
3348
3323
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3349
|
-
const rawPayload = (0,
|
3324
|
+
const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
|
3350
3325
|
const operations = getOperations({
|
3351
3326
|
transactionType: transaction.type,
|
3352
3327
|
inputs: transaction.inputs || [],
|
@@ -3373,7 +3348,7 @@ function assembleTransactionSummary(params) {
|
|
3373
3348
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3374
3349
|
let date;
|
3375
3350
|
if (time) {
|
3376
|
-
date =
|
3351
|
+
date = import_utils19.DateTime.fromTai64(time);
|
3377
3352
|
}
|
3378
3353
|
const transactionSummary = {
|
3379
3354
|
id,
|
@@ -3463,7 +3438,7 @@ var TransactionResponse = class {
|
|
3463
3438
|
*/
|
3464
3439
|
decodeTransaction(transactionWithReceipts) {
|
3465
3440
|
return new import_transactions15.TransactionCoder().decode(
|
3466
|
-
(0,
|
3441
|
+
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3467
3442
|
0
|
3468
3443
|
)?.[0];
|
3469
3444
|
}
|
@@ -3489,7 +3464,7 @@ var TransactionResponse = class {
|
|
3489
3464
|
id: this.id,
|
3490
3465
|
receipts,
|
3491
3466
|
transaction: decodedTransaction,
|
3492
|
-
transactionBytes: (0,
|
3467
|
+
transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
|
3493
3468
|
gqlTransactionStatus: transaction.status,
|
3494
3469
|
gasPerByte,
|
3495
3470
|
gasPriceFactor,
|
@@ -3554,7 +3529,9 @@ function getDecodedLogs(receipts, abiInterface) {
|
|
3554
3529
|
logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
|
3555
3530
|
}
|
3556
3531
|
if (r.type === import_transactions16.ReceiptType.Log) {
|
3557
|
-
logs.push(
|
3532
|
+
logs.push(
|
3533
|
+
abiInterface.decodeLog(new import_abi_coder3.BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
|
3534
|
+
);
|
3558
3535
|
}
|
3559
3536
|
return logs;
|
3560
3537
|
}, []);
|
@@ -3790,7 +3767,7 @@ var _Provider = class {
|
|
3790
3767
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
3791
3768
|
const isSubscription = opDefinition?.operation === "subscription";
|
3792
3769
|
if (isSubscription) {
|
3793
|
-
return
|
3770
|
+
return new FuelGraphqlSubscriber({
|
3794
3771
|
url: this.url,
|
3795
3772
|
query,
|
3796
3773
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
@@ -3824,7 +3801,7 @@ var _Provider = class {
|
|
3824
3801
|
name,
|
3825
3802
|
consensusParameters: { chainId }
|
3826
3803
|
} = await this.getChain();
|
3827
|
-
const network = new
|
3804
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3828
3805
|
return Promise.resolve(network);
|
3829
3806
|
}
|
3830
3807
|
/**
|
@@ -3892,7 +3869,7 @@ var _Provider = class {
|
|
3892
3869
|
if (estimateTxDependencies) {
|
3893
3870
|
await this.estimateTxDependencies(transactionRequest);
|
3894
3871
|
}
|
3895
|
-
const encodedTransaction = (0,
|
3872
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3896
3873
|
if (awaitExecution) {
|
3897
3874
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3898
3875
|
for await (const { submitAndAwait } of subscription) {
|
@@ -3923,9 +3900,9 @@ var _Provider = class {
|
|
3923
3900
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
3924
3901
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3925
3902
|
if (estimateTxDependencies) {
|
3926
|
-
|
3903
|
+
return this.estimateTxDependencies(transactionRequest);
|
3927
3904
|
}
|
3928
|
-
const encodedTransaction = (0,
|
3905
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3929
3906
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3930
3907
|
encodedTransaction,
|
3931
3908
|
utxoValidation: utxoValidation || false
|
@@ -3942,7 +3919,15 @@ var _Provider = class {
|
|
3942
3919
|
* @returns A promise that resolves to the estimated transaction request object.
|
3943
3920
|
*/
|
3944
3921
|
async estimatePredicates(transactionRequest) {
|
3945
|
-
const
|
3922
|
+
const shouldEstimatePredicates = Boolean(
|
3923
|
+
transactionRequest.inputs.find(
|
3924
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3925
|
+
)
|
3926
|
+
);
|
3927
|
+
if (!shouldEstimatePredicates) {
|
3928
|
+
return transactionRequest;
|
3929
|
+
}
|
3930
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3946
3931
|
const response = await this.operations.estimatePredicates({
|
3947
3932
|
encodedTransaction
|
3948
3933
|
});
|
@@ -3972,34 +3957,41 @@ var _Provider = class {
|
|
3972
3957
|
* @returns A promise.
|
3973
3958
|
*/
|
3974
3959
|
async estimateTxDependencies(transactionRequest) {
|
3975
|
-
let missingOutputVariableCount = 0;
|
3976
|
-
let missingOutputContractIdsCount = 0;
|
3977
|
-
let tries = 0;
|
3978
3960
|
if (transactionRequest.type === import_transactions17.TransactionType.Create) {
|
3979
|
-
return
|
3980
|
-
|
3981
|
-
|
3982
|
-
|
3983
|
-
|
3961
|
+
return {
|
3962
|
+
receipts: [],
|
3963
|
+
outputVariables: 0,
|
3964
|
+
missingContractIds: []
|
3965
|
+
};
|
3984
3966
|
}
|
3985
|
-
|
3967
|
+
await this.estimatePredicates(transactionRequest);
|
3968
|
+
let receipts = [];
|
3969
|
+
const missingContractIds = [];
|
3970
|
+
let outputVariables = 0;
|
3971
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3986
3972
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3987
|
-
encodedTransaction: (0,
|
3973
|
+
encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
|
3988
3974
|
utxoValidation: false
|
3989
3975
|
});
|
3990
|
-
|
3976
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3991
3977
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3992
|
-
|
3993
|
-
|
3994
|
-
|
3995
|
-
|
3978
|
+
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3979
|
+
if (hasMissingOutputs) {
|
3980
|
+
outputVariables += missingOutputVariables.length;
|
3981
|
+
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
3982
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
3983
|
+
transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
3984
|
+
missingContractIds.push(contractId);
|
3985
|
+
});
|
3986
|
+
} else {
|
3987
|
+
break;
|
3996
3988
|
}
|
3997
|
-
txRequest.addVariableOutputs(missingOutputVariableCount);
|
3998
|
-
missingOutputContractIds.forEach(
|
3999
|
-
({ contractId }) => txRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId))
|
4000
|
-
);
|
4001
|
-
tries += 1;
|
4002
3989
|
}
|
3990
|
+
return {
|
3991
|
+
receipts,
|
3992
|
+
outputVariables,
|
3993
|
+
missingContractIds
|
3994
|
+
};
|
4003
3995
|
}
|
4004
3996
|
/**
|
4005
3997
|
* Executes a signed transaction without applying the states changes
|
@@ -4014,9 +4006,9 @@ var _Provider = class {
|
|
4014
4006
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4015
4007
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4016
4008
|
if (estimateTxDependencies) {
|
4017
|
-
|
4009
|
+
return this.estimateTxDependencies(transactionRequest);
|
4018
4010
|
}
|
4019
|
-
const encodedTransaction = (0,
|
4011
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4020
4012
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4021
4013
|
encodedTransaction,
|
4022
4014
|
utxoValidation: true
|
@@ -4046,35 +4038,37 @@ var _Provider = class {
|
|
4046
4038
|
estimatePredicates = true,
|
4047
4039
|
resourcesOwner
|
4048
4040
|
} = {}) {
|
4049
|
-
const
|
4041
|
+
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4050
4042
|
const chainInfo = this.getChain();
|
4051
4043
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4052
|
-
const gasPrice = (0, import_math14.max)(
|
4053
|
-
const isScriptTransaction =
|
4054
|
-
|
4044
|
+
const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
|
4045
|
+
const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
|
4046
|
+
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4047
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4048
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4049
|
+
if (estimatePredicates) {
|
4055
4050
|
if (isScriptTransaction) {
|
4056
|
-
|
4051
|
+
txRequestClone.gasLimit = (0, import_math14.bn)(0);
|
4052
|
+
}
|
4053
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4054
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4057
4055
|
}
|
4058
|
-
await this.estimatePredicates(
|
4056
|
+
await this.estimatePredicates(txRequestClone);
|
4059
4057
|
}
|
4060
|
-
const minGas =
|
4061
|
-
const maxGas =
|
4062
|
-
const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
|
4063
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4064
|
-
transactionRequest.fundWithFakeUtxos(allQuantities, resourcesOwner);
|
4065
|
-
let gasUsed = minGas;
|
4058
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
4059
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
4066
4060
|
let receipts = [];
|
4067
|
-
|
4068
|
-
|
4069
|
-
|
4070
|
-
|
4071
|
-
|
4072
|
-
|
4061
|
+
let missingContractIds = [];
|
4062
|
+
let outputVariables = 0;
|
4063
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
4064
|
+
txRequestClone.gasPrice = (0, import_math14.bn)(0);
|
4065
|
+
txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
4066
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
4073
4067
|
receipts = result.receipts;
|
4074
|
-
|
4075
|
-
|
4076
|
-
gasUsed = minGas;
|
4068
|
+
outputVariables = result.outputVariables;
|
4069
|
+
missingContractIds = result.missingContractIds;
|
4077
4070
|
}
|
4071
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
4078
4072
|
const usedFee = calculatePriceWithFactor(
|
4079
4073
|
gasUsed,
|
4080
4074
|
gasPrice,
|
@@ -4092,7 +4086,10 @@ var _Provider = class {
|
|
4092
4086
|
maxGas,
|
4093
4087
|
usedFee,
|
4094
4088
|
minFee,
|
4095
|
-
maxFee
|
4089
|
+
maxFee,
|
4090
|
+
estimatedInputs: txRequestClone.inputs,
|
4091
|
+
outputVariables,
|
4092
|
+
missingContractIds
|
4096
4093
|
};
|
4097
4094
|
}
|
4098
4095
|
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
@@ -4121,7 +4118,7 @@ var _Provider = class {
|
|
4121
4118
|
const result = await this.operations.getCoins({
|
4122
4119
|
first: 10,
|
4123
4120
|
...paginationArgs,
|
4124
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4121
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4125
4122
|
});
|
4126
4123
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4127
4124
|
return coins.map((coin) => ({
|
@@ -4145,19 +4142,19 @@ var _Provider = class {
|
|
4145
4142
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4146
4143
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4147
4144
|
const excludeInput = {
|
4148
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4149
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4145
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4146
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4150
4147
|
};
|
4151
4148
|
if (this.cache) {
|
4152
4149
|
const uniqueUtxos = new Set(
|
4153
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4150
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4154
4151
|
);
|
4155
4152
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4156
4153
|
}
|
4157
4154
|
const coinsQuery = {
|
4158
4155
|
owner: ownerAddress.toB256(),
|
4159
4156
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4160
|
-
assetId: (0,
|
4157
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4161
4158
|
amount: amount.toString(10),
|
4162
4159
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4163
4160
|
})),
|
@@ -4260,7 +4257,7 @@ var _Provider = class {
|
|
4260
4257
|
time: block.header.time,
|
4261
4258
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4262
4259
|
transactions: block.transactions.map(
|
4263
|
-
(tx) => new import_transactions17.TransactionCoder().decode((0,
|
4260
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4264
4261
|
)
|
4265
4262
|
};
|
4266
4263
|
}
|
@@ -4276,7 +4273,7 @@ var _Provider = class {
|
|
4276
4273
|
return null;
|
4277
4274
|
}
|
4278
4275
|
return new import_transactions17.TransactionCoder().decode(
|
4279
|
-
(0,
|
4276
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4280
4277
|
0
|
4281
4278
|
)?.[0];
|
4282
4279
|
}
|
@@ -4303,7 +4300,7 @@ var _Provider = class {
|
|
4303
4300
|
async getContractBalance(contractId, assetId) {
|
4304
4301
|
const { contractBalance } = await this.operations.getContractBalance({
|
4305
4302
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4306
|
-
asset: (0,
|
4303
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4307
4304
|
});
|
4308
4305
|
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4309
4306
|
}
|
@@ -4317,7 +4314,7 @@ var _Provider = class {
|
|
4317
4314
|
async getBalance(owner, assetId) {
|
4318
4315
|
const { balance } = await this.operations.getBalance({
|
4319
4316
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4320
|
-
assetId: (0,
|
4317
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4321
4318
|
});
|
4322
4319
|
return (0, import_math14.bn)(balance.amount, 10);
|
4323
4320
|
}
|
@@ -4472,13 +4469,13 @@ var _Provider = class {
|
|
4472
4469
|
* Lets you produce blocks with custom timestamps and the block number of the last block produced.
|
4473
4470
|
*
|
4474
4471
|
* @param amount - The amount of blocks to produce
|
4475
|
-
* @param startTime - The UNIX timestamp to set for the first produced block
|
4472
|
+
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
|
4476
4473
|
* @returns A promise that resolves to the block number of the last produced block.
|
4477
4474
|
*/
|
4478
4475
|
async produceBlocks(amount, startTime) {
|
4479
4476
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4480
4477
|
blocksToProduce: (0, import_math14.bn)(amount).toString(10),
|
4481
|
-
startTimestamp: startTime ?
|
4478
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4482
4479
|
});
|
4483
4480
|
return (0, import_math14.bn)(latestBlockHeight);
|
4484
4481
|
}
|
@@ -4506,7 +4503,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4506
4503
|
var import_errors14 = require("@fuel-ts/errors");
|
4507
4504
|
var import_math15 = require("@fuel-ts/math");
|
4508
4505
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4509
|
-
var
|
4506
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4510
4507
|
async function getTransactionSummary(params) {
|
4511
4508
|
const { id, provider, abiMap } = params;
|
4512
4509
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4519,7 +4516,7 @@ async function getTransactionSummary(params) {
|
|
4519
4516
|
);
|
4520
4517
|
}
|
4521
4518
|
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
|
4522
|
-
(0,
|
4519
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4523
4520
|
0
|
4524
4521
|
);
|
4525
4522
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4530,7 +4527,7 @@ async function getTransactionSummary(params) {
|
|
4530
4527
|
id: gqlTransaction.id,
|
4531
4528
|
receipts,
|
4532
4529
|
transaction: decodedTransaction,
|
4533
|
-
transactionBytes: (0,
|
4530
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4534
4531
|
gqlTransactionStatus: gqlTransaction.status,
|
4535
4532
|
gasPerByte: (0, import_math15.bn)(gasPerByte),
|
4536
4533
|
gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
|
@@ -4572,13 +4569,13 @@ async function getTransactionsSummaries(params) {
|
|
4572
4569
|
const transactions = edges.map((edge) => {
|
4573
4570
|
const { node: gqlTransaction } = edge;
|
4574
4571
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4575
|
-
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0,
|
4572
|
+
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
4576
4573
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4577
4574
|
const transactionSummary = assembleTransactionSummary({
|
4578
4575
|
id,
|
4579
4576
|
receipts,
|
4580
4577
|
transaction: decodedTransaction,
|
4581
|
-
transactionBytes: (0,
|
4578
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
4582
4579
|
gqlTransactionStatus: status,
|
4583
4580
|
abiMap,
|
4584
4581
|
gasPerByte,
|
@@ -4598,19 +4595,140 @@ async function getTransactionsSummaries(params) {
|
|
4598
4595
|
};
|
4599
4596
|
}
|
4600
4597
|
|
4598
|
+
// src/providers/chains.ts
|
4599
|
+
var CHAIN_IDS = {
|
4600
|
+
eth: {
|
4601
|
+
sepolia: 11155111,
|
4602
|
+
foundry: 31337
|
4603
|
+
},
|
4604
|
+
fuel: {
|
4605
|
+
beta5: 0,
|
4606
|
+
devnet: 10
|
4607
|
+
}
|
4608
|
+
};
|
4609
|
+
|
4610
|
+
// src/providers/assets/utils/network.ts
|
4611
|
+
var getDefaultChainId = (networkType) => {
|
4612
|
+
if (networkType === "ethereum") {
|
4613
|
+
return CHAIN_IDS.eth.sepolia;
|
4614
|
+
}
|
4615
|
+
if (networkType === "fuel") {
|
4616
|
+
return CHAIN_IDS.fuel.beta5;
|
4617
|
+
}
|
4618
|
+
return void 0;
|
4619
|
+
};
|
4620
|
+
var getAssetNetwork = ({
|
4621
|
+
asset,
|
4622
|
+
chainId,
|
4623
|
+
networkType
|
4624
|
+
}) => {
|
4625
|
+
const network = asset.networks.find(
|
4626
|
+
(item) => item.chainId === chainId && item.type === networkType
|
4627
|
+
);
|
4628
|
+
return network;
|
4629
|
+
};
|
4630
|
+
var getAssetWithNetwork = ({
|
4631
|
+
asset,
|
4632
|
+
chainId,
|
4633
|
+
networkType
|
4634
|
+
}) => {
|
4635
|
+
const { networks: _, ...assetRest } = asset;
|
4636
|
+
const chainIdToUse = chainId ?? getDefaultChainId(networkType);
|
4637
|
+
if (chainIdToUse === void 0) {
|
4638
|
+
return void 0;
|
4639
|
+
}
|
4640
|
+
const assetNetwork = getAssetNetwork({
|
4641
|
+
asset,
|
4642
|
+
chainId: chainIdToUse,
|
4643
|
+
networkType
|
4644
|
+
});
|
4645
|
+
if (!assetNetwork) {
|
4646
|
+
return void 0;
|
4647
|
+
}
|
4648
|
+
return {
|
4649
|
+
...assetRest,
|
4650
|
+
...assetNetwork
|
4651
|
+
};
|
4652
|
+
};
|
4653
|
+
var getAssetEth = (asset, chainId) => getAssetWithNetwork({
|
4654
|
+
asset,
|
4655
|
+
networkType: "ethereum",
|
4656
|
+
chainId
|
4657
|
+
});
|
4658
|
+
var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
|
4659
|
+
asset,
|
4660
|
+
networkType: "fuel",
|
4661
|
+
chainId
|
4662
|
+
});
|
4663
|
+
|
4664
|
+
// src/providers/assets/utils/url.ts
|
4665
|
+
var DELIMITER_PATH = "/";
|
4666
|
+
var trimRegex = /^\/|\/$/g;
|
4667
|
+
var trimPath = (path = "") => path.replace(trimRegex, "");
|
4668
|
+
function urlJoin(baseUrl, ...paths) {
|
4669
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4670
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4671
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4672
|
+
if (rootPath && hasBaseUrl) {
|
4673
|
+
allPaths.unshift("");
|
4674
|
+
}
|
4675
|
+
return allPaths.join(DELIMITER_PATH);
|
4676
|
+
}
|
4677
|
+
|
4678
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4679
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4680
|
+
return assets2.map((asset) => ({
|
4681
|
+
...asset,
|
4682
|
+
icon: urlJoin(basePath, asset.icon)
|
4683
|
+
}));
|
4684
|
+
}
|
4685
|
+
|
4686
|
+
// src/providers/assets/index.ts
|
4687
|
+
var assets = [
|
4688
|
+
{
|
4689
|
+
name: "Ethereum",
|
4690
|
+
symbol: "ETH",
|
4691
|
+
icon: "eth.svg",
|
4692
|
+
networks: [
|
4693
|
+
{
|
4694
|
+
type: "ethereum",
|
4695
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
4696
|
+
decimals: 18
|
4697
|
+
},
|
4698
|
+
{
|
4699
|
+
type: "ethereum",
|
4700
|
+
chainId: CHAIN_IDS.eth.foundry,
|
4701
|
+
decimals: 18
|
4702
|
+
},
|
4703
|
+
{
|
4704
|
+
type: "fuel",
|
4705
|
+
chainId: CHAIN_IDS.fuel.beta5,
|
4706
|
+
decimals: 9,
|
4707
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
4708
|
+
},
|
4709
|
+
{
|
4710
|
+
type: "fuel",
|
4711
|
+
chainId: CHAIN_IDS.fuel.devnet,
|
4712
|
+
decimals: 9,
|
4713
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
4714
|
+
}
|
4715
|
+
]
|
4716
|
+
}
|
4717
|
+
];
|
4718
|
+
|
4601
4719
|
// src/utils/formatTransferToContractScriptData.ts
|
4602
4720
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4603
4721
|
var import_math16 = require("@fuel-ts/math");
|
4722
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4604
4723
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4605
|
-
var import_ethers20 = require("ethers");
|
4606
4724
|
var formatTransferToContractScriptData = (params) => {
|
4607
4725
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4608
|
-
const numberCoder = new import_abi_coder4.
|
4726
|
+
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4609
4727
|
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4610
4728
|
const scriptData = Uint8Array.from([
|
4611
|
-
...(0,
|
4729
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4612
4730
|
...encoded,
|
4613
|
-
...(0,
|
4731
|
+
...(0, import_utils26.arrayify)(assetId)
|
4614
4732
|
]);
|
4615
4733
|
return scriptData;
|
4616
4734
|
};
|
@@ -4757,7 +4875,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4757
4875
|
* @param assetId - The asset ID to check the balance for.
|
4758
4876
|
* @returns A promise that resolves to the balance amount.
|
4759
4877
|
*/
|
4760
|
-
async getBalance(assetId =
|
4878
|
+
async getBalance(assetId = import_configs11.BaseAssetId) {
|
4761
4879
|
const amount = await this.provider.getBalance(this.address, assetId);
|
4762
4880
|
return amount;
|
4763
4881
|
}
|
@@ -4798,7 +4916,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4798
4916
|
async fund(request, coinQuantities, fee) {
|
4799
4917
|
const updatedQuantities = addAmountToAsset({
|
4800
4918
|
amount: (0, import_math17.bn)(fee),
|
4801
|
-
assetId:
|
4919
|
+
assetId: import_configs11.BaseAssetId,
|
4802
4920
|
coinQuantities
|
4803
4921
|
});
|
4804
4922
|
const quantitiesDict = {};
|
@@ -4822,8 +4940,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4822
4940
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4823
4941
|
cachedUtxos.push(input.id);
|
4824
4942
|
}
|
4825
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4826
|
-
quantitiesDict[
|
4943
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
|
4944
|
+
quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
|
4827
4945
|
cachedMessages.push(input.nonce);
|
4828
4946
|
}
|
4829
4947
|
}
|
@@ -4855,12 +4973,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4855
4973
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4856
4974
|
* @returns A promise that resolves to the prepared transaction request.
|
4857
4975
|
*/
|
4858
|
-
async createTransfer(destination, amount, assetId =
|
4976
|
+
async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4859
4977
|
const { minGasPrice } = this.provider.getGasConfig();
|
4860
4978
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4861
4979
|
const request = new ScriptTransactionRequest(params);
|
4862
4980
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
4863
|
-
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request
|
4981
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4982
|
+
estimateTxDependencies: true,
|
4983
|
+
resourcesOwner: this
|
4984
|
+
});
|
4864
4985
|
request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
|
4865
4986
|
request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
|
4866
4987
|
this.validateGas({
|
@@ -4870,6 +4991,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4870
4991
|
minGasPrice
|
4871
4992
|
});
|
4872
4993
|
await this.fund(request, requiredQuantities, maxFee);
|
4994
|
+
request.updatePredicateInputs(estimatedInputs);
|
4873
4995
|
return request;
|
4874
4996
|
}
|
4875
4997
|
/**
|
@@ -4881,9 +5003,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4881
5003
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4882
5004
|
* @returns A promise that resolves to the transaction response.
|
4883
5005
|
*/
|
4884
|
-
async transfer(destination, amount, assetId =
|
5006
|
+
async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4885
5007
|
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
4886
|
-
return this.sendTransaction(request);
|
5008
|
+
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4887
5009
|
}
|
4888
5010
|
/**
|
4889
5011
|
* Transfers coins to a contract address.
|
@@ -4894,7 +5016,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4894
5016
|
* @param txParams - The optional transaction parameters.
|
4895
5017
|
* @returns A promise that resolves to the transaction response.
|
4896
5018
|
*/
|
4897
|
-
async transferToContract(contractId, amount, assetId =
|
5019
|
+
async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4898
5020
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4899
5021
|
const { minGasPrice } = this.provider.getGasConfig();
|
4900
5022
|
const params = { gasPrice: minGasPrice, ...txParams };
|
@@ -4934,20 +5056,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4934
5056
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4935
5057
|
const { minGasPrice } = this.provider.getGasConfig();
|
4936
5058
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4937
|
-
const recipientDataArray = (0,
|
5059
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
4938
5060
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4939
5061
|
);
|
4940
|
-
const amountDataArray = (0,
|
5062
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
4941
5063
|
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4942
5064
|
);
|
4943
5065
|
const script = new Uint8Array([
|
4944
|
-
...(0,
|
5066
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
4945
5067
|
...recipientDataArray,
|
4946
5068
|
...amountDataArray
|
4947
5069
|
]);
|
4948
5070
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
4949
5071
|
const request = new ScriptTransactionRequest(params);
|
4950
|
-
const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId:
|
5072
|
+
const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
|
4951
5073
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4952
5074
|
request,
|
4953
5075
|
forwardingQuantities
|
@@ -4974,16 +5096,18 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4974
5096
|
* @param transactionRequestLike - The transaction request to be sent.
|
4975
5097
|
* @returns A promise that resolves to the transaction response.
|
4976
5098
|
*/
|
4977
|
-
async sendTransaction(transactionRequestLike,
|
5099
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
4978
5100
|
if (this._connector) {
|
4979
5101
|
return this.provider.getTransactionResponse(
|
4980
5102
|
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
|
4981
5103
|
);
|
4982
5104
|
}
|
4983
5105
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4984
|
-
|
5106
|
+
if (estimateTxDependencies) {
|
5107
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5108
|
+
}
|
4985
5109
|
return this.provider.sendTransaction(transactionRequest, {
|
4986
|
-
|
5110
|
+
awaitExecution,
|
4987
5111
|
estimateTxDependencies: false
|
4988
5112
|
});
|
4989
5113
|
}
|
@@ -4993,9 +5117,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4993
5117
|
* @param transactionRequestLike - The transaction request to be simulated.
|
4994
5118
|
* @returns A promise that resolves to the call result.
|
4995
5119
|
*/
|
4996
|
-
async simulateTransaction(transactionRequestLike) {
|
5120
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4997
5121
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4998
|
-
|
5122
|
+
if (estimateTxDependencies) {
|
5123
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5124
|
+
}
|
4999
5125
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5000
5126
|
}
|
5001
5127
|
validateGas({
|
@@ -5021,14 +5147,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5021
5147
|
|
5022
5148
|
// src/wallet/base-wallet-unlocked.ts
|
5023
5149
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5150
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5024
5151
|
|
5025
5152
|
// src/signer/signer.ts
|
5026
5153
|
var import_address5 = require("@fuel-ts/address");
|
5027
5154
|
var import_crypto = require("@fuel-ts/crypto");
|
5028
5155
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5029
5156
|
var import_math18 = require("@fuel-ts/math");
|
5157
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5030
5158
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5031
|
-
var import_ethers22 = require("ethers");
|
5032
5159
|
var Signer = class {
|
5033
5160
|
address;
|
5034
5161
|
publicKey;
|
@@ -5047,9 +5174,9 @@ var Signer = class {
|
|
5047
5174
|
}
|
5048
5175
|
}
|
5049
5176
|
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
5050
|
-
this.privateKey = (0,
|
5051
|
-
this.publicKey = (0,
|
5052
|
-
this.compressedPublicKey = (0,
|
5177
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5178
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5179
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5053
5180
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5054
5181
|
}
|
5055
5182
|
/**
|
@@ -5063,11 +5190,11 @@ var Signer = class {
|
|
5063
5190
|
* @returns hashed signature
|
5064
5191
|
*/
|
5065
5192
|
sign(data) {
|
5066
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5193
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5067
5194
|
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5068
5195
|
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5069
5196
|
s[0] |= (signature.recovery || 0) << 7;
|
5070
|
-
return (0,
|
5197
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
5071
5198
|
}
|
5072
5199
|
/**
|
5073
5200
|
* Add point on the current elliptic curve
|
@@ -5076,8 +5203,8 @@ var Signer = class {
|
|
5076
5203
|
* @returns compressed point on the curve
|
5077
5204
|
*/
|
5078
5205
|
addPoint(point) {
|
5079
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5080
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5206
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
5207
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
5081
5208
|
const result = p0.add(p1);
|
5082
5209
|
return `0x${result.toHex(true)}`;
|
5083
5210
|
}
|
@@ -5089,16 +5216,16 @@ var Signer = class {
|
|
5089
5216
|
* @returns public key from signature from the
|
5090
5217
|
*/
|
5091
5218
|
static recoverPublicKey(data, signature) {
|
5092
|
-
const signedMessageBytes = (0,
|
5219
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
5093
5220
|
const r = signedMessageBytes.slice(0, 32);
|
5094
5221
|
const s = signedMessageBytes.slice(32, 64);
|
5095
5222
|
const recoveryParam = (s[0] & 128) >> 7;
|
5096
5223
|
s[0] &= 127;
|
5097
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5224
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
5098
5225
|
recoveryParam
|
5099
5226
|
);
|
5100
|
-
const publicKey = sig.recoverPublicKey((0,
|
5101
|
-
return (0,
|
5227
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
5228
|
+
return (0, import_utils28.hexlify)(publicKey);
|
5102
5229
|
}
|
5103
5230
|
/**
|
5104
5231
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5117,7 +5244,7 @@ var Signer = class {
|
|
5117
5244
|
* @returns random 32-byte hashed
|
5118
5245
|
*/
|
5119
5246
|
static generatePrivateKey(entropy) {
|
5120
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5247
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5121
5248
|
}
|
5122
5249
|
/**
|
5123
5250
|
* Extended publicKey from a compact publicKey
|
@@ -5126,8 +5253,8 @@ var Signer = class {
|
|
5126
5253
|
* @returns extended publicKey
|
5127
5254
|
*/
|
5128
5255
|
static extendPublicKey(publicKey) {
|
5129
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5130
|
-
return (0,
|
5256
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
5257
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5131
5258
|
}
|
5132
5259
|
};
|
5133
5260
|
|
@@ -5135,7 +5262,7 @@ var Signer = class {
|
|
5135
5262
|
var import_address6 = require("@fuel-ts/address");
|
5136
5263
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5137
5264
|
var import_errors16 = require("@fuel-ts/errors");
|
5138
|
-
var
|
5265
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5139
5266
|
var import_uuid = require("uuid");
|
5140
5267
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5141
5268
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5218,7 +5345,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5218
5345
|
);
|
5219
5346
|
}
|
5220
5347
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5221
|
-
const privateKey = (0,
|
5348
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5222
5349
|
return privateKey;
|
5223
5350
|
}
|
5224
5351
|
|
@@ -5263,7 +5390,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5263
5390
|
*/
|
5264
5391
|
async signMessage(message) {
|
5265
5392
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5266
|
-
return signedMessage;
|
5393
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5267
5394
|
}
|
5268
5395
|
/**
|
5269
5396
|
* Signs a transaction with the wallet's private key.
|
@@ -5276,7 +5403,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5276
5403
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5277
5404
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5278
5405
|
const signature = await this.signer().sign(hashedTransaction);
|
5279
|
-
return signature;
|
5406
|
+
return (0, import_utils30.hexlify)(signature);
|
5280
5407
|
}
|
5281
5408
|
/**
|
5282
5409
|
* Populates a transaction with the witnesses signature.
|
@@ -5296,12 +5423,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
5296
5423
|
* @param transactionRequestLike - The transaction request to send.
|
5297
5424
|
* @returns A promise that resolves to the TransactionResponse object.
|
5298
5425
|
*/
|
5299
|
-
async sendTransaction(transactionRequestLike,
|
5426
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5300
5427
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5301
|
-
|
5428
|
+
if (estimateTxDependencies) {
|
5429
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5430
|
+
}
|
5302
5431
|
return this.provider.sendTransaction(
|
5303
5432
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
5304
|
-
{
|
5433
|
+
{ awaitExecution, estimateTxDependencies: false }
|
5305
5434
|
);
|
5306
5435
|
}
|
5307
5436
|
/**
|
@@ -5310,9 +5439,11 @@ var BaseWalletUnlocked = class extends Account {
|
|
5310
5439
|
* @param transactionRequestLike - The transaction request to simulate.
|
5311
5440
|
* @returns A promise that resolves to the CallResult object.
|
5312
5441
|
*/
|
5313
|
-
async simulateTransaction(transactionRequestLike) {
|
5442
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
5314
5443
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5315
|
-
|
5444
|
+
if (estimateTxDependencies) {
|
5445
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5446
|
+
}
|
5316
5447
|
return this.provider.call(
|
5317
5448
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
5318
5449
|
{
|
@@ -5333,12 +5464,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5333
5464
|
// src/hdwallet/hdwallet.ts
|
5334
5465
|
var import_errors19 = require("@fuel-ts/errors");
|
5335
5466
|
var import_math19 = require("@fuel-ts/math");
|
5336
|
-
var
|
5467
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5468
|
+
var import_ethers5 = require("ethers");
|
5337
5469
|
|
5338
5470
|
// src/mnemonic/mnemonic.ts
|
5339
5471
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5340
5472
|
var import_errors18 = require("@fuel-ts/errors");
|
5341
|
-
var
|
5473
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5474
|
+
var import_ethers4 = require("ethers");
|
5342
5475
|
|
5343
5476
|
// src/wordlists/words/english.ts
|
5344
5477
|
var english = [
|
@@ -7400,7 +7533,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7400
7533
|
|
7401
7534
|
// src/mnemonic/utils.ts
|
7402
7535
|
var import_errors17 = require("@fuel-ts/errors");
|
7403
|
-
var
|
7536
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7537
|
+
var import_ethers3 = require("ethers");
|
7404
7538
|
function toUtf8Bytes(stri) {
|
7405
7539
|
const str = stri.normalize("NFKD");
|
7406
7540
|
const result = [];
|
@@ -7467,14 +7601,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7467
7601
|
}
|
7468
7602
|
}
|
7469
7603
|
const checksumBits = entropy.length / 4;
|
7470
|
-
const checksum = (0,
|
7604
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7471
7605
|
indices[indices.length - 1] <<= checksumBits;
|
7472
7606
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7473
7607
|
return indices;
|
7474
7608
|
}
|
7475
7609
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7476
7610
|
const size = Math.ceil(11 * words.length / 8);
|
7477
|
-
const entropy = (0,
|
7611
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7478
7612
|
let offset = 0;
|
7479
7613
|
for (let i = 0; i < words.length; i += 1) {
|
7480
7614
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7494,7 +7628,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7494
7628
|
const entropyBits = 32 * words.length / 3;
|
7495
7629
|
const checksumBits = words.length / 3;
|
7496
7630
|
const checksumMask = getUpperMask(checksumBits);
|
7497
|
-
const checksum = (0,
|
7631
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7498
7632
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7499
7633
|
throw new import_errors17.FuelError(
|
7500
7634
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7569,7 +7703,7 @@ var Mnemonic = class {
|
|
7569
7703
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7570
7704
|
const words = getWords(phrase);
|
7571
7705
|
assertMnemonic(words);
|
7572
|
-
return (0,
|
7706
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7573
7707
|
}
|
7574
7708
|
/**
|
7575
7709
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7577,7 +7711,7 @@ var Mnemonic = class {
|
|
7577
7711
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7578
7712
|
*/
|
7579
7713
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7580
|
-
const entropyBytes = (0,
|
7714
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7581
7715
|
assertWordList(wordlist);
|
7582
7716
|
assertEntropy(entropyBytes);
|
7583
7717
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7591,7 +7725,7 @@ var Mnemonic = class {
|
|
7591
7725
|
assertMnemonic(getWords(phrase));
|
7592
7726
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7593
7727
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7594
|
-
return (0,
|
7728
|
+
return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7595
7729
|
}
|
7596
7730
|
/**
|
7597
7731
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7646,14 +7780,14 @@ var Mnemonic = class {
|
|
7646
7780
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7647
7781
|
*/
|
7648
7782
|
static masterKeysFromSeed(seed) {
|
7649
|
-
const seedArray = (0,
|
7783
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7650
7784
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7651
7785
|
throw new import_errors18.FuelError(
|
7652
7786
|
import_errors18.ErrorCode.INVALID_SEED,
|
7653
7787
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7654
7788
|
);
|
7655
7789
|
}
|
7656
|
-
return (0,
|
7790
|
+
return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
|
7657
7791
|
}
|
7658
7792
|
/**
|
7659
7793
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7664,22 +7798,22 @@ var Mnemonic = class {
|
|
7664
7798
|
*/
|
7665
7799
|
static seedToExtendedKey(seed, testnet = false) {
|
7666
7800
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7667
|
-
const prefix = (0,
|
7801
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7668
7802
|
const depth = "0x00";
|
7669
7803
|
const fingerprint = "0x00000000";
|
7670
7804
|
const index = "0x00000000";
|
7671
7805
|
const chainCode = masterKey.slice(32);
|
7672
7806
|
const privateKey = masterKey.slice(0, 32);
|
7673
|
-
const extendedKey = (0,
|
7807
|
+
const extendedKey = (0, import_utils32.concat)([
|
7674
7808
|
prefix,
|
7675
7809
|
depth,
|
7676
7810
|
fingerprint,
|
7677
7811
|
index,
|
7678
7812
|
chainCode,
|
7679
|
-
(0,
|
7813
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7680
7814
|
]);
|
7681
|
-
const checksum = (0,
|
7682
|
-
return (0,
|
7815
|
+
const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
|
7816
|
+
return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7683
7817
|
}
|
7684
7818
|
/**
|
7685
7819
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7694,7 +7828,7 @@ var Mnemonic = class {
|
|
7694
7828
|
* @returns A randomly generated mnemonic
|
7695
7829
|
*/
|
7696
7830
|
static generate(size = 32, extraEntropy = "") {
|
7697
|
-
const entropy = extraEntropy ? (0,
|
7831
|
+
const entropy = extraEntropy ? (0, import_ethers4.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7698
7832
|
return Mnemonic.entropyToMnemonic(entropy);
|
7699
7833
|
}
|
7700
7834
|
};
|
@@ -7702,12 +7836,12 @@ var mnemonic_default = Mnemonic;
|
|
7702
7836
|
|
7703
7837
|
// src/hdwallet/hdwallet.ts
|
7704
7838
|
var HARDENED_INDEX = 2147483648;
|
7705
|
-
var MainnetPRV2 = (0,
|
7706
|
-
var MainnetPUB = (0,
|
7707
|
-
var TestnetPRV2 = (0,
|
7708
|
-
var TestnetPUB = (0,
|
7839
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7840
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7841
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7842
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7709
7843
|
function base58check(data) {
|
7710
|
-
return (0,
|
7844
|
+
return (0, import_ethers5.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers5.dataSlice)((0, import_ethers5.sha256)((0, import_ethers5.sha256)(data)), 0, 4)]));
|
7711
7845
|
}
|
7712
7846
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7713
7847
|
if (isPublic) {
|
@@ -7716,11 +7850,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7716
7850
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7717
7851
|
}
|
7718
7852
|
function isPublicExtendedKey(extendedKey) {
|
7719
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7853
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7720
7854
|
}
|
7721
7855
|
function isValidExtendedKey(extendedKey) {
|
7722
7856
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7723
|
-
(0,
|
7857
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7724
7858
|
);
|
7725
7859
|
}
|
7726
7860
|
function parsePath(path, depth = 0) {
|
@@ -7738,8 +7872,8 @@ function parsePath(path, depth = 0) {
|
|
7738
7872
|
var HDWallet = class {
|
7739
7873
|
depth = 0;
|
7740
7874
|
index = 0;
|
7741
|
-
fingerprint = (0,
|
7742
|
-
parentFingerprint = (0,
|
7875
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7876
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7743
7877
|
privateKey;
|
7744
7878
|
publicKey;
|
7745
7879
|
chainCode;
|
@@ -7751,8 +7885,8 @@ var HDWallet = class {
|
|
7751
7885
|
constructor(config) {
|
7752
7886
|
if (config.privateKey) {
|
7753
7887
|
const signer = new Signer(config.privateKey);
|
7754
|
-
this.publicKey = (0,
|
7755
|
-
this.privateKey = (0,
|
7888
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7889
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7756
7890
|
} else {
|
7757
7891
|
if (!config.publicKey) {
|
7758
7892
|
throw new import_errors19.FuelError(
|
@@ -7760,10 +7894,10 @@ var HDWallet = class {
|
|
7760
7894
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7761
7895
|
);
|
7762
7896
|
}
|
7763
|
-
this.publicKey = (0,
|
7897
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7764
7898
|
}
|
7765
7899
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7766
|
-
this.fingerprint = (0,
|
7900
|
+
this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
|
7767
7901
|
this.depth = config.depth || this.depth;
|
7768
7902
|
this.index = config.index || this.index;
|
7769
7903
|
this.chainCode = config.chainCode;
|
@@ -7779,9 +7913,9 @@ var HDWallet = class {
|
|
7779
7913
|
* @returns A new instance of HDWallet on the derived index
|
7780
7914
|
*/
|
7781
7915
|
deriveIndex(index) {
|
7782
|
-
const privateKey = this.privateKey && (0,
|
7783
|
-
const publicKey = (0,
|
7784
|
-
const chainCode = (0,
|
7916
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7917
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7918
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7785
7919
|
const data = new Uint8Array(37);
|
7786
7920
|
if (index & HARDENED_INDEX) {
|
7787
7921
|
if (!privateKey) {
|
@@ -7792,10 +7926,10 @@ var HDWallet = class {
|
|
7792
7926
|
}
|
7793
7927
|
data.set(privateKey, 1);
|
7794
7928
|
} else {
|
7795
|
-
data.set((0,
|
7929
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7796
7930
|
}
|
7797
7931
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7798
|
-
const bytes = (0,
|
7932
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
|
7799
7933
|
const IL = bytes.slice(0, 32);
|
7800
7934
|
const IR = bytes.slice(32);
|
7801
7935
|
if (privateKey) {
|
@@ -7809,7 +7943,7 @@ var HDWallet = class {
|
|
7809
7943
|
parentFingerprint: this.fingerprint
|
7810
7944
|
});
|
7811
7945
|
}
|
7812
|
-
const signer = new Signer((0,
|
7946
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7813
7947
|
const Ki = signer.addPoint(publicKey);
|
7814
7948
|
return new HDWallet({
|
7815
7949
|
publicKey: Ki,
|
@@ -7844,14 +7978,12 @@ var HDWallet = class {
|
|
7844
7978
|
);
|
7845
7979
|
}
|
7846
7980
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7847
|
-
const depth = (0,
|
7981
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
7848
7982
|
const parentFingerprint = this.parentFingerprint;
|
7849
7983
|
const index = (0, import_math19.toHex)(this.index, 4);
|
7850
7984
|
const chainCode = this.chainCode;
|
7851
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7852
|
-
const extendedKey = (0,
|
7853
|
-
(0, import_ethers26.concat)([prefix, depth, parentFingerprint, index, chainCode, key])
|
7854
|
-
);
|
7985
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7986
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7855
7987
|
return base58check(extendedKey);
|
7856
7988
|
}
|
7857
7989
|
/**
|
@@ -7863,13 +7995,13 @@ var HDWallet = class {
|
|
7863
7995
|
static fromSeed(seed) {
|
7864
7996
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7865
7997
|
return new HDWallet({
|
7866
|
-
chainCode: (0,
|
7867
|
-
privateKey: (0,
|
7998
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
7999
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
7868
8000
|
});
|
7869
8001
|
}
|
7870
8002
|
static fromExtendedKey(extendedKey) {
|
7871
|
-
const decoded = (0,
|
7872
|
-
const bytes = (0,
|
8003
|
+
const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
|
8004
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
7873
8005
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7874
8006
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7875
8007
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7878,9 +8010,9 @@ var HDWallet = class {
|
|
7878
8010
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7879
8011
|
}
|
7880
8012
|
const depth = bytes[4];
|
7881
|
-
const parentFingerprint = (0,
|
7882
|
-
const index = parseInt((0,
|
7883
|
-
const chainCode = (0,
|
8013
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
8014
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8015
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
7884
8016
|
const key = bytes.slice(45, 78);
|
7885
8017
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7886
8018
|
throw new import_errors19.FuelError(
|
@@ -8483,22 +8615,21 @@ var StorageAbstract = class {
|
|
8483
8615
|
// src/predicate/predicate.ts
|
8484
8616
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
8485
8617
|
var import_address10 = require("@fuel-ts/address");
|
8486
|
-
var
|
8618
|
+
var import_configs12 = require("@fuel-ts/address/configs");
|
8487
8619
|
var import_errors24 = require("@fuel-ts/errors");
|
8488
8620
|
var import_transactions19 = require("@fuel-ts/transactions");
|
8489
|
-
var
|
8621
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8490
8622
|
|
8491
8623
|
// src/predicate/utils/getPredicateRoot.ts
|
8492
8624
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8493
8625
|
var import_merkle = require("@fuel-ts/merkle");
|
8494
|
-
var
|
8495
|
-
var import_ethers27 = require("ethers");
|
8626
|
+
var import_utils35 = require("@fuel-ts/utils");
|
8496
8627
|
var getPredicateRoot = (bytecode) => {
|
8497
8628
|
const chunkSize = 16 * 1024;
|
8498
|
-
const bytes = (0,
|
8499
|
-
const chunks = (0,
|
8500
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
8501
|
-
const predicateRoot = (0, import_hasher4.hash)((0,
|
8629
|
+
const bytes = (0, import_utils35.arrayify)(bytecode);
|
8630
|
+
const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
|
8631
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
|
8632
|
+
const predicateRoot = (0, import_hasher4.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
|
8502
8633
|
return predicateRoot;
|
8503
8634
|
};
|
8504
8635
|
|
@@ -8537,7 +8668,7 @@ var Predicate = class extends Account {
|
|
8537
8668
|
const request = transactionRequestify(transactionRequestLike);
|
8538
8669
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8539
8670
|
request.inputs?.forEach((input) => {
|
8540
|
-
if (input.type === import_transactions19.InputType.Coin && (0,
|
8671
|
+
if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
|
8541
8672
|
input.predicate = this.bytes;
|
8542
8673
|
input.predicateData = this.getPredicateData(policies.length);
|
8543
8674
|
}
|
@@ -8553,7 +8684,7 @@ var Predicate = class extends Account {
|
|
8553
8684
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8554
8685
|
* @returns A promise that resolves to the prepared transaction request.
|
8555
8686
|
*/
|
8556
|
-
async createTransfer(destination, amount, assetId =
|
8687
|
+
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
8557
8688
|
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
8558
8689
|
return this.populateTransactionPredicateData(request);
|
8559
8690
|
}
|
@@ -8608,7 +8739,7 @@ var Predicate = class extends Account {
|
|
8608
8739
|
* @returns An object containing the new predicate bytes and interface.
|
8609
8740
|
*/
|
8610
8741
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8611
|
-
let predicateBytes = (0,
|
8742
|
+
let predicateBytes = (0, import_utils36.arrayify)(bytes);
|
8612
8743
|
let abiInterface;
|
8613
8744
|
if (jsonAbi) {
|
8614
8745
|
abiInterface = new import_abi_coder5.Interface(jsonAbi);
|
@@ -8668,6 +8799,9 @@ var Predicate = class extends Account {
|
|
8668
8799
|
}
|
8669
8800
|
};
|
8670
8801
|
|
8802
|
+
// src/connectors/fuel.ts
|
8803
|
+
var import_errors25 = require("@fuel-ts/errors");
|
8804
|
+
|
8671
8805
|
// src/connectors/fuel-connector.ts
|
8672
8806
|
var import_events2 = require("events");
|
8673
8807
|
|
@@ -8708,17 +8842,6 @@ var FuelConnectorEventTypes = /* @__PURE__ */ ((FuelConnectorEventTypes2) => {
|
|
8708
8842
|
})(FuelConnectorEventTypes || {});
|
8709
8843
|
var FuelConnectorEventType = "FuelConnector";
|
8710
8844
|
|
8711
|
-
// src/connectors/types/data-type.ts
|
8712
|
-
var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
|
8713
|
-
MessageTypes2["ping"] = "ping";
|
8714
|
-
MessageTypes2["uiEvent"] = "uiEvent";
|
8715
|
-
MessageTypes2["event"] = "event";
|
8716
|
-
MessageTypes2["request"] = "request";
|
8717
|
-
MessageTypes2["response"] = "response";
|
8718
|
-
MessageTypes2["removeConnection"] = "removeConnection";
|
8719
|
-
return MessageTypes2;
|
8720
|
-
})(MessageTypes || {});
|
8721
|
-
|
8722
8845
|
// src/connectors/types/local-storage.ts
|
8723
8846
|
var LocalStorage = class {
|
8724
8847
|
storage;
|
@@ -9007,6 +9130,7 @@ async function withTimeout(promise, timeout = 1050) {
|
|
9007
9130
|
// src/connectors/fuel.ts
|
9008
9131
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
9009
9132
|
var PING_CACHE_TIME = 5e3;
|
9133
|
+
var { warn } = console;
|
9010
9134
|
var _Fuel = class extends FuelConnector {
|
9011
9135
|
_storage = null;
|
9012
9136
|
_connectors = [];
|
@@ -9275,14 +9399,12 @@ var _Fuel = class extends FuelConnector {
|
|
9275
9399
|
* Return a Fuel Provider instance with extends features to work with
|
9276
9400
|
* connectors.
|
9277
9401
|
*
|
9278
|
-
* @deprecated
|
9402
|
+
* @deprecated getProvider is deprecated and is going to be removed in the future, use getWallet instead.
|
9279
9403
|
*/
|
9280
9404
|
async getProvider(providerOrNetwork) {
|
9281
|
-
|
9282
|
-
|
9283
|
-
|
9284
|
-
);
|
9285
|
-
}
|
9405
|
+
warn(
|
9406
|
+
"getProvider is deprecated and is going to be removed in the future, use getWallet instead."
|
9407
|
+
);
|
9286
9408
|
return this._getProvider(providerOrNetwork);
|
9287
9409
|
}
|
9288
9410
|
/**
|
@@ -9299,7 +9421,7 @@ var _Fuel = class extends FuelConnector {
|
|
9299
9421
|
const currentNetwork = await this.currentNetwork();
|
9300
9422
|
provider = await Provider.create(currentNetwork.url);
|
9301
9423
|
} else {
|
9302
|
-
throw new
|
9424
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
9303
9425
|
}
|
9304
9426
|
return provider;
|
9305
9427
|
}
|
@@ -9343,6 +9465,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9343
9465
|
AddressType,
|
9344
9466
|
BaseTransactionRequest,
|
9345
9467
|
BaseWalletUnlocked,
|
9468
|
+
CHAIN_IDS,
|
9346
9469
|
ChainName,
|
9347
9470
|
ChangeOutputCollisionError,
|
9348
9471
|
CreateTransactionRequest,
|
@@ -9356,7 +9479,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9356
9479
|
LocalStorage,
|
9357
9480
|
MNEMONIC_SIZES,
|
9358
9481
|
MemoryStorage,
|
9359
|
-
MessageTypes,
|
9360
9482
|
Mnemonic,
|
9361
9483
|
MnemonicVault,
|
9362
9484
|
NoWitnessAtIndexError,
|
@@ -9381,6 +9503,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9381
9503
|
addOperation,
|
9382
9504
|
assembleReceiptByType,
|
9383
9505
|
assembleTransactionSummary,
|
9506
|
+
assets,
|
9384
9507
|
buildBlockExplorerUrl,
|
9385
9508
|
cacheFor,
|
9386
9509
|
calculateMetadataGasForTxCreate,
|
@@ -9393,15 +9516,15 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9393
9516
|
english,
|
9394
9517
|
extractBurnedAssetsFromReceipts,
|
9395
9518
|
extractMintedAssetsFromReceipts,
|
9396
|
-
fromDateToTai64,
|
9397
|
-
fromTai64ToDate,
|
9398
|
-
fromTai64ToUnix,
|
9399
|
-
fromUnixToTai64,
|
9400
9519
|
gasUsedByInputs,
|
9520
|
+
getAssetEth,
|
9521
|
+
getAssetFuel,
|
9522
|
+
getAssetNetwork,
|
9523
|
+
getAssetWithNetwork,
|
9401
9524
|
getContractCallOperations,
|
9402
9525
|
getContractCreatedOperations,
|
9403
|
-
getContractTransferOperations,
|
9404
9526
|
getDecodedLogs,
|
9527
|
+
getDefaultChainId,
|
9405
9528
|
getGasUsedFromReceipts,
|
9406
9529
|
getInputAccountAddress,
|
9407
9530
|
getInputContractFromIndex,
|
@@ -9450,9 +9573,11 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9450
9573
|
processGqlReceipt,
|
9451
9574
|
processGraphqlStatus,
|
9452
9575
|
resolveGasDependentCosts,
|
9576
|
+
resolveIconPaths,
|
9453
9577
|
returnZeroScript,
|
9454
9578
|
sleep,
|
9455
9579
|
transactionRequestify,
|
9580
|
+
urlJoin,
|
9456
9581
|
withTimeout,
|
9457
9582
|
withdrawScript
|
9458
9583
|
});
|