@fuel-ts/account 0.0.0-rc-2021-20240424175107 → 0.0.0-rc-2037-20240424175231
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 +1 -1
- package/dist/account.d.ts +6 -7
- 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 +622 -814
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +659 -837
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +478 -661
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +39 -12
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +359 -810
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +1 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -6
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -37
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +10 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.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 +11 -6
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- 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 +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- 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 +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +1 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +1089 -1533
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +624 -820
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +457 -656
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- 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 max2(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 clone(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(clone(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 ? clone(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,8 +28952,8 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
|
+
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.81.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29053,7 +29053,6 @@ 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";
|
29057
29056
|
ErrorCode2["TRANSACTION_NOT_FOUND"] = "transaction-not-found";
|
29058
29057
|
ErrorCode2["TRANSACTION_FAILED"] = "transaction-failed";
|
29059
29058
|
ErrorCode2["INVALID_CONFIGURABLE_CONSTANTS"] = "invalid-configurable-constants";
|
@@ -29244,9 +29243,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29244
29243
|
};
|
29245
29244
|
var DateTime = _DateTime;
|
29246
29245
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29247
|
-
function isDefined(value) {
|
29248
|
-
return value !== void 0;
|
29249
|
-
}
|
29250
29246
|
|
29251
29247
|
// ../crypto/dist/index.mjs
|
29252
29248
|
var import_crypto8 = __toESM(__require("crypto"), 1);
|
@@ -31499,182 +31495,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31499
31495
|
function toBytes3(value, bytesPadding) {
|
31500
31496
|
return bn(value).toBytes(bytesPadding);
|
31501
31497
|
}
|
31502
|
-
|
31503
|
-
|
31504
|
-
function _isPlaceholder(a) {
|
31505
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31506
|
-
}
|
31507
|
-
|
31508
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31509
|
-
function _curry1(fn) {
|
31510
|
-
return function f1(a) {
|
31511
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31512
|
-
return f1;
|
31513
|
-
} else {
|
31514
|
-
return fn.apply(this, arguments);
|
31515
|
-
}
|
31516
|
-
};
|
31517
|
-
}
|
31518
|
-
|
31519
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31520
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
31521
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31522
|
-
};
|
31523
|
-
|
31524
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31525
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31526
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31527
|
-
});
|
31528
|
-
var type_default = type;
|
31529
|
-
|
31530
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31531
|
-
var pad = function pad2(n) {
|
31532
|
-
return (n < 10 ? "0" : "") + n;
|
31533
|
-
};
|
31534
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31535
|
-
return d.toISOString();
|
31536
|
-
} : function _toISOString3(d) {
|
31537
|
-
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";
|
31538
|
-
};
|
31539
|
-
|
31540
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31541
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31542
|
-
return n << 0 === n;
|
31543
|
-
};
|
31544
|
-
|
31545
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31546
|
-
function _cloneRegExp(pattern) {
|
31547
|
-
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" : ""));
|
31548
|
-
}
|
31549
|
-
|
31550
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31551
|
-
function _clone(value, deep, map) {
|
31552
|
-
map || (map = new _ObjectMap());
|
31553
|
-
if (_isPrimitive(value)) {
|
31554
|
-
return value;
|
31555
|
-
}
|
31556
|
-
var copy = function copy2(copiedValue) {
|
31557
|
-
var cachedCopy = map.get(value);
|
31558
|
-
if (cachedCopy) {
|
31559
|
-
return cachedCopy;
|
31560
|
-
}
|
31561
|
-
map.set(value, copiedValue);
|
31562
|
-
for (var key in value) {
|
31563
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31564
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31565
|
-
}
|
31566
|
-
}
|
31567
|
-
return copiedValue;
|
31568
|
-
};
|
31569
|
-
switch (type_default(value)) {
|
31570
|
-
case "Object":
|
31571
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31572
|
-
case "Array":
|
31573
|
-
return copy([]);
|
31574
|
-
case "Date":
|
31575
|
-
return new Date(value.valueOf());
|
31576
|
-
case "RegExp":
|
31577
|
-
return _cloneRegExp(value);
|
31578
|
-
case "Int8Array":
|
31579
|
-
case "Uint8Array":
|
31580
|
-
case "Uint8ClampedArray":
|
31581
|
-
case "Int16Array":
|
31582
|
-
case "Uint16Array":
|
31583
|
-
case "Int32Array":
|
31584
|
-
case "Uint32Array":
|
31585
|
-
case "Float32Array":
|
31586
|
-
case "Float64Array":
|
31587
|
-
case "BigInt64Array":
|
31588
|
-
case "BigUint64Array":
|
31589
|
-
return value.slice();
|
31590
|
-
default:
|
31591
|
-
return value;
|
31592
|
-
}
|
31593
|
-
}
|
31594
|
-
function _isPrimitive(param) {
|
31595
|
-
var type3 = typeof param;
|
31596
|
-
return param == null || type3 != "object" && type3 != "function";
|
31498
|
+
function max(...numbers) {
|
31499
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31597
31500
|
}
|
31598
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
31599
|
-
function _ObjectMap2() {
|
31600
|
-
this.map = {};
|
31601
|
-
this.length = 0;
|
31602
|
-
}
|
31603
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
31604
|
-
const hashedKey = this.hash(key);
|
31605
|
-
let bucket = this.map[hashedKey];
|
31606
|
-
if (!bucket) {
|
31607
|
-
this.map[hashedKey] = bucket = [];
|
31608
|
-
}
|
31609
|
-
bucket.push([key, value]);
|
31610
|
-
this.length += 1;
|
31611
|
-
};
|
31612
|
-
_ObjectMap2.prototype.hash = function(key) {
|
31613
|
-
let hashedKey = [];
|
31614
|
-
for (var value in key) {
|
31615
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31616
|
-
}
|
31617
|
-
return hashedKey.join();
|
31618
|
-
};
|
31619
|
-
_ObjectMap2.prototype.get = function(key) {
|
31620
|
-
if (this.length <= 180) {
|
31621
|
-
for (const p in this.map) {
|
31622
|
-
const bucket2 = this.map[p];
|
31623
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
31624
|
-
const element = bucket2[i];
|
31625
|
-
if (element[0] === key) {
|
31626
|
-
return element[1];
|
31627
|
-
}
|
31628
|
-
}
|
31629
|
-
}
|
31630
|
-
return;
|
31631
|
-
}
|
31632
|
-
const hashedKey = this.hash(key);
|
31633
|
-
const bucket = this.map[hashedKey];
|
31634
|
-
if (!bucket) {
|
31635
|
-
return;
|
31636
|
-
}
|
31637
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
31638
|
-
const element = bucket[i];
|
31639
|
-
if (element[0] === key) {
|
31640
|
-
return element[1];
|
31641
|
-
}
|
31642
|
-
}
|
31643
|
-
};
|
31644
|
-
return _ObjectMap2;
|
31645
|
-
}();
|
31646
|
-
|
31647
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31648
|
-
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31649
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31650
|
-
});
|
31651
|
-
var clone_default = clone;
|
31652
|
-
|
31653
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31654
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31655
31501
|
|
31656
31502
|
// src/providers/coin-quantity.ts
|
31657
31503
|
var coinQuantityfy = (coinQuantityLike) => {
|
31658
31504
|
let assetId;
|
31659
31505
|
let amount;
|
31660
|
-
let
|
31506
|
+
let max2;
|
31661
31507
|
if (Array.isArray(coinQuantityLike)) {
|
31662
31508
|
amount = coinQuantityLike[0];
|
31663
31509
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31664
|
-
|
31510
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31665
31511
|
} else {
|
31666
31512
|
amount = coinQuantityLike.amount;
|
31667
31513
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31668
|
-
|
31514
|
+
max2 = coinQuantityLike.max ?? void 0;
|
31669
31515
|
}
|
31670
31516
|
const bnAmount = bn(amount);
|
31671
31517
|
return {
|
31672
31518
|
assetId: hexlify(assetId),
|
31673
31519
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31674
|
-
max:
|
31520
|
+
max: max2 ? bn(max2) : void 0
|
31675
31521
|
};
|
31676
31522
|
};
|
31677
|
-
var
|
31523
|
+
var addAmountToAsset = (params) => {
|
31678
31524
|
const { amount, assetId } = params;
|
31679
31525
|
const coinQuantities = [...params.coinQuantities];
|
31680
31526
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31759,7 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31759
31605
|
var ENCODING_V1 = "1";
|
31760
31606
|
var WORD_SIZE = 8;
|
31761
31607
|
var BYTES_32 = 32;
|
31762
|
-
var UTXO_ID_LEN = BYTES_32 +
|
31608
|
+
var UTXO_ID_LEN = BYTES_32 + 1;
|
31763
31609
|
var ASSET_ID_LEN = BYTES_32;
|
31764
31610
|
var ADDRESS_LEN = BYTES_32;
|
31765
31611
|
var NONCE_LEN = BYTES_32;
|
@@ -31767,9 +31613,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31767
31613
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31768
31614
|
var MAX_BYTES = 2 ** 32 - 1;
|
31769
31615
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31770
|
-
|
31616
|
+
WORD_SIZE + // Tx size
|
31771
31617
|
// Asset ID/Balance coin input pairs
|
31772
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE)
|
31618
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31773
31619
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31774
31620
|
WORD_SIZE + // Gas limit
|
31775
31621
|
WORD_SIZE + // Script size
|
@@ -31787,6 +31633,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31787
31633
|
ASSET_ID_LEN + // Asset id
|
31788
31634
|
TX_POINTER_LEN + // TxPointer
|
31789
31635
|
WORD_SIZE + // Witnesses index
|
31636
|
+
WORD_SIZE + // Maturity
|
31790
31637
|
WORD_SIZE + // Predicate size
|
31791
31638
|
WORD_SIZE + // Predicate data size
|
31792
31639
|
WORD_SIZE;
|
@@ -32108,7 +31955,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32108
31955
|
constructor(name, coders) {
|
32109
31956
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32110
31957
|
const encodedValueSize = Object.values(coders).reduce(
|
32111
|
-
(
|
31958
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32112
31959
|
0
|
32113
31960
|
);
|
32114
31961
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32826,7 +32673,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32826
32673
|
constructor(name, coders) {
|
32827
32674
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32828
32675
|
const encodedValueSize = Object.values(coders).reduce(
|
32829
|
-
(
|
32676
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32830
32677
|
0
|
32831
32678
|
);
|
32832
32679
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33540,19 +33387,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33540
33387
|
encode(value) {
|
33541
33388
|
const parts = [];
|
33542
33389
|
parts.push(new B256Coder().encode(value.txID));
|
33543
|
-
parts.push(new NumberCoder("
|
33390
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33544
33391
|
parts.push(new B256Coder().encode(value.owner));
|
33545
33392
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33546
33393
|
parts.push(new B256Coder().encode(value.assetId));
|
33547
33394
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33548
|
-
parts.push(new NumberCoder("
|
33395
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33396
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33549
33397
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33550
|
-
parts.push(new
|
33551
|
-
parts.push(new
|
33552
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33553
|
-
parts.push(
|
33554
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33555
|
-
);
|
33398
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33399
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33400
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33401
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33556
33402
|
return concat(parts);
|
33557
33403
|
}
|
33558
33404
|
decode(data, offset) {
|
@@ -33560,7 +33406,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33560
33406
|
let o = offset;
|
33561
33407
|
[decoded, o] = new B256Coder().decode(data, o);
|
33562
33408
|
const txID = decoded;
|
33563
|
-
[decoded, o] = new NumberCoder("
|
33409
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33564
33410
|
const outputIndex = decoded;
|
33565
33411
|
[decoded, o] = new B256Coder().decode(data, o);
|
33566
33412
|
const owner = decoded;
|
@@ -33570,17 +33416,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33570
33416
|
const assetId = decoded;
|
33571
33417
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33572
33418
|
const txPointer = decoded;
|
33573
|
-
[decoded, o] = new NumberCoder("
|
33419
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33574
33420
|
const witnessIndex = Number(decoded);
|
33421
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33422
|
+
const maturity = decoded;
|
33575
33423
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33576
33424
|
const predicateGasUsed = decoded;
|
33577
|
-
[decoded, o] = new
|
33425
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33578
33426
|
const predicateLength = decoded;
|
33579
|
-
[decoded, o] = new
|
33427
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33580
33428
|
const predicateDataLength = decoded;
|
33581
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33429
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33582
33430
|
const predicate = decoded;
|
33583
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33431
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33584
33432
|
const predicateData = decoded;
|
33585
33433
|
return [
|
33586
33434
|
{
|
@@ -33592,6 +33440,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33592
33440
|
assetId,
|
33593
33441
|
txPointer,
|
33594
33442
|
witnessIndex,
|
33443
|
+
maturity,
|
33595
33444
|
predicateGasUsed,
|
33596
33445
|
predicateLength,
|
33597
33446
|
predicateDataLength,
|
@@ -33609,7 +33458,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33609
33458
|
encode(value) {
|
33610
33459
|
const parts = [];
|
33611
33460
|
parts.push(new B256Coder().encode(value.txID));
|
33612
|
-
parts.push(new NumberCoder("
|
33461
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33613
33462
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33614
33463
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33615
33464
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33621,7 +33470,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33621
33470
|
let o = offset;
|
33622
33471
|
[decoded, o] = new B256Coder().decode(data, o);
|
33623
33472
|
const txID = decoded;
|
33624
|
-
[decoded, o] = new NumberCoder("
|
33473
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33625
33474
|
const outputIndex = decoded;
|
33626
33475
|
[decoded, o] = new B256Coder().decode(data, o);
|
33627
33476
|
const balanceRoot = decoded;
|
@@ -33670,16 +33519,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33670
33519
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33671
33520
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33672
33521
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33673
|
-
parts.push(new NumberCoder("
|
33522
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33674
33523
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33675
|
-
parts.push(new
|
33676
|
-
parts.push(new
|
33677
|
-
parts.push(new
|
33524
|
+
parts.push(new NumberCoder("u32").encode(data.length));
|
33525
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33526
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33678
33527
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33679
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33680
|
-
parts.push(
|
33681
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33682
|
-
);
|
33528
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33529
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33683
33530
|
return concat(parts);
|
33684
33531
|
}
|
33685
33532
|
static decodeData(messageData) {
|
@@ -33699,21 +33546,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33699
33546
|
const amount = decoded;
|
33700
33547
|
[decoded, o] = new B256Coder().decode(data, o);
|
33701
33548
|
const nonce = decoded;
|
33702
|
-
[decoded, o] = new NumberCoder("
|
33549
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33703
33550
|
const witnessIndex = Number(decoded);
|
33704
33551
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33705
33552
|
const predicateGasUsed = decoded;
|
33706
33553
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33707
33554
|
const dataLength2 = decoded;
|
33708
|
-
[decoded, o] = new
|
33555
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33709
33556
|
const predicateLength = decoded;
|
33710
|
-
[decoded, o] = new
|
33557
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33711
33558
|
const predicateDataLength = decoded;
|
33712
33559
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33713
33560
|
const messageData = decoded;
|
33714
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33561
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33715
33562
|
const predicate = decoded;
|
33716
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33563
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33717
33564
|
const predicateData = decoded;
|
33718
33565
|
return [
|
33719
33566
|
{
|
@@ -34025,7 +33872,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34025
33872
|
}
|
34026
33873
|
};
|
34027
33874
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
34028
|
-
PolicyType2[PolicyType2["
|
33875
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
34029
33876
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
34030
33877
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
34031
33878
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34073,9 +33920,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34073
33920
|
let o = offset;
|
34074
33921
|
const policies = [];
|
34075
33922
|
if (policyTypes & 1) {
|
34076
|
-
const [
|
33923
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34077
33924
|
o = nextOffset;
|
34078
|
-
policies.push({ type: 1, data:
|
33925
|
+
policies.push({ type: 1, data: gasPrice });
|
34079
33926
|
}
|
34080
33927
|
if (policyTypes & 2) {
|
34081
33928
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34307,15 +34154,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34307
34154
|
encode(value) {
|
34308
34155
|
const parts = [];
|
34309
34156
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34310
|
-
parts.push(new
|
34311
|
-
parts.push(new
|
34312
|
-
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34157
|
+
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34158
|
+
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34313
34159
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34314
|
-
parts.push(new NumberCoder("
|
34315
|
-
parts.push(new NumberCoder("
|
34316
|
-
parts.push(new NumberCoder("
|
34317
|
-
parts.push(new
|
34318
|
-
parts.push(new ByteArrayCoder(value.
|
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
|
+
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34164
|
+
parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
|
34165
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
|
34319
34166
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34320
34167
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34321
34168
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34327,23 +34174,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34327
34174
|
let o = offset;
|
34328
34175
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34329
34176
|
const scriptGasLimit = decoded;
|
34330
|
-
[decoded, o] = new
|
34331
|
-
const receiptsRoot = decoded;
|
34332
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34177
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34333
34178
|
const scriptLength = decoded;
|
34334
|
-
[decoded, o] = new
|
34179
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34335
34180
|
const scriptDataLength = decoded;
|
34336
34181
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34337
34182
|
const policyTypes = decoded;
|
34338
|
-
[decoded, o] = new NumberCoder("
|
34183
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34339
34184
|
const inputsCount = decoded;
|
34340
|
-
[decoded, o] = new NumberCoder("
|
34185
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34341
34186
|
const outputsCount = decoded;
|
34342
|
-
[decoded, o] = new NumberCoder("
|
34187
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34343
34188
|
const witnessesCount = decoded;
|
34344
|
-
[decoded, o] = new
|
34189
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34190
|
+
const receiptsRoot = decoded;
|
34191
|
+
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34345
34192
|
const script = decoded;
|
34346
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength
|
34193
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34347
34194
|
const scriptData = decoded;
|
34348
34195
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34349
34196
|
const policies = decoded;
|
@@ -34381,19 +34228,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34381
34228
|
}
|
34382
34229
|
encode(value) {
|
34383
34230
|
const parts = [];
|
34384
|
-
parts.push(new NumberCoder("
|
34385
|
-
parts.push(new
|
34386
|
-
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34231
|
+
parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
|
34232
|
+
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34387
34233
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34388
|
-
parts.push(new NumberCoder("u16").encode(value.
|
34389
|
-
parts.push(new NumberCoder("
|
34390
|
-
parts.push(new NumberCoder("
|
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));
|
34238
|
+
parts.push(new B256Coder().encode(value.salt));
|
34239
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34391
34240
|
parts.push(
|
34392
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount
|
34393
|
-
value.storageSlots
|
34394
|
-
)
|
34241
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
|
34395
34242
|
);
|
34396
|
-
parts.push(new PoliciesCoder().encode(value.policies));
|
34397
34243
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34398
34244
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34399
34245
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34402,27 +34248,26 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34402
34248
|
decode(data, offset) {
|
34403
34249
|
let decoded;
|
34404
34250
|
let o = offset;
|
34405
|
-
[decoded, o] = new NumberCoder("
|
34251
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34252
|
+
const bytecodeLength = decoded;
|
34253
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34406
34254
|
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;
|
34411
34255
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34412
34256
|
const policyTypes = decoded;
|
34413
34257
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34258
|
+
const storageSlotsCount = decoded;
|
34259
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34414
34260
|
const inputsCount = decoded;
|
34415
|
-
[decoded, o] = new NumberCoder("
|
34261
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34416
34262
|
const outputsCount = decoded;
|
34417
|
-
[decoded, o] = new NumberCoder("
|
34263
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34418
34264
|
const witnessesCount = decoded;
|
34419
|
-
[decoded, o] = new
|
34420
|
-
|
34421
|
-
o
|
34422
|
-
);
|
34423
|
-
const storageSlots = decoded;
|
34265
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34266
|
+
const salt = decoded;
|
34424
34267
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34425
34268
|
const policies = decoded;
|
34269
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34270
|
+
const storageSlots = decoded;
|
34426
34271
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34427
34272
|
const inputs = decoded;
|
34428
34273
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34432,6 +34277,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34432
34277
|
return [
|
34433
34278
|
{
|
34434
34279
|
type: 1,
|
34280
|
+
bytecodeLength,
|
34435
34281
|
bytecodeWitnessIndex,
|
34436
34282
|
policyTypes,
|
34437
34283
|
storageSlotsCount,
|
@@ -34460,7 +34306,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34460
34306
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34461
34307
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34462
34308
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34463
|
-
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34464
34309
|
return concat(parts);
|
34465
34310
|
}
|
34466
34311
|
decode(data, offset) {
|
@@ -34476,8 +34321,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34476
34321
|
const mintAmount = decoded;
|
34477
34322
|
[decoded, o] = new B256Coder().decode(data, o);
|
34478
34323
|
const mintAssetId = decoded;
|
34479
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34480
|
-
const gasPrice = decoded;
|
34481
34324
|
return [
|
34482
34325
|
{
|
34483
34326
|
type: 2,
|
@@ -34485,8 +34328,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34485
34328
|
inputContract,
|
34486
34329
|
outputContract,
|
34487
34330
|
mintAmount,
|
34488
|
-
mintAssetId
|
34489
|
-
gasPrice
|
34331
|
+
mintAssetId
|
34490
34332
|
},
|
34491
34333
|
o
|
34492
34334
|
];
|
@@ -34793,6 +34635,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34793
34635
|
// src/providers/provider.ts
|
34794
34636
|
var import_graphql_request = __toESM(require_dist2());
|
34795
34637
|
|
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
|
+
|
34796
34791
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34797
34792
|
var __assign = function() {
|
34798
34793
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37958,20 +37953,16 @@ spurious results.`);
|
|
37958
37953
|
var lib_default2 = gql;
|
37959
37954
|
|
37960
37955
|
// 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
|
-
`;
|
37969
37956
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37970
37957
|
fragment receiptFragment on Receipt {
|
37971
|
-
|
37958
|
+
contract {
|
37959
|
+
id
|
37960
|
+
}
|
37972
37961
|
pc
|
37973
37962
|
is
|
37974
|
-
to
|
37963
|
+
to {
|
37964
|
+
id
|
37965
|
+
}
|
37975
37966
|
toAddress
|
37976
37967
|
amount
|
37977
37968
|
assetId
|
@@ -38009,16 +38000,10 @@ spurious results.`);
|
|
38009
38000
|
id
|
38010
38001
|
}
|
38011
38002
|
time
|
38012
|
-
receipts {
|
38013
|
-
...receiptFragment
|
38014
|
-
}
|
38015
38003
|
programState {
|
38016
38004
|
returnType
|
38017
38005
|
data
|
38018
38006
|
}
|
38019
|
-
receipts {
|
38020
|
-
...receiptFragment
|
38021
|
-
}
|
38022
38007
|
}
|
38023
38008
|
... on FailureStatus {
|
38024
38009
|
block {
|
@@ -38026,24 +38011,26 @@ spurious results.`);
|
|
38026
38011
|
}
|
38027
38012
|
time
|
38028
38013
|
reason
|
38029
|
-
receipts {
|
38030
|
-
...receiptFragment
|
38031
|
-
}
|
38032
38014
|
}
|
38033
38015
|
... on SqueezedOutStatus {
|
38034
38016
|
reason
|
38035
38017
|
}
|
38036
38018
|
}
|
38037
|
-
|
38019
|
+
`;
|
38038
38020
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38039
38021
|
fragment transactionFragment on Transaction {
|
38040
38022
|
id
|
38041
38023
|
rawPayload
|
38024
|
+
gasPrice
|
38025
|
+
receipts {
|
38026
|
+
...receiptFragment
|
38027
|
+
}
|
38042
38028
|
status {
|
38043
38029
|
...transactionStatusFragment
|
38044
38030
|
}
|
38045
38031
|
}
|
38046
|
-
${
|
38032
|
+
${ReceiptFragmentFragmentDoc}
|
38033
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38047
38034
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38048
38035
|
fragment inputEstimatePredicatesFragment on Input {
|
38049
38036
|
... on InputCoin {
|
@@ -38061,46 +38048,6 @@ spurious results.`);
|
|
38061
38048
|
}
|
38062
38049
|
}
|
38063
38050
|
${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}`;
|
38104
38051
|
var CoinFragmentFragmentDoc = lib_default2`
|
38105
38052
|
fragment coinFragment on Coin {
|
38106
38053
|
__typename
|
@@ -38108,6 +38055,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38108
38055
|
owner
|
38109
38056
|
amount
|
38110
38057
|
assetId
|
38058
|
+
maturity
|
38111
38059
|
blockCreated
|
38112
38060
|
txCreatedIdx
|
38113
38061
|
}
|
@@ -38146,32 +38094,26 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38146
38094
|
messageBlockHeader {
|
38147
38095
|
id
|
38148
38096
|
daHeight
|
38149
|
-
consensusParametersVersion
|
38150
|
-
stateTransitionBytecodeVersion
|
38151
38097
|
transactionsCount
|
38152
|
-
messageReceiptCount
|
38153
38098
|
transactionsRoot
|
38154
|
-
messageOutboxRoot
|
38155
|
-
eventInboxRoot
|
38156
38099
|
height
|
38157
38100
|
prevRoot
|
38158
38101
|
time
|
38159
38102
|
applicationHash
|
38103
|
+
messageReceiptRoot
|
38104
|
+
messageReceiptCount
|
38160
38105
|
}
|
38161
38106
|
commitBlockHeader {
|
38162
38107
|
id
|
38163
38108
|
daHeight
|
38164
|
-
consensusParametersVersion
|
38165
|
-
stateTransitionBytecodeVersion
|
38166
38109
|
transactionsCount
|
38167
|
-
messageReceiptCount
|
38168
38110
|
transactionsRoot
|
38169
|
-
messageOutboxRoot
|
38170
|
-
eventInboxRoot
|
38171
38111
|
height
|
38172
38112
|
prevRoot
|
38173
38113
|
time
|
38174
38114
|
applicationHash
|
38115
|
+
messageReceiptRoot
|
38116
|
+
messageReceiptCount
|
38175
38117
|
}
|
38176
38118
|
sender
|
38177
38119
|
recipient
|
@@ -38190,8 +38132,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38190
38132
|
var BlockFragmentFragmentDoc = lib_default2`
|
38191
38133
|
fragment blockFragment on Block {
|
38192
38134
|
id
|
38193
|
-
height
|
38194
38135
|
header {
|
38136
|
+
height
|
38195
38137
|
time
|
38196
38138
|
}
|
38197
38139
|
transactions {
|
@@ -38201,7 +38143,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38201
38143
|
`;
|
38202
38144
|
var TxParametersFragmentFragmentDoc = lib_default2`
|
38203
38145
|
fragment TxParametersFragment on TxParameters {
|
38204
|
-
version
|
38205
38146
|
maxInputs
|
38206
38147
|
maxOutputs
|
38207
38148
|
maxWitnesses
|
@@ -38211,7 +38152,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38211
38152
|
`;
|
38212
38153
|
var PredicateParametersFragmentFragmentDoc = lib_default2`
|
38213
38154
|
fragment PredicateParametersFragment on PredicateParameters {
|
38214
|
-
version
|
38215
38155
|
maxPredicateLength
|
38216
38156
|
maxPredicateDataLength
|
38217
38157
|
maxGasPerPredicate
|
@@ -38220,21 +38160,18 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38220
38160
|
`;
|
38221
38161
|
var ScriptParametersFragmentFragmentDoc = lib_default2`
|
38222
38162
|
fragment ScriptParametersFragment on ScriptParameters {
|
38223
|
-
version
|
38224
38163
|
maxScriptLength
|
38225
38164
|
maxScriptDataLength
|
38226
38165
|
}
|
38227
38166
|
`;
|
38228
38167
|
var ContractParametersFragmentFragmentDoc = lib_default2`
|
38229
38168
|
fragment ContractParametersFragment on ContractParameters {
|
38230
|
-
version
|
38231
38169
|
contractMaxSize
|
38232
38170
|
maxStorageSlots
|
38233
38171
|
}
|
38234
38172
|
`;
|
38235
38173
|
var FeeParametersFragmentFragmentDoc = lib_default2`
|
38236
38174
|
fragment FeeParametersFragment on FeeParameters {
|
38237
|
-
version
|
38238
38175
|
gasPriceFactor
|
38239
38176
|
gasPerByte
|
38240
38177
|
}
|
@@ -38254,7 +38191,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38254
38191
|
`;
|
38255
38192
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38256
38193
|
fragment GasCostsFragment on GasCosts {
|
38257
|
-
version
|
38258
38194
|
add
|
38259
38195
|
addi
|
38260
38196
|
aloc
|
@@ -38267,6 +38203,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38267
38203
|
cb
|
38268
38204
|
cfei
|
38269
38205
|
cfsi
|
38206
|
+
croo
|
38270
38207
|
div
|
38271
38208
|
divi
|
38272
38209
|
ecr1
|
@@ -38349,9 +38286,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38349
38286
|
ccp {
|
38350
38287
|
...DependentCostFragment
|
38351
38288
|
}
|
38352
|
-
croo {
|
38353
|
-
...DependentCostFragment
|
38354
|
-
}
|
38355
38289
|
csiz {
|
38356
38290
|
...DependentCostFragment
|
38357
38291
|
}
|
@@ -38411,7 +38345,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38411
38345
|
${DependentCostFragmentFragmentDoc}`;
|
38412
38346
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38413
38347
|
fragment consensusParametersFragment on ConsensusParameters {
|
38414
|
-
version
|
38415
38348
|
txParams {
|
38416
38349
|
...TxParametersFragment
|
38417
38350
|
}
|
@@ -38471,9 +38404,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38471
38404
|
fragment nodeInfoFragment on NodeInfo {
|
38472
38405
|
utxoValidation
|
38473
38406
|
vmBacktrace
|
38407
|
+
minGasPrice
|
38474
38408
|
maxTx
|
38475
38409
|
maxDepth
|
38476
38410
|
nodeVersion
|
38411
|
+
peers {
|
38412
|
+
id
|
38413
|
+
addresses
|
38414
|
+
clientVersion
|
38415
|
+
blockHeight
|
38416
|
+
lastHeartbeatMs
|
38417
|
+
appScore
|
38418
|
+
}
|
38477
38419
|
}
|
38478
38420
|
`;
|
38479
38421
|
var GetVersionDocument = lib_default2`
|
@@ -38508,9 +38450,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38508
38450
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38509
38451
|
transaction(id: $transactionId) {
|
38510
38452
|
...transactionFragment
|
38453
|
+
receipts {
|
38454
|
+
...receiptFragment
|
38455
|
+
}
|
38511
38456
|
}
|
38512
38457
|
}
|
38513
|
-
${TransactionFragmentFragmentDoc}
|
38458
|
+
${TransactionFragmentFragmentDoc}
|
38459
|
+
${ReceiptFragmentFragmentDoc}`;
|
38514
38460
|
var GetTransactionsDocument = lib_default2`
|
38515
38461
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38516
38462
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38638,20 +38584,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38638
38584
|
}
|
38639
38585
|
}
|
38640
38586
|
${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
|
-
`;
|
38655
38587
|
var GetBalancesDocument = lib_default2`
|
38656
38588
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38657
38589
|
balances(
|
@@ -38706,12 +38638,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38706
38638
|
}
|
38707
38639
|
`;
|
38708
38640
|
var DryRunDocument = lib_default2`
|
38709
|
-
mutation dryRun($
|
38710
|
-
dryRun(
|
38711
|
-
...
|
38641
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38642
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38643
|
+
...receiptFragment
|
38712
38644
|
}
|
38713
38645
|
}
|
38714
|
-
${
|
38646
|
+
${ReceiptFragmentFragmentDoc}`;
|
38715
38647
|
var SubmitDocument = lib_default2`
|
38716
38648
|
mutation submit($encodedTransaction: HexString!) {
|
38717
38649
|
submit(tx: $encodedTransaction) {
|
@@ -38730,17 +38662,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38730
38662
|
var SubmitAndAwaitDocument = lib_default2`
|
38731
38663
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
38732
38664
|
submitAndAwait(tx: $encodedTransaction) {
|
38733
|
-
...
|
38665
|
+
...transactionStatusFragment
|
38734
38666
|
}
|
38735
38667
|
}
|
38736
|
-
${
|
38668
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38737
38669
|
var StatusChangeDocument = lib_default2`
|
38738
38670
|
subscription statusChange($transactionId: TransactionId!) {
|
38739
38671
|
statusChange(id: $transactionId) {
|
38740
|
-
...
|
38672
|
+
...transactionStatusFragment
|
38741
38673
|
}
|
38742
38674
|
}
|
38743
|
-
${
|
38675
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38744
38676
|
function getSdk(requester) {
|
38745
38677
|
return {
|
38746
38678
|
getVersion(variables, options) {
|
@@ -38794,12 +38726,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38794
38726
|
getBalance(variables, options) {
|
38795
38727
|
return requester(GetBalanceDocument, variables, options);
|
38796
38728
|
},
|
38797
|
-
getLatestGasPrice(variables, options) {
|
38798
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38799
|
-
},
|
38800
|
-
estimateGasPrice(variables, options) {
|
38801
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38802
|
-
},
|
38803
38729
|
getBalances(variables, options) {
|
38804
38730
|
return requester(GetBalancesDocument, variables, options);
|
38805
38731
|
},
|
@@ -38983,9 +38909,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38983
38909
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38984
38910
|
},
|
38985
38911
|
witnessIndex: value.witnessIndex,
|
38912
|
+
maturity: value.maturity ?? 0,
|
38986
38913
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38987
|
-
predicateLength:
|
38988
|
-
predicateDataLength:
|
38914
|
+
predicateLength: predicate.length,
|
38915
|
+
predicateDataLength: predicateData.length,
|
38989
38916
|
predicate: hexlify(predicate),
|
38990
38917
|
predicateData: hexlify(predicateData)
|
38991
38918
|
};
|
@@ -39016,8 +38943,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39016
38943
|
nonce: hexlify(value.nonce),
|
39017
38944
|
witnessIndex: value.witnessIndex,
|
39018
38945
|
predicateGasUsed: bn(value.predicateGasUsed),
|
39019
|
-
predicateLength:
|
39020
|
-
predicateDataLength:
|
38946
|
+
predicateLength: predicate.length,
|
38947
|
+
predicateDataLength: predicateData.length,
|
39021
38948
|
predicate: hexlify(predicate),
|
39022
38949
|
predicateData: hexlify(predicateData),
|
39023
38950
|
data: hexlify(data),
|
@@ -39177,8 +39104,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39177
39104
|
case "CALL" /* Call */: {
|
39178
39105
|
const callReceipt = {
|
39179
39106
|
type: ReceiptType.Call,
|
39180
|
-
from: hexOrZero(receipt.id
|
39181
|
-
to: hexOrZero(receipt?.to),
|
39107
|
+
from: hexOrZero(receipt.contract?.id),
|
39108
|
+
to: hexOrZero(receipt?.to?.id),
|
39182
39109
|
amount: bn(receipt.amount),
|
39183
39110
|
assetId: hexOrZero(receipt.assetId),
|
39184
39111
|
gas: bn(receipt.gas),
|
@@ -39192,7 +39119,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39192
39119
|
case "RETURN" /* Return */: {
|
39193
39120
|
const returnReceipt = {
|
39194
39121
|
type: ReceiptType.Return,
|
39195
|
-
id: hexOrZero(receipt.id
|
39122
|
+
id: hexOrZero(receipt.contract?.id),
|
39196
39123
|
val: bn(receipt.val),
|
39197
39124
|
pc: bn(receipt.pc),
|
39198
39125
|
is: bn(receipt.is)
|
@@ -39202,7 +39129,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39202
39129
|
case "RETURN_DATA" /* ReturnData */: {
|
39203
39130
|
const returnDataReceipt = {
|
39204
39131
|
type: ReceiptType.ReturnData,
|
39205
|
-
id: hexOrZero(receipt.id
|
39132
|
+
id: hexOrZero(receipt.contract?.id),
|
39206
39133
|
ptr: bn(receipt.ptr),
|
39207
39134
|
len: bn(receipt.len),
|
39208
39135
|
digest: hexOrZero(receipt.digest),
|
@@ -39214,7 +39141,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39214
39141
|
case "PANIC" /* Panic */: {
|
39215
39142
|
const panicReceipt = {
|
39216
39143
|
type: ReceiptType.Panic,
|
39217
|
-
id: hexOrZero(receipt.id),
|
39144
|
+
id: hexOrZero(receipt.contract?.id),
|
39218
39145
|
reason: bn(receipt.reason),
|
39219
39146
|
pc: bn(receipt.pc),
|
39220
39147
|
is: bn(receipt.is),
|
@@ -39225,7 +39152,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39225
39152
|
case "REVERT" /* Revert */: {
|
39226
39153
|
const revertReceipt = {
|
39227
39154
|
type: ReceiptType.Revert,
|
39228
|
-
id: hexOrZero(receipt.id
|
39155
|
+
id: hexOrZero(receipt.contract?.id),
|
39229
39156
|
val: bn(receipt.ra),
|
39230
39157
|
pc: bn(receipt.pc),
|
39231
39158
|
is: bn(receipt.is)
|
@@ -39235,7 +39162,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39235
39162
|
case "LOG" /* Log */: {
|
39236
39163
|
const logReceipt = {
|
39237
39164
|
type: ReceiptType.Log,
|
39238
|
-
id: hexOrZero(receipt.id
|
39165
|
+
id: hexOrZero(receipt.contract?.id),
|
39239
39166
|
val0: bn(receipt.ra),
|
39240
39167
|
val1: bn(receipt.rb),
|
39241
39168
|
val2: bn(receipt.rc),
|
@@ -39248,7 +39175,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39248
39175
|
case "LOG_DATA" /* LogData */: {
|
39249
39176
|
const logDataReceipt = {
|
39250
39177
|
type: ReceiptType.LogData,
|
39251
|
-
id: hexOrZero(receipt.id
|
39178
|
+
id: hexOrZero(receipt.contract?.id),
|
39252
39179
|
val0: bn(receipt.ra),
|
39253
39180
|
val1: bn(receipt.rb),
|
39254
39181
|
ptr: bn(receipt.ptr),
|
@@ -39262,8 +39189,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39262
39189
|
case "TRANSFER" /* Transfer */: {
|
39263
39190
|
const transferReceipt = {
|
39264
39191
|
type: ReceiptType.Transfer,
|
39265
|
-
from: hexOrZero(receipt.id
|
39266
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39192
|
+
from: hexOrZero(receipt.contract?.id),
|
39193
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39267
39194
|
amount: bn(receipt.amount),
|
39268
39195
|
assetId: hexOrZero(receipt.assetId),
|
39269
39196
|
pc: bn(receipt.pc),
|
@@ -39274,8 +39201,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39274
39201
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39275
39202
|
const transferOutReceipt = {
|
39276
39203
|
type: ReceiptType.TransferOut,
|
39277
|
-
from: hexOrZero(receipt.id
|
39278
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39204
|
+
from: hexOrZero(receipt.contract?.id),
|
39205
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39279
39206
|
amount: bn(receipt.amount),
|
39280
39207
|
assetId: hexOrZero(receipt.assetId),
|
39281
39208
|
pc: bn(receipt.pc),
|
@@ -39318,7 +39245,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39318
39245
|
return receiptMessageOut;
|
39319
39246
|
}
|
39320
39247
|
case "MINT" /* Mint */: {
|
39321
|
-
const contractId = hexOrZero(receipt.id
|
39248
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39322
39249
|
const subId = hexOrZero(receipt.subId);
|
39323
39250
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39324
39251
|
const mintReceipt = {
|
@@ -39333,7 +39260,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39333
39260
|
return mintReceipt;
|
39334
39261
|
}
|
39335
39262
|
case "BURN" /* Burn */: {
|
39336
|
-
const contractId = hexOrZero(receipt.id
|
39263
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39337
39264
|
const subId = hexOrZero(receipt.subId);
|
39338
39265
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39339
39266
|
const burnReceipt = {
|
@@ -39414,6 +39341,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39414
39341
|
};
|
39415
39342
|
|
39416
39343
|
// src/providers/utils/gas.ts
|
39344
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39417
39345
|
var getGasUsedFromReceipts = (receipts) => {
|
39418
39346
|
const scriptResult = receipts.filter(
|
39419
39347
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39434,28 +39362,18 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39434
39362
|
}
|
39435
39363
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39436
39364
|
const witnessCache = [];
|
39437
|
-
const
|
39438
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39439
|
-
if (isCoinOrMessage) {
|
39440
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39441
|
-
return true;
|
39442
|
-
}
|
39443
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39444
|
-
witnessCache.push(input.witnessIndex);
|
39445
|
-
return true;
|
39446
|
-
}
|
39447
|
-
}
|
39448
|
-
return false;
|
39449
|
-
});
|
39450
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39451
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39365
|
+
const totalGas = inputs.reduce((total, input) => {
|
39452
39366
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39453
39367
|
return total.add(
|
39454
|
-
|
39368
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39455
39369
|
);
|
39456
39370
|
}
|
39457
|
-
|
39458
|
-
|
39371
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39372
|
+
witnessCache.push(input.witnessIndex);
|
39373
|
+
return total.add(gasCosts.ecr1);
|
39374
|
+
}
|
39375
|
+
return total;
|
39376
|
+
}, bn());
|
39459
39377
|
return totalGas;
|
39460
39378
|
}
|
39461
39379
|
function getMinGas(params) {
|
@@ -39467,20 +39385,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39467
39385
|
return minGas;
|
39468
39386
|
}
|
39469
39387
|
function getMaxGas(params) {
|
39470
|
-
const {
|
39471
|
-
gasPerByte,
|
39472
|
-
witnessesLength,
|
39473
|
-
witnessLimit,
|
39474
|
-
minGas,
|
39475
|
-
gasLimit = bn(0),
|
39476
|
-
maxGasPerTx
|
39477
|
-
} = params;
|
39388
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39478
39389
|
let remainingAllowedWitnessGas = bn(0);
|
39479
39390
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39480
39391
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39481
39392
|
}
|
39482
|
-
|
39483
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39393
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39484
39394
|
}
|
39485
39395
|
function calculateMetadataGasForTxCreate({
|
39486
39396
|
gasCosts,
|
@@ -39502,10 +39412,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39502
39412
|
}) {
|
39503
39413
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39504
39414
|
}
|
39505
|
-
var calculateGasFee = (params) => {
|
39506
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39507
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39508
|
-
};
|
39509
39415
|
|
39510
39416
|
// src/providers/utils/json.ts
|
39511
39417
|
function normalize2(object) {
|
@@ -39635,6 +39541,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39635
39541
|
name = "NoWitnessByOwnerError";
|
39636
39542
|
};
|
39637
39543
|
|
39544
|
+
// src/providers/transaction-request/helpers.ts
|
39545
|
+
var isRequestInputCoin = (input) => input.type === InputType.Coin;
|
39546
|
+
var isRequestInputMessage = (input) => input.type === InputType.Message;
|
39547
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
39548
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
39549
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
39550
|
+
var cacheResources = (resources) => resources.reduce(
|
39551
|
+
(cache2, resource) => {
|
39552
|
+
if (isCoin(resource)) {
|
39553
|
+
cache2.utxos.push(resource.id);
|
39554
|
+
} else {
|
39555
|
+
cache2.messages.push(resource.nonce);
|
39556
|
+
}
|
39557
|
+
return cache2;
|
39558
|
+
},
|
39559
|
+
{
|
39560
|
+
utxos: [],
|
39561
|
+
messages: []
|
39562
|
+
}
|
39563
|
+
);
|
39564
|
+
|
39638
39565
|
// src/providers/transaction-request/witness.ts
|
39639
39566
|
var witnessify = (value) => {
|
39640
39567
|
const data = arrayify(value);
|
@@ -39647,7 +39574,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39647
39574
|
// src/providers/transaction-request/transaction-request.ts
|
39648
39575
|
var BaseTransactionRequest = class {
|
39649
39576
|
/** Gas price for transaction */
|
39650
|
-
|
39577
|
+
gasPrice;
|
39651
39578
|
/** Block until which tx cannot be included */
|
39652
39579
|
maturity;
|
39653
39580
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39666,7 +39593,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39666
39593
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39667
39594
|
*/
|
39668
39595
|
constructor({
|
39669
|
-
|
39596
|
+
gasPrice,
|
39670
39597
|
maturity,
|
39671
39598
|
maxFee,
|
39672
39599
|
witnessLimit,
|
@@ -39674,7 +39601,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39674
39601
|
outputs,
|
39675
39602
|
witnesses
|
39676
39603
|
} = {}) {
|
39677
|
-
this.
|
39604
|
+
this.gasPrice = bn(gasPrice);
|
39678
39605
|
this.maturity = maturity ?? 0;
|
39679
39606
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39680
39607
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -39685,9 +39612,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39685
39612
|
static getPolicyMeta(req) {
|
39686
39613
|
let policyTypes = 0;
|
39687
39614
|
const policies = [];
|
39688
|
-
if (req.
|
39689
|
-
policyTypes += PolicyType.
|
39690
|
-
policies.push({ data: req.
|
39615
|
+
if (req.gasPrice) {
|
39616
|
+
policyTypes += PolicyType.GasPrice;
|
39617
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39691
39618
|
}
|
39692
39619
|
if (req.witnessLimit) {
|
39693
39620
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39871,11 +39798,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39871
39798
|
* assetId, if one it was not added yet.
|
39872
39799
|
*
|
39873
39800
|
* @param coin - Coin resource.
|
39801
|
+
* @param predicate - Predicate bytes.
|
39802
|
+
* @param predicateData - Predicate data bytes.
|
39874
39803
|
*/
|
39875
39804
|
addCoinInput(coin) {
|
39876
|
-
const { assetId, owner, amount } = coin;
|
39805
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
39877
39806
|
let witnessIndex;
|
39878
|
-
if (
|
39807
|
+
if (predicate) {
|
39879
39808
|
witnessIndex = 0;
|
39880
39809
|
} else {
|
39881
39810
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39884,13 +39813,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39884
39813
|
}
|
39885
39814
|
}
|
39886
39815
|
const input = {
|
39887
|
-
|
39816
|
+
id,
|
39888
39817
|
type: InputType.Coin,
|
39889
39818
|
owner: owner.toB256(),
|
39890
39819
|
amount,
|
39891
39820
|
assetId,
|
39892
39821
|
txPointer: "0x00000000000000000000000000000000",
|
39893
|
-
witnessIndex
|
39822
|
+
witnessIndex,
|
39823
|
+
predicate
|
39894
39824
|
};
|
39895
39825
|
this.pushInput(input);
|
39896
39826
|
this.addChangeOutput(owner, assetId);
|
@@ -39900,12 +39830,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39900
39830
|
* baseAssetId, if one it was not added yet.
|
39901
39831
|
*
|
39902
39832
|
* @param message - Message resource.
|
39833
|
+
* @param predicate - Predicate bytes.
|
39834
|
+
* @param predicateData - Predicate data bytes.
|
39903
39835
|
*/
|
39904
39836
|
addMessageInput(message) {
|
39905
|
-
const { recipient, sender, amount } = message;
|
39837
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
39906
39838
|
const assetId = BaseAssetId;
|
39907
39839
|
let witnessIndex;
|
39908
|
-
if (
|
39840
|
+
if (predicate) {
|
39909
39841
|
witnessIndex = 0;
|
39910
39842
|
} else {
|
39911
39843
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39914,12 +39846,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39914
39846
|
}
|
39915
39847
|
}
|
39916
39848
|
const input = {
|
39917
|
-
|
39849
|
+
nonce,
|
39918
39850
|
type: InputType.Message,
|
39919
39851
|
sender: sender.toB256(),
|
39920
39852
|
recipient: recipient.toB256(),
|
39921
39853
|
amount,
|
39922
|
-
witnessIndex
|
39854
|
+
witnessIndex,
|
39855
|
+
predicate
|
39923
39856
|
};
|
39924
39857
|
this.pushInput(input);
|
39925
39858
|
this.addChangeOutput(recipient, assetId);
|
@@ -40029,7 +39962,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40029
39962
|
}
|
40030
39963
|
calculateMaxGas(chainInfo, minGas) {
|
40031
39964
|
const { consensusParameters } = chainInfo;
|
40032
|
-
const { gasPerByte
|
39965
|
+
const { gasPerByte } = consensusParameters;
|
40033
39966
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40034
39967
|
(acc, wit) => acc + wit.dataLength,
|
40035
39968
|
0
|
@@ -40038,8 +39971,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40038
39971
|
gasPerByte,
|
40039
39972
|
minGas,
|
40040
39973
|
witnessesLength,
|
40041
|
-
witnessLimit: this.witnessLimit
|
40042
|
-
maxGasPerTx
|
39974
|
+
witnessLimit: this.witnessLimit
|
40043
39975
|
});
|
40044
39976
|
}
|
40045
39977
|
/**
|
@@ -40057,20 +39989,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40057
39989
|
});
|
40058
39990
|
const updateAssetInput = (assetId, quantity) => {
|
40059
39991
|
const assetInput = findAssetInput(assetId);
|
40060
|
-
let usedQuantity = quantity;
|
40061
|
-
if (assetId === BaseAssetId) {
|
40062
|
-
usedQuantity = bn("1000000000000000000");
|
40063
|
-
}
|
40064
39992
|
if (assetInput && "assetId" in assetInput) {
|
40065
39993
|
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
40066
|
-
assetInput.amount =
|
39994
|
+
assetInput.amount = quantity;
|
40067
39995
|
} else {
|
40068
39996
|
this.addResources([
|
40069
39997
|
{
|
40070
39998
|
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
40071
|
-
amount:
|
39999
|
+
amount: quantity,
|
40072
40000
|
assetId,
|
40073
40001
|
owner: resourcesOwner || Address.fromRandom(),
|
40002
|
+
maturity: 0,
|
40074
40003
|
blockCreated: bn(1),
|
40075
40004
|
txCreatedIdx: bn(1)
|
40076
40005
|
}
|
@@ -40102,7 +40031,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40102
40031
|
toJSON() {
|
40103
40032
|
return normalizeJSON(this);
|
40104
40033
|
}
|
40105
|
-
|
40034
|
+
removeWitness(index) {
|
40035
|
+
this.witnesses.splice(index, 1);
|
40036
|
+
this.adjustWitnessIndexes(index);
|
40037
|
+
}
|
40038
|
+
updatePredicateInputs(inputs) {
|
40106
40039
|
this.inputs.forEach((i) => {
|
40107
40040
|
let correspondingInput;
|
40108
40041
|
switch (i.type) {
|
@@ -40124,12 +40057,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40124
40057
|
}
|
40125
40058
|
});
|
40126
40059
|
}
|
40127
|
-
|
40128
|
-
this.inputs.forEach((input) => {
|
40129
|
-
if (
|
40130
|
-
input.
|
40131
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40132
|
-
);
|
40060
|
+
adjustWitnessIndexes(removedIndex) {
|
40061
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
40062
|
+
if (input.witnessIndex > removedIndex) {
|
40063
|
+
input.witnessIndex -= 1;
|
40133
40064
|
}
|
40134
40065
|
});
|
40135
40066
|
}
|
@@ -40266,8 +40197,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40266
40197
|
return {
|
40267
40198
|
type: TransactionType.Create,
|
40268
40199
|
...baseTransaction,
|
40200
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40269
40201
|
bytecodeWitnessIndex,
|
40270
|
-
storageSlotsCount:
|
40202
|
+
storageSlotsCount: storageSlots.length,
|
40271
40203
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40272
40204
|
storageSlots
|
40273
40205
|
};
|
@@ -40381,8 +40313,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40381
40313
|
type: TransactionType.Script,
|
40382
40314
|
scriptGasLimit: this.gasLimit,
|
40383
40315
|
...super.getBaseTransaction(),
|
40384
|
-
scriptLength:
|
40385
|
-
scriptDataLength:
|
40316
|
+
scriptLength: script.length,
|
40317
|
+
scriptDataLength: scriptData.length,
|
40386
40318
|
receiptsRoot: ZeroBytes32,
|
40387
40319
|
script: hexlify(script),
|
40388
40320
|
scriptData: hexlify(scriptData)
|
@@ -40446,7 +40378,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40446
40378
|
}
|
40447
40379
|
calculateMaxGas(chainInfo, minGas) {
|
40448
40380
|
const { consensusParameters } = chainInfo;
|
40449
|
-
const { gasPerByte
|
40381
|
+
const { gasPerByte } = consensusParameters;
|
40450
40382
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40451
40383
|
(acc, wit) => acc + wit.dataLength,
|
40452
40384
|
0
|
@@ -40456,8 +40388,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40456
40388
|
minGas,
|
40457
40389
|
witnessesLength,
|
40458
40390
|
witnessLimit: this.witnessLimit,
|
40459
|
-
gasLimit: this.gasLimit
|
40460
|
-
maxGasPerTx
|
40391
|
+
gasLimit: this.gasLimit
|
40461
40392
|
});
|
40462
40393
|
}
|
40463
40394
|
/**
|
@@ -40530,29 +40461,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40530
40461
|
}
|
40531
40462
|
}
|
40532
40463
|
};
|
40533
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40534
|
-
(acc, input) => {
|
40535
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40536
|
-
acc.utxos.push(input.id);
|
40537
|
-
}
|
40538
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40539
|
-
acc.messages.push(input.nonce);
|
40540
|
-
}
|
40541
|
-
return acc;
|
40542
|
-
},
|
40543
|
-
{
|
40544
|
-
utxos: [],
|
40545
|
-
messages: []
|
40546
|
-
}
|
40547
|
-
);
|
40548
40464
|
|
40549
40465
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40550
40466
|
var calculateTransactionFee = (params) => {
|
40551
40467
|
const {
|
40552
|
-
|
40468
|
+
gasUsed,
|
40553
40469
|
rawPayload,
|
40554
|
-
|
40555
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40470
|
+
consensusParameters: { gasCosts, feeParams }
|
40556
40471
|
} = params;
|
40557
40472
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40558
40473
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40562,7 +40477,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40562
40477
|
return {
|
40563
40478
|
fee: bn(0),
|
40564
40479
|
minFee: bn(0),
|
40565
|
-
maxFee: bn(0)
|
40480
|
+
maxFee: bn(0),
|
40481
|
+
feeFromGasUsed: bn(0)
|
40566
40482
|
};
|
40567
40483
|
}
|
40568
40484
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40594,6 +40510,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40594
40510
|
metadataGas,
|
40595
40511
|
txBytesSize: transactionBytes.length
|
40596
40512
|
});
|
40513
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40597
40514
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40598
40515
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40599
40516
|
const maxGas = getMaxGas({
|
@@ -40601,25 +40518,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40601
40518
|
minGas,
|
40602
40519
|
witnessesLength,
|
40603
40520
|
gasLimit,
|
40604
|
-
witnessLimit
|
40605
|
-
maxGasPerTx
|
40606
|
-
});
|
40607
|
-
const minFee = calculateGasFee({
|
40608
|
-
gasPrice,
|
40609
|
-
gas: minGas,
|
40610
|
-
priceFactor: gasPriceFactor,
|
40611
|
-
tip
|
40612
|
-
});
|
40613
|
-
const maxFee = calculateGasFee({
|
40614
|
-
gasPrice,
|
40615
|
-
gas: maxGas,
|
40616
|
-
priceFactor: gasPriceFactor,
|
40617
|
-
tip
|
40521
|
+
witnessLimit
|
40618
40522
|
});
|
40523
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40524
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40525
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40526
|
+
const fee = minFee.add(feeFromGasUsed);
|
40619
40527
|
return {
|
40528
|
+
fee,
|
40620
40529
|
minFee,
|
40621
40530
|
maxFee,
|
40622
|
-
|
40531
|
+
feeFromGasUsed
|
40623
40532
|
};
|
40624
40533
|
};
|
40625
40534
|
|
@@ -41220,9 +41129,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41220
41129
|
gqlTransactionStatus,
|
41221
41130
|
abiMap = {},
|
41222
41131
|
maxInputs,
|
41223
|
-
gasCosts
|
41224
|
-
maxGasPerTx,
|
41225
|
-
gasPrice
|
41132
|
+
gasCosts
|
41226
41133
|
} = params;
|
41227
41134
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41228
41135
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41236,14 +41143,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41236
41143
|
maxInputs
|
41237
41144
|
});
|
41238
41145
|
const typeName = getTransactionTypeName(transaction.type);
|
41239
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41240
41146
|
const { fee } = calculateTransactionFee({
|
41241
|
-
|
41147
|
+
gasUsed,
|
41242
41148
|
rawPayload,
|
41243
|
-
tip,
|
41244
41149
|
consensusParameters: {
|
41245
41150
|
gasCosts,
|
41246
|
-
maxGasPerTx,
|
41247
41151
|
feeParams: {
|
41248
41152
|
gasPerByte,
|
41249
41153
|
gasPriceFactor
|
@@ -41379,13 +41283,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41379
41283
|
const decodedTransaction = this.decodeTransaction(
|
41380
41284
|
transaction
|
41381
41285
|
);
|
41382
|
-
|
41383
|
-
|
41384
|
-
txReceipts = transaction.status.receipts;
|
41385
|
-
}
|
41386
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41387
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41388
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41286
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41287
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41389
41288
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41390
41289
|
const transactionSummary = assembleTransactionSummary({
|
41391
41290
|
id: this.id,
|
@@ -41397,9 +41296,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41397
41296
|
gasPriceFactor,
|
41398
41297
|
abiMap: contractsAbiMap,
|
41399
41298
|
maxInputs,
|
41400
|
-
gasCosts
|
41401
|
-
maxGasPerTx,
|
41402
|
-
gasPrice
|
41299
|
+
gasCosts
|
41403
41300
|
});
|
41404
41301
|
return transactionSummary;
|
41405
41302
|
}
|
@@ -41548,7 +41445,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41548
41445
|
gasCosts,
|
41549
41446
|
latestBlock: {
|
41550
41447
|
id: latestBlock.id,
|
41551
|
-
height: bn(latestBlock.height),
|
41448
|
+
height: bn(latestBlock.header.height),
|
41552
41449
|
time: latestBlock.header.time,
|
41553
41450
|
transactions: latestBlock.transactions.map((i) => ({
|
41554
41451
|
id: i.id
|
@@ -41642,8 +41539,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41642
41539
|
* Returns some helpful parameters related to gas fees.
|
41643
41540
|
*/
|
41644
41541
|
getGasConfig() {
|
41542
|
+
const { minGasPrice } = this.getNode();
|
41645
41543
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41646
41544
|
return {
|
41545
|
+
minGasPrice,
|
41647
41546
|
maxGasPerTx,
|
41648
41547
|
maxGasPerPredicate,
|
41649
41548
|
gasPriceFactor,
|
@@ -41741,7 +41640,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41741
41640
|
*/
|
41742
41641
|
async getBlockNumber() {
|
41743
41642
|
const { chain } = await this.operations.getChain();
|
41744
|
-
return bn(chain.latestBlock.height, 10);
|
41643
|
+
return bn(chain.latestBlock.header.height, 10);
|
41745
41644
|
}
|
41746
41645
|
/**
|
41747
41646
|
* Returns the chain information.
|
@@ -41753,9 +41652,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41753
41652
|
const processedNodeInfo = {
|
41754
41653
|
maxDepth: bn(nodeInfo.maxDepth),
|
41755
41654
|
maxTx: bn(nodeInfo.maxTx),
|
41655
|
+
minGasPrice: bn(nodeInfo.minGasPrice),
|
41756
41656
|
nodeVersion: nodeInfo.nodeVersion,
|
41757
41657
|
utxoValidation: nodeInfo.utxoValidation,
|
41758
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41658
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41659
|
+
peers: nodeInfo.peers
|
41759
41660
|
};
|
41760
41661
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41761
41662
|
return processedNodeInfo;
|
@@ -41841,13 +41742,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41841
41742
|
return this.estimateTxDependencies(transactionRequest);
|
41842
41743
|
}
|
41843
41744
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41844
|
-
const { dryRun:
|
41845
|
-
|
41745
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41746
|
+
encodedTransaction,
|
41846
41747
|
utxoValidation: utxoValidation || false
|
41847
41748
|
});
|
41848
|
-
const
|
41849
|
-
|
41850
|
-
|
41749
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41750
|
+
return {
|
41751
|
+
receipts
|
41752
|
+
};
|
41851
41753
|
}
|
41852
41754
|
/**
|
41853
41755
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41886,6 +41788,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41886
41788
|
* If there are missing variable outputs,
|
41887
41789
|
* `addVariableOutputs` is called on the transaction.
|
41888
41790
|
*
|
41791
|
+
* @privateRemarks
|
41792
|
+
* TODO: Investigate support for missing contract IDs
|
41793
|
+
* TODO: Add support for missing output messages
|
41889
41794
|
*
|
41890
41795
|
* @param transactionRequest - The transaction request object.
|
41891
41796
|
* @returns A promise.
|
@@ -41898,19 +41803,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41898
41803
|
missingContractIds: []
|
41899
41804
|
};
|
41900
41805
|
}
|
41806
|
+
await this.estimatePredicates(transactionRequest);
|
41901
41807
|
let receipts = [];
|
41902
41808
|
const missingContractIds = [];
|
41903
41809
|
let outputVariables = 0;
|
41904
|
-
let dryrunStatus;
|
41905
41810
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41906
|
-
const {
|
41907
|
-
|
41908
|
-
} = await this.operations.dryRun({
|
41909
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41811
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41812
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41910
41813
|
utxoValidation: false
|
41911
41814
|
});
|
41912
|
-
receipts =
|
41913
|
-
dryrunStatus = status;
|
41815
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41914
41816
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41915
41817
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41916
41818
|
if (hasMissingOutputs) {
|
@@ -41920,10 +41822,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41920
41822
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41921
41823
|
missingContractIds.push(contractId);
|
41922
41824
|
});
|
41923
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41924
|
-
transactionRequest
|
41925
|
-
});
|
41926
|
-
transactionRequest.maxFee = maxFee;
|
41927
41825
|
} else {
|
41928
41826
|
break;
|
41929
41827
|
}
|
@@ -41931,136 +41829,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41931
41829
|
return {
|
41932
41830
|
receipts,
|
41933
41831
|
outputVariables,
|
41934
|
-
missingContractIds
|
41935
|
-
dryrunStatus
|
41832
|
+
missingContractIds
|
41936
41833
|
};
|
41937
41834
|
}
|
41938
|
-
/**
|
41939
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41940
|
-
*
|
41941
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41942
|
-
* further modifications are identified. The method iteratively updates these transactions
|
41943
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41944
|
-
*
|
41945
|
-
* @param transactionRequests - Array of transaction request objects.
|
41946
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
41947
|
-
*/
|
41948
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41949
|
-
const results = transactionRequests.map(() => ({
|
41950
|
-
receipts: [],
|
41951
|
-
outputVariables: 0,
|
41952
|
-
missingContractIds: [],
|
41953
|
-
dryrunStatus: void 0
|
41954
|
-
}));
|
41955
|
-
const allRequests = clone_default(transactionRequests);
|
41956
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41957
|
-
allRequests.forEach((req, index) => {
|
41958
|
-
if (req.type === TransactionType.Script) {
|
41959
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41960
|
-
}
|
41961
|
-
});
|
41962
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41963
|
-
let attempt = 0;
|
41964
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41965
|
-
const encodedTransactions = transactionsToProcess.map(
|
41966
|
-
(index) => serializedTransactionsMap.get(index)
|
41967
|
-
);
|
41968
|
-
const dryRunResults = await this.operations.dryRun({
|
41969
|
-
encodedTransactions,
|
41970
|
-
utxoValidation: false
|
41971
|
-
});
|
41972
|
-
const nextRoundTransactions = [];
|
41973
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41974
|
-
const requestIdx = transactionsToProcess[i];
|
41975
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41976
|
-
const result = results[requestIdx];
|
41977
|
-
result.receipts = rawReceipts.map(processGqlReceipt);
|
41978
|
-
result.dryrunStatus = status;
|
41979
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41980
|
-
result.receipts
|
41981
|
-
);
|
41982
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41983
|
-
const request = allRequests[requestIdx];
|
41984
|
-
if (hasMissingOutputs && request?.type === TransactionType.Script) {
|
41985
|
-
result.outputVariables += missingOutputVariables.length;
|
41986
|
-
request.addVariableOutputs(missingOutputVariables.length);
|
41987
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41988
|
-
request.addContractInputAndOutput(Address.fromString(contractId));
|
41989
|
-
result.missingContractIds.push(contractId);
|
41990
|
-
});
|
41991
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41992
|
-
transactionRequest: request
|
41993
|
-
});
|
41994
|
-
request.maxFee = maxFee;
|
41995
|
-
serializedTransactionsMap.set(requestIdx, hexlify(request.toTransactionBytes()));
|
41996
|
-
nextRoundTransactions.push(requestIdx);
|
41997
|
-
}
|
41998
|
-
}
|
41999
|
-
transactionsToProcess = nextRoundTransactions;
|
42000
|
-
attempt += 1;
|
42001
|
-
}
|
42002
|
-
return results;
|
42003
|
-
}
|
42004
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
42005
|
-
if (estimateTxDependencies) {
|
42006
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
42007
|
-
}
|
42008
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
42009
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42010
|
-
encodedTransactions,
|
42011
|
-
utxoValidation: utxoValidation || false
|
42012
|
-
});
|
42013
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42014
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
42015
|
-
return { receipts, dryrunStatus: status };
|
42016
|
-
});
|
42017
|
-
return results;
|
42018
|
-
}
|
42019
41835
|
/**
|
42020
41836
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
42021
41837
|
* @param transactionRequest - The transaction request object.
|
42022
41838
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
42023
41839
|
*/
|
42024
|
-
|
41840
|
+
estimateTxGasAndFee(params) {
|
42025
41841
|
const { transactionRequest } = params;
|
42026
|
-
|
41842
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
42027
41843
|
const chainInfo = this.getChain();
|
42028
|
-
const
|
41844
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41845
|
+
transactionRequest.gasPrice = gasPrice;
|
42029
41846
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42030
|
-
|
42031
|
-
gasPrice = await this.estimateGasPrice(10);
|
42032
|
-
}
|
42033
|
-
const minFee = calculateGasFee({
|
42034
|
-
gasPrice: bn(gasPrice),
|
42035
|
-
gas: minGas,
|
42036
|
-
priceFactor: gasPriceFactor,
|
42037
|
-
tip: transactionRequest.tip
|
42038
|
-
}).add(1);
|
42039
|
-
let gasLimit = bn(0);
|
41847
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42040
41848
|
if (transactionRequest.type === TransactionType.Script) {
|
42041
|
-
gasLimit = transactionRequest.gasLimit;
|
42042
41849
|
if (transactionRequest.gasLimit.eq(0)) {
|
42043
41850
|
transactionRequest.gasLimit = minGas;
|
42044
41851
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
42045
41852
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
42046
41853
|
);
|
42047
|
-
gasLimit = transactionRequest.gasLimit;
|
42048
41854
|
}
|
42049
41855
|
}
|
42050
41856
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42051
|
-
const maxFee =
|
42052
|
-
gasPrice: bn(gasPrice),
|
42053
|
-
gas: maxGas,
|
42054
|
-
priceFactor: gasPriceFactor,
|
42055
|
-
tip: transactionRequest.tip
|
42056
|
-
}).add(1);
|
41857
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42057
41858
|
return {
|
42058
41859
|
minGas,
|
42059
41860
|
minFee,
|
42060
41861
|
maxGas,
|
42061
|
-
maxFee
|
42062
|
-
gasPrice,
|
42063
|
-
gasLimit
|
41862
|
+
maxFee
|
42064
41863
|
};
|
42065
41864
|
}
|
42066
41865
|
/**
|
@@ -42078,17 +41877,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42078
41877
|
if (estimateTxDependencies) {
|
42079
41878
|
return this.estimateTxDependencies(transactionRequest);
|
42080
41879
|
}
|
42081
|
-
const
|
42082
|
-
const { dryRun:
|
42083
|
-
|
41880
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41881
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41882
|
+
encodedTransaction,
|
42084
41883
|
utxoValidation: true
|
42085
41884
|
});
|
42086
|
-
const
|
42087
|
-
|
42088
|
-
|
42089
|
-
|
42090
|
-
});
|
42091
|
-
return { receipts: callResult[0].receipts };
|
41885
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41886
|
+
return {
|
41887
|
+
receipts
|
41888
|
+
};
|
42092
41889
|
}
|
42093
41890
|
/**
|
42094
41891
|
* Returns a transaction cost to enable user
|
@@ -42105,79 +41902,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42105
41902
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42106
41903
|
* @returns A promise that resolves to the transaction cost object.
|
42107
41904
|
*/
|
42108
|
-
async getTransactionCost(transactionRequestLike,
|
41905
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41906
|
+
estimateTxDependencies = true,
|
41907
|
+
estimatePredicates = true,
|
41908
|
+
resourcesOwner,
|
41909
|
+
signatureCallback
|
41910
|
+
} = {}) {
|
42109
41911
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41912
|
+
const { minGasPrice } = this.getGasConfig();
|
41913
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42110
41914
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42111
41915
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42112
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41916
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42113
41917
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42114
|
-
txRequestClone.maxFee = bn(0);
|
42115
41918
|
if (isScriptTransaction) {
|
42116
41919
|
txRequestClone.gasLimit = bn(0);
|
42117
41920
|
}
|
42118
|
-
if (
|
42119
|
-
resourcesOwner
|
41921
|
+
if (estimatePredicates) {
|
41922
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41923
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41924
|
+
}
|
41925
|
+
await this.estimatePredicates(txRequestClone);
|
42120
41926
|
}
|
42121
|
-
const signedRequest = clone_default(txRequestClone);
|
42122
|
-
let addedSignatures = 0;
|
42123
41927
|
if (signatureCallback && isScriptTransaction) {
|
42124
|
-
|
42125
|
-
await signatureCallback(signedRequest);
|
42126
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
41928
|
+
await signatureCallback(txRequestClone);
|
42127
41929
|
}
|
42128
|
-
|
42129
|
-
|
42130
|
-
transactionRequest: signedRequest
|
41930
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41931
|
+
transactionRequest: txRequestClone
|
42131
41932
|
});
|
42132
41933
|
let receipts = [];
|
42133
41934
|
let missingContractIds = [];
|
42134
41935
|
let outputVariables = 0;
|
42135
41936
|
let gasUsed = bn(0);
|
42136
|
-
|
42137
|
-
|
42138
|
-
if (isScriptTransaction) {
|
42139
|
-
txRequestClone.gasLimit = gasLimit;
|
42140
|
-
if (signatureCallback) {
|
42141
|
-
await signatureCallback(txRequestClone);
|
42142
|
-
}
|
41937
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41938
|
+
txRequestClone.gasPrice = bn(0);
|
42143
41939
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42144
41940
|
receipts = result.receipts;
|
42145
41941
|
outputVariables = result.outputVariables;
|
42146
41942
|
missingContractIds = result.missingContractIds;
|
42147
41943
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
42148
41944
|
txRequestClone.gasLimit = gasUsed;
|
42149
|
-
|
42150
|
-
|
42151
|
-
|
41945
|
+
txRequestClone.gasPrice = setGasPrice;
|
41946
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41947
|
+
transactionRequest: txRequestClone
|
42152
41948
|
}));
|
42153
41949
|
}
|
42154
41950
|
return {
|
42155
41951
|
requiredQuantities: allQuantities,
|
42156
41952
|
receipts,
|
42157
41953
|
gasUsed,
|
42158
|
-
|
41954
|
+
minGasPrice,
|
41955
|
+
gasPrice: setGasPrice,
|
42159
41956
|
minGas,
|
42160
41957
|
maxGas,
|
42161
41958
|
minFee,
|
42162
41959
|
maxFee,
|
41960
|
+
estimatedInputs: txRequestClone.inputs,
|
42163
41961
|
outputVariables,
|
42164
|
-
missingContractIds
|
42165
|
-
addedSignatures,
|
42166
|
-
estimatedPredicates: txRequestClone.inputs
|
41962
|
+
missingContractIds
|
42167
41963
|
};
|
42168
41964
|
}
|
42169
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41965
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42170
41966
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42171
41967
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42172
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42173
|
-
quantitiesToContract
|
42174
|
-
});
|
41968
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42175
41969
|
transactionRequest.addResources(
|
42176
41970
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42177
41971
|
);
|
42178
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42179
|
-
|
42180
|
-
|
41972
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41973
|
+
transactionRequest,
|
41974
|
+
forwardingQuantities
|
41975
|
+
);
|
42181
41976
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42182
41977
|
return {
|
42183
41978
|
resources,
|
@@ -42201,6 +41996,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42201
41996
|
assetId: coin.assetId,
|
42202
41997
|
amount: bn(coin.amount),
|
42203
41998
|
owner: Address.fromAddressOrString(coin.owner),
|
41999
|
+
maturity: bn(coin.maturity).toNumber(),
|
42204
42000
|
blockCreated: bn(coin.blockCreated),
|
42205
42001
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42206
42002
|
}));
|
@@ -42252,6 +42048,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42252
42048
|
amount: bn(coin.amount),
|
42253
42049
|
assetId: coin.assetId,
|
42254
42050
|
owner: Address.fromAddressOrString(coin.owner),
|
42051
|
+
maturity: bn(coin.maturity).toNumber(),
|
42255
42052
|
blockCreated: bn(coin.blockCreated),
|
42256
42053
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42257
42054
|
};
|
@@ -42284,7 +42081,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42284
42081
|
}
|
42285
42082
|
return {
|
42286
42083
|
id: block2.id,
|
42287
|
-
height: bn(block2.height),
|
42084
|
+
height: bn(block2.header.height),
|
42288
42085
|
time: block2.header.time,
|
42289
42086
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42290
42087
|
};
|
@@ -42299,7 +42096,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42299
42096
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42300
42097
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42301
42098
|
id: block2.id,
|
42302
|
-
height: bn(block2.height),
|
42099
|
+
height: bn(block2.header.height),
|
42303
42100
|
time: block2.header.time,
|
42304
42101
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42305
42102
|
}));
|
@@ -42326,7 +42123,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42326
42123
|
}
|
42327
42124
|
return {
|
42328
42125
|
id: block2.id,
|
42329
|
-
height: bn(block2.height, 10),
|
42126
|
+
height: bn(block2.header.height, 10),
|
42330
42127
|
time: block2.header.time,
|
42331
42128
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42332
42129
|
transactions: block2.transactions.map(
|
@@ -42506,11 +42303,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42506
42303
|
prevRoot: messageBlockHeader.prevRoot,
|
42507
42304
|
time: messageBlockHeader.time,
|
42508
42305
|
applicationHash: messageBlockHeader.applicationHash,
|
42509
|
-
|
42510
|
-
|
42511
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
42512
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
42513
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
42306
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42307
|
+
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42514
42308
|
},
|
42515
42309
|
commitBlockHeader: {
|
42516
42310
|
id: commitBlockHeader.id,
|
@@ -42521,11 +42315,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42521
42315
|
prevRoot: commitBlockHeader.prevRoot,
|
42522
42316
|
time: commitBlockHeader.time,
|
42523
42317
|
applicationHash: commitBlockHeader.applicationHash,
|
42524
|
-
|
42525
|
-
|
42526
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
42527
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
42528
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
42318
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42319
|
+
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42529
42320
|
},
|
42530
42321
|
sender: Address.fromAddressOrString(sender),
|
42531
42322
|
recipient: Address.fromAddressOrString(recipient),
|
@@ -42534,16 +42325,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42534
42325
|
data
|
42535
42326
|
};
|
42536
42327
|
}
|
42537
|
-
async getLatestGasPrice() {
|
42538
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42539
|
-
return bn(latestGasPrice.gasPrice);
|
42540
|
-
}
|
42541
|
-
async estimateGasPrice(blockHorizon) {
|
42542
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42543
|
-
blockHorizon: String(blockHorizon)
|
42544
|
-
});
|
42545
|
-
return bn(estimateGasPrice.gasPrice);
|
42546
|
-
}
|
42547
42328
|
/**
|
42548
42329
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42549
42330
|
*
|
@@ -42604,15 +42385,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42604
42385
|
arrayify(gqlTransaction.rawPayload),
|
42605
42386
|
0
|
42606
42387
|
);
|
42607
|
-
|
42608
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42609
|
-
txReceipts = gqlTransaction.status.receipts;
|
42610
|
-
}
|
42611
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42388
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42612
42389
|
const {
|
42613
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42390
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42614
42391
|
} = provider.getChain();
|
42615
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42616
42392
|
const transactionInfo = assembleTransactionSummary({
|
42617
42393
|
id: gqlTransaction.id,
|
42618
42394
|
receipts,
|
@@ -42623,9 +42399,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42623
42399
|
gasPriceFactor: bn(gasPriceFactor),
|
42624
42400
|
abiMap,
|
42625
42401
|
maxInputs,
|
42626
|
-
gasCosts
|
42627
|
-
maxGasPerTx,
|
42628
|
-
gasPrice
|
42402
|
+
gasCosts
|
42629
42403
|
});
|
42630
42404
|
return {
|
42631
42405
|
gqlTransaction,
|
@@ -42635,11 +42409,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42635
42409
|
async function getTransactionSummaryFromRequest(params) {
|
42636
42410
|
const { provider, transactionRequest, abiMap } = params;
|
42637
42411
|
const { receipts } = await provider.call(transactionRequest);
|
42638
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42412
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42639
42413
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42640
42414
|
const transaction = transactionRequest.toTransaction();
|
42641
42415
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42642
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42643
42416
|
const transactionSummary = assembleTransactionSummary({
|
42644
42417
|
receipts,
|
42645
42418
|
transaction,
|
@@ -42648,9 +42421,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42648
42421
|
gasPerByte,
|
42649
42422
|
gasPriceFactor,
|
42650
42423
|
maxInputs,
|
42651
|
-
gasCosts
|
42652
|
-
maxGasPerTx,
|
42653
|
-
gasPrice
|
42424
|
+
gasCosts
|
42654
42425
|
});
|
42655
42426
|
return transactionSummary;
|
42656
42427
|
}
|
@@ -42659,18 +42430,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42659
42430
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42660
42431
|
const { edges, pageInfo } = transactionsByOwner;
|
42661
42432
|
const {
|
42662
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42433
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42663
42434
|
} = provider.getChain();
|
42664
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42665
42435
|
const transactions = edges.map((edge) => {
|
42666
42436
|
const { node: gqlTransaction } = edge;
|
42667
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42437
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42668
42438
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42669
|
-
|
42670
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42671
|
-
txReceipts = gqlTransaction.status.receipts;
|
42672
|
-
}
|
42673
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42439
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42674
42440
|
const transactionSummary = assembleTransactionSummary({
|
42675
42441
|
id,
|
42676
42442
|
receipts,
|
@@ -42681,9 +42447,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42681
42447
|
gasPerByte,
|
42682
42448
|
gasPriceFactor,
|
42683
42449
|
maxInputs,
|
42684
|
-
gasCosts
|
42685
|
-
maxGasPerTx,
|
42686
|
-
gasPrice
|
42450
|
+
gasCosts
|
42687
42451
|
});
|
42688
42452
|
const output3 = {
|
42689
42453
|
gqlTransaction,
|
@@ -43012,30 +42776,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43012
42776
|
* @param fee - The estimated transaction fee.
|
43013
42777
|
* @returns A promise that resolves when the resources are added to the transaction.
|
43014
42778
|
*/
|
43015
|
-
async fund(request,
|
43016
|
-
const
|
43017
|
-
const txRequest = request;
|
43018
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42779
|
+
async fund(request, coinQuantities, fee) {
|
42780
|
+
const updatedQuantities = addAmountToAsset({
|
43019
42781
|
amount: bn(fee),
|
43020
42782
|
assetId: BaseAssetId,
|
43021
|
-
coinQuantities
|
42783
|
+
coinQuantities
|
43022
42784
|
});
|
43023
42785
|
const quantitiesDict = {};
|
43024
|
-
|
42786
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
43025
42787
|
quantitiesDict[assetId] = {
|
43026
42788
|
required: amount,
|
43027
42789
|
owned: bn(0)
|
43028
42790
|
};
|
43029
42791
|
});
|
43030
|
-
|
42792
|
+
const cachedUtxos = [];
|
42793
|
+
const cachedMessages = [];
|
42794
|
+
const owner = this.address.toB256();
|
42795
|
+
request.inputs.forEach((input) => {
|
43031
42796
|
const isResource = "amount" in input;
|
43032
|
-
if (
|
43033
|
-
|
43034
|
-
|
43035
|
-
|
43036
|
-
|
43037
|
-
|
43038
|
-
|
42797
|
+
if (isResource) {
|
42798
|
+
const isCoin2 = "owner" in input;
|
42799
|
+
if (isCoin2) {
|
42800
|
+
const assetId = String(input.assetId);
|
42801
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
42802
|
+
const amount = bn(input.amount);
|
42803
|
+
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42804
|
+
cachedUtxos.push(input.id);
|
42805
|
+
}
|
42806
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42807
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42808
|
+
cachedMessages.push(input.nonce);
|
42809
|
+
}
|
43039
42810
|
}
|
43040
42811
|
});
|
43041
42812
|
const missingQuantities = [];
|
@@ -43049,21 +42820,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43049
42820
|
});
|
43050
42821
|
const needsToBeFunded = missingQuantities.length;
|
43051
42822
|
if (needsToBeFunded) {
|
43052
|
-
const
|
43053
|
-
|
43054
|
-
|
43055
|
-
|
43056
|
-
|
43057
|
-
|
43058
|
-
const requestToReestimate = clone_default(txRequest);
|
43059
|
-
if (addedSignatures) {
|
43060
|
-
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
43061
|
-
}
|
43062
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43063
|
-
transactionRequest: requestToReestimate
|
43064
|
-
});
|
43065
|
-
txRequest.maxFee = maxFee;
|
43066
|
-
return txRequest;
|
42823
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42824
|
+
messages: cachedMessages,
|
42825
|
+
utxos: cachedUtxos
|
42826
|
+
});
|
42827
|
+
request.addResources(resources);
|
42828
|
+
}
|
43067
42829
|
}
|
43068
42830
|
/**
|
43069
42831
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -43071,24 +42833,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43071
42833
|
* @param destination - The address of the destination.
|
43072
42834
|
* @param amount - The amount of coins to transfer.
|
43073
42835
|
* @param assetId - The asset ID of the coins to transfer.
|
43074
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42836
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43075
42837
|
* @returns A promise that resolves to the prepared transaction request.
|
43076
42838
|
*/
|
43077
42839
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43078
|
-
const
|
42840
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42841
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42842
|
+
const request = new ScriptTransactionRequest(params);
|
43079
42843
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43080
|
-
const
|
42844
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43081
42845
|
estimateTxDependencies: true,
|
43082
42846
|
resourcesOwner: this
|
43083
42847
|
});
|
43084
|
-
|
43085
|
-
|
43086
|
-
|
43087
|
-
|
42848
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42849
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42850
|
+
this.validateGas({
|
42851
|
+
gasUsed,
|
42852
|
+
gasPrice: request.gasPrice,
|
42853
|
+
gasLimit: request.gasLimit,
|
42854
|
+
minGasPrice
|
43088
42855
|
});
|
43089
|
-
request
|
43090
|
-
request.
|
43091
|
-
await this.fund(request, txCost);
|
42856
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42857
|
+
request.updatePredicateInputs(estimatedInputs);
|
43092
42858
|
return request;
|
43093
42859
|
}
|
43094
42860
|
/**
|
@@ -43097,7 +42863,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43097
42863
|
* @param destination - The address of the destination.
|
43098
42864
|
* @param amount - The amount of coins to transfer.
|
43099
42865
|
* @param assetId - The asset ID of the coins to transfer.
|
43100
|
-
* @param txParams - The transaction parameters (gasLimit, maturity).
|
42866
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43101
42867
|
* @returns A promise that resolves to the transaction response.
|
43102
42868
|
*/
|
43103
42869
|
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
@@ -43127,29 +42893,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43127
42893
|
);
|
43128
42894
|
}
|
43129
42895
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42896
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42897
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
43130
42898
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43131
42899
|
hexlifiedContractId: contractAddress.toB256(),
|
43132
42900
|
amountToTransfer: bn(amount),
|
43133
42901
|
assetId
|
43134
42902
|
});
|
43135
42903
|
const request = new ScriptTransactionRequest({
|
43136
|
-
...
|
42904
|
+
...params,
|
43137
42905
|
script,
|
43138
42906
|
scriptData
|
43139
42907
|
});
|
43140
42908
|
request.addContractInputAndOutput(contractAddress);
|
43141
|
-
const
|
43142
|
-
|
43143
|
-
|
43144
|
-
|
43145
|
-
|
43146
|
-
|
43147
|
-
|
43148
|
-
|
42909
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42910
|
+
request,
|
42911
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42912
|
+
);
|
42913
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42914
|
+
this.validateGas({
|
42915
|
+
gasUsed,
|
42916
|
+
gasPrice: request.gasPrice,
|
42917
|
+
gasLimit: request.gasLimit,
|
42918
|
+
minGasPrice
|
43149
42919
|
});
|
43150
|
-
request
|
43151
|
-
request.maxFee = txCost.maxFee;
|
43152
|
-
await this.fund(request, txCost);
|
42920
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43153
42921
|
return this.sendTransaction(request);
|
43154
42922
|
}
|
43155
42923
|
/**
|
@@ -43161,6 +42929,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43161
42929
|
* @returns A promise that resolves to the transaction response.
|
43162
42930
|
*/
|
43163
42931
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42932
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
43164
42933
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43165
42934
|
const recipientDataArray = arrayify(
|
43166
42935
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43173,18 +42942,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43173
42942
|
...recipientDataArray,
|
43174
42943
|
...amountDataArray
|
43175
42944
|
]);
|
43176
|
-
const params = { script, ...txParams };
|
42945
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
43177
42946
|
const request = new ScriptTransactionRequest(params);
|
43178
|
-
const
|
43179
|
-
const
|
43180
|
-
|
43181
|
-
|
43182
|
-
|
43183
|
-
|
42947
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42948
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42949
|
+
request,
|
42950
|
+
forwardingQuantities
|
42951
|
+
);
|
42952
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42953
|
+
this.validateGas({
|
42954
|
+
gasUsed,
|
42955
|
+
gasPrice: request.gasPrice,
|
42956
|
+
gasLimit: request.gasLimit,
|
42957
|
+
minGasPrice
|
43184
42958
|
});
|
43185
|
-
request
|
43186
|
-
request.gasLimit = txCost.gasUsed;
|
43187
|
-
await this.fund(request, txCost);
|
42959
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43188
42960
|
return this.sendTransaction(request);
|
43189
42961
|
}
|
43190
42962
|
async signMessage(message) {
|
@@ -43242,21 +43014,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43242
43014
|
}
|
43243
43015
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43244
43016
|
}
|
43245
|
-
|
43246
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
43017
|
+
validateGas({
|
43247
43018
|
gasUsed,
|
43248
|
-
|
43019
|
+
gasPrice,
|
43020
|
+
gasLimit,
|
43021
|
+
minGasPrice
|
43249
43022
|
}) {
|
43250
|
-
if (
|
43023
|
+
if (minGasPrice.gt(gasPrice)) {
|
43251
43024
|
throw new FuelError(
|
43252
|
-
ErrorCode.
|
43253
|
-
`Gas
|
43025
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
43026
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
43254
43027
|
);
|
43255
43028
|
}
|
43256
|
-
if (
|
43029
|
+
if (gasUsed.gt(gasLimit)) {
|
43257
43030
|
throw new FuelError(
|
43258
|
-
ErrorCode.
|
43259
|
-
`
|
43031
|
+
ErrorCode.GAS_LIMIT_TOO_LOW,
|
43032
|
+
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
43260
43033
|
);
|
43261
43034
|
}
|
43262
43035
|
}
|
@@ -44841,7 +44614,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44841
44614
|
* @param transactionRequestLike - The transaction request to send.
|
44842
44615
|
* @returns A promise that resolves to the TransactionResponse object.
|
44843
44616
|
*/
|
44844
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44617
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44845
44618
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44846
44619
|
if (estimateTxDependencies) {
|
44847
44620
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48117,23 +47890,41 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48117
47890
|
populateTransactionPredicateData(transactionRequestLike) {
|
48118
47891
|
const request = transactionRequestify(transactionRequestLike);
|
48119
47892
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48120
|
-
|
48121
|
-
|
48122
|
-
|
48123
|
-
|
47893
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
47894
|
+
if (placeholderIndex !== -1) {
|
47895
|
+
request.removeWitness(placeholderIndex);
|
47896
|
+
}
|
47897
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
47898
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
47899
|
+
input.predicate = this.bytes;
|
47900
|
+
input.predicateData = this.getPredicateData(policies.length);
|
47901
|
+
input.witnessIndex = 0;
|
48124
47902
|
}
|
48125
47903
|
});
|
48126
47904
|
return request;
|
48127
47905
|
}
|
47906
|
+
/**
|
47907
|
+
* A helper that creates a transfer transaction request and returns it.
|
47908
|
+
*
|
47909
|
+
* @param destination - The address of the destination.
|
47910
|
+
* @param amount - The amount of coins to transfer.
|
47911
|
+
* @param assetId - The asset ID of the coins to transfer.
|
47912
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47913
|
+
* @returns A promise that resolves to the prepared transaction request.
|
47914
|
+
*/
|
47915
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47916
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47917
|
+
return this.populateTransactionPredicateData(request);
|
47918
|
+
}
|
48128
47919
|
/**
|
48129
47920
|
* Sends a transaction with the populated predicate data.
|
48130
47921
|
*
|
48131
47922
|
* @param transactionRequestLike - The transaction request-like object.
|
48132
47923
|
* @returns A promise that resolves to the transaction response.
|
48133
47924
|
*/
|
48134
|
-
sendTransaction(transactionRequestLike) {
|
48135
|
-
const transactionRequest =
|
48136
|
-
return super.sendTransaction(transactionRequest,
|
47925
|
+
sendTransaction(transactionRequestLike, options) {
|
47926
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47927
|
+
return super.sendTransaction(transactionRequest, options);
|
48137
47928
|
}
|
48138
47929
|
/**
|
48139
47930
|
* Simulates a transaction with the populated predicate data.
|
@@ -48142,8 +47933,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48142
47933
|
* @returns A promise that resolves to the call result.
|
48143
47934
|
*/
|
48144
47935
|
simulateTransaction(transactionRequestLike) {
|
48145
|
-
const transactionRequest =
|
48146
|
-
return super.simulateTransaction(transactionRequest
|
47936
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47937
|
+
return super.simulateTransaction(transactionRequest);
|
47938
|
+
}
|
47939
|
+
/**
|
47940
|
+
* Retrieves resources satisfying the spend query for the account.
|
47941
|
+
*
|
47942
|
+
* @param quantities - Coins to retrieve.
|
47943
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
47944
|
+
* @returns A promise that resolves to an array of Resources.
|
47945
|
+
*/
|
47946
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
47947
|
+
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47948
|
+
return resources.map((resource) => ({
|
47949
|
+
...resource,
|
47950
|
+
predicate: hexlify(this.bytes)
|
47951
|
+
}));
|
48147
47952
|
}
|
48148
47953
|
getPredicateData(policiesLength) {
|
48149
47954
|
if (!this.predicateData.length) {
|
@@ -48189,25 +47994,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48189
47994
|
predicateInterface: abiInterface
|
48190
47995
|
};
|
48191
47996
|
}
|
48192
|
-
/**
|
48193
|
-
* Retrieves resources satisfying the spend query for the account.
|
48194
|
-
*
|
48195
|
-
* @param quantities - IDs of coins to exclude.
|
48196
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48197
|
-
* @returns A promise that resolves to an array of Resources.
|
48198
|
-
*/
|
48199
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48200
|
-
const resources = await this.provider.getResourcesToSpend(
|
48201
|
-
this.address,
|
48202
|
-
quantities,
|
48203
|
-
excludedIds
|
48204
|
-
);
|
48205
|
-
return resources.map((resource) => ({
|
48206
|
-
...resource,
|
48207
|
-
predicate: hexlify(this.bytes),
|
48208
|
-
padPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48209
|
-
}));
|
48210
|
-
}
|
48211
47997
|
/**
|
48212
47998
|
* Sets the configurable constants for the predicate.
|
48213
47999
|
*
|
@@ -48243,6 +48029,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48243
48029
|
}
|
48244
48030
|
return mutatedBytes;
|
48245
48031
|
}
|
48032
|
+
/**
|
48033
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
48034
|
+
* If no witness placeholder was added, it returns -1.
|
48035
|
+
* @param request - The transaction request.
|
48036
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
48037
|
+
*/
|
48038
|
+
getIndexFromPlaceholderWitness(request) {
|
48039
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
48040
|
+
let index = -1;
|
48041
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
48042
|
+
if (hasEmptyPredicateInputs) {
|
48043
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
48044
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
48045
|
+
if (!allInputsAreEmpty) {
|
48046
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
48047
|
+
if (wasFilledInputAddedFirst) {
|
48048
|
+
index = -1;
|
48049
|
+
}
|
48050
|
+
}
|
48051
|
+
}
|
48052
|
+
return index;
|
48053
|
+
}
|
48246
48054
|
};
|
48247
48055
|
|
48248
48056
|
// src/connectors/fuel-connector.ts
|