@fuel-ts/account 0.94.4 → 0.94.5
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 +41 -170
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +39 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -121
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +169 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +9 -1
- package/dist/providers/provider.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/receipts.d.ts.map +1 -1
- package/dist/test-utils.global.js +41 -170
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +39 -29
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +115 -110
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.js
CHANGED
@@ -1370,6 +1370,13 @@ var SubmitAndAwaitDocument = import_graphql_tag.default`
|
|
1370
1370
|
}
|
1371
1371
|
}
|
1372
1372
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1373
|
+
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1374
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1375
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1376
|
+
...transactionStatusSubscriptionFragment
|
1377
|
+
}
|
1378
|
+
}
|
1379
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1373
1380
|
var StatusChangeDocument = import_graphql_tag.default`
|
1374
1381
|
subscription statusChange($transactionId: TransactionId!) {
|
1375
1382
|
statusChange(id: $transactionId) {
|
@@ -1466,6 +1473,9 @@ function getSdk(requester) {
|
|
1466
1473
|
submitAndAwait(variables, options) {
|
1467
1474
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1468
1475
|
},
|
1476
|
+
submitAndAwaitStatus(variables, options) {
|
1477
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1478
|
+
},
|
1469
1479
|
statusChange(variables, options) {
|
1470
1480
|
return requester(StatusChangeDocument, variables, options);
|
1471
1481
|
}
|
@@ -1492,7 +1502,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1492
1502
|
Accept: "text/event-stream"
|
1493
1503
|
}
|
1494
1504
|
});
|
1495
|
-
|
1505
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1506
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1507
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1496
1508
|
}
|
1497
1509
|
events = [];
|
1498
1510
|
parsingLeftover = "";
|
@@ -1535,10 +1547,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1535
1547
|
/**
|
1536
1548
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1537
1549
|
*/
|
1538
|
-
|
1539
|
-
|
1540
|
-
this.stream.releaseLock();
|
1541
|
-
return { done: true, value: void 0 };
|
1550
|
+
return() {
|
1551
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1542
1552
|
}
|
1543
1553
|
[Symbol.asyncIterator]() {
|
1544
1554
|
return this;
|
@@ -1909,12 +1919,12 @@ function assembleReceiptByType(receipt) {
|
|
1909
1919
|
const amount = (0, import_math5.bn)(receipt.amount);
|
1910
1920
|
const data = receipt.data ? (0, import_utils7.arrayify)(receipt.data) : Uint8Array.from([]);
|
1911
1921
|
const digest = hexOrZero(receipt.digest);
|
1912
|
-
const messageId = import_transactions3.
|
1922
|
+
const messageId = import_transactions3.InputMessageCoder.getMessageId({
|
1913
1923
|
sender,
|
1914
1924
|
recipient,
|
1915
1925
|
nonce,
|
1916
1926
|
amount,
|
1917
|
-
data
|
1927
|
+
data: (0, import_utils7.hexlify)(data)
|
1918
1928
|
});
|
1919
1929
|
const receiptMessageOut = {
|
1920
1930
|
type: import_transactions3.ReceiptType.MessageOut,
|
@@ -1931,7 +1941,7 @@ function assembleReceiptByType(receipt) {
|
|
1931
1941
|
case "MINT" /* Mint */: {
|
1932
1942
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1933
1943
|
const subId = hexOrZero(receipt.subId);
|
1934
|
-
const assetId = import_transactions3.
|
1944
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1935
1945
|
const mintReceipt = {
|
1936
1946
|
type: import_transactions3.ReceiptType.Mint,
|
1937
1947
|
subId,
|
@@ -1946,7 +1956,7 @@ function assembleReceiptByType(receipt) {
|
|
1946
1956
|
case "BURN" /* Burn */: {
|
1947
1957
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1948
1958
|
const subId = hexOrZero(receipt.subId);
|
1949
|
-
const assetId = import_transactions3.
|
1959
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1950
1960
|
const burnReceipt = {
|
1951
1961
|
type: import_transactions3.ReceiptType.Burn,
|
1952
1962
|
subId,
|
@@ -4068,29 +4078,30 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4068
4078
|
});
|
4069
4079
|
}
|
4070
4080
|
var TransactionResponse = class {
|
4071
|
-
/** Transaction ID */
|
4072
|
-
id;
|
4073
|
-
/** Current provider */
|
4074
|
-
provider;
|
4075
|
-
/** Gas used on the transaction */
|
4076
|
-
gasUsed = (0, import_math18.bn)(0);
|
4077
|
-
/** The graphql Transaction with receipts object. */
|
4078
|
-
gqlTransaction;
|
4079
|
-
request;
|
4080
|
-
status;
|
4081
|
-
abis;
|
4082
4081
|
/**
|
4083
4082
|
* Constructor for `TransactionResponse`.
|
4084
4083
|
*
|
4085
4084
|
* @param tx - The transaction ID or TransactionRequest.
|
4086
4085
|
* @param provider - The provider.
|
4087
4086
|
*/
|
4088
|
-
constructor(tx, provider, abis) {
|
4087
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4088
|
+
this.submitTxSubscription = submitTxSubscription;
|
4089
4089
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
4090
4090
|
this.provider = provider;
|
4091
4091
|
this.abis = abis;
|
4092
4092
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4093
4093
|
}
|
4094
|
+
/** Transaction ID */
|
4095
|
+
id;
|
4096
|
+
/** Current provider */
|
4097
|
+
provider;
|
4098
|
+
/** Gas used on the transaction */
|
4099
|
+
gasUsed = (0, import_math18.bn)(0);
|
4100
|
+
/** The graphql Transaction with receipts object. */
|
4101
|
+
gqlTransaction;
|
4102
|
+
request;
|
4103
|
+
status;
|
4104
|
+
abis;
|
4094
4105
|
/**
|
4095
4106
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
4096
4107
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -4223,10 +4234,11 @@ var TransactionResponse = class {
|
|
4223
4234
|
if (status && status !== "SubmittedStatus") {
|
4224
4235
|
return;
|
4225
4236
|
}
|
4226
|
-
const subscription = await this.provider.operations.statusChange({
|
4237
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4227
4238
|
transactionId: this.id
|
4228
4239
|
});
|
4229
|
-
for await (const
|
4240
|
+
for await (const sub of subscription) {
|
4241
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4230
4242
|
this.status = statusChange;
|
4231
4243
|
if (statusChange.type === "SqueezedOutStatus") {
|
4232
4244
|
this.unsetResourceCache();
|
@@ -4504,7 +4516,7 @@ var _Provider = class {
|
|
4504
4516
|
const provider = new _Provider(urlToUse, {
|
4505
4517
|
...options,
|
4506
4518
|
requestMiddleware: async (request) => {
|
4507
|
-
if (auth) {
|
4519
|
+
if (auth && request) {
|
4508
4520
|
request.headers ??= {};
|
4509
4521
|
request.headers.Authorization = auth;
|
4510
4522
|
}
|
@@ -4764,11 +4776,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4764
4776
|
if (isTransactionTypeScript(transactionRequest)) {
|
4765
4777
|
abis = transactionRequest.abis;
|
4766
4778
|
}
|
4767
|
-
const {
|
4768
|
-
|
4769
|
-
|
4770
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4771
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
4779
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
4780
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
4781
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4772
4782
|
}
|
4773
4783
|
/**
|
4774
4784
|
* Executes a transaction without actually submitting it to the chain.
|