@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/index.js
CHANGED
@@ -1211,6 +1211,13 @@ var SubmitAndAwaitDocument = import_graphql_tag.default`
|
|
1211
1211
|
}
|
1212
1212
|
}
|
1213
1213
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1214
|
+
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1215
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1216
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1217
|
+
...transactionStatusSubscriptionFragment
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1214
1221
|
var StatusChangeDocument = import_graphql_tag.default`
|
1215
1222
|
subscription statusChange($transactionId: TransactionId!) {
|
1216
1223
|
statusChange(id: $transactionId) {
|
@@ -1307,6 +1314,9 @@ function getSdk(requester) {
|
|
1307
1314
|
submitAndAwait(variables, options) {
|
1308
1315
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1309
1316
|
},
|
1317
|
+
submitAndAwaitStatus(variables, options) {
|
1318
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1319
|
+
},
|
1310
1320
|
statusChange(variables, options) {
|
1311
1321
|
return requester(StatusChangeDocument, variables, options);
|
1312
1322
|
}
|
@@ -1333,7 +1343,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1333
1343
|
Accept: "text/event-stream"
|
1334
1344
|
}
|
1335
1345
|
});
|
1336
|
-
|
1346
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1347
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1348
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1337
1349
|
}
|
1338
1350
|
events = [];
|
1339
1351
|
parsingLeftover = "";
|
@@ -1376,10 +1388,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1376
1388
|
/**
|
1377
1389
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1378
1390
|
*/
|
1379
|
-
|
1380
|
-
|
1381
|
-
this.stream.releaseLock();
|
1382
|
-
return { done: true, value: void 0 };
|
1391
|
+
return() {
|
1392
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1383
1393
|
}
|
1384
1394
|
[Symbol.asyncIterator]() {
|
1385
1395
|
return this;
|
@@ -1753,12 +1763,12 @@ function assembleReceiptByType(receipt) {
|
|
1753
1763
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1754
1764
|
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1755
1765
|
const digest = hexOrZero(receipt.digest);
|
1756
|
-
const messageId = import_transactions3.
|
1766
|
+
const messageId = import_transactions3.InputMessageCoder.getMessageId({
|
1757
1767
|
sender,
|
1758
1768
|
recipient,
|
1759
1769
|
nonce,
|
1760
1770
|
amount,
|
1761
|
-
data
|
1771
|
+
data: (0, import_utils5.hexlify)(data)
|
1762
1772
|
});
|
1763
1773
|
const receiptMessageOut = {
|
1764
1774
|
type: import_transactions3.ReceiptType.MessageOut,
|
@@ -1775,7 +1785,7 @@ function assembleReceiptByType(receipt) {
|
|
1775
1785
|
case "MINT" /* Mint */: {
|
1776
1786
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1777
1787
|
const subId = hexOrZero(receipt.subId);
|
1778
|
-
const assetId = import_transactions3.
|
1788
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1779
1789
|
const mintReceipt = {
|
1780
1790
|
type: import_transactions3.ReceiptType.Mint,
|
1781
1791
|
subId,
|
@@ -1790,7 +1800,7 @@ function assembleReceiptByType(receipt) {
|
|
1790
1800
|
case "BURN" /* Burn */: {
|
1791
1801
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1792
1802
|
const subId = hexOrZero(receipt.subId);
|
1793
|
-
const assetId = import_transactions3.
|
1803
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1794
1804
|
const burnReceipt = {
|
1795
1805
|
type: import_transactions3.ReceiptType.Burn,
|
1796
1806
|
subId,
|
@@ -4048,29 +4058,30 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4048
4058
|
});
|
4049
4059
|
}
|
4050
4060
|
var TransactionResponse = class {
|
4051
|
-
/** Transaction ID */
|
4052
|
-
id;
|
4053
|
-
/** Current provider */
|
4054
|
-
provider;
|
4055
|
-
/** Gas used on the transaction */
|
4056
|
-
gasUsed = (0, import_math17.bn)(0);
|
4057
|
-
/** The graphql Transaction with receipts object. */
|
4058
|
-
gqlTransaction;
|
4059
|
-
request;
|
4060
|
-
status;
|
4061
|
-
abis;
|
4062
4061
|
/**
|
4063
4062
|
* Constructor for `TransactionResponse`.
|
4064
4063
|
*
|
4065
4064
|
* @param tx - The transaction ID or TransactionRequest.
|
4066
4065
|
* @param provider - The provider.
|
4067
4066
|
*/
|
4068
|
-
constructor(tx, provider, abis) {
|
4067
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4068
|
+
this.submitTxSubscription = submitTxSubscription;
|
4069
4069
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
4070
4070
|
this.provider = provider;
|
4071
4071
|
this.abis = abis;
|
4072
4072
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4073
4073
|
}
|
4074
|
+
/** Transaction ID */
|
4075
|
+
id;
|
4076
|
+
/** Current provider */
|
4077
|
+
provider;
|
4078
|
+
/** Gas used on the transaction */
|
4079
|
+
gasUsed = (0, import_math17.bn)(0);
|
4080
|
+
/** The graphql Transaction with receipts object. */
|
4081
|
+
gqlTransaction;
|
4082
|
+
request;
|
4083
|
+
status;
|
4084
|
+
abis;
|
4074
4085
|
/**
|
4075
4086
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
4076
4087
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -4203,10 +4214,11 @@ var TransactionResponse = class {
|
|
4203
4214
|
if (status && status !== "SubmittedStatus") {
|
4204
4215
|
return;
|
4205
4216
|
}
|
4206
|
-
const subscription = await this.provider.operations.statusChange({
|
4217
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4207
4218
|
transactionId: this.id
|
4208
4219
|
});
|
4209
|
-
for await (const
|
4220
|
+
for await (const sub of subscription) {
|
4221
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4210
4222
|
this.status = statusChange;
|
4211
4223
|
if (statusChange.type === "SqueezedOutStatus") {
|
4212
4224
|
this.unsetResourceCache();
|
@@ -4484,7 +4496,7 @@ var _Provider = class {
|
|
4484
4496
|
const provider = new _Provider(urlToUse, {
|
4485
4497
|
...options,
|
4486
4498
|
requestMiddleware: async (request) => {
|
4487
|
-
if (auth) {
|
4499
|
+
if (auth && request) {
|
4488
4500
|
request.headers ??= {};
|
4489
4501
|
request.headers.Authorization = auth;
|
4490
4502
|
}
|
@@ -4744,11 +4756,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4744
4756
|
if (isTransactionTypeScript(transactionRequest)) {
|
4745
4757
|
abis = transactionRequest.abis;
|
4746
4758
|
}
|
4747
|
-
const {
|
4748
|
-
|
4749
|
-
|
4750
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4751
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
4759
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
4760
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
4761
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4752
4762
|
}
|
4753
4763
|
/**
|
4754
4764
|
* Executes a transaction without actually submitting it to the chain.
|