@fuel-ts/account 0.100.2 → 0.100.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +128 -80
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +331 -278
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -213
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-response/getAllDecodedLogs.d.ts +30 -0
- package/dist/providers/transaction-response/getAllDecodedLogs.d.ts.map +1 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts +20 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/index.d.ts +1 -0
- package/dist/providers/transaction-response/index.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +4 -3
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/test-utils.global.js +83 -71
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +232 -216
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +179 -163
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.global.js
CHANGED
@@ -17891,7 +17891,7 @@
|
|
17891
17891
|
return {
|
17892
17892
|
FUEL_CORE: "0.41.9",
|
17893
17893
|
FORC: "0.67.0",
|
17894
|
-
FUELS: "0.100.
|
17894
|
+
FUELS: "0.100.3"
|
17895
17895
|
};
|
17896
17896
|
}
|
17897
17897
|
__name(getBuiltinVersions, "getBuiltinVersions");
|
@@ -27013,26 +27013,6 @@ spurious results.`);
|
|
27013
27013
|
gql["default"] = gql;
|
27014
27014
|
var lib_default2 = gql;
|
27015
27015
|
|
27016
|
-
// src/connectors/utils/promises.ts
|
27017
|
-
function deferPromise() {
|
27018
|
-
const defer = {};
|
27019
|
-
defer.promise = new Promise((resolve, reject) => {
|
27020
|
-
defer.reject = reject;
|
27021
|
-
defer.resolve = resolve;
|
27022
|
-
});
|
27023
|
-
return defer;
|
27024
|
-
}
|
27025
|
-
__name(deferPromise, "deferPromise");
|
27026
|
-
async function withTimeout(promise, timeout = 1050) {
|
27027
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
27028
|
-
setTimeout(() => {
|
27029
|
-
reject(new FuelError(FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
27030
|
-
}, timeout);
|
27031
|
-
});
|
27032
|
-
return Promise.race([timeoutPromise, promise]);
|
27033
|
-
}
|
27034
|
-
__name(withTimeout, "withTimeout");
|
27035
|
-
|
27036
27016
|
// src/providers/__generated__/operations.ts
|
27037
27017
|
var SubmittedStatusFragmentDoc = lib_default2`
|
27038
27018
|
fragment SubmittedStatusFragment on SubmittedStatus {
|
@@ -29079,11 +29059,12 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
29079
29059
|
});
|
29080
29060
|
}, "assembleRevertError");
|
29081
29061
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
29082
|
-
const { receipts, statusReason, logs } = params;
|
29062
|
+
const { receipts, statusReason, logs, groupedLogs } = params;
|
29083
29063
|
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
29084
29064
|
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
29085
29065
|
const metadata = {
|
29086
29066
|
logs,
|
29067
|
+
groupedLogs,
|
29087
29068
|
receipts,
|
29088
29069
|
panic: isPanic,
|
29089
29070
|
revert: isRevert,
|
@@ -31399,8 +31380,9 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31399
31380
|
}
|
31400
31381
|
__name(assembleTransactionSummary, "assembleTransactionSummary");
|
31401
31382
|
|
31402
|
-
// src/providers/transaction-response/
|
31403
|
-
function
|
31383
|
+
// src/providers/transaction-response/getAllDecodedLogs.ts
|
31384
|
+
function getAllDecodedLogs(opts) {
|
31385
|
+
const { receipts, mainAbi, externalAbis = {} } = opts;
|
31404
31386
|
let mainContract = "";
|
31405
31387
|
if (mainAbi.programType === "contract") {
|
31406
31388
|
const firstCallReceipt = receipts.find(
|
@@ -31408,21 +31390,25 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31408
31390
|
);
|
31409
31391
|
mainContract = firstCallReceipt.to;
|
31410
31392
|
}
|
31411
|
-
return receipts.reduce(
|
31412
|
-
|
31413
|
-
|
31414
|
-
|
31415
|
-
|
31416
|
-
|
31417
|
-
|
31418
|
-
|
31419
|
-
|
31393
|
+
return receipts.reduce(
|
31394
|
+
({ logs, groupedLogs }, receipt) => {
|
31395
|
+
if (receipt.type === ReceiptType.LogData || receipt.type === ReceiptType.Log) {
|
31396
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes32 || mainContract === receipt.id;
|
31397
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
31398
|
+
if (isDecodable) {
|
31399
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface(mainAbi) : new Interface(externalAbis[receipt.id]);
|
31400
|
+
const data = receipt.type === ReceiptType.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
31401
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
31402
|
+
logs.push(decodedLog);
|
31403
|
+
groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
|
31404
|
+
}
|
31420
31405
|
}
|
31421
|
-
|
31422
|
-
|
31423
|
-
|
31406
|
+
return { logs, groupedLogs };
|
31407
|
+
},
|
31408
|
+
{ logs: [], groupedLogs: {} }
|
31409
|
+
);
|
31424
31410
|
}
|
31425
|
-
__name(
|
31411
|
+
__name(getAllDecodedLogs, "getAllDecodedLogs");
|
31426
31412
|
|
31427
31413
|
// src/providers/transaction-response/transaction-response.ts
|
31428
31414
|
function mapGqlOutputsToTxOutputs(outputs) {
|
@@ -31654,14 +31640,15 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31654
31640
|
const transactionResult = {
|
31655
31641
|
...transactionSummary
|
31656
31642
|
};
|
31657
|
-
let logs = [];
|
31643
|
+
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
31658
31644
|
if (this.abis) {
|
31659
|
-
logs =
|
31660
|
-
transactionSummary.receipts,
|
31661
|
-
this.abis.main,
|
31662
|
-
this.abis.otherContractsAbis
|
31663
|
-
);
|
31645
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
31646
|
+
receipts: transactionSummary.receipts,
|
31647
|
+
mainAbi: this.abis.main,
|
31648
|
+
externalAbis: this.abis.otherContractsAbis
|
31649
|
+
}));
|
31664
31650
|
transactionResult.logs = logs;
|
31651
|
+
transactionResult.groupedLogs = groupedLogs;
|
31665
31652
|
}
|
31666
31653
|
const { receipts } = transactionResult;
|
31667
31654
|
const status = this.status ?? this.gqlTransaction?.status;
|
@@ -31670,7 +31657,8 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31670
31657
|
throw extractTxError({
|
31671
31658
|
receipts,
|
31672
31659
|
statusReason: reason,
|
31673
|
-
logs
|
31660
|
+
logs,
|
31661
|
+
groupedLogs
|
31674
31662
|
});
|
31675
31663
|
}
|
31676
31664
|
return transactionResult;
|
@@ -31698,6 +31686,31 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31698
31686
|
}
|
31699
31687
|
};
|
31700
31688
|
|
31689
|
+
// src/providers/transaction-response/getDecodedLogs.ts
|
31690
|
+
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
31691
|
+
let mainContract = "";
|
31692
|
+
if (mainAbi.programType === "contract") {
|
31693
|
+
const firstCallReceipt = receipts.find(
|
31694
|
+
(r) => r.type === ReceiptType.Call && r.id === ZeroBytes32
|
31695
|
+
);
|
31696
|
+
mainContract = firstCallReceipt.to;
|
31697
|
+
}
|
31698
|
+
return receipts.reduce((logs, receipt) => {
|
31699
|
+
if (receipt.type === ReceiptType.LogData || receipt.type === ReceiptType.Log) {
|
31700
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes32 || mainContract === receipt.id;
|
31701
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
31702
|
+
if (isDecodable) {
|
31703
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface(mainAbi) : new Interface(externalAbis[receipt.id]);
|
31704
|
+
const data = receipt.type === ReceiptType.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
31705
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
31706
|
+
logs.push(decodedLog);
|
31707
|
+
}
|
31708
|
+
}
|
31709
|
+
return logs;
|
31710
|
+
}, []);
|
31711
|
+
}
|
31712
|
+
__name(getDecodedLogs, "getDecodedLogs");
|
31713
|
+
|
31701
31714
|
// src/providers/utils/auto-retry-fetch.ts
|
31702
31715
|
function getWaitDelay(options, retryAttemptNum) {
|
31703
31716
|
const duration = options.baseDelay ?? 150;
|
@@ -31969,39 +31982,52 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31969
31982
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
31970
31983
|
*/
|
31971
31984
|
async fetchChainAndNodeInfo(ignoreCache = false) {
|
31972
|
-
|
31973
|
-
|
31974
|
-
|
31975
|
-
|
31976
|
-
chain
|
31977
|
-
|
31978
|
-
|
31979
|
-
|
31980
|
-
|
31981
|
-
|
31982
|
-
|
31983
|
-
|
31984
|
-
|
31985
|
-
|
31986
|
-
|
31987
|
-
}
|
31988
|
-
const { promise, resolve } = deferPromise();
|
31989
|
-
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
31990
|
-
const data = await this.operations.getChainAndNodeInfo();
|
31991
|
-
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
31992
|
-
chain = deserializeChain(data.chain);
|
31993
|
-
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
31994
|
-
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
31995
|
-
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
31996
|
-
const now = Date.now();
|
31997
|
-
this.consensusParametersTimestamp = now;
|
31998
|
-
resolve(now);
|
31999
|
-
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
31985
|
+
const nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
31986
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
31987
|
+
const hasCache = nodeInfo && chain;
|
31988
|
+
if (hasCache && !ignoreCache) {
|
31989
|
+
return { nodeInfo, chain };
|
31990
|
+
}
|
31991
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
31992
|
+
if (inflightRequest) {
|
31993
|
+
return inflightRequest.then((data) => {
|
31994
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
31995
|
+
return {
|
31996
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
31997
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
31998
|
+
};
|
31999
|
+
});
|
32000
32000
|
}
|
32001
|
-
|
32002
|
-
chain,
|
32003
|
-
nodeInfo
|
32004
|
-
|
32001
|
+
const getChainAndNodeInfoFromNetwork = this.operations.getChainAndNodeInfo().then((data) => ({
|
32002
|
+
chain: deserializeChain(data.chain),
|
32003
|
+
nodeInfo: deserializeNodeInfo(data.nodeInfo),
|
32004
|
+
consensusParametersTimestamp: Date.now()
|
32005
|
+
})).then((data) => {
|
32006
|
+
_Provider.setIncompatibleNodeVersionMessage(data.nodeInfo);
|
32007
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = data.chain;
|
32008
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = data.nodeInfo;
|
32009
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
32010
|
+
return data;
|
32011
|
+
}).catch((err) => {
|
32012
|
+
const error2 = new FuelError(
|
32013
|
+
FuelError.CODES.CONNECTION_REFUSED,
|
32014
|
+
"Unable to fetch chain and node info from the network",
|
32015
|
+
{ url: this.urlWithoutAuth },
|
32016
|
+
err
|
32017
|
+
);
|
32018
|
+
error2.cause = { code: "ECONNREFUSED" };
|
32019
|
+
throw error2;
|
32020
|
+
}).finally(() => {
|
32021
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
32022
|
+
});
|
32023
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = getChainAndNodeInfoFromNetwork;
|
32024
|
+
return _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth].then((data) => {
|
32025
|
+
this.consensusParametersTimestamp = data.consensusParametersTimestamp;
|
32026
|
+
return {
|
32027
|
+
nodeInfo: _Provider.nodeInfoCache[this.urlWithoutAuth],
|
32028
|
+
chain: _Provider.chainInfoCache[this.urlWithoutAuth]
|
32029
|
+
};
|
32030
|
+
});
|
32005
32031
|
}
|
32006
32032
|
/**
|
32007
32033
|
* @hidden
|
@@ -33285,15 +33311,17 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
33285
33311
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
33286
33312
|
const status = dryRunStatus;
|
33287
33313
|
let logs = [];
|
33314
|
+
let groupedLogs = {};
|
33288
33315
|
if (transactionRequest.abis) {
|
33289
|
-
logs =
|
33316
|
+
({ logs, groupedLogs } = getAllDecodedLogs({
|
33290
33317
|
receipts,
|
33291
|
-
transactionRequest.abis.main,
|
33292
|
-
transactionRequest.abis.otherContractsAbis
|
33293
|
-
);
|
33318
|
+
mainAbi: transactionRequest.abis.main,
|
33319
|
+
externalAbis: transactionRequest.abis.otherContractsAbis
|
33320
|
+
}));
|
33294
33321
|
}
|
33295
33322
|
return extractTxError({
|
33296
33323
|
logs,
|
33324
|
+
groupedLogs,
|
33297
33325
|
receipts,
|
33298
33326
|
statusReason: status.reason
|
33299
33327
|
});
|
@@ -40651,6 +40679,26 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
40651
40679
|
}
|
40652
40680
|
__name(dispatchFuelConnectorEvent, "dispatchFuelConnectorEvent");
|
40653
40681
|
|
40682
|
+
// src/connectors/utils/promises.ts
|
40683
|
+
function deferPromise() {
|
40684
|
+
const defer = {};
|
40685
|
+
defer.promise = new Promise((resolve, reject) => {
|
40686
|
+
defer.reject = reject;
|
40687
|
+
defer.resolve = resolve;
|
40688
|
+
});
|
40689
|
+
return defer;
|
40690
|
+
}
|
40691
|
+
__name(deferPromise, "deferPromise");
|
40692
|
+
async function withTimeout(promise, timeout = 1050) {
|
40693
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
40694
|
+
setTimeout(() => {
|
40695
|
+
reject(new FuelError(FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
40696
|
+
}, timeout);
|
40697
|
+
});
|
40698
|
+
return Promise.race([timeoutPromise, promise]);
|
40699
|
+
}
|
40700
|
+
__name(withTimeout, "withTimeout");
|
40701
|
+
|
40654
40702
|
// src/connectors/fuel.ts
|
40655
40703
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
40656
40704
|
var PING_CACHE_TIME = 5e3;
|