@fuel-ts/account 0.82.0 → 0.83.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/README.md +3 -3
- package/dist/account.d.ts +7 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +872 -617
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +853 -604
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +696 -448
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +12 -24
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +810 -359
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +3 -3
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +44 -27
- package/dist/providers/provider.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/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +13 -33
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/merge-quantities.d.ts +1 -1
- package/dist/providers/utils/merge-quantities.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1597 -1112
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +841 -596
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +696 -451
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone3(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone3(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,9 +28952,9 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28957
|
-
FUELS: "0.
|
28955
|
+
FORC: "0.56.0",
|
28956
|
+
FUEL_CORE: "0.24.3",
|
28957
|
+
FUELS: "0.83.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
28960
28960
|
function parseVersion(version2) {
|
@@ -29053,6 +29053,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29053
29053
|
ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
|
29054
29054
|
ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
|
29055
29055
|
ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
|
29056
|
+
ErrorCode2["MAX_FEE_TOO_LOW"] = "max-fee-too-low";
|
29056
29057
|
ErrorCode2["TRANSACTION_NOT_FOUND"] = "transaction-not-found";
|
29057
29058
|
ErrorCode2["TRANSACTION_FAILED"] = "transaction-failed";
|
29058
29059
|
ErrorCode2["INVALID_CONFIGURABLE_CONSTANTS"] = "invalid-configurable-constants";
|
@@ -29243,6 +29244,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29243
29244
|
};
|
29244
29245
|
var DateTime = _DateTime;
|
29245
29246
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29247
|
+
function isDefined(value) {
|
29248
|
+
return value !== void 0;
|
29249
|
+
}
|
29246
29250
|
|
29247
29251
|
// ../crypto/dist/index.mjs
|
29248
29252
|
var import_crypto8 = __toESM(__require("crypto"), 1);
|
@@ -31144,7 +31148,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31144
31148
|
toEvmAddress() {
|
31145
31149
|
const b256Address = toB256(this.bech32Address);
|
31146
31150
|
return {
|
31147
|
-
|
31151
|
+
bits: clearFirst12BytesFromB256(b256Address)
|
31148
31152
|
};
|
31149
31153
|
}
|
31150
31154
|
/**
|
@@ -31154,7 +31158,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31154
31158
|
*/
|
31155
31159
|
toAssetId() {
|
31156
31160
|
return {
|
31157
|
-
|
31161
|
+
bits: this.toB256()
|
31158
31162
|
};
|
31159
31163
|
}
|
31160
31164
|
/**
|
@@ -31272,10 +31276,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31276
|
}
|
31273
31277
|
};
|
31274
31278
|
|
31275
|
-
// ../address/dist/configs.mjs
|
31276
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31277
|
-
var BaseAssetId = ZeroBytes32;
|
31278
|
-
|
31279
31279
|
// ../math/dist/index.mjs
|
31280
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31281
31281
|
var DEFAULT_PRECISION = 9;
|
@@ -31495,32 +31495,182 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31495
31495
|
function toBytes3(value, bytesPadding) {
|
31496
31496
|
return bn(value).toBytes(bytesPadding);
|
31497
31497
|
}
|
31498
|
-
|
31499
|
-
|
31498
|
+
|
31499
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
31500
|
+
function _isPlaceholder(a) {
|
31501
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31502
|
+
}
|
31503
|
+
|
31504
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31505
|
+
function _curry1(fn) {
|
31506
|
+
return function f1(a) {
|
31507
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31508
|
+
return f1;
|
31509
|
+
} else {
|
31510
|
+
return fn.apply(this, arguments);
|
31511
|
+
}
|
31512
|
+
};
|
31513
|
+
}
|
31514
|
+
|
31515
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31516
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
31517
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31518
|
+
};
|
31519
|
+
|
31520
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31521
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31522
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31523
|
+
});
|
31524
|
+
var type_default = type;
|
31525
|
+
|
31526
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31527
|
+
var pad = function pad2(n) {
|
31528
|
+
return (n < 10 ? "0" : "") + n;
|
31529
|
+
};
|
31530
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31531
|
+
return d.toISOString();
|
31532
|
+
} : function _toISOString3(d) {
|
31533
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
31534
|
+
};
|
31535
|
+
|
31536
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31537
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31538
|
+
return n << 0 === n;
|
31539
|
+
};
|
31540
|
+
|
31541
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31542
|
+
function _cloneRegExp(pattern) {
|
31543
|
+
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
31544
|
+
}
|
31545
|
+
|
31546
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31547
|
+
function _clone(value, deep, map) {
|
31548
|
+
map || (map = new _ObjectMap());
|
31549
|
+
if (_isPrimitive(value)) {
|
31550
|
+
return value;
|
31551
|
+
}
|
31552
|
+
var copy = function copy2(copiedValue) {
|
31553
|
+
var cachedCopy = map.get(value);
|
31554
|
+
if (cachedCopy) {
|
31555
|
+
return cachedCopy;
|
31556
|
+
}
|
31557
|
+
map.set(value, copiedValue);
|
31558
|
+
for (var key in value) {
|
31559
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31560
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31561
|
+
}
|
31562
|
+
}
|
31563
|
+
return copiedValue;
|
31564
|
+
};
|
31565
|
+
switch (type_default(value)) {
|
31566
|
+
case "Object":
|
31567
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
31568
|
+
case "Array":
|
31569
|
+
return copy([]);
|
31570
|
+
case "Date":
|
31571
|
+
return new Date(value.valueOf());
|
31572
|
+
case "RegExp":
|
31573
|
+
return _cloneRegExp(value);
|
31574
|
+
case "Int8Array":
|
31575
|
+
case "Uint8Array":
|
31576
|
+
case "Uint8ClampedArray":
|
31577
|
+
case "Int16Array":
|
31578
|
+
case "Uint16Array":
|
31579
|
+
case "Int32Array":
|
31580
|
+
case "Uint32Array":
|
31581
|
+
case "Float32Array":
|
31582
|
+
case "Float64Array":
|
31583
|
+
case "BigInt64Array":
|
31584
|
+
case "BigUint64Array":
|
31585
|
+
return value.slice();
|
31586
|
+
default:
|
31587
|
+
return value;
|
31588
|
+
}
|
31589
|
+
}
|
31590
|
+
function _isPrimitive(param) {
|
31591
|
+
var type3 = typeof param;
|
31592
|
+
return param == null || type3 != "object" && type3 != "function";
|
31500
31593
|
}
|
31594
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
31595
|
+
function _ObjectMap2() {
|
31596
|
+
this.map = {};
|
31597
|
+
this.length = 0;
|
31598
|
+
}
|
31599
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
31600
|
+
const hashedKey = this.hash(key);
|
31601
|
+
let bucket = this.map[hashedKey];
|
31602
|
+
if (!bucket) {
|
31603
|
+
this.map[hashedKey] = bucket = [];
|
31604
|
+
}
|
31605
|
+
bucket.push([key, value]);
|
31606
|
+
this.length += 1;
|
31607
|
+
};
|
31608
|
+
_ObjectMap2.prototype.hash = function(key) {
|
31609
|
+
let hashedKey = [];
|
31610
|
+
for (var value in key) {
|
31611
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31612
|
+
}
|
31613
|
+
return hashedKey.join();
|
31614
|
+
};
|
31615
|
+
_ObjectMap2.prototype.get = function(key) {
|
31616
|
+
if (this.length <= 180) {
|
31617
|
+
for (const p in this.map) {
|
31618
|
+
const bucket2 = this.map[p];
|
31619
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
31620
|
+
const element = bucket2[i];
|
31621
|
+
if (element[0] === key) {
|
31622
|
+
return element[1];
|
31623
|
+
}
|
31624
|
+
}
|
31625
|
+
}
|
31626
|
+
return;
|
31627
|
+
}
|
31628
|
+
const hashedKey = this.hash(key);
|
31629
|
+
const bucket = this.map[hashedKey];
|
31630
|
+
if (!bucket) {
|
31631
|
+
return;
|
31632
|
+
}
|
31633
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
31634
|
+
const element = bucket[i];
|
31635
|
+
if (element[0] === key) {
|
31636
|
+
return element[1];
|
31637
|
+
}
|
31638
|
+
}
|
31639
|
+
};
|
31640
|
+
return _ObjectMap2;
|
31641
|
+
}();
|
31642
|
+
|
31643
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31644
|
+
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31645
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31646
|
+
});
|
31647
|
+
var clone_default = clone;
|
31648
|
+
|
31649
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31650
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31501
31651
|
|
31502
31652
|
// src/providers/coin-quantity.ts
|
31503
31653
|
var coinQuantityfy = (coinQuantityLike) => {
|
31504
31654
|
let assetId;
|
31505
31655
|
let amount;
|
31506
|
-
let
|
31656
|
+
let max;
|
31507
31657
|
if (Array.isArray(coinQuantityLike)) {
|
31508
31658
|
amount = coinQuantityLike[0];
|
31509
|
-
assetId = coinQuantityLike[1]
|
31510
|
-
|
31659
|
+
assetId = coinQuantityLike[1];
|
31660
|
+
max = coinQuantityLike[2] ?? void 0;
|
31511
31661
|
} else {
|
31512
31662
|
amount = coinQuantityLike.amount;
|
31513
|
-
assetId = coinQuantityLike.assetId
|
31514
|
-
|
31663
|
+
assetId = coinQuantityLike.assetId;
|
31664
|
+
max = coinQuantityLike.max ?? void 0;
|
31515
31665
|
}
|
31516
31666
|
const bnAmount = bn(amount);
|
31517
31667
|
return {
|
31518
31668
|
assetId: hexlify(assetId),
|
31519
31669
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31520
|
-
max:
|
31670
|
+
max: max ? bn(max) : void 0
|
31521
31671
|
};
|
31522
31672
|
};
|
31523
|
-
var
|
31673
|
+
var addAmountToCoinQuantities = (params) => {
|
31524
31674
|
const { amount, assetId } = params;
|
31525
31675
|
const coinQuantities = [...params.coinQuantities];
|
31526
31676
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31605,7 +31755,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31605
31755
|
var ENCODING_V1 = "1";
|
31606
31756
|
var WORD_SIZE = 8;
|
31607
31757
|
var BYTES_32 = 32;
|
31608
|
-
var UTXO_ID_LEN = BYTES_32 +
|
31758
|
+
var UTXO_ID_LEN = BYTES_32 + 2;
|
31609
31759
|
var ASSET_ID_LEN = BYTES_32;
|
31610
31760
|
var ADDRESS_LEN = BYTES_32;
|
31611
31761
|
var NONCE_LEN = BYTES_32;
|
@@ -31613,9 +31763,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31613
31763
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31614
31764
|
var MAX_BYTES = 2 ** 32 - 1;
|
31615
31765
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31616
|
-
|
31766
|
+
ASSET_ID_LEN + // Base asset ID
|
31617
31767
|
// Asset ID/Balance coin input pairs
|
31618
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31768
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
|
31619
31769
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31620
31770
|
WORD_SIZE + // Gas limit
|
31621
31771
|
WORD_SIZE + // Script size
|
@@ -31633,7 +31783,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31633
31783
|
ASSET_ID_LEN + // Asset id
|
31634
31784
|
TX_POINTER_LEN + // TxPointer
|
31635
31785
|
WORD_SIZE + // Witnesses index
|
31636
|
-
WORD_SIZE + // Maturity
|
31637
31786
|
WORD_SIZE + // Predicate size
|
31638
31787
|
WORD_SIZE + // Predicate data size
|
31639
31788
|
WORD_SIZE;
|
@@ -31955,7 +32104,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31955
32104
|
constructor(name, coders) {
|
31956
32105
|
const caseIndexCoder = new BigNumberCoder("u64");
|
31957
32106
|
const encodedValueSize = Object.values(coders).reduce(
|
31958
|
-
(
|
32107
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
31959
32108
|
0
|
31960
32109
|
);
|
31961
32110
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32673,7 +32822,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32673
32822
|
constructor(name, coders) {
|
32674
32823
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32675
32824
|
const encodedValueSize = Object.values(coders).reduce(
|
32676
|
-
(
|
32825
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
32677
32826
|
0
|
32678
32827
|
);
|
32679
32828
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32964,9 +33113,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32964
33113
|
};
|
32965
33114
|
var VecCoder2 = class extends Coder {
|
32966
33115
|
coder;
|
33116
|
+
#isOptionVec;
|
32967
33117
|
constructor(coder) {
|
32968
33118
|
super("struct", `struct Vec`, coder.encodedLength + WORD_SIZE);
|
32969
33119
|
this.coder = coder;
|
33120
|
+
this.#isOptionVec = this.coder instanceof OptionCoder2;
|
32970
33121
|
}
|
32971
33122
|
encode(value) {
|
32972
33123
|
if (!Array.isArray(value)) {
|
@@ -32977,7 +33128,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32977
33128
|
return new Uint8Array([...lengthBytes, ...concatBytes2(bytes3)]);
|
32978
33129
|
}
|
32979
33130
|
decode(data, offset) {
|
32980
|
-
if (data.length < this.encodedLength || data.length > MAX_BYTES) {
|
33131
|
+
if (!this.#isOptionVec && (data.length < this.encodedLength || data.length > MAX_BYTES)) {
|
32981
33132
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`);
|
32982
33133
|
}
|
32983
33134
|
const offsetAndLength = offset + WORD_SIZE;
|
@@ -32985,15 +33136,17 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32985
33136
|
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32986
33137
|
const dataLength2 = length * this.coder.encodedLength;
|
32987
33138
|
const dataBytes = data.slice(offsetAndLength, offsetAndLength + dataLength2);
|
32988
|
-
if (dataBytes.length !== dataLength2) {
|
33139
|
+
if (!this.#isOptionVec && dataBytes.length !== dataLength2) {
|
32989
33140
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`);
|
32990
33141
|
}
|
32991
|
-
|
32992
|
-
|
32993
|
-
|
32994
|
-
)
|
32995
|
-
|
32996
|
-
|
33142
|
+
let newOffset = offsetAndLength;
|
33143
|
+
const chunks = [];
|
33144
|
+
for (let i = 0; i < length; i++) {
|
33145
|
+
const [decoded, optionOffset] = this.coder.decode(data, newOffset);
|
33146
|
+
chunks.push(decoded);
|
33147
|
+
newOffset = optionOffset;
|
33148
|
+
}
|
33149
|
+
return [chunks, newOffset];
|
32997
33150
|
}
|
32998
33151
|
};
|
32999
33152
|
var getCoder2 = (resolvedAbiType, _options) => {
|
@@ -33387,18 +33540,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33387
33540
|
encode(value) {
|
33388
33541
|
const parts = [];
|
33389
33542
|
parts.push(new B256Coder().encode(value.txID));
|
33390
|
-
parts.push(new NumberCoder("
|
33543
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33391
33544
|
parts.push(new B256Coder().encode(value.owner));
|
33392
33545
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33393
33546
|
parts.push(new B256Coder().encode(value.assetId));
|
33394
33547
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33395
|
-
parts.push(new NumberCoder("
|
33396
|
-
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33548
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33397
33549
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33398
|
-
parts.push(new
|
33399
|
-
parts.push(new
|
33400
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33401
|
-
parts.push(
|
33550
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33551
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33552
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33553
|
+
parts.push(
|
33554
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33555
|
+
);
|
33402
33556
|
return concat(parts);
|
33403
33557
|
}
|
33404
33558
|
decode(data, offset) {
|
@@ -33406,7 +33560,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33406
33560
|
let o = offset;
|
33407
33561
|
[decoded, o] = new B256Coder().decode(data, o);
|
33408
33562
|
const txID = decoded;
|
33409
|
-
[decoded, o] = new NumberCoder("
|
33563
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33410
33564
|
const outputIndex = decoded;
|
33411
33565
|
[decoded, o] = new B256Coder().decode(data, o);
|
33412
33566
|
const owner = decoded;
|
@@ -33416,19 +33570,17 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33416
33570
|
const assetId = decoded;
|
33417
33571
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33418
33572
|
const txPointer = decoded;
|
33419
|
-
[decoded, o] = new NumberCoder("
|
33573
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33420
33574
|
const witnessIndex = Number(decoded);
|
33421
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33422
|
-
const maturity = decoded;
|
33423
33575
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33424
33576
|
const predicateGasUsed = decoded;
|
33425
|
-
[decoded, o] = new
|
33577
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33426
33578
|
const predicateLength = decoded;
|
33427
|
-
[decoded, o] = new
|
33579
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33428
33580
|
const predicateDataLength = decoded;
|
33429
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33581
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33430
33582
|
const predicate = decoded;
|
33431
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33583
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33432
33584
|
const predicateData = decoded;
|
33433
33585
|
return [
|
33434
33586
|
{
|
@@ -33440,7 +33592,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33440
33592
|
assetId,
|
33441
33593
|
txPointer,
|
33442
33594
|
witnessIndex,
|
33443
|
-
maturity,
|
33444
33595
|
predicateGasUsed,
|
33445
33596
|
predicateLength,
|
33446
33597
|
predicateDataLength,
|
@@ -33458,7 +33609,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33458
33609
|
encode(value) {
|
33459
33610
|
const parts = [];
|
33460
33611
|
parts.push(new B256Coder().encode(value.txID));
|
33461
|
-
parts.push(new NumberCoder("
|
33612
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33462
33613
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33463
33614
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33464
33615
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33470,7 +33621,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33470
33621
|
let o = offset;
|
33471
33622
|
[decoded, o] = new B256Coder().decode(data, o);
|
33472
33623
|
const txID = decoded;
|
33473
|
-
[decoded, o] = new NumberCoder("
|
33624
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33474
33625
|
const outputIndex = decoded;
|
33475
33626
|
[decoded, o] = new B256Coder().decode(data, o);
|
33476
33627
|
const balanceRoot = decoded;
|
@@ -33519,14 +33670,16 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33519
33670
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33520
33671
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33521
33672
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33522
|
-
parts.push(new NumberCoder("
|
33673
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33523
33674
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33524
|
-
parts.push(new
|
33525
|
-
parts.push(new
|
33526
|
-
parts.push(new
|
33675
|
+
parts.push(new BigNumberCoder("u64").encode(data.length));
|
33676
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33677
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33527
33678
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33528
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33529
|
-
parts.push(
|
33679
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33680
|
+
parts.push(
|
33681
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33682
|
+
);
|
33530
33683
|
return concat(parts);
|
33531
33684
|
}
|
33532
33685
|
static decodeData(messageData) {
|
@@ -33546,21 +33699,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33546
33699
|
const amount = decoded;
|
33547
33700
|
[decoded, o] = new B256Coder().decode(data, o);
|
33548
33701
|
const nonce = decoded;
|
33549
|
-
[decoded, o] = new NumberCoder("
|
33702
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33550
33703
|
const witnessIndex = Number(decoded);
|
33551
33704
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33552
33705
|
const predicateGasUsed = decoded;
|
33553
33706
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33554
33707
|
const dataLength2 = decoded;
|
33555
|
-
[decoded, o] = new
|
33708
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33556
33709
|
const predicateLength = decoded;
|
33557
|
-
[decoded, o] = new
|
33710
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33558
33711
|
const predicateDataLength = decoded;
|
33559
33712
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33560
33713
|
const messageData = decoded;
|
33561
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33714
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33562
33715
|
const predicate = decoded;
|
33563
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33716
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33564
33717
|
const predicateData = decoded;
|
33565
33718
|
return [
|
33566
33719
|
{
|
@@ -33872,7 +34025,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33872
34025
|
}
|
33873
34026
|
};
|
33874
34027
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
33875
|
-
PolicyType2[PolicyType2["
|
34028
|
+
PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
|
33876
34029
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
33877
34030
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
33878
34031
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -33920,9 +34073,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33920
34073
|
let o = offset;
|
33921
34074
|
const policies = [];
|
33922
34075
|
if (policyTypes & 1) {
|
33923
|
-
const [
|
34076
|
+
const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
33924
34077
|
o = nextOffset;
|
33925
|
-
policies.push({ type: 1, data:
|
34078
|
+
policies.push({ type: 1, data: tip });
|
33926
34079
|
}
|
33927
34080
|
if (policyTypes & 2) {
|
33928
34081
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34154,15 +34307,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34154
34307
|
encode(value) {
|
34155
34308
|
const parts = [];
|
34156
34309
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34157
|
-
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34158
|
-
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34159
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34160
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34161
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34162
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34163
34310
|
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34164
|
-
parts.push(new
|
34165
|
-
parts.push(new
|
34311
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
|
34312
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34313
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34314
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34315
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34316
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34317
|
+
parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
|
34318
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
|
34166
34319
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34167
34320
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34168
34321
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34174,23 +34327,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34174
34327
|
let o = offset;
|
34175
34328
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34176
34329
|
const scriptGasLimit = decoded;
|
34177
|
-
[decoded, o] = new
|
34330
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34331
|
+
const receiptsRoot = decoded;
|
34332
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34178
34333
|
const scriptLength = decoded;
|
34179
|
-
[decoded, o] = new
|
34334
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34180
34335
|
const scriptDataLength = decoded;
|
34181
34336
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34182
34337
|
const policyTypes = decoded;
|
34183
|
-
[decoded, o] = new NumberCoder("
|
34338
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34184
34339
|
const inputsCount = decoded;
|
34185
|
-
[decoded, o] = new NumberCoder("
|
34340
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34186
34341
|
const outputsCount = decoded;
|
34187
|
-
[decoded, o] = new NumberCoder("
|
34342
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34188
34343
|
const witnessesCount = decoded;
|
34189
|
-
[decoded, o] = new
|
34190
|
-
const receiptsRoot = decoded;
|
34191
|
-
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34344
|
+
[decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
|
34192
34345
|
const script = decoded;
|
34193
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34346
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
|
34194
34347
|
const scriptData = decoded;
|
34195
34348
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34196
34349
|
const policies = decoded;
|
@@ -34228,18 +34381,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34228
34381
|
}
|
34229
34382
|
encode(value) {
|
34230
34383
|
const parts = [];
|
34231
|
-
parts.push(new NumberCoder("
|
34232
|
-
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34233
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34234
|
-
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34235
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34236
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34237
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34384
|
+
parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
|
34238
34385
|
parts.push(new B256Coder().encode(value.salt));
|
34239
|
-
parts.push(new
|
34386
|
+
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34387
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34388
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34389
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34390
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34240
34391
|
parts.push(
|
34241
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(
|
34392
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
|
34393
|
+
value.storageSlots
|
34394
|
+
)
|
34242
34395
|
);
|
34396
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34243
34397
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34244
34398
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34245
34399
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34248,26 +34402,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34248
34402
|
decode(data, offset) {
|
34249
34403
|
let decoded;
|
34250
34404
|
let o = offset;
|
34251
|
-
[decoded, o] = new NumberCoder("
|
34252
|
-
const bytecodeLength = decoded;
|
34253
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34405
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34254
34406
|
const bytecodeWitnessIndex = decoded;
|
34407
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34408
|
+
const salt = decoded;
|
34409
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34410
|
+
const storageSlotsCount = decoded;
|
34255
34411
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34256
34412
|
const policyTypes = decoded;
|
34257
34413
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34258
|
-
const storageSlotsCount = decoded;
|
34259
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34260
34414
|
const inputsCount = decoded;
|
34261
|
-
[decoded, o] = new NumberCoder("
|
34415
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34262
34416
|
const outputsCount = decoded;
|
34263
|
-
[decoded, o] = new NumberCoder("
|
34417
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34264
34418
|
const witnessesCount = decoded;
|
34265
|
-
[decoded, o] = new
|
34266
|
-
|
34419
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
|
34420
|
+
data,
|
34421
|
+
o
|
34422
|
+
);
|
34423
|
+
const storageSlots = decoded;
|
34267
34424
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34268
34425
|
const policies = decoded;
|
34269
|
-
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34270
|
-
const storageSlots = decoded;
|
34271
34426
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34272
34427
|
const inputs = decoded;
|
34273
34428
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34277,7 +34432,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34277
34432
|
return [
|
34278
34433
|
{
|
34279
34434
|
type: 1,
|
34280
|
-
bytecodeLength,
|
34281
34435
|
bytecodeWitnessIndex,
|
34282
34436
|
policyTypes,
|
34283
34437
|
storageSlotsCount,
|
@@ -34306,6 +34460,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34306
34460
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34307
34461
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34308
34462
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34463
|
+
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34309
34464
|
return concat(parts);
|
34310
34465
|
}
|
34311
34466
|
decode(data, offset) {
|
@@ -34321,6 +34476,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34321
34476
|
const mintAmount = decoded;
|
34322
34477
|
[decoded, o] = new B256Coder().decode(data, o);
|
34323
34478
|
const mintAssetId = decoded;
|
34479
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34480
|
+
const gasPrice = decoded;
|
34324
34481
|
return [
|
34325
34482
|
{
|
34326
34483
|
type: 2,
|
@@ -34328,7 +34485,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34328
34485
|
inputContract,
|
34329
34486
|
outputContract,
|
34330
34487
|
mintAmount,
|
34331
|
-
mintAssetId
|
34488
|
+
mintAssetId,
|
34489
|
+
gasPrice
|
34332
34490
|
},
|
34333
34491
|
o
|
34334
34492
|
];
|
@@ -34635,159 +34793,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34635
34793
|
// src/providers/provider.ts
|
34636
34794
|
var import_graphql_request = __toESM(require_dist2());
|
34637
34795
|
|
34638
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34639
|
-
function _isPlaceholder(a) {
|
34640
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34641
|
-
}
|
34642
|
-
|
34643
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34644
|
-
function _curry1(fn) {
|
34645
|
-
return function f1(a) {
|
34646
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34647
|
-
return f1;
|
34648
|
-
} else {
|
34649
|
-
return fn.apply(this, arguments);
|
34650
|
-
}
|
34651
|
-
};
|
34652
|
-
}
|
34653
|
-
|
34654
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34655
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
34656
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34657
|
-
};
|
34658
|
-
|
34659
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34660
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34661
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34662
|
-
});
|
34663
|
-
var type_default = type;
|
34664
|
-
|
34665
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34666
|
-
var pad = function pad2(n) {
|
34667
|
-
return (n < 10 ? "0" : "") + n;
|
34668
|
-
};
|
34669
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34670
|
-
return d.toISOString();
|
34671
|
-
} : function _toISOString3(d) {
|
34672
|
-
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
34673
|
-
};
|
34674
|
-
|
34675
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34676
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34677
|
-
return n << 0 === n;
|
34678
|
-
};
|
34679
|
-
|
34680
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34681
|
-
function _cloneRegExp(pattern) {
|
34682
|
-
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
34683
|
-
}
|
34684
|
-
|
34685
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34686
|
-
function _clone(value, deep, map) {
|
34687
|
-
map || (map = new _ObjectMap());
|
34688
|
-
if (_isPrimitive(value)) {
|
34689
|
-
return value;
|
34690
|
-
}
|
34691
|
-
var copy = function copy2(copiedValue) {
|
34692
|
-
var cachedCopy = map.get(value);
|
34693
|
-
if (cachedCopy) {
|
34694
|
-
return cachedCopy;
|
34695
|
-
}
|
34696
|
-
map.set(value, copiedValue);
|
34697
|
-
for (var key in value) {
|
34698
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34699
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34700
|
-
}
|
34701
|
-
}
|
34702
|
-
return copiedValue;
|
34703
|
-
};
|
34704
|
-
switch (type_default(value)) {
|
34705
|
-
case "Object":
|
34706
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
34707
|
-
case "Array":
|
34708
|
-
return copy([]);
|
34709
|
-
case "Date":
|
34710
|
-
return new Date(value.valueOf());
|
34711
|
-
case "RegExp":
|
34712
|
-
return _cloneRegExp(value);
|
34713
|
-
case "Int8Array":
|
34714
|
-
case "Uint8Array":
|
34715
|
-
case "Uint8ClampedArray":
|
34716
|
-
case "Int16Array":
|
34717
|
-
case "Uint16Array":
|
34718
|
-
case "Int32Array":
|
34719
|
-
case "Uint32Array":
|
34720
|
-
case "Float32Array":
|
34721
|
-
case "Float64Array":
|
34722
|
-
case "BigInt64Array":
|
34723
|
-
case "BigUint64Array":
|
34724
|
-
return value.slice();
|
34725
|
-
default:
|
34726
|
-
return value;
|
34727
|
-
}
|
34728
|
-
}
|
34729
|
-
function _isPrimitive(param) {
|
34730
|
-
var type3 = typeof param;
|
34731
|
-
return param == null || type3 != "object" && type3 != "function";
|
34732
|
-
}
|
34733
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
34734
|
-
function _ObjectMap2() {
|
34735
|
-
this.map = {};
|
34736
|
-
this.length = 0;
|
34737
|
-
}
|
34738
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
34739
|
-
const hashedKey = this.hash(key);
|
34740
|
-
let bucket = this.map[hashedKey];
|
34741
|
-
if (!bucket) {
|
34742
|
-
this.map[hashedKey] = bucket = [];
|
34743
|
-
}
|
34744
|
-
bucket.push([key, value]);
|
34745
|
-
this.length += 1;
|
34746
|
-
};
|
34747
|
-
_ObjectMap2.prototype.hash = function(key) {
|
34748
|
-
let hashedKey = [];
|
34749
|
-
for (var value in key) {
|
34750
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34751
|
-
}
|
34752
|
-
return hashedKey.join();
|
34753
|
-
};
|
34754
|
-
_ObjectMap2.prototype.get = function(key) {
|
34755
|
-
if (this.length <= 180) {
|
34756
|
-
for (const p in this.map) {
|
34757
|
-
const bucket2 = this.map[p];
|
34758
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
34759
|
-
const element = bucket2[i];
|
34760
|
-
if (element[0] === key) {
|
34761
|
-
return element[1];
|
34762
|
-
}
|
34763
|
-
}
|
34764
|
-
}
|
34765
|
-
return;
|
34766
|
-
}
|
34767
|
-
const hashedKey = this.hash(key);
|
34768
|
-
const bucket = this.map[hashedKey];
|
34769
|
-
if (!bucket) {
|
34770
|
-
return;
|
34771
|
-
}
|
34772
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
34773
|
-
const element = bucket[i];
|
34774
|
-
if (element[0] === key) {
|
34775
|
-
return element[1];
|
34776
|
-
}
|
34777
|
-
}
|
34778
|
-
};
|
34779
|
-
return _ObjectMap2;
|
34780
|
-
}();
|
34781
|
-
|
34782
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34783
|
-
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34784
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34785
|
-
});
|
34786
|
-
var clone_default = clone2;
|
34787
|
-
|
34788
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34789
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34790
|
-
|
34791
34796
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34792
34797
|
var __assign = function() {
|
34793
34798
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37953,16 +37958,20 @@ spurious results.`);
|
|
37953
37958
|
var lib_default2 = gql;
|
37954
37959
|
|
37955
37960
|
// src/providers/__generated__/operations.ts
|
37961
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = lib_default2`
|
37962
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
37963
|
+
type: __typename
|
37964
|
+
... on SqueezedOutStatus {
|
37965
|
+
reason
|
37966
|
+
}
|
37967
|
+
}
|
37968
|
+
`;
|
37956
37969
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37957
37970
|
fragment receiptFragment on Receipt {
|
37958
|
-
|
37959
|
-
id
|
37960
|
-
}
|
37971
|
+
id
|
37961
37972
|
pc
|
37962
37973
|
is
|
37963
|
-
to
|
37964
|
-
id
|
37965
|
-
}
|
37974
|
+
to
|
37966
37975
|
toAddress
|
37967
37976
|
amount
|
37968
37977
|
assetId
|
@@ -38000,10 +38009,16 @@ spurious results.`);
|
|
38000
38009
|
id
|
38001
38010
|
}
|
38002
38011
|
time
|
38012
|
+
receipts {
|
38013
|
+
...receiptFragment
|
38014
|
+
}
|
38003
38015
|
programState {
|
38004
38016
|
returnType
|
38005
38017
|
data
|
38006
38018
|
}
|
38019
|
+
receipts {
|
38020
|
+
...receiptFragment
|
38021
|
+
}
|
38007
38022
|
}
|
38008
38023
|
... on FailureStatus {
|
38009
38024
|
block {
|
@@ -38011,26 +38026,24 @@ spurious results.`);
|
|
38011
38026
|
}
|
38012
38027
|
time
|
38013
38028
|
reason
|
38029
|
+
receipts {
|
38030
|
+
...receiptFragment
|
38031
|
+
}
|
38014
38032
|
}
|
38015
38033
|
... on SqueezedOutStatus {
|
38016
38034
|
reason
|
38017
38035
|
}
|
38018
38036
|
}
|
38019
|
-
`;
|
38037
|
+
${ReceiptFragmentFragmentDoc}`;
|
38020
38038
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38021
38039
|
fragment transactionFragment on Transaction {
|
38022
38040
|
id
|
38023
38041
|
rawPayload
|
38024
|
-
gasPrice
|
38025
|
-
receipts {
|
38026
|
-
...receiptFragment
|
38027
|
-
}
|
38028
38042
|
status {
|
38029
38043
|
...transactionStatusFragment
|
38030
38044
|
}
|
38031
38045
|
}
|
38032
|
-
${
|
38033
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
38046
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38034
38047
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38035
38048
|
fragment inputEstimatePredicatesFragment on Input {
|
38036
38049
|
... on InputCoin {
|
@@ -38048,6 +38061,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38048
38061
|
}
|
38049
38062
|
}
|
38050
38063
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38064
|
+
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38065
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38066
|
+
reason
|
38067
|
+
programState {
|
38068
|
+
returnType
|
38069
|
+
data
|
38070
|
+
}
|
38071
|
+
}
|
38072
|
+
`;
|
38073
|
+
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38074
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38075
|
+
programState {
|
38076
|
+
returnType
|
38077
|
+
data
|
38078
|
+
}
|
38079
|
+
}
|
38080
|
+
`;
|
38081
|
+
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38082
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38083
|
+
... on DryRunFailureStatus {
|
38084
|
+
...dryRunFailureStatusFragment
|
38085
|
+
}
|
38086
|
+
... on DryRunSuccessStatus {
|
38087
|
+
...dryRunSuccessStatusFragment
|
38088
|
+
}
|
38089
|
+
}
|
38090
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
38091
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38092
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38093
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38094
|
+
id
|
38095
|
+
status {
|
38096
|
+
...dryRunTransactionStatusFragment
|
38097
|
+
}
|
38098
|
+
receipts {
|
38099
|
+
...receiptFragment
|
38100
|
+
}
|
38101
|
+
}
|
38102
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
38103
|
+
${ReceiptFragmentFragmentDoc}`;
|
38051
38104
|
var CoinFragmentFragmentDoc = lib_default2`
|
38052
38105
|
fragment coinFragment on Coin {
|
38053
38106
|
__typename
|
@@ -38055,7 +38108,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38055
38108
|
owner
|
38056
38109
|
amount
|
38057
38110
|
assetId
|
38058
|
-
maturity
|
38059
38111
|
blockCreated
|
38060
38112
|
txCreatedIdx
|
38061
38113
|
}
|
@@ -38094,26 +38146,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38094
38146
|
messageBlockHeader {
|
38095
38147
|
id
|
38096
38148
|
daHeight
|
38149
|
+
consensusParametersVersion
|
38150
|
+
stateTransitionBytecodeVersion
|
38097
38151
|
transactionsCount
|
38152
|
+
messageReceiptCount
|
38098
38153
|
transactionsRoot
|
38154
|
+
messageOutboxRoot
|
38155
|
+
eventInboxRoot
|
38099
38156
|
height
|
38100
38157
|
prevRoot
|
38101
38158
|
time
|
38102
38159
|
applicationHash
|
38103
|
-
messageReceiptRoot
|
38104
|
-
messageReceiptCount
|
38105
38160
|
}
|
38106
38161
|
commitBlockHeader {
|
38107
38162
|
id
|
38108
38163
|
daHeight
|
38164
|
+
consensusParametersVersion
|
38165
|
+
stateTransitionBytecodeVersion
|
38109
38166
|
transactionsCount
|
38167
|
+
messageReceiptCount
|
38110
38168
|
transactionsRoot
|
38169
|
+
messageOutboxRoot
|
38170
|
+
eventInboxRoot
|
38111
38171
|
height
|
38112
38172
|
prevRoot
|
38113
38173
|
time
|
38114
38174
|
applicationHash
|
38115
|
-
messageReceiptRoot
|
38116
|
-
messageReceiptCount
|
38117
38175
|
}
|
38118
38176
|
sender
|
38119
38177
|
recipient
|
@@ -38132,8 +38190,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38132
38190
|
var BlockFragmentFragmentDoc = lib_default2`
|
38133
38191
|
fragment blockFragment on Block {
|
38134
38192
|
id
|
38193
|
+
height
|
38135
38194
|
header {
|
38136
|
-
height
|
38137
38195
|
time
|
38138
38196
|
}
|
38139
38197
|
transactions {
|
@@ -38143,6 +38201,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38143
38201
|
`;
|
38144
38202
|
var TxParametersFragmentFragmentDoc = lib_default2`
|
38145
38203
|
fragment TxParametersFragment on TxParameters {
|
38204
|
+
version
|
38146
38205
|
maxInputs
|
38147
38206
|
maxOutputs
|
38148
38207
|
maxWitnesses
|
@@ -38152,6 +38211,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38152
38211
|
`;
|
38153
38212
|
var PredicateParametersFragmentFragmentDoc = lib_default2`
|
38154
38213
|
fragment PredicateParametersFragment on PredicateParameters {
|
38214
|
+
version
|
38155
38215
|
maxPredicateLength
|
38156
38216
|
maxPredicateDataLength
|
38157
38217
|
maxGasPerPredicate
|
@@ -38160,18 +38220,21 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38160
38220
|
`;
|
38161
38221
|
var ScriptParametersFragmentFragmentDoc = lib_default2`
|
38162
38222
|
fragment ScriptParametersFragment on ScriptParameters {
|
38223
|
+
version
|
38163
38224
|
maxScriptLength
|
38164
38225
|
maxScriptDataLength
|
38165
38226
|
}
|
38166
38227
|
`;
|
38167
38228
|
var ContractParametersFragmentFragmentDoc = lib_default2`
|
38168
38229
|
fragment ContractParametersFragment on ContractParameters {
|
38230
|
+
version
|
38169
38231
|
contractMaxSize
|
38170
38232
|
maxStorageSlots
|
38171
38233
|
}
|
38172
38234
|
`;
|
38173
38235
|
var FeeParametersFragmentFragmentDoc = lib_default2`
|
38174
38236
|
fragment FeeParametersFragment on FeeParameters {
|
38237
|
+
version
|
38175
38238
|
gasPriceFactor
|
38176
38239
|
gasPerByte
|
38177
38240
|
}
|
@@ -38191,6 +38254,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38191
38254
|
`;
|
38192
38255
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38193
38256
|
fragment GasCostsFragment on GasCosts {
|
38257
|
+
version
|
38194
38258
|
add
|
38195
38259
|
addi
|
38196
38260
|
aloc
|
@@ -38203,7 +38267,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38203
38267
|
cb
|
38204
38268
|
cfei
|
38205
38269
|
cfsi
|
38206
|
-
croo
|
38207
38270
|
div
|
38208
38271
|
divi
|
38209
38272
|
ecr1
|
@@ -38286,6 +38349,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38286
38349
|
ccp {
|
38287
38350
|
...DependentCostFragment
|
38288
38351
|
}
|
38352
|
+
croo {
|
38353
|
+
...DependentCostFragment
|
38354
|
+
}
|
38289
38355
|
csiz {
|
38290
38356
|
...DependentCostFragment
|
38291
38357
|
}
|
@@ -38345,6 +38411,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38345
38411
|
${DependentCostFragmentFragmentDoc}`;
|
38346
38412
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38347
38413
|
fragment consensusParametersFragment on ConsensusParameters {
|
38414
|
+
version
|
38348
38415
|
txParams {
|
38349
38416
|
...TxParametersFragment
|
38350
38417
|
}
|
@@ -38404,18 +38471,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38404
38471
|
fragment nodeInfoFragment on NodeInfo {
|
38405
38472
|
utxoValidation
|
38406
38473
|
vmBacktrace
|
38407
|
-
minGasPrice
|
38408
38474
|
maxTx
|
38409
38475
|
maxDepth
|
38410
38476
|
nodeVersion
|
38411
|
-
peers {
|
38412
|
-
id
|
38413
|
-
addresses
|
38414
|
-
clientVersion
|
38415
|
-
blockHeight
|
38416
|
-
lastHeartbeatMs
|
38417
|
-
appScore
|
38418
|
-
}
|
38419
38477
|
}
|
38420
38478
|
`;
|
38421
38479
|
var GetVersionDocument = lib_default2`
|
@@ -38450,13 +38508,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38450
38508
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38451
38509
|
transaction(id: $transactionId) {
|
38452
38510
|
...transactionFragment
|
38453
|
-
receipts {
|
38454
|
-
...receiptFragment
|
38455
|
-
}
|
38456
38511
|
}
|
38457
38512
|
}
|
38458
|
-
${TransactionFragmentFragmentDoc}
|
38459
|
-
${ReceiptFragmentFragmentDoc}`;
|
38513
|
+
${TransactionFragmentFragmentDoc}`;
|
38460
38514
|
var GetTransactionsDocument = lib_default2`
|
38461
38515
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38462
38516
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38584,6 +38638,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38584
38638
|
}
|
38585
38639
|
}
|
38586
38640
|
${BalanceFragmentFragmentDoc}`;
|
38641
|
+
var GetLatestGasPriceDocument = lib_default2`
|
38642
|
+
query getLatestGasPrice {
|
38643
|
+
latestGasPrice {
|
38644
|
+
gasPrice
|
38645
|
+
}
|
38646
|
+
}
|
38647
|
+
`;
|
38648
|
+
var EstimateGasPriceDocument = lib_default2`
|
38649
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
38650
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38651
|
+
gasPrice
|
38652
|
+
}
|
38653
|
+
}
|
38654
|
+
`;
|
38587
38655
|
var GetBalancesDocument = lib_default2`
|
38588
38656
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38589
38657
|
balances(
|
@@ -38638,12 +38706,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38638
38706
|
}
|
38639
38707
|
`;
|
38640
38708
|
var DryRunDocument = lib_default2`
|
38641
|
-
mutation dryRun($
|
38642
|
-
dryRun(
|
38643
|
-
...
|
38709
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
38710
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
38711
|
+
...dryRunTransactionExecutionStatusFragment
|
38644
38712
|
}
|
38645
38713
|
}
|
38646
|
-
${
|
38714
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
38647
38715
|
var SubmitDocument = lib_default2`
|
38648
38716
|
mutation submit($encodedTransaction: HexString!) {
|
38649
38717
|
submit(tx: $encodedTransaction) {
|
@@ -38662,17 +38730,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38662
38730
|
var SubmitAndAwaitDocument = lib_default2`
|
38663
38731
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
38664
38732
|
submitAndAwait(tx: $encodedTransaction) {
|
38665
|
-
...
|
38733
|
+
...transactionStatusSubscriptionFragment
|
38666
38734
|
}
|
38667
38735
|
}
|
38668
|
-
${
|
38736
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
38669
38737
|
var StatusChangeDocument = lib_default2`
|
38670
38738
|
subscription statusChange($transactionId: TransactionId!) {
|
38671
38739
|
statusChange(id: $transactionId) {
|
38672
|
-
...
|
38740
|
+
...transactionStatusSubscriptionFragment
|
38673
38741
|
}
|
38674
38742
|
}
|
38675
|
-
${
|
38743
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
38676
38744
|
function getSdk(requester) {
|
38677
38745
|
return {
|
38678
38746
|
getVersion(variables, options) {
|
@@ -38726,6 +38794,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38726
38794
|
getBalance(variables, options) {
|
38727
38795
|
return requester(GetBalanceDocument, variables, options);
|
38728
38796
|
},
|
38797
|
+
getLatestGasPrice(variables, options) {
|
38798
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
38799
|
+
},
|
38800
|
+
estimateGasPrice(variables, options) {
|
38801
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
38802
|
+
},
|
38729
38803
|
getBalances(variables, options) {
|
38730
38804
|
return requester(GetBalancesDocument, variables, options);
|
38731
38805
|
},
|
@@ -38890,6 +38964,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38890
38964
|
}
|
38891
38965
|
};
|
38892
38966
|
|
38967
|
+
// ../address/dist/configs.mjs
|
38968
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38969
|
+
|
38893
38970
|
// src/providers/transaction-request/input.ts
|
38894
38971
|
var inputify = (value) => {
|
38895
38972
|
const { type: type3 } = value;
|
@@ -38909,10 +38986,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38909
38986
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38910
38987
|
},
|
38911
38988
|
witnessIndex: value.witnessIndex,
|
38912
|
-
maturity: value.maturity ?? 0,
|
38913
38989
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38914
|
-
predicateLength: predicate.length,
|
38915
|
-
predicateDataLength: predicateData.length,
|
38990
|
+
predicateLength: bn(predicate.length),
|
38991
|
+
predicateDataLength: bn(predicateData.length),
|
38916
38992
|
predicate: hexlify(predicate),
|
38917
38993
|
predicateData: hexlify(predicateData)
|
38918
38994
|
};
|
@@ -38943,8 +39019,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38943
39019
|
nonce: hexlify(value.nonce),
|
38944
39020
|
witnessIndex: value.witnessIndex,
|
38945
39021
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38946
|
-
predicateLength: predicate.length,
|
38947
|
-
predicateDataLength: predicateData.length,
|
39022
|
+
predicateLength: bn(predicate.length),
|
39023
|
+
predicateDataLength: bn(predicateData.length),
|
38948
39024
|
predicate: hexlify(predicate),
|
38949
39025
|
predicateData: hexlify(predicateData),
|
38950
39026
|
data: hexlify(data),
|
@@ -39104,8 +39180,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39104
39180
|
case "CALL" /* Call */: {
|
39105
39181
|
const callReceipt = {
|
39106
39182
|
type: ReceiptType.Call,
|
39107
|
-
from: hexOrZero(receipt.
|
39108
|
-
to: hexOrZero(receipt?.to
|
39183
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39184
|
+
to: hexOrZero(receipt?.to),
|
39109
39185
|
amount: bn(receipt.amount),
|
39110
39186
|
assetId: hexOrZero(receipt.assetId),
|
39111
39187
|
gas: bn(receipt.gas),
|
@@ -39119,7 +39195,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39119
39195
|
case "RETURN" /* Return */: {
|
39120
39196
|
const returnReceipt = {
|
39121
39197
|
type: ReceiptType.Return,
|
39122
|
-
id: hexOrZero(receipt.
|
39198
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39123
39199
|
val: bn(receipt.val),
|
39124
39200
|
pc: bn(receipt.pc),
|
39125
39201
|
is: bn(receipt.is)
|
@@ -39129,7 +39205,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39129
39205
|
case "RETURN_DATA" /* ReturnData */: {
|
39130
39206
|
const returnDataReceipt = {
|
39131
39207
|
type: ReceiptType.ReturnData,
|
39132
|
-
id: hexOrZero(receipt.
|
39208
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39133
39209
|
ptr: bn(receipt.ptr),
|
39134
39210
|
len: bn(receipt.len),
|
39135
39211
|
digest: hexOrZero(receipt.digest),
|
@@ -39141,7 +39217,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39141
39217
|
case "PANIC" /* Panic */: {
|
39142
39218
|
const panicReceipt = {
|
39143
39219
|
type: ReceiptType.Panic,
|
39144
|
-
id: hexOrZero(receipt.
|
39220
|
+
id: hexOrZero(receipt.id),
|
39145
39221
|
reason: bn(receipt.reason),
|
39146
39222
|
pc: bn(receipt.pc),
|
39147
39223
|
is: bn(receipt.is),
|
@@ -39152,7 +39228,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39152
39228
|
case "REVERT" /* Revert */: {
|
39153
39229
|
const revertReceipt = {
|
39154
39230
|
type: ReceiptType.Revert,
|
39155
|
-
id: hexOrZero(receipt.
|
39231
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39156
39232
|
val: bn(receipt.ra),
|
39157
39233
|
pc: bn(receipt.pc),
|
39158
39234
|
is: bn(receipt.is)
|
@@ -39162,7 +39238,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39162
39238
|
case "LOG" /* Log */: {
|
39163
39239
|
const logReceipt = {
|
39164
39240
|
type: ReceiptType.Log,
|
39165
|
-
id: hexOrZero(receipt.
|
39241
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39166
39242
|
val0: bn(receipt.ra),
|
39167
39243
|
val1: bn(receipt.rb),
|
39168
39244
|
val2: bn(receipt.rc),
|
@@ -39175,7 +39251,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39175
39251
|
case "LOG_DATA" /* LogData */: {
|
39176
39252
|
const logDataReceipt = {
|
39177
39253
|
type: ReceiptType.LogData,
|
39178
|
-
id: hexOrZero(receipt.
|
39254
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39179
39255
|
val0: bn(receipt.ra),
|
39180
39256
|
val1: bn(receipt.rb),
|
39181
39257
|
ptr: bn(receipt.ptr),
|
@@ -39189,8 +39265,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39189
39265
|
case "TRANSFER" /* Transfer */: {
|
39190
39266
|
const transferReceipt = {
|
39191
39267
|
type: ReceiptType.Transfer,
|
39192
|
-
from: hexOrZero(receipt.
|
39193
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
39268
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39269
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39194
39270
|
amount: bn(receipt.amount),
|
39195
39271
|
assetId: hexOrZero(receipt.assetId),
|
39196
39272
|
pc: bn(receipt.pc),
|
@@ -39201,8 +39277,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39201
39277
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39202
39278
|
const transferOutReceipt = {
|
39203
39279
|
type: ReceiptType.TransferOut,
|
39204
|
-
from: hexOrZero(receipt.
|
39205
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
39280
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39281
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
39206
39282
|
amount: bn(receipt.amount),
|
39207
39283
|
assetId: hexOrZero(receipt.assetId),
|
39208
39284
|
pc: bn(receipt.pc),
|
@@ -39245,7 +39321,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39245
39321
|
return receiptMessageOut;
|
39246
39322
|
}
|
39247
39323
|
case "MINT" /* Mint */: {
|
39248
|
-
const contractId = hexOrZero(receipt.
|
39324
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39249
39325
|
const subId = hexOrZero(receipt.subId);
|
39250
39326
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39251
39327
|
const mintReceipt = {
|
@@ -39260,7 +39336,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39260
39336
|
return mintReceipt;
|
39261
39337
|
}
|
39262
39338
|
case "BURN" /* Burn */: {
|
39263
|
-
const contractId = hexOrZero(receipt.
|
39339
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39264
39340
|
const subId = hexOrZero(receipt.subId);
|
39265
39341
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39266
39342
|
const burnReceipt = {
|
@@ -39341,7 +39417,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39341
39417
|
};
|
39342
39418
|
|
39343
39419
|
// src/providers/utils/gas.ts
|
39344
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39345
39420
|
var getGasUsedFromReceipts = (receipts) => {
|
39346
39421
|
const scriptResult = receipts.filter(
|
39347
39422
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39362,18 +39437,28 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39362
39437
|
}
|
39363
39438
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39364
39439
|
const witnessCache = [];
|
39365
|
-
const
|
39440
|
+
const chargeableInputs = inputs.filter((input) => {
|
39441
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39442
|
+
if (isCoinOrMessage) {
|
39443
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39444
|
+
return true;
|
39445
|
+
}
|
39446
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
39447
|
+
witnessCache.push(input.witnessIndex);
|
39448
|
+
return true;
|
39449
|
+
}
|
39450
|
+
}
|
39451
|
+
return false;
|
39452
|
+
});
|
39453
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39454
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
39366
39455
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39367
39456
|
return total.add(
|
39368
|
-
|
39457
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39369
39458
|
);
|
39370
39459
|
}
|
39371
|
-
|
39372
|
-
|
39373
|
-
return total.add(gasCosts.ecr1);
|
39374
|
-
}
|
39375
|
-
return total;
|
39376
|
-
}, bn());
|
39460
|
+
return total.add(gasCosts.ecr1);
|
39461
|
+
}, bn(0));
|
39377
39462
|
return totalGas;
|
39378
39463
|
}
|
39379
39464
|
function getMinGas(params) {
|
@@ -39385,12 +39470,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39385
39470
|
return minGas;
|
39386
39471
|
}
|
39387
39472
|
function getMaxGas(params) {
|
39388
|
-
const {
|
39473
|
+
const {
|
39474
|
+
gasPerByte,
|
39475
|
+
witnessesLength,
|
39476
|
+
witnessLimit,
|
39477
|
+
minGas,
|
39478
|
+
gasLimit = bn(0),
|
39479
|
+
maxGasPerTx
|
39480
|
+
} = params;
|
39389
39481
|
let remainingAllowedWitnessGas = bn(0);
|
39390
39482
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39391
39483
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39392
39484
|
}
|
39393
|
-
|
39485
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39486
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39394
39487
|
}
|
39395
39488
|
function calculateMetadataGasForTxCreate({
|
39396
39489
|
gasCosts,
|
@@ -39412,6 +39505,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39412
39505
|
}) {
|
39413
39506
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39414
39507
|
}
|
39508
|
+
var calculateGasFee = (params) => {
|
39509
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
39510
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39511
|
+
};
|
39415
39512
|
|
39416
39513
|
// src/providers/utils/json.ts
|
39417
39514
|
function normalize2(object) {
|
@@ -39553,7 +39650,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39553
39650
|
// src/providers/transaction-request/transaction-request.ts
|
39554
39651
|
var BaseTransactionRequest = class {
|
39555
39652
|
/** Gas price for transaction */
|
39556
|
-
|
39653
|
+
tip;
|
39557
39654
|
/** Block until which tx cannot be included */
|
39558
39655
|
maturity;
|
39559
39656
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39572,7 +39669,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39572
39669
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39573
39670
|
*/
|
39574
39671
|
constructor({
|
39575
|
-
|
39672
|
+
tip,
|
39576
39673
|
maturity,
|
39577
39674
|
maxFee,
|
39578
39675
|
witnessLimit,
|
@@ -39580,7 +39677,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39580
39677
|
outputs,
|
39581
39678
|
witnesses
|
39582
39679
|
} = {}) {
|
39583
|
-
this.
|
39680
|
+
this.tip = bn(tip);
|
39584
39681
|
this.maturity = maturity ?? 0;
|
39585
39682
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39586
39683
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -39591,9 +39688,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39591
39688
|
static getPolicyMeta(req) {
|
39592
39689
|
let policyTypes = 0;
|
39593
39690
|
const policies = [];
|
39594
|
-
if (req.
|
39595
|
-
policyTypes += PolicyType.
|
39596
|
-
policies.push({ data: req.
|
39691
|
+
if (req.tip) {
|
39692
|
+
policyTypes += PolicyType.Tip;
|
39693
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
39597
39694
|
}
|
39598
39695
|
if (req.witnessLimit) {
|
39599
39696
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39777,13 +39874,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39777
39874
|
* assetId, if one it was not added yet.
|
39778
39875
|
*
|
39779
39876
|
* @param coin - Coin resource.
|
39780
|
-
* @param predicate - Predicate bytes.
|
39781
|
-
* @param predicateData - Predicate data bytes.
|
39782
39877
|
*/
|
39783
|
-
addCoinInput(coin
|
39878
|
+
addCoinInput(coin) {
|
39784
39879
|
const { assetId, owner, amount } = coin;
|
39785
39880
|
let witnessIndex;
|
39786
|
-
if (predicate) {
|
39881
|
+
if (coin.predicate) {
|
39787
39882
|
witnessIndex = 0;
|
39788
39883
|
} else {
|
39789
39884
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39798,25 +39893,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39798
39893
|
amount,
|
39799
39894
|
assetId,
|
39800
39895
|
txPointer: "0x00000000000000000000000000000000",
|
39801
|
-
witnessIndex
|
39802
|
-
predicate: predicate?.bytes
|
39896
|
+
witnessIndex
|
39803
39897
|
};
|
39804
39898
|
this.pushInput(input);
|
39805
39899
|
this.addChangeOutput(owner, assetId);
|
39806
39900
|
}
|
39807
39901
|
/**
|
39808
39902
|
* Adds a single message input to the transaction and a change output for the
|
39809
|
-
*
|
39903
|
+
* asset against the message
|
39810
39904
|
*
|
39811
39905
|
* @param message - Message resource.
|
39812
|
-
* @param predicate - Predicate bytes.
|
39813
|
-
* @param predicateData - Predicate data bytes.
|
39814
39906
|
*/
|
39815
|
-
addMessageInput(message
|
39816
|
-
const { recipient, sender, amount } = message;
|
39817
|
-
const assetId = BaseAssetId;
|
39907
|
+
addMessageInput(message) {
|
39908
|
+
const { recipient, sender, amount, assetId } = message;
|
39818
39909
|
let witnessIndex;
|
39819
|
-
if (predicate) {
|
39910
|
+
if (message.predicate) {
|
39820
39911
|
witnessIndex = 0;
|
39821
39912
|
} else {
|
39822
39913
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39830,8 +39921,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39830
39921
|
sender: sender.toB256(),
|
39831
39922
|
recipient: recipient.toB256(),
|
39832
39923
|
amount,
|
39833
|
-
witnessIndex
|
39834
|
-
predicate: predicate?.bytes
|
39924
|
+
witnessIndex
|
39835
39925
|
};
|
39836
39926
|
this.pushInput(input);
|
39837
39927
|
this.addChangeOutput(recipient, assetId);
|
@@ -39862,32 +39952,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39862
39952
|
resources.forEach((resource) => this.addResource(resource));
|
39863
39953
|
return this;
|
39864
39954
|
}
|
39865
|
-
/**
|
39866
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39867
|
-
* outputs from the related assetIds.
|
39868
|
-
*
|
39869
|
-
* @param resources - The resources to add.
|
39870
|
-
* @returns This transaction.
|
39871
|
-
*/
|
39872
|
-
addPredicateResource(resource, predicate) {
|
39873
|
-
if (isCoin(resource)) {
|
39874
|
-
this.addCoinInput(resource, predicate);
|
39875
|
-
} else {
|
39876
|
-
this.addMessageInput(resource, predicate);
|
39877
|
-
}
|
39878
|
-
return this;
|
39879
|
-
}
|
39880
|
-
/**
|
39881
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39882
|
-
* from the related assetIds.
|
39883
|
-
*
|
39884
|
-
* @param resources - The resources to add.
|
39885
|
-
* @returns This transaction.
|
39886
|
-
*/
|
39887
|
-
addPredicateResources(resources, predicate) {
|
39888
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39889
|
-
return this;
|
39890
|
-
}
|
39891
39955
|
/**
|
39892
39956
|
* Adds a coin output to the transaction.
|
39893
39957
|
*
|
@@ -39895,7 +39959,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39895
39959
|
* @param amount - Amount of coin.
|
39896
39960
|
* @param assetId - Asset ID of coin.
|
39897
39961
|
*/
|
39898
|
-
addCoinOutput(to, amount, assetId
|
39962
|
+
addCoinOutput(to, amount, assetId) {
|
39899
39963
|
this.pushOutput({
|
39900
39964
|
type: OutputType.Coin,
|
39901
39965
|
to: addressify(to).toB256(),
|
@@ -39927,7 +39991,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39927
39991
|
* @param to - Address of the owner.
|
39928
39992
|
* @param assetId - Asset ID of coin.
|
39929
39993
|
*/
|
39930
|
-
addChangeOutput(to, assetId
|
39994
|
+
addChangeOutput(to, assetId) {
|
39931
39995
|
const changeOutput = this.getChangeOutputs().find(
|
39932
39996
|
(output3) => hexlify(output3.assetId) === assetId
|
39933
39997
|
);
|
@@ -39967,7 +40031,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39967
40031
|
}
|
39968
40032
|
calculateMaxGas(chainInfo, minGas) {
|
39969
40033
|
const { consensusParameters } = chainInfo;
|
39970
|
-
const { gasPerByte } = consensusParameters;
|
40034
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
39971
40035
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
39972
40036
|
(acc, wit) => acc + wit.dataLength,
|
39973
40037
|
0
|
@@ -39976,7 +40040,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39976
40040
|
gasPerByte,
|
39977
40041
|
minGas,
|
39978
40042
|
witnessesLength,
|
39979
|
-
witnessLimit: this.witnessLimit
|
40043
|
+
witnessLimit: this.witnessLimit,
|
40044
|
+
maxGasPerTx
|
39980
40045
|
});
|
39981
40046
|
}
|
39982
40047
|
/**
|
@@ -39984,8 +40049,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39984
40049
|
* quantities array.
|
39985
40050
|
*
|
39986
40051
|
* @param quantities - CoinQuantity Array.
|
40052
|
+
* @param baseAssetId - The base asset to fund the transaction.
|
39987
40053
|
*/
|
39988
|
-
fundWithFakeUtxos(quantities, resourcesOwner) {
|
40054
|
+
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
39989
40055
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39990
40056
|
if ("assetId" in input) {
|
39991
40057
|
return input.assetId === assetId;
|
@@ -39994,24 +40060,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39994
40060
|
});
|
39995
40061
|
const updateAssetInput = (assetId, quantity) => {
|
39996
40062
|
const assetInput = findAssetInput(assetId);
|
40063
|
+
let usedQuantity = quantity;
|
40064
|
+
if (assetId === baseAssetId) {
|
40065
|
+
usedQuantity = bn("1000000000000000000");
|
40066
|
+
}
|
39997
40067
|
if (assetInput && "assetId" in assetInput) {
|
39998
40068
|
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
39999
|
-
assetInput.amount =
|
40069
|
+
assetInput.amount = usedQuantity;
|
40000
40070
|
} else {
|
40001
40071
|
this.addResources([
|
40002
40072
|
{
|
40003
40073
|
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
40004
|
-
amount:
|
40074
|
+
amount: usedQuantity,
|
40005
40075
|
assetId,
|
40006
40076
|
owner: resourcesOwner || Address.fromRandom(),
|
40007
|
-
maturity: 0,
|
40008
40077
|
blockCreated: bn(1),
|
40009
40078
|
txCreatedIdx: bn(1)
|
40010
40079
|
}
|
40011
40080
|
]);
|
40012
40081
|
}
|
40013
40082
|
};
|
40014
|
-
updateAssetInput(
|
40083
|
+
updateAssetInput(baseAssetId, bn(1e11));
|
40015
40084
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40016
40085
|
}
|
40017
40086
|
/**
|
@@ -40036,7 +40105,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40036
40105
|
toJSON() {
|
40037
40106
|
return normalizeJSON(this);
|
40038
40107
|
}
|
40039
|
-
|
40108
|
+
updatePredicateGasUsed(inputs) {
|
40040
40109
|
this.inputs.forEach((i) => {
|
40041
40110
|
let correspondingInput;
|
40042
40111
|
switch (i.type) {
|
@@ -40058,6 +40127,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40058
40127
|
}
|
40059
40128
|
});
|
40060
40129
|
}
|
40130
|
+
shiftPredicateData() {
|
40131
|
+
this.inputs.forEach((input) => {
|
40132
|
+
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
40133
|
+
input.predicateData = input.padPredicateData(
|
40134
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40135
|
+
);
|
40136
|
+
}
|
40137
|
+
});
|
40138
|
+
}
|
40061
40139
|
};
|
40062
40140
|
|
40063
40141
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40168,12 +40246,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40168
40246
|
*
|
40169
40247
|
* @param createTransactionRequestLike - The initial values for the instance
|
40170
40248
|
*/
|
40171
|
-
constructor({
|
40172
|
-
bytecodeWitnessIndex,
|
40173
|
-
salt,
|
40174
|
-
storageSlots,
|
40175
|
-
...rest
|
40176
|
-
} = {}) {
|
40249
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40177
40250
|
super(rest);
|
40178
40251
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40179
40252
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40191,9 +40264,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40191
40264
|
return {
|
40192
40265
|
type: TransactionType.Create,
|
40193
40266
|
...baseTransaction,
|
40194
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40195
40267
|
bytecodeWitnessIndex,
|
40196
|
-
storageSlotsCount: storageSlots.length,
|
40268
|
+
storageSlotsCount: bn(storageSlots.length),
|
40197
40269
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40198
40270
|
storageSlots
|
40199
40271
|
};
|
@@ -40307,8 +40379,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40307
40379
|
type: TransactionType.Script,
|
40308
40380
|
scriptGasLimit: this.gasLimit,
|
40309
40381
|
...super.getBaseTransaction(),
|
40310
|
-
scriptLength: script.length,
|
40311
|
-
scriptDataLength: scriptData.length,
|
40382
|
+
scriptLength: bn(script.length),
|
40383
|
+
scriptDataLength: bn(scriptData.length),
|
40312
40384
|
receiptsRoot: ZeroBytes32,
|
40313
40385
|
script: hexlify(script),
|
40314
40386
|
scriptData: hexlify(scriptData)
|
@@ -40372,7 +40444,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40372
40444
|
}
|
40373
40445
|
calculateMaxGas(chainInfo, minGas) {
|
40374
40446
|
const { consensusParameters } = chainInfo;
|
40375
|
-
const { gasPerByte } = consensusParameters;
|
40447
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
40376
40448
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40377
40449
|
(acc, wit) => acc + wit.dataLength,
|
40378
40450
|
0
|
@@ -40382,7 +40454,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40382
40454
|
minGas,
|
40383
40455
|
witnessesLength,
|
40384
40456
|
witnessLimit: this.witnessLimit,
|
40385
|
-
gasLimit: this.gasLimit
|
40457
|
+
gasLimit: this.gasLimit,
|
40458
|
+
maxGasPerTx
|
40386
40459
|
});
|
40387
40460
|
}
|
40388
40461
|
/**
|
@@ -40455,13 +40528,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40455
40528
|
}
|
40456
40529
|
}
|
40457
40530
|
};
|
40531
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40532
|
+
(acc, input) => {
|
40533
|
+
if (input.type === InputType.Coin && input.owner === owner) {
|
40534
|
+
acc.utxos.push(input.id);
|
40535
|
+
}
|
40536
|
+
if (input.type === InputType.Message && input.recipient === owner) {
|
40537
|
+
acc.messages.push(input.nonce);
|
40538
|
+
}
|
40539
|
+
return acc;
|
40540
|
+
},
|
40541
|
+
{
|
40542
|
+
utxos: [],
|
40543
|
+
messages: []
|
40544
|
+
}
|
40545
|
+
);
|
40458
40546
|
|
40459
40547
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40460
40548
|
var calculateTransactionFee = (params) => {
|
40461
40549
|
const {
|
40462
|
-
|
40550
|
+
gasPrice,
|
40463
40551
|
rawPayload,
|
40464
|
-
|
40552
|
+
tip,
|
40553
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40465
40554
|
} = params;
|
40466
40555
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40467
40556
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40471,8 +40560,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40471
40560
|
return {
|
40472
40561
|
fee: bn(0),
|
40473
40562
|
minFee: bn(0),
|
40474
|
-
maxFee: bn(0)
|
40475
|
-
feeFromGasUsed: bn(0)
|
40563
|
+
maxFee: bn(0)
|
40476
40564
|
};
|
40477
40565
|
}
|
40478
40566
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40504,7 +40592,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40504
40592
|
metadataGas,
|
40505
40593
|
txBytesSize: transactionBytes.length
|
40506
40594
|
});
|
40507
|
-
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40508
40595
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40509
40596
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40510
40597
|
const maxGas = getMaxGas({
|
@@ -40512,17 +40599,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40512
40599
|
minGas,
|
40513
40600
|
witnessesLength,
|
40514
40601
|
gasLimit,
|
40515
|
-
witnessLimit
|
40602
|
+
witnessLimit,
|
40603
|
+
maxGasPerTx
|
40604
|
+
});
|
40605
|
+
const minFee = calculateGasFee({
|
40606
|
+
gasPrice,
|
40607
|
+
gas: minGas,
|
40608
|
+
priceFactor: gasPriceFactor,
|
40609
|
+
tip
|
40610
|
+
});
|
40611
|
+
const maxFee = calculateGasFee({
|
40612
|
+
gasPrice,
|
40613
|
+
gas: maxGas,
|
40614
|
+
priceFactor: gasPriceFactor,
|
40615
|
+
tip
|
40516
40616
|
});
|
40517
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40518
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40519
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40520
|
-
const fee = minFee.add(feeFromGasUsed);
|
40521
40617
|
return {
|
40522
|
-
fee,
|
40523
40618
|
minFee,
|
40524
40619
|
maxFee,
|
40525
|
-
|
40620
|
+
fee: maxFee
|
40526
40621
|
};
|
40527
40622
|
};
|
40528
40623
|
|
@@ -41123,7 +41218,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41123
41218
|
gqlTransactionStatus,
|
41124
41219
|
abiMap = {},
|
41125
41220
|
maxInputs,
|
41126
|
-
gasCosts
|
41221
|
+
gasCosts,
|
41222
|
+
maxGasPerTx,
|
41223
|
+
gasPrice
|
41127
41224
|
} = params;
|
41128
41225
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41129
41226
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41137,11 +41234,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41137
41234
|
maxInputs
|
41138
41235
|
});
|
41139
41236
|
const typeName = getTransactionTypeName(transaction.type);
|
41237
|
+
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41140
41238
|
const { fee } = calculateTransactionFee({
|
41141
|
-
|
41239
|
+
gasPrice,
|
41142
41240
|
rawPayload,
|
41241
|
+
tip,
|
41143
41242
|
consensusParameters: {
|
41144
41243
|
gasCosts,
|
41244
|
+
maxGasPerTx,
|
41145
41245
|
feeParams: {
|
41146
41246
|
gasPerByte,
|
41147
41247
|
gasPriceFactor
|
@@ -41277,8 +41377,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41277
41377
|
const decodedTransaction = this.decodeTransaction(
|
41278
41378
|
transaction
|
41279
41379
|
);
|
41280
|
-
|
41281
|
-
|
41380
|
+
let txReceipts = [];
|
41381
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
41382
|
+
txReceipts = transaction.status.receipts;
|
41383
|
+
}
|
41384
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41385
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41386
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
41282
41387
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41283
41388
|
const transactionSummary = assembleTransactionSummary({
|
41284
41389
|
id: this.id,
|
@@ -41290,7 +41395,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41290
41395
|
gasPriceFactor,
|
41291
41396
|
abiMap: contractsAbiMap,
|
41292
41397
|
maxInputs,
|
41293
|
-
gasCosts
|
41398
|
+
gasCosts,
|
41399
|
+
maxGasPerTx,
|
41400
|
+
gasPrice
|
41294
41401
|
});
|
41295
41402
|
return transactionSummary;
|
41296
41403
|
}
|
@@ -41396,7 +41503,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41396
41503
|
}
|
41397
41504
|
|
41398
41505
|
// src/providers/utils/merge-quantities.ts
|
41399
|
-
var mergeQuantities = (
|
41506
|
+
var mergeQuantities = (...coinQuantities) => {
|
41400
41507
|
const resultMap = {};
|
41401
41508
|
function addToMap({ amount, assetId }) {
|
41402
41509
|
if (resultMap[assetId]) {
|
@@ -41405,8 +41512,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41405
41512
|
resultMap[assetId] = amount;
|
41406
41513
|
}
|
41407
41514
|
}
|
41408
|
-
|
41409
|
-
arr2.forEach(addToMap);
|
41515
|
+
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
41410
41516
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
41411
41517
|
};
|
41412
41518
|
|
@@ -41434,12 +41540,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41434
41540
|
gasPerByte: bn(feeParams.gasPerByte),
|
41435
41541
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41436
41542
|
chainId: bn(consensusParameters.chainId),
|
41543
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41437
41544
|
gasCosts
|
41438
41545
|
},
|
41439
41546
|
gasCosts,
|
41440
41547
|
latestBlock: {
|
41441
41548
|
id: latestBlock.id,
|
41442
|
-
height: bn(latestBlock.
|
41549
|
+
height: bn(latestBlock.height),
|
41443
41550
|
time: latestBlock.header.time,
|
41444
41551
|
transactions: latestBlock.transactions.map((i) => ({
|
41445
41552
|
id: i.id
|
@@ -41533,10 +41640,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41533
41640
|
* Returns some helpful parameters related to gas fees.
|
41534
41641
|
*/
|
41535
41642
|
getGasConfig() {
|
41536
|
-
const { minGasPrice } = this.getNode();
|
41537
41643
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41538
41644
|
return {
|
41539
|
-
minGasPrice,
|
41540
41645
|
maxGasPerTx,
|
41541
41646
|
maxGasPerPredicate,
|
41542
41647
|
gasPriceFactor,
|
@@ -41634,7 +41739,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41634
41739
|
*/
|
41635
41740
|
async getBlockNumber() {
|
41636
41741
|
const { chain } = await this.operations.getChain();
|
41637
|
-
return bn(chain.latestBlock.
|
41742
|
+
return bn(chain.latestBlock.height, 10);
|
41638
41743
|
}
|
41639
41744
|
/**
|
41640
41745
|
* Returns the chain information.
|
@@ -41646,11 +41751,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41646
41751
|
const processedNodeInfo = {
|
41647
41752
|
maxDepth: bn(nodeInfo.maxDepth),
|
41648
41753
|
maxTx: bn(nodeInfo.maxTx),
|
41649
|
-
minGasPrice: bn(nodeInfo.minGasPrice),
|
41650
41754
|
nodeVersion: nodeInfo.nodeVersion,
|
41651
41755
|
utxoValidation: nodeInfo.utxoValidation,
|
41652
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41653
|
-
peers: nodeInfo.peers
|
41756
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
41654
41757
|
};
|
41655
41758
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41656
41759
|
return processedNodeInfo;
|
@@ -41676,6 +41779,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41676
41779
|
} = this.getChain();
|
41677
41780
|
return chainId.toNumber();
|
41678
41781
|
}
|
41782
|
+
/**
|
41783
|
+
* Returns the base asset ID for the current provider network
|
41784
|
+
*
|
41785
|
+
* @returns the base asset ID
|
41786
|
+
*/
|
41787
|
+
getBaseAssetId() {
|
41788
|
+
const {
|
41789
|
+
consensusParameters: { baseAssetId }
|
41790
|
+
} = this.getChain();
|
41791
|
+
return baseAssetId;
|
41792
|
+
}
|
41679
41793
|
/**
|
41680
41794
|
* Submits a transaction to the chain to be executed.
|
41681
41795
|
*
|
@@ -41736,14 +41850,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41736
41850
|
return this.estimateTxDependencies(transactionRequest);
|
41737
41851
|
}
|
41738
41852
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41739
|
-
const { dryRun:
|
41740
|
-
encodedTransaction,
|
41853
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41854
|
+
encodedTransactions: encodedTransaction,
|
41741
41855
|
utxoValidation: utxoValidation || false
|
41742
41856
|
});
|
41743
|
-
const receipts =
|
41744
|
-
|
41745
|
-
|
41746
|
-
};
|
41857
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
41858
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
41859
|
+
return { receipts, dryrunStatus: status };
|
41747
41860
|
}
|
41748
41861
|
/**
|
41749
41862
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41782,9 +41895,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41782
41895
|
* If there are missing variable outputs,
|
41783
41896
|
* `addVariableOutputs` is called on the transaction.
|
41784
41897
|
*
|
41785
|
-
* @privateRemarks
|
41786
|
-
* TODO: Investigate support for missing contract IDs
|
41787
|
-
* TODO: Add support for missing output messages
|
41788
41898
|
*
|
41789
41899
|
* @param transactionRequest - The transaction request object.
|
41790
41900
|
* @returns A promise.
|
@@ -41797,16 +41907,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41797
41907
|
missingContractIds: []
|
41798
41908
|
};
|
41799
41909
|
}
|
41800
|
-
await this.estimatePredicates(transactionRequest);
|
41801
41910
|
let receipts = [];
|
41802
41911
|
const missingContractIds = [];
|
41803
41912
|
let outputVariables = 0;
|
41913
|
+
let dryrunStatus;
|
41804
41914
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41805
|
-
const {
|
41806
|
-
|
41915
|
+
const {
|
41916
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
41917
|
+
} = await this.operations.dryRun({
|
41918
|
+
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41807
41919
|
utxoValidation: false
|
41808
41920
|
});
|
41809
|
-
receipts =
|
41921
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
41922
|
+
dryrunStatus = status;
|
41810
41923
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41811
41924
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41812
41925
|
if (hasMissingOutputs) {
|
@@ -41816,6 +41929,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41816
41929
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41817
41930
|
missingContractIds.push(contractId);
|
41818
41931
|
});
|
41932
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41933
|
+
transactionRequest
|
41934
|
+
});
|
41935
|
+
transactionRequest.maxFee = maxFee;
|
41819
41936
|
} else {
|
41820
41937
|
break;
|
41821
41938
|
}
|
@@ -41823,37 +41940,136 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41823
41940
|
return {
|
41824
41941
|
receipts,
|
41825
41942
|
outputVariables,
|
41826
|
-
missingContractIds
|
41943
|
+
missingContractIds,
|
41944
|
+
dryrunStatus
|
41827
41945
|
};
|
41828
41946
|
}
|
41947
|
+
/**
|
41948
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41949
|
+
*
|
41950
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41951
|
+
* further modifications are identified. The method iteratively updates these transactions
|
41952
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41953
|
+
*
|
41954
|
+
* @param transactionRequests - Array of transaction request objects.
|
41955
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
41956
|
+
*/
|
41957
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
41958
|
+
const results = transactionRequests.map(() => ({
|
41959
|
+
receipts: [],
|
41960
|
+
outputVariables: 0,
|
41961
|
+
missingContractIds: [],
|
41962
|
+
dryrunStatus: void 0
|
41963
|
+
}));
|
41964
|
+
const allRequests = clone_default(transactionRequests);
|
41965
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41966
|
+
allRequests.forEach((req, index) => {
|
41967
|
+
if (req.type === TransactionType.Script) {
|
41968
|
+
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41969
|
+
}
|
41970
|
+
});
|
41971
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41972
|
+
let attempt = 0;
|
41973
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41974
|
+
const encodedTransactions = transactionsToProcess.map(
|
41975
|
+
(index) => serializedTransactionsMap.get(index)
|
41976
|
+
);
|
41977
|
+
const dryRunResults = await this.operations.dryRun({
|
41978
|
+
encodedTransactions,
|
41979
|
+
utxoValidation: false
|
41980
|
+
});
|
41981
|
+
const nextRoundTransactions = [];
|
41982
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41983
|
+
const requestIdx = transactionsToProcess[i];
|
41984
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41985
|
+
const result = results[requestIdx];
|
41986
|
+
result.receipts = rawReceipts.map(processGqlReceipt);
|
41987
|
+
result.dryrunStatus = status;
|
41988
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41989
|
+
result.receipts
|
41990
|
+
);
|
41991
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41992
|
+
const request = allRequests[requestIdx];
|
41993
|
+
if (hasMissingOutputs && request?.type === TransactionType.Script) {
|
41994
|
+
result.outputVariables += missingOutputVariables.length;
|
41995
|
+
request.addVariableOutputs(missingOutputVariables.length);
|
41996
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
41997
|
+
request.addContractInputAndOutput(Address.fromString(contractId));
|
41998
|
+
result.missingContractIds.push(contractId);
|
41999
|
+
});
|
42000
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
42001
|
+
transactionRequest: request
|
42002
|
+
});
|
42003
|
+
request.maxFee = maxFee;
|
42004
|
+
serializedTransactionsMap.set(requestIdx, hexlify(request.toTransactionBytes()));
|
42005
|
+
nextRoundTransactions.push(requestIdx);
|
42006
|
+
}
|
42007
|
+
}
|
42008
|
+
transactionsToProcess = nextRoundTransactions;
|
42009
|
+
attempt += 1;
|
42010
|
+
}
|
42011
|
+
return results;
|
42012
|
+
}
|
42013
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
42014
|
+
if (estimateTxDependencies) {
|
42015
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
42016
|
+
}
|
42017
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
42018
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42019
|
+
encodedTransactions,
|
42020
|
+
utxoValidation: utxoValidation || false
|
42021
|
+
});
|
42022
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42023
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
42024
|
+
return { receipts, dryrunStatus: status };
|
42025
|
+
});
|
42026
|
+
return results;
|
42027
|
+
}
|
41829
42028
|
/**
|
41830
42029
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
41831
42030
|
* @param transactionRequest - The transaction request object.
|
41832
42031
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41833
42032
|
*/
|
41834
|
-
estimateTxGasAndFee(params) {
|
42033
|
+
async estimateTxGasAndFee(params) {
|
41835
42034
|
const { transactionRequest } = params;
|
41836
|
-
|
42035
|
+
let { gasPrice } = params;
|
41837
42036
|
const chainInfo = this.getChain();
|
41838
|
-
const
|
41839
|
-
transactionRequest.gasPrice = gasPrice;
|
42037
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
41840
42038
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41841
|
-
|
42039
|
+
if (!gasPrice) {
|
42040
|
+
gasPrice = await this.estimateGasPrice(10);
|
42041
|
+
}
|
42042
|
+
const minFee = calculateGasFee({
|
42043
|
+
gasPrice: bn(gasPrice),
|
42044
|
+
gas: minGas,
|
42045
|
+
priceFactor: gasPriceFactor,
|
42046
|
+
tip: transactionRequest.tip
|
42047
|
+
}).add(1);
|
42048
|
+
let gasLimit = bn(0);
|
41842
42049
|
if (transactionRequest.type === TransactionType.Script) {
|
42050
|
+
gasLimit = transactionRequest.gasLimit;
|
41843
42051
|
if (transactionRequest.gasLimit.eq(0)) {
|
41844
42052
|
transactionRequest.gasLimit = minGas;
|
41845
42053
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41846
42054
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41847
42055
|
);
|
42056
|
+
gasLimit = transactionRequest.gasLimit;
|
41848
42057
|
}
|
41849
42058
|
}
|
41850
42059
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41851
|
-
const maxFee =
|
42060
|
+
const maxFee = calculateGasFee({
|
42061
|
+
gasPrice: bn(gasPrice),
|
42062
|
+
gas: maxGas,
|
42063
|
+
priceFactor: gasPriceFactor,
|
42064
|
+
tip: transactionRequest.tip
|
42065
|
+
}).add(1);
|
41852
42066
|
return {
|
41853
42067
|
minGas,
|
41854
42068
|
minFee,
|
41855
42069
|
maxGas,
|
41856
|
-
maxFee
|
42070
|
+
maxFee,
|
42071
|
+
gasPrice,
|
42072
|
+
gasLimit
|
41857
42073
|
};
|
41858
42074
|
}
|
41859
42075
|
/**
|
@@ -41871,15 +42087,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41871
42087
|
if (estimateTxDependencies) {
|
41872
42088
|
return this.estimateTxDependencies(transactionRequest);
|
41873
42089
|
}
|
41874
|
-
const
|
41875
|
-
const { dryRun:
|
41876
|
-
|
42090
|
+
const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
|
42091
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42092
|
+
encodedTransactions,
|
41877
42093
|
utxoValidation: true
|
41878
42094
|
});
|
41879
|
-
const
|
41880
|
-
|
41881
|
-
receipts
|
41882
|
-
|
42095
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
42096
|
+
const { id, receipts, status } = dryRunStatus;
|
42097
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
42098
|
+
return { id, receipts: processedReceipts, status };
|
42099
|
+
});
|
42100
|
+
return { receipts: callResult[0].receipts };
|
41883
42101
|
}
|
41884
42102
|
/**
|
41885
42103
|
* Returns a transaction cost to enable user
|
@@ -41896,77 +42114,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41896
42114
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
41897
42115
|
* @returns A promise that resolves to the transaction cost object.
|
41898
42116
|
*/
|
41899
|
-
async getTransactionCost(transactionRequestLike,
|
41900
|
-
estimateTxDependencies = true,
|
41901
|
-
estimatePredicates = true,
|
41902
|
-
resourcesOwner,
|
41903
|
-
signatureCallback
|
41904
|
-
} = {}) {
|
42117
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
41905
42118
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41906
|
-
const { minGasPrice } = this.getGasConfig();
|
41907
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41908
42119
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42120
|
+
const baseAssetId = this.getBaseAssetId();
|
41909
42121
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41910
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41911
|
-
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42122
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
42123
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
42124
|
+
txRequestClone.maxFee = bn(0);
|
41912
42125
|
if (isScriptTransaction) {
|
41913
42126
|
txRequestClone.gasLimit = bn(0);
|
41914
42127
|
}
|
41915
|
-
if (
|
41916
|
-
|
41917
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41918
|
-
}
|
41919
|
-
await this.estimatePredicates(txRequestClone);
|
42128
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
42129
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41920
42130
|
}
|
42131
|
+
const signedRequest = clone_default(txRequestClone);
|
42132
|
+
let addedSignatures = 0;
|
41921
42133
|
if (signatureCallback && isScriptTransaction) {
|
41922
|
-
|
42134
|
+
const lengthBefore = signedRequest.witnesses.length;
|
42135
|
+
await signatureCallback(signedRequest);
|
42136
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
41923
42137
|
}
|
41924
|
-
|
41925
|
-
|
42138
|
+
await this.estimatePredicates(signedRequest);
|
42139
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42140
|
+
transactionRequest: signedRequest
|
41926
42141
|
});
|
41927
42142
|
let receipts = [];
|
41928
42143
|
let missingContractIds = [];
|
41929
42144
|
let outputVariables = 0;
|
41930
42145
|
let gasUsed = bn(0);
|
41931
|
-
|
41932
|
-
|
42146
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
42147
|
+
txRequestClone.maxFee = maxFee;
|
42148
|
+
if (isScriptTransaction) {
|
42149
|
+
txRequestClone.gasLimit = gasLimit;
|
42150
|
+
if (signatureCallback) {
|
42151
|
+
await signatureCallback(txRequestClone);
|
42152
|
+
}
|
41933
42153
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41934
42154
|
receipts = result.receipts;
|
41935
42155
|
outputVariables = result.outputVariables;
|
41936
42156
|
missingContractIds = result.missingContractIds;
|
41937
42157
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41938
42158
|
txRequestClone.gasLimit = gasUsed;
|
41939
|
-
|
41940
|
-
|
41941
|
-
|
42159
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42160
|
+
transactionRequest: txRequestClone,
|
42161
|
+
gasPrice
|
41942
42162
|
}));
|
41943
42163
|
}
|
41944
42164
|
return {
|
41945
42165
|
requiredQuantities: allQuantities,
|
41946
42166
|
receipts,
|
41947
42167
|
gasUsed,
|
41948
|
-
|
41949
|
-
gasPrice: setGasPrice,
|
42168
|
+
gasPrice,
|
41950
42169
|
minGas,
|
41951
42170
|
maxGas,
|
41952
42171
|
minFee,
|
41953
42172
|
maxFee,
|
41954
|
-
estimatedInputs: txRequestClone.inputs,
|
41955
42173
|
outputVariables,
|
41956
|
-
missingContractIds
|
42174
|
+
missingContractIds,
|
42175
|
+
addedSignatures,
|
42176
|
+
estimatedPredicates: txRequestClone.inputs
|
41957
42177
|
};
|
41958
42178
|
}
|
41959
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
42179
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
41960
42180
|
const ownerAddress = Address.fromAddressOrString(owner);
|
41961
42181
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
41962
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42182
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
42183
|
+
quantitiesToContract
|
42184
|
+
});
|
41963
42185
|
transactionRequest.addResources(
|
41964
42186
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
41965
42187
|
);
|
41966
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41967
|
-
|
41968
|
-
|
41969
|
-
);
|
42188
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
42189
|
+
quantitiesToContract
|
42190
|
+
});
|
41970
42191
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
41971
42192
|
return {
|
41972
42193
|
resources,
|
@@ -41990,7 +42211,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41990
42211
|
assetId: coin.assetId,
|
41991
42212
|
amount: bn(coin.amount),
|
41992
42213
|
owner: Address.fromAddressOrString(coin.owner),
|
41993
|
-
maturity: bn(coin.maturity).toNumber(),
|
41994
42214
|
blockCreated: bn(coin.blockCreated),
|
41995
42215
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
41996
42216
|
}));
|
@@ -42042,7 +42262,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42042
42262
|
amount: bn(coin.amount),
|
42043
42263
|
assetId: coin.assetId,
|
42044
42264
|
owner: Address.fromAddressOrString(coin.owner),
|
42045
|
-
maturity: bn(coin.maturity).toNumber(),
|
42046
42265
|
blockCreated: bn(coin.blockCreated),
|
42047
42266
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42048
42267
|
};
|
@@ -42075,7 +42294,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42075
42294
|
}
|
42076
42295
|
return {
|
42077
42296
|
id: block2.id,
|
42078
|
-
height: bn(block2.
|
42297
|
+
height: bn(block2.height),
|
42079
42298
|
time: block2.header.time,
|
42080
42299
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42081
42300
|
};
|
@@ -42090,7 +42309,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42090
42309
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42091
42310
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42092
42311
|
id: block2.id,
|
42093
|
-
height: bn(block2.
|
42312
|
+
height: bn(block2.height),
|
42094
42313
|
time: block2.header.time,
|
42095
42314
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42096
42315
|
}));
|
@@ -42117,7 +42336,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42117
42336
|
}
|
42118
42337
|
return {
|
42119
42338
|
id: block2.id,
|
42120
|
-
height: bn(block2.
|
42339
|
+
height: bn(block2.height, 10),
|
42121
42340
|
time: block2.header.time,
|
42122
42341
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42123
42342
|
transactions: block2.transactions.map(
|
@@ -42297,8 +42516,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42297
42516
|
prevRoot: messageBlockHeader.prevRoot,
|
42298
42517
|
time: messageBlockHeader.time,
|
42299
42518
|
applicationHash: messageBlockHeader.applicationHash,
|
42300
|
-
|
42301
|
-
|
42519
|
+
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
|
42520
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
42521
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
42522
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
42523
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
42302
42524
|
},
|
42303
42525
|
commitBlockHeader: {
|
42304
42526
|
id: commitBlockHeader.id,
|
@@ -42309,8 +42531,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42309
42531
|
prevRoot: commitBlockHeader.prevRoot,
|
42310
42532
|
time: commitBlockHeader.time,
|
42311
42533
|
applicationHash: commitBlockHeader.applicationHash,
|
42312
|
-
|
42313
|
-
|
42534
|
+
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
|
42535
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
42536
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
42537
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
42538
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
42314
42539
|
},
|
42315
42540
|
sender: Address.fromAddressOrString(sender),
|
42316
42541
|
recipient: Address.fromAddressOrString(recipient),
|
@@ -42319,6 +42544,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42319
42544
|
data
|
42320
42545
|
};
|
42321
42546
|
}
|
42547
|
+
async getLatestGasPrice() {
|
42548
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42549
|
+
return bn(latestGasPrice.gasPrice);
|
42550
|
+
}
|
42551
|
+
async estimateGasPrice(blockHorizon) {
|
42552
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42553
|
+
blockHorizon: String(blockHorizon)
|
42554
|
+
});
|
42555
|
+
return bn(estimateGasPrice.gasPrice);
|
42556
|
+
}
|
42322
42557
|
/**
|
42323
42558
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42324
42559
|
*
|
@@ -42379,10 +42614,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42379
42614
|
arrayify(gqlTransaction.rawPayload),
|
42380
42615
|
0
|
42381
42616
|
);
|
42382
|
-
|
42617
|
+
let txReceipts = [];
|
42618
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42619
|
+
txReceipts = gqlTransaction.status.receipts;
|
42620
|
+
}
|
42621
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42383
42622
|
const {
|
42384
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42623
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42385
42624
|
} = provider.getChain();
|
42625
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42386
42626
|
const transactionInfo = assembleTransactionSummary({
|
42387
42627
|
id: gqlTransaction.id,
|
42388
42628
|
receipts,
|
@@ -42393,7 +42633,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42393
42633
|
gasPriceFactor: bn(gasPriceFactor),
|
42394
42634
|
abiMap,
|
42395
42635
|
maxInputs,
|
42396
|
-
gasCosts
|
42636
|
+
gasCosts,
|
42637
|
+
maxGasPerTx,
|
42638
|
+
gasPrice
|
42397
42639
|
});
|
42398
42640
|
return {
|
42399
42641
|
gqlTransaction,
|
@@ -42403,10 +42645,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42403
42645
|
async function getTransactionSummaryFromRequest(params) {
|
42404
42646
|
const { provider, transactionRequest, abiMap } = params;
|
42405
42647
|
const { receipts } = await provider.call(transactionRequest);
|
42406
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42648
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
42407
42649
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42408
42650
|
const transaction = transactionRequest.toTransaction();
|
42409
42651
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42652
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42410
42653
|
const transactionSummary = assembleTransactionSummary({
|
42411
42654
|
receipts,
|
42412
42655
|
transaction,
|
@@ -42415,7 +42658,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42415
42658
|
gasPerByte,
|
42416
42659
|
gasPriceFactor,
|
42417
42660
|
maxInputs,
|
42418
|
-
gasCosts
|
42661
|
+
gasCosts,
|
42662
|
+
maxGasPerTx,
|
42663
|
+
gasPrice
|
42419
42664
|
});
|
42420
42665
|
return transactionSummary;
|
42421
42666
|
}
|
@@ -42424,13 +42669,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42424
42669
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42425
42670
|
const { edges, pageInfo } = transactionsByOwner;
|
42426
42671
|
const {
|
42427
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42672
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42428
42673
|
} = provider.getChain();
|
42674
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42429
42675
|
const transactions = edges.map((edge) => {
|
42430
42676
|
const { node: gqlTransaction } = edge;
|
42431
|
-
const { id, rawPayload,
|
42677
|
+
const { id, rawPayload, status } = gqlTransaction;
|
42432
42678
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42433
|
-
|
42679
|
+
let txReceipts = [];
|
42680
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42681
|
+
txReceipts = gqlTransaction.status.receipts;
|
42682
|
+
}
|
42683
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42434
42684
|
const transactionSummary = assembleTransactionSummary({
|
42435
42685
|
id,
|
42436
42686
|
receipts,
|
@@ -42441,7 +42691,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42441
42691
|
gasPerByte,
|
42442
42692
|
gasPriceFactor,
|
42443
42693
|
maxInputs,
|
42444
|
-
gasCosts
|
42694
|
+
gasCosts,
|
42695
|
+
maxGasPerTx,
|
42696
|
+
gasPrice
|
42445
42697
|
});
|
42446
42698
|
const output3 = {
|
42447
42699
|
gqlTransaction,
|
@@ -42732,8 +42984,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42732
42984
|
* @param assetId - The asset ID to check the balance for.
|
42733
42985
|
* @returns A promise that resolves to the balance amount.
|
42734
42986
|
*/
|
42735
|
-
async getBalance(assetId
|
42736
|
-
const
|
42987
|
+
async getBalance(assetId) {
|
42988
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42989
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42737
42990
|
return amount;
|
42738
42991
|
}
|
42739
42992
|
/**
|
@@ -42770,37 +43023,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42770
43023
|
* @param fee - The estimated transaction fee.
|
42771
43024
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42772
43025
|
*/
|
42773
|
-
async fund(request,
|
42774
|
-
const
|
43026
|
+
async fund(request, params) {
|
43027
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
43028
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
43029
|
+
const txRequest = request;
|
43030
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42775
43031
|
amount: bn(fee),
|
42776
|
-
assetId:
|
42777
|
-
coinQuantities
|
43032
|
+
assetId: baseAssetId,
|
43033
|
+
coinQuantities: requiredQuantities
|
42778
43034
|
});
|
42779
43035
|
const quantitiesDict = {};
|
42780
|
-
|
43036
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
42781
43037
|
quantitiesDict[assetId] = {
|
42782
43038
|
required: amount,
|
42783
43039
|
owned: bn(0)
|
42784
43040
|
};
|
42785
43041
|
});
|
42786
|
-
|
42787
|
-
const cachedMessages = [];
|
42788
|
-
const owner = this.address.toB256();
|
42789
|
-
request.inputs.forEach((input) => {
|
43042
|
+
txRequest.inputs.forEach((input) => {
|
42790
43043
|
const isResource = "amount" in input;
|
42791
|
-
if (isResource) {
|
42792
|
-
|
42793
|
-
|
42794
|
-
|
42795
|
-
|
42796
|
-
|
42797
|
-
|
42798
|
-
cachedUtxos.push(input.id);
|
42799
|
-
}
|
42800
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42801
|
-
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42802
|
-
cachedMessages.push(input.nonce);
|
42803
|
-
}
|
43044
|
+
if (!isResource) {
|
43045
|
+
return;
|
43046
|
+
}
|
43047
|
+
const isCoin2 = "owner" in input;
|
43048
|
+
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
43049
|
+
if (quantitiesDict[assetId]) {
|
43050
|
+
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
42804
43051
|
}
|
42805
43052
|
});
|
42806
43053
|
const missingQuantities = [];
|
@@ -42814,12 +43061,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42814
43061
|
});
|
42815
43062
|
const needsToBeFunded = missingQuantities.length;
|
42816
43063
|
if (needsToBeFunded) {
|
42817
|
-
const
|
42818
|
-
|
42819
|
-
|
42820
|
-
|
42821
|
-
|
42822
|
-
|
43064
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
43065
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
43066
|
+
txRequest.addResources(resources);
|
43067
|
+
}
|
43068
|
+
txRequest.shiftPredicateData();
|
43069
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43070
|
+
const requestToReestimate = clone_default(txRequest);
|
43071
|
+
if (addedSignatures) {
|
43072
|
+
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
43073
|
+
}
|
43074
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43075
|
+
transactionRequest: requestToReestimate
|
43076
|
+
});
|
43077
|
+
txRequest.maxFee = maxFee;
|
43078
|
+
return txRequest;
|
42823
43079
|
}
|
42824
43080
|
/**
|
42825
43081
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -42827,28 +43083,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42827
43083
|
* @param destination - The address of the destination.
|
42828
43084
|
* @param amount - The amount of coins to transfer.
|
42829
43085
|
* @param assetId - The asset ID of the coins to transfer.
|
42830
|
-
* @param txParams - The transaction parameters (gasLimit,
|
43086
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
42831
43087
|
* @returns A promise that resolves to the prepared transaction request.
|
42832
43088
|
*/
|
42833
|
-
async createTransfer(destination, amount, assetId
|
42834
|
-
const
|
42835
|
-
const
|
42836
|
-
|
42837
|
-
|
42838
|
-
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43089
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
43090
|
+
const request = new ScriptTransactionRequest(txParams);
|
43091
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
43092
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
43093
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
42839
43094
|
estimateTxDependencies: true,
|
42840
43095
|
resourcesOwner: this
|
42841
43096
|
});
|
42842
|
-
|
42843
|
-
|
42844
|
-
|
42845
|
-
|
42846
|
-
gasPrice: request.gasPrice,
|
42847
|
-
gasLimit: request.gasLimit,
|
42848
|
-
minGasPrice
|
43097
|
+
this.validateGasLimitAndMaxFee({
|
43098
|
+
gasUsed: txCost.gasUsed,
|
43099
|
+
maxFee: txCost.maxFee,
|
43100
|
+
txParams
|
42849
43101
|
});
|
42850
|
-
|
42851
|
-
request.
|
43102
|
+
request.gasLimit = txCost.gasUsed;
|
43103
|
+
request.maxFee = txCost.maxFee;
|
43104
|
+
await this.fund(request, txCost);
|
42852
43105
|
return request;
|
42853
43106
|
}
|
42854
43107
|
/**
|
@@ -42857,17 +43110,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42857
43110
|
* @param destination - The address of the destination.
|
42858
43111
|
* @param amount - The amount of coins to transfer.
|
42859
43112
|
* @param assetId - The asset ID of the coins to transfer.
|
42860
|
-
* @param txParams - The transaction parameters (gasLimit,
|
43113
|
+
* @param txParams - The transaction parameters (gasLimit, maturity).
|
42861
43114
|
* @returns A promise that resolves to the transaction response.
|
42862
43115
|
*/
|
42863
|
-
async transfer(destination, amount, assetId
|
43116
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42864
43117
|
if (bn(amount).lte(0)) {
|
42865
43118
|
throw new FuelError(
|
42866
43119
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42867
43120
|
"Transfer amount must be a positive number."
|
42868
43121
|
);
|
42869
43122
|
}
|
42870
|
-
const
|
43123
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
43124
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42871
43125
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42872
43126
|
}
|
42873
43127
|
/**
|
@@ -42879,7 +43133,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42879
43133
|
* @param txParams - The optional transaction parameters.
|
42880
43134
|
* @returns A promise that resolves to the transaction response.
|
42881
43135
|
*/
|
42882
|
-
async transferToContract(contractId, amount, assetId
|
43136
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42883
43137
|
if (bn(amount).lte(0)) {
|
42884
43138
|
throw new FuelError(
|
42885
43139
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42887,31 +43141,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42887
43141
|
);
|
42888
43142
|
}
|
42889
43143
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42890
|
-
const
|
42891
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
43144
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42892
43145
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42893
43146
|
hexlifiedContractId: contractAddress.toB256(),
|
42894
43147
|
amountToTransfer: bn(amount),
|
42895
|
-
assetId
|
43148
|
+
assetId: assetIdToTransfer
|
42896
43149
|
});
|
42897
43150
|
const request = new ScriptTransactionRequest({
|
42898
|
-
...
|
43151
|
+
...txParams,
|
42899
43152
|
script,
|
42900
43153
|
scriptData
|
42901
43154
|
});
|
42902
43155
|
request.addContractInputAndOutput(contractAddress);
|
42903
|
-
const
|
42904
|
-
|
42905
|
-
[{ amount: bn(amount), assetId: String(
|
42906
|
-
);
|
42907
|
-
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42908
|
-
this.validateGas({
|
42909
|
-
gasUsed,
|
42910
|
-
gasPrice: request.gasPrice,
|
42911
|
-
gasLimit: request.gasLimit,
|
42912
|
-
minGasPrice
|
43156
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
43157
|
+
resourcesOwner: this,
|
43158
|
+
quantitiesToContract: [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42913
43159
|
});
|
42914
|
-
|
43160
|
+
this.validateGasLimitAndMaxFee({
|
43161
|
+
gasUsed: txCost.gasUsed,
|
43162
|
+
maxFee: txCost.maxFee,
|
43163
|
+
txParams
|
43164
|
+
});
|
43165
|
+
request.gasLimit = txCost.gasUsed;
|
43166
|
+
request.maxFee = txCost.maxFee;
|
43167
|
+
await this.fund(request, txCost);
|
42915
43168
|
return this.sendTransaction(request);
|
42916
43169
|
}
|
42917
43170
|
/**
|
@@ -42923,7 +43176,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42923
43176
|
* @returns A promise that resolves to the transaction response.
|
42924
43177
|
*/
|
42925
43178
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42926
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42927
43179
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42928
43180
|
const recipientDataArray = arrayify(
|
42929
43181
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42936,21 +43188,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42936
43188
|
...recipientDataArray,
|
42937
43189
|
...amountDataArray
|
42938
43190
|
]);
|
42939
|
-
const params = { script,
|
43191
|
+
const params = { script, ...txParams };
|
43192
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42940
43193
|
const request = new ScriptTransactionRequest(params);
|
42941
|
-
const
|
42942
|
-
const
|
42943
|
-
|
42944
|
-
|
42945
|
-
|
42946
|
-
|
42947
|
-
this.validateGas({
|
42948
|
-
gasUsed,
|
42949
|
-
gasPrice: request.gasPrice,
|
42950
|
-
gasLimit: request.gasLimit,
|
42951
|
-
minGasPrice
|
43194
|
+
const quantitiesToContract = [{ amount: bn(amount), assetId: baseAssetId }];
|
43195
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
43196
|
+
this.validateGasLimitAndMaxFee({
|
43197
|
+
gasUsed: txCost.gasUsed,
|
43198
|
+
maxFee: txCost.maxFee,
|
43199
|
+
txParams
|
42952
43200
|
});
|
42953
|
-
|
43201
|
+
request.maxFee = txCost.maxFee;
|
43202
|
+
request.gasLimit = txCost.gasUsed;
|
43203
|
+
await this.fund(request, txCost);
|
42954
43204
|
return this.sendTransaction(request);
|
42955
43205
|
}
|
42956
43206
|
async signMessage(message) {
|
@@ -43008,22 +43258,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43008
43258
|
}
|
43009
43259
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43010
43260
|
}
|
43011
|
-
|
43261
|
+
validateGasLimitAndMaxFee({
|
43262
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
43012
43263
|
gasUsed,
|
43013
|
-
|
43014
|
-
gasLimit,
|
43015
|
-
minGasPrice
|
43264
|
+
maxFee
|
43016
43265
|
}) {
|
43017
|
-
if (
|
43266
|
+
if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
|
43018
43267
|
throw new FuelError(
|
43019
|
-
ErrorCode.
|
43020
|
-
`Gas
|
43268
|
+
ErrorCode.GAS_LIMIT_TOO_LOW,
|
43269
|
+
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
43021
43270
|
);
|
43022
43271
|
}
|
43023
|
-
if (
|
43272
|
+
if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
|
43024
43273
|
throw new FuelError(
|
43025
|
-
ErrorCode.
|
43026
|
-
`
|
43274
|
+
ErrorCode.MAX_FEE_TOO_LOW,
|
43275
|
+
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
43027
43276
|
);
|
43028
43277
|
}
|
43029
43278
|
}
|
@@ -44608,7 +44857,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44608
44857
|
* @param transactionRequestLike - The transaction request to send.
|
44609
44858
|
* @returns A promise that resolves to the TransactionResponse object.
|
44610
44859
|
*/
|
44611
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44860
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
44612
44861
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44613
44862
|
if (estimateTxDependencies) {
|
44614
44863
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -47886,34 +48135,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47886
48135
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47887
48136
|
request.inputs?.forEach((input) => {
|
47888
48137
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47889
|
-
input.predicate = this.bytes;
|
47890
|
-
input.predicateData = this.getPredicateData(policies.length);
|
48138
|
+
input.predicate = hexlify(this.bytes);
|
48139
|
+
input.predicateData = hexlify(this.getPredicateData(policies.length));
|
47891
48140
|
}
|
47892
48141
|
});
|
47893
48142
|
return request;
|
47894
48143
|
}
|
47895
|
-
/**
|
47896
|
-
* A helper that creates a transfer transaction request and returns it.
|
47897
|
-
*
|
47898
|
-
* @param destination - The address of the destination.
|
47899
|
-
* @param amount - The amount of coins to transfer.
|
47900
|
-
* @param assetId - The asset ID of the coins to transfer.
|
47901
|
-
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47902
|
-
* @returns A promise that resolves to the prepared transaction request.
|
47903
|
-
*/
|
47904
|
-
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47905
|
-
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47906
|
-
return this.populateTransactionPredicateData(request);
|
47907
|
-
}
|
47908
48144
|
/**
|
47909
48145
|
* Sends a transaction with the populated predicate data.
|
47910
48146
|
*
|
47911
48147
|
* @param transactionRequestLike - The transaction request-like object.
|
47912
48148
|
* @returns A promise that resolves to the transaction response.
|
47913
48149
|
*/
|
47914
|
-
sendTransaction(transactionRequestLike
|
47915
|
-
const transactionRequest =
|
47916
|
-
return super.sendTransaction(transactionRequest,
|
48150
|
+
sendTransaction(transactionRequestLike) {
|
48151
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48152
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
47917
48153
|
}
|
47918
48154
|
/**
|
47919
48155
|
* Simulates a transaction with the populated predicate data.
|
@@ -47922,8 +48158,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47922
48158
|
* @returns A promise that resolves to the call result.
|
47923
48159
|
*/
|
47924
48160
|
simulateTransaction(transactionRequestLike) {
|
47925
|
-
const transactionRequest =
|
47926
|
-
return super.simulateTransaction(transactionRequest);
|
48161
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48162
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
47927
48163
|
}
|
47928
48164
|
getPredicateData(policiesLength) {
|
47929
48165
|
if (!this.predicateData.length) {
|
@@ -47969,6 +48205,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47969
48205
|
predicateInterface: abiInterface
|
47970
48206
|
};
|
47971
48207
|
}
|
48208
|
+
/**
|
48209
|
+
* Retrieves resources satisfying the spend query for the account.
|
48210
|
+
*
|
48211
|
+
* @param quantities - IDs of coins to exclude.
|
48212
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
48213
|
+
* @returns A promise that resolves to an array of Resources.
|
48214
|
+
*/
|
48215
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
48216
|
+
const resources = await this.provider.getResourcesToSpend(
|
48217
|
+
this.address,
|
48218
|
+
quantities,
|
48219
|
+
excludedIds
|
48220
|
+
);
|
48221
|
+
return resources.map((resource) => ({
|
48222
|
+
...resource,
|
48223
|
+
predicate: hexlify(this.bytes),
|
48224
|
+
padPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48225
|
+
}));
|
48226
|
+
}
|
47972
48227
|
/**
|
47973
48228
|
* Sets the configurable constants for the predicate.
|
47974
48229
|
*
|