@fuel-ts/account 0.0.0-rc-1764-20240404125616 → 0.0.0-rc-1832-20240404143349
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 +4 -5
- 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 +558 -772
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +511 -764
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +392 -644
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +305 -824
- 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 +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -3
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +24 -44
- package/dist/providers/provider.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 +25 -8
- 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.global.js +551 -729
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +490 -705
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +379 -594
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
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.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29244,7 +29244,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29244
29244
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29245
29245
|
|
29246
29246
|
// ../crypto/dist/index.mjs
|
29247
|
-
var
|
29247
|
+
var import_crypto8 = __toESM(__require("crypto"), 1);
|
29248
29248
|
|
29249
29249
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29250
29250
|
var version = "6.7.1";
|
@@ -30316,27 +30316,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30316
30316
|
};
|
30317
30317
|
Object.freeze(pbkdf22);
|
30318
30318
|
|
30319
|
-
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30320
|
-
var locked5 = false;
|
30321
|
-
var _randomBytes = function(length) {
|
30322
|
-
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30323
|
-
};
|
30324
|
-
var __randomBytes = _randomBytes;
|
30325
|
-
function randomBytes3(length) {
|
30326
|
-
return __randomBytes(length);
|
30327
|
-
}
|
30328
|
-
randomBytes3._ = _randomBytes;
|
30329
|
-
randomBytes3.lock = function() {
|
30330
|
-
locked5 = true;
|
30331
|
-
};
|
30332
|
-
randomBytes3.register = function(func) {
|
30333
|
-
if (locked5) {
|
30334
|
-
throw new Error("randomBytes is locked");
|
30335
|
-
}
|
30336
|
-
__randomBytes = func;
|
30337
|
-
};
|
30338
|
-
Object.freeze(randomBytes3);
|
30339
|
-
|
30340
30319
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30341
30320
|
var BN_03 = BigInt(0);
|
30342
30321
|
var BN_36 = BigInt(36);
|
@@ -30921,8 +30900,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30921
30900
|
}
|
30922
30901
|
|
30923
30902
|
// ../crypto/dist/index.mjs
|
30903
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30924
30904
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30925
|
-
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30926
30905
|
var scrypt3 = (params) => {
|
30927
30906
|
const { password, salt, n, p, r, dklen } = params;
|
30928
30907
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30931,7 +30910,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30931
30910
|
var keccak2562 = (data) => keccak_256(data);
|
30932
30911
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30933
30912
|
var randomBytes4 = (length) => {
|
30934
|
-
const randomValues = Uint8Array.from(
|
30913
|
+
const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
|
30935
30914
|
return randomValues;
|
30936
30915
|
};
|
30937
30916
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30946,7 +30925,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30946
30925
|
const salt = randomBytes4(32);
|
30947
30926
|
const secret = keyFromPassword(password, salt);
|
30948
30927
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30949
|
-
const cipher = await
|
30928
|
+
const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
|
30950
30929
|
let cipherData = cipher.update(dataBuffer);
|
30951
30930
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30952
30931
|
return {
|
@@ -30960,7 +30939,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30960
30939
|
const salt = bufferFromString(keystore.salt);
|
30961
30940
|
const secret = keyFromPassword(password, salt);
|
30962
30941
|
const encryptedText = bufferFromString(keystore.data);
|
30963
|
-
const decipher = await
|
30942
|
+
const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
|
30964
30943
|
const decrypted = decipher.update(encryptedText);
|
30965
30944
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30966
30945
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30971,12 +30950,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30971
30950
|
}
|
30972
30951
|
};
|
30973
30952
|
async function encryptJsonWalletData(data, key, iv) {
|
30974
|
-
const cipher = await
|
30953
|
+
const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30975
30954
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30976
30955
|
return new Uint8Array(encrypted);
|
30977
30956
|
}
|
30978
30957
|
async function decryptJsonWalletData(data, key, iv) {
|
30979
|
-
const decipher =
|
30958
|
+
const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30980
30959
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30981
30960
|
return new Uint8Array(decrypted);
|
30982
30961
|
}
|
@@ -31515,182 +31494,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31515
31494
|
function toBytes3(value, bytesPadding) {
|
31516
31495
|
return bn(value).toBytes(bytesPadding);
|
31517
31496
|
}
|
31518
|
-
|
31519
|
-
|
31520
|
-
function _isPlaceholder(a) {
|
31521
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31522
|
-
}
|
31523
|
-
|
31524
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31525
|
-
function _curry1(fn) {
|
31526
|
-
return function f1(a) {
|
31527
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31528
|
-
return f1;
|
31529
|
-
} else {
|
31530
|
-
return fn.apply(this, arguments);
|
31531
|
-
}
|
31532
|
-
};
|
31497
|
+
function max(...numbers) {
|
31498
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31533
31499
|
}
|
31534
31500
|
|
31535
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31536
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
31537
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31538
|
-
};
|
31539
|
-
|
31540
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31541
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31542
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31543
|
-
});
|
31544
|
-
var type_default = type;
|
31545
|
-
|
31546
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31547
|
-
var pad = function pad2(n) {
|
31548
|
-
return (n < 10 ? "0" : "") + n;
|
31549
|
-
};
|
31550
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31551
|
-
return d.toISOString();
|
31552
|
-
} : function _toISOString3(d) {
|
31553
|
-
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";
|
31554
|
-
};
|
31555
|
-
|
31556
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31557
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31558
|
-
return n << 0 === n;
|
31559
|
-
};
|
31560
|
-
|
31561
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31562
|
-
function _cloneRegExp(pattern) {
|
31563
|
-
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" : ""));
|
31564
|
-
}
|
31565
|
-
|
31566
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31567
|
-
function _clone(value, deep, map) {
|
31568
|
-
map || (map = new _ObjectMap());
|
31569
|
-
if (_isPrimitive(value)) {
|
31570
|
-
return value;
|
31571
|
-
}
|
31572
|
-
var copy = function copy2(copiedValue) {
|
31573
|
-
var cachedCopy = map.get(value);
|
31574
|
-
if (cachedCopy) {
|
31575
|
-
return cachedCopy;
|
31576
|
-
}
|
31577
|
-
map.set(value, copiedValue);
|
31578
|
-
for (var key in value) {
|
31579
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31580
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31581
|
-
}
|
31582
|
-
}
|
31583
|
-
return copiedValue;
|
31584
|
-
};
|
31585
|
-
switch (type_default(value)) {
|
31586
|
-
case "Object":
|
31587
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31588
|
-
case "Array":
|
31589
|
-
return copy([]);
|
31590
|
-
case "Date":
|
31591
|
-
return new Date(value.valueOf());
|
31592
|
-
case "RegExp":
|
31593
|
-
return _cloneRegExp(value);
|
31594
|
-
case "Int8Array":
|
31595
|
-
case "Uint8Array":
|
31596
|
-
case "Uint8ClampedArray":
|
31597
|
-
case "Int16Array":
|
31598
|
-
case "Uint16Array":
|
31599
|
-
case "Int32Array":
|
31600
|
-
case "Uint32Array":
|
31601
|
-
case "Float32Array":
|
31602
|
-
case "Float64Array":
|
31603
|
-
case "BigInt64Array":
|
31604
|
-
case "BigUint64Array":
|
31605
|
-
return value.slice();
|
31606
|
-
default:
|
31607
|
-
return value;
|
31608
|
-
}
|
31609
|
-
}
|
31610
|
-
function _isPrimitive(param) {
|
31611
|
-
var type3 = typeof param;
|
31612
|
-
return param == null || type3 != "object" && type3 != "function";
|
31613
|
-
}
|
31614
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
31615
|
-
function _ObjectMap2() {
|
31616
|
-
this.map = {};
|
31617
|
-
this.length = 0;
|
31618
|
-
}
|
31619
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
31620
|
-
const hashedKey = this.hash(key);
|
31621
|
-
let bucket = this.map[hashedKey];
|
31622
|
-
if (!bucket) {
|
31623
|
-
this.map[hashedKey] = bucket = [];
|
31624
|
-
}
|
31625
|
-
bucket.push([key, value]);
|
31626
|
-
this.length += 1;
|
31627
|
-
};
|
31628
|
-
_ObjectMap2.prototype.hash = function(key) {
|
31629
|
-
let hashedKey = [];
|
31630
|
-
for (var value in key) {
|
31631
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31632
|
-
}
|
31633
|
-
return hashedKey.join();
|
31634
|
-
};
|
31635
|
-
_ObjectMap2.prototype.get = function(key) {
|
31636
|
-
if (this.length <= 180) {
|
31637
|
-
for (const p in this.map) {
|
31638
|
-
const bucket2 = this.map[p];
|
31639
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
31640
|
-
const element = bucket2[i];
|
31641
|
-
if (element[0] === key) {
|
31642
|
-
return element[1];
|
31643
|
-
}
|
31644
|
-
}
|
31645
|
-
}
|
31646
|
-
return;
|
31647
|
-
}
|
31648
|
-
const hashedKey = this.hash(key);
|
31649
|
-
const bucket = this.map[hashedKey];
|
31650
|
-
if (!bucket) {
|
31651
|
-
return;
|
31652
|
-
}
|
31653
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
31654
|
-
const element = bucket[i];
|
31655
|
-
if (element[0] === key) {
|
31656
|
-
return element[1];
|
31657
|
-
}
|
31658
|
-
}
|
31659
|
-
};
|
31660
|
-
return _ObjectMap2;
|
31661
|
-
}();
|
31662
|
-
|
31663
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31664
|
-
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31665
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31666
|
-
});
|
31667
|
-
var clone_default = clone;
|
31668
|
-
|
31669
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31670
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31671
|
-
|
31672
31501
|
// src/providers/coin-quantity.ts
|
31673
31502
|
var coinQuantityfy = (coinQuantityLike) => {
|
31674
31503
|
let assetId;
|
31675
31504
|
let amount;
|
31676
|
-
let
|
31505
|
+
let max2;
|
31677
31506
|
if (Array.isArray(coinQuantityLike)) {
|
31678
31507
|
amount = coinQuantityLike[0];
|
31679
31508
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31680
|
-
|
31509
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31681
31510
|
} else {
|
31682
31511
|
amount = coinQuantityLike.amount;
|
31683
31512
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31684
|
-
|
31513
|
+
max2 = coinQuantityLike.max ?? void 0;
|
31685
31514
|
}
|
31686
31515
|
const bnAmount = bn(amount);
|
31687
31516
|
return {
|
31688
31517
|
assetId: hexlify(assetId),
|
31689
31518
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31690
|
-
max:
|
31519
|
+
max: max2 ? bn(max2) : void 0
|
31691
31520
|
};
|
31692
31521
|
};
|
31693
|
-
var
|
31522
|
+
var addAmountToAsset = (params) => {
|
31694
31523
|
const { amount, assetId } = params;
|
31695
31524
|
const coinQuantities = [...params.coinQuantities];
|
31696
31525
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31802,6 +31631,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31802
31631
|
ASSET_ID_LEN + // Asset id
|
31803
31632
|
TX_POINTER_LEN + // TxPointer
|
31804
31633
|
WORD_SIZE + // Witnesses index
|
31634
|
+
WORD_SIZE + // Maturity
|
31805
31635
|
WORD_SIZE + // Predicate size
|
31806
31636
|
WORD_SIZE + // Predicate data size
|
31807
31637
|
WORD_SIZE;
|
@@ -32085,9 +31915,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32085
31915
|
__privateAdd2(this, _getPaddedData);
|
32086
31916
|
}
|
32087
31917
|
encode(value) {
|
32088
|
-
if (!Array.isArray(value)) {
|
32089
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
32090
|
-
}
|
32091
31918
|
const parts = [];
|
32092
31919
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
32093
31920
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -32114,7 +31941,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32114
31941
|
};
|
32115
31942
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
32116
31943
|
getPaddedData_fn = function(value) {
|
32117
|
-
const data = [Uint8Array
|
31944
|
+
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
32118
31945
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
32119
31946
|
if (paddingLength) {
|
32120
31947
|
data.push(new Uint8Array(paddingLength));
|
@@ -32134,10 +31961,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32134
31961
|
constructor(name, coders) {
|
32135
31962
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32136
31963
|
const encodedValueSize = Object.values(coders).reduce(
|
32137
|
-
(
|
31964
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32138
31965
|
0
|
32139
31966
|
);
|
32140
|
-
super(
|
31967
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32141
31968
|
this.name = name;
|
32142
31969
|
this.coders = coders;
|
32143
31970
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32207,7 +32034,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32207
32034
|
return { None: [] };
|
32208
32035
|
}
|
32209
32036
|
decode(data, offset) {
|
32210
|
-
if (data.length < this.encodedLength
|
32037
|
+
if (data.length < this.encodedLength) {
|
32211
32038
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
32212
32039
|
}
|
32213
32040
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -32790,11 +32617,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32790
32617
|
super("struct", "struct Bytes", WORD_SIZE);
|
32791
32618
|
}
|
32792
32619
|
encode(value) {
|
32793
|
-
|
32794
|
-
|
32795
|
-
}
|
32796
|
-
const bytes3 = new Uint8Array(value);
|
32797
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32620
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
32621
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
32798
32622
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32799
32623
|
}
|
32800
32624
|
decode(data, offset) {
|
@@ -32824,10 +32648,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32824
32648
|
constructor(name, coders) {
|
32825
32649
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32826
32650
|
const encodedValueSize = Object.values(coders).reduce(
|
32827
|
-
(
|
32651
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32828
32652
|
0
|
32829
32653
|
);
|
32830
|
-
super(
|
32654
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32831
32655
|
this.name = name;
|
32832
32656
|
this.coders = coders;
|
32833
32657
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32925,6 +32749,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32925
32749
|
return [toNumber2(bytes3), offset + this.length];
|
32926
32750
|
}
|
32927
32751
|
};
|
32752
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
32753
|
+
encode(value) {
|
32754
|
+
const result = super.encode(this.toSwayOption(value));
|
32755
|
+
return result;
|
32756
|
+
}
|
32757
|
+
toSwayOption(input) {
|
32758
|
+
if (input !== void 0) {
|
32759
|
+
return { Some: input };
|
32760
|
+
}
|
32761
|
+
return { None: [] };
|
32762
|
+
}
|
32763
|
+
decode(data, offset) {
|
32764
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
32765
|
+
return [this.toOption(decoded), newOffset];
|
32766
|
+
}
|
32767
|
+
toOption(output3) {
|
32768
|
+
if (output3 && "Some" in output3) {
|
32769
|
+
return output3.Some;
|
32770
|
+
}
|
32771
|
+
return void 0;
|
32772
|
+
}
|
32773
|
+
};
|
32928
32774
|
var RawSliceCoder2 = class extends Coder {
|
32929
32775
|
constructor() {
|
32930
32776
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -32978,6 +32824,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32978
32824
|
}
|
32979
32825
|
};
|
32980
32826
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
32827
|
+
var StrSliceCoder = class extends Coder {
|
32828
|
+
constructor() {
|
32829
|
+
super("strSlice", "str", WORD_SIZE);
|
32830
|
+
}
|
32831
|
+
encode(value) {
|
32832
|
+
const bytes3 = toUtf8Bytes(value);
|
32833
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32834
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32835
|
+
}
|
32836
|
+
decode(data, offset) {
|
32837
|
+
if (data.length < this.encodedLength) {
|
32838
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
32839
|
+
}
|
32840
|
+
const offsetAndLength = offset + WORD_SIZE;
|
32841
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
32842
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32843
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
32844
|
+
if (bytes3.length !== length) {
|
32845
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
32846
|
+
}
|
32847
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
32848
|
+
}
|
32849
|
+
};
|
32850
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
32981
32851
|
var StringCoder2 = class extends Coder {
|
32982
32852
|
constructor(length) {
|
32983
32853
|
super("string", `str[${length}]`, length);
|
@@ -33016,7 +32886,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33016
32886
|
Object.keys(this.coders).map((fieldName) => {
|
33017
32887
|
const fieldCoder = this.coders[fieldName];
|
33018
32888
|
const fieldValue = value[fieldName];
|
33019
|
-
if (!(fieldCoder instanceof
|
32889
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
33020
32890
|
throw new FuelError(
|
33021
32891
|
ErrorCode.ENCODE_ERROR,
|
33022
32892
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -33124,6 +32994,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33124
32994
|
return new ByteCoder2();
|
33125
32995
|
case STD_STRING_CODER_TYPE:
|
33126
32996
|
return new StdStringCoder2();
|
32997
|
+
case STR_SLICE_CODER_TYPE:
|
32998
|
+
return new StrSliceCoder();
|
33127
32999
|
default:
|
33128
33000
|
break;
|
33129
33001
|
}
|
@@ -33168,7 +33040,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33168
33040
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
33169
33041
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
33170
33042
|
if (isOptionEnum) {
|
33171
|
-
return new
|
33043
|
+
return new OptionCoder2(enumMatch.name, coders);
|
33172
33044
|
}
|
33173
33045
|
return new EnumCoder2(enumMatch.name, coders);
|
33174
33046
|
}
|
@@ -33179,12 +33051,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33179
33051
|
);
|
33180
33052
|
return new TupleCoder2(coders);
|
33181
33053
|
}
|
33182
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
33183
|
-
throw new FuelError(
|
33184
|
-
ErrorCode.INVALID_DATA,
|
33185
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
33186
|
-
);
|
33187
|
-
}
|
33188
33054
|
throw new FuelError(
|
33189
33055
|
ErrorCode.CODER_NOT_FOUND,
|
33190
33056
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -33220,6 +33086,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33220
33086
|
var FunctionFragment = class {
|
33221
33087
|
signature;
|
33222
33088
|
selector;
|
33089
|
+
selectorBytes;
|
33090
|
+
encoding;
|
33223
33091
|
name;
|
33224
33092
|
jsonFn;
|
33225
33093
|
attributes;
|
@@ -33232,6 +33100,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33232
33100
|
this.name = name;
|
33233
33101
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33234
33102
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
33103
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
33104
|
+
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
33235
33105
|
this.isInputDataPointer = this.#isInputDataPointer();
|
33236
33106
|
this.outputMetadata = {
|
33237
33107
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -33285,11 +33155,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33285
33155
|
}
|
33286
33156
|
const coders = nonEmptyInputs.map(
|
33287
33157
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
33288
|
-
isRightPadded: nonEmptyInputs.length > 1
|
33158
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
33159
|
+
encoding: this.encoding
|
33289
33160
|
})
|
33290
33161
|
);
|
33291
|
-
|
33292
|
-
|
33162
|
+
if (this.encoding === ENCODING_V1) {
|
33163
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
33164
|
+
}
|
33165
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
33293
33166
|
return unpackDynamicData(results, offset, results.byteLength);
|
33294
33167
|
}
|
33295
33168
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -33336,7 +33209,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33336
33209
|
}
|
33337
33210
|
const result = nonEmptyInputs.reduce(
|
33338
33211
|
(obj, input) => {
|
33339
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
33212
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
33340
33213
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
33341
33214
|
return {
|
33342
33215
|
decoded: [...obj.decoded, decodedValue],
|
@@ -33356,7 +33229,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33356
33229
|
return [void 0, 0];
|
33357
33230
|
}
|
33358
33231
|
const bytes3 = arrayify(data);
|
33359
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
33232
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
33233
|
+
encoding: this.encoding
|
33234
|
+
});
|
33360
33235
|
return coder.decode(bytes3, 0);
|
33361
33236
|
}
|
33362
33237
|
};
|
@@ -33418,7 +33293,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33418
33293
|
}
|
33419
33294
|
);
|
33420
33295
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33421
|
-
isRightPadded: true
|
33296
|
+
isRightPadded: true,
|
33297
|
+
encoding: this.jsonAbi.encoding
|
33422
33298
|
});
|
33423
33299
|
}
|
33424
33300
|
getTypeById(typeId) {
|
@@ -33501,6 +33377,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33501
33377
|
parts.push(new B256Coder().encode(value.assetId));
|
33502
33378
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33503
33379
|
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33380
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33504
33381
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33505
33382
|
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33506
33383
|
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
@@ -33525,6 +33402,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33525
33402
|
const txPointer = decoded;
|
33526
33403
|
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33527
33404
|
const witnessIndex = Number(decoded);
|
33405
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33406
|
+
const maturity = decoded;
|
33528
33407
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33529
33408
|
const predicateGasUsed = decoded;
|
33530
33409
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
@@ -33545,6 +33424,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33545
33424
|
assetId,
|
33546
33425
|
txPointer,
|
33547
33426
|
witnessIndex,
|
33427
|
+
maturity,
|
33548
33428
|
predicateGasUsed,
|
33549
33429
|
predicateLength,
|
33550
33430
|
predicateDataLength,
|
@@ -33976,7 +33856,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33976
33856
|
}
|
33977
33857
|
};
|
33978
33858
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
33979
|
-
PolicyType2[PolicyType2["
|
33859
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
33980
33860
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
33981
33861
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
33982
33862
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34024,9 +33904,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34024
33904
|
let o = offset;
|
34025
33905
|
const policies = [];
|
34026
33906
|
if (policyTypes & 1) {
|
34027
|
-
const [
|
33907
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34028
33908
|
o = nextOffset;
|
34029
|
-
policies.push({ type: 1, data:
|
33909
|
+
policies.push({ type: 1, data: gasPrice });
|
34030
33910
|
}
|
34031
33911
|
if (policyTypes & 2) {
|
34032
33912
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34739,6 +34619,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34739
34619
|
// src/providers/provider.ts
|
34740
34620
|
var import_graphql_request = __toESM(require_dist2());
|
34741
34621
|
|
34622
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34623
|
+
function _isPlaceholder(a) {
|
34624
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34625
|
+
}
|
34626
|
+
|
34627
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34628
|
+
function _curry1(fn) {
|
34629
|
+
return function f1(a) {
|
34630
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34631
|
+
return f1;
|
34632
|
+
} else {
|
34633
|
+
return fn.apply(this, arguments);
|
34634
|
+
}
|
34635
|
+
};
|
34636
|
+
}
|
34637
|
+
|
34638
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34639
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
34640
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34641
|
+
};
|
34642
|
+
|
34643
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34644
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34645
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34646
|
+
});
|
34647
|
+
var type_default = type;
|
34648
|
+
|
34649
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34650
|
+
var pad = function pad2(n) {
|
34651
|
+
return (n < 10 ? "0" : "") + n;
|
34652
|
+
};
|
34653
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34654
|
+
return d.toISOString();
|
34655
|
+
} : function _toISOString3(d) {
|
34656
|
+
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";
|
34657
|
+
};
|
34658
|
+
|
34659
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34660
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34661
|
+
return n << 0 === n;
|
34662
|
+
};
|
34663
|
+
|
34664
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34665
|
+
function _cloneRegExp(pattern) {
|
34666
|
+
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" : ""));
|
34667
|
+
}
|
34668
|
+
|
34669
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34670
|
+
function _clone(value, deep, map) {
|
34671
|
+
map || (map = new _ObjectMap());
|
34672
|
+
if (_isPrimitive(value)) {
|
34673
|
+
return value;
|
34674
|
+
}
|
34675
|
+
var copy = function copy2(copiedValue) {
|
34676
|
+
var cachedCopy = map.get(value);
|
34677
|
+
if (cachedCopy) {
|
34678
|
+
return cachedCopy;
|
34679
|
+
}
|
34680
|
+
map.set(value, copiedValue);
|
34681
|
+
for (var key in value) {
|
34682
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34683
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34684
|
+
}
|
34685
|
+
}
|
34686
|
+
return copiedValue;
|
34687
|
+
};
|
34688
|
+
switch (type_default(value)) {
|
34689
|
+
case "Object":
|
34690
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
34691
|
+
case "Array":
|
34692
|
+
return copy([]);
|
34693
|
+
case "Date":
|
34694
|
+
return new Date(value.valueOf());
|
34695
|
+
case "RegExp":
|
34696
|
+
return _cloneRegExp(value);
|
34697
|
+
case "Int8Array":
|
34698
|
+
case "Uint8Array":
|
34699
|
+
case "Uint8ClampedArray":
|
34700
|
+
case "Int16Array":
|
34701
|
+
case "Uint16Array":
|
34702
|
+
case "Int32Array":
|
34703
|
+
case "Uint32Array":
|
34704
|
+
case "Float32Array":
|
34705
|
+
case "Float64Array":
|
34706
|
+
case "BigInt64Array":
|
34707
|
+
case "BigUint64Array":
|
34708
|
+
return value.slice();
|
34709
|
+
default:
|
34710
|
+
return value;
|
34711
|
+
}
|
34712
|
+
}
|
34713
|
+
function _isPrimitive(param) {
|
34714
|
+
var type3 = typeof param;
|
34715
|
+
return param == null || type3 != "object" && type3 != "function";
|
34716
|
+
}
|
34717
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
34718
|
+
function _ObjectMap2() {
|
34719
|
+
this.map = {};
|
34720
|
+
this.length = 0;
|
34721
|
+
}
|
34722
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
34723
|
+
const hashedKey = this.hash(key);
|
34724
|
+
let bucket = this.map[hashedKey];
|
34725
|
+
if (!bucket) {
|
34726
|
+
this.map[hashedKey] = bucket = [];
|
34727
|
+
}
|
34728
|
+
bucket.push([key, value]);
|
34729
|
+
this.length += 1;
|
34730
|
+
};
|
34731
|
+
_ObjectMap2.prototype.hash = function(key) {
|
34732
|
+
let hashedKey = [];
|
34733
|
+
for (var value in key) {
|
34734
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34735
|
+
}
|
34736
|
+
return hashedKey.join();
|
34737
|
+
};
|
34738
|
+
_ObjectMap2.prototype.get = function(key) {
|
34739
|
+
if (this.length <= 180) {
|
34740
|
+
for (const p in this.map) {
|
34741
|
+
const bucket2 = this.map[p];
|
34742
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
34743
|
+
const element = bucket2[i];
|
34744
|
+
if (element[0] === key) {
|
34745
|
+
return element[1];
|
34746
|
+
}
|
34747
|
+
}
|
34748
|
+
}
|
34749
|
+
return;
|
34750
|
+
}
|
34751
|
+
const hashedKey = this.hash(key);
|
34752
|
+
const bucket = this.map[hashedKey];
|
34753
|
+
if (!bucket) {
|
34754
|
+
return;
|
34755
|
+
}
|
34756
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
34757
|
+
const element = bucket[i];
|
34758
|
+
if (element[0] === key) {
|
34759
|
+
return element[1];
|
34760
|
+
}
|
34761
|
+
}
|
34762
|
+
};
|
34763
|
+
return _ObjectMap2;
|
34764
|
+
}();
|
34765
|
+
|
34766
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34767
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34768
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34769
|
+
});
|
34770
|
+
var clone_default = clone2;
|
34771
|
+
|
34772
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34773
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34774
|
+
|
34742
34775
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34743
34776
|
var __assign = function() {
|
34744
34777
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37906,10 +37939,14 @@ spurious results.`);
|
|
37906
37939
|
// src/providers/__generated__/operations.ts
|
37907
37940
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37908
37941
|
fragment receiptFragment on Receipt {
|
37909
|
-
|
37942
|
+
contract {
|
37943
|
+
id
|
37944
|
+
}
|
37910
37945
|
pc
|
37911
37946
|
is
|
37912
|
-
to
|
37947
|
+
to {
|
37948
|
+
id
|
37949
|
+
}
|
37913
37950
|
toAddress
|
37914
37951
|
amount
|
37915
37952
|
assetId
|
@@ -37947,16 +37984,10 @@ spurious results.`);
|
|
37947
37984
|
id
|
37948
37985
|
}
|
37949
37986
|
time
|
37950
|
-
receipts {
|
37951
|
-
...receiptFragment
|
37952
|
-
}
|
37953
37987
|
programState {
|
37954
37988
|
returnType
|
37955
37989
|
data
|
37956
37990
|
}
|
37957
|
-
receipts {
|
37958
|
-
...receiptFragment
|
37959
|
-
}
|
37960
37991
|
}
|
37961
37992
|
... on FailureStatus {
|
37962
37993
|
block {
|
@@ -37964,24 +37995,26 @@ spurious results.`);
|
|
37964
37995
|
}
|
37965
37996
|
time
|
37966
37997
|
reason
|
37967
|
-
receipts {
|
37968
|
-
...receiptFragment
|
37969
|
-
}
|
37970
37998
|
}
|
37971
37999
|
... on SqueezedOutStatus {
|
37972
38000
|
reason
|
37973
38001
|
}
|
37974
38002
|
}
|
37975
|
-
|
38003
|
+
`;
|
37976
38004
|
var TransactionFragmentFragmentDoc = lib_default2`
|
37977
38005
|
fragment transactionFragment on Transaction {
|
37978
38006
|
id
|
37979
38007
|
rawPayload
|
38008
|
+
gasPrice
|
38009
|
+
receipts {
|
38010
|
+
...receiptFragment
|
38011
|
+
}
|
37980
38012
|
status {
|
37981
38013
|
...transactionStatusFragment
|
37982
38014
|
}
|
37983
38015
|
}
|
37984
|
-
${
|
38016
|
+
${ReceiptFragmentFragmentDoc}
|
38017
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
37985
38018
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
37986
38019
|
fragment inputEstimatePredicatesFragment on Input {
|
37987
38020
|
... on InputCoin {
|
@@ -37999,46 +38032,6 @@ spurious results.`);
|
|
37999
38032
|
}
|
38000
38033
|
}
|
38001
38034
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38002
|
-
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38003
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38004
|
-
reason
|
38005
|
-
programState {
|
38006
|
-
returnType
|
38007
|
-
data
|
38008
|
-
}
|
38009
|
-
}
|
38010
|
-
`;
|
38011
|
-
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38012
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38013
|
-
programState {
|
38014
|
-
returnType
|
38015
|
-
data
|
38016
|
-
}
|
38017
|
-
}
|
38018
|
-
`;
|
38019
|
-
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38020
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38021
|
-
... on DryRunFailureStatus {
|
38022
|
-
...dryRunFailureStatusFragment
|
38023
|
-
}
|
38024
|
-
... on DryRunSuccessStatus {
|
38025
|
-
...dryRunSuccessStatusFragment
|
38026
|
-
}
|
38027
|
-
}
|
38028
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
38029
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38030
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38031
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38032
|
-
id
|
38033
|
-
status {
|
38034
|
-
...dryRunTransactionStatusFragment
|
38035
|
-
}
|
38036
|
-
receipts {
|
38037
|
-
...receiptFragment
|
38038
|
-
}
|
38039
|
-
}
|
38040
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
38041
|
-
${ReceiptFragmentFragmentDoc}`;
|
38042
38035
|
var CoinFragmentFragmentDoc = lib_default2`
|
38043
38036
|
fragment coinFragment on Coin {
|
38044
38037
|
__typename
|
@@ -38046,6 +38039,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38046
38039
|
owner
|
38047
38040
|
amount
|
38048
38041
|
assetId
|
38042
|
+
maturity
|
38049
38043
|
blockCreated
|
38050
38044
|
txCreatedIdx
|
38051
38045
|
}
|
@@ -38122,8 +38116,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38122
38116
|
var BlockFragmentFragmentDoc = lib_default2`
|
38123
38117
|
fragment blockFragment on Block {
|
38124
38118
|
id
|
38125
|
-
height
|
38126
38119
|
header {
|
38120
|
+
height
|
38127
38121
|
time
|
38128
38122
|
}
|
38129
38123
|
transactions {
|
@@ -38193,6 +38187,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38193
38187
|
cb
|
38194
38188
|
cfei
|
38195
38189
|
cfsi
|
38190
|
+
croo
|
38196
38191
|
div
|
38197
38192
|
divi
|
38198
38193
|
ecr1
|
@@ -38275,9 +38270,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38275
38270
|
ccp {
|
38276
38271
|
...DependentCostFragment
|
38277
38272
|
}
|
38278
|
-
croo {
|
38279
|
-
...DependentCostFragment
|
38280
|
-
}
|
38281
38273
|
csiz {
|
38282
38274
|
...DependentCostFragment
|
38283
38275
|
}
|
@@ -38400,6 +38392,14 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38400
38392
|
maxTx
|
38401
38393
|
maxDepth
|
38402
38394
|
nodeVersion
|
38395
|
+
peers {
|
38396
|
+
id
|
38397
|
+
addresses
|
38398
|
+
clientVersion
|
38399
|
+
blockHeight
|
38400
|
+
lastHeartbeatMs
|
38401
|
+
appScore
|
38402
|
+
}
|
38403
38403
|
}
|
38404
38404
|
`;
|
38405
38405
|
var GetVersionDocument = lib_default2`
|
@@ -38434,9 +38434,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38434
38434
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38435
38435
|
transaction(id: $transactionId) {
|
38436
38436
|
...transactionFragment
|
38437
|
+
receipts {
|
38438
|
+
...receiptFragment
|
38439
|
+
}
|
38437
38440
|
}
|
38438
38441
|
}
|
38439
|
-
${TransactionFragmentFragmentDoc}
|
38442
|
+
${TransactionFragmentFragmentDoc}
|
38443
|
+
${ReceiptFragmentFragmentDoc}`;
|
38440
38444
|
var GetTransactionsDocument = lib_default2`
|
38441
38445
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38442
38446
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38564,20 +38568,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38564
38568
|
}
|
38565
38569
|
}
|
38566
38570
|
${BalanceFragmentFragmentDoc}`;
|
38567
|
-
var GetLatestGasPriceDocument = lib_default2`
|
38568
|
-
query getLatestGasPrice {
|
38569
|
-
latestGasPrice {
|
38570
|
-
gasPrice
|
38571
|
-
}
|
38572
|
-
}
|
38573
|
-
`;
|
38574
|
-
var EstimateGasPriceDocument = lib_default2`
|
38575
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
38576
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38577
|
-
gasPrice
|
38578
|
-
}
|
38579
|
-
}
|
38580
|
-
`;
|
38581
38571
|
var GetBalancesDocument = lib_default2`
|
38582
38572
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38583
38573
|
balances(
|
@@ -38632,12 +38622,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38632
38622
|
}
|
38633
38623
|
`;
|
38634
38624
|
var DryRunDocument = lib_default2`
|
38635
|
-
mutation dryRun($
|
38636
|
-
dryRun(
|
38637
|
-
...
|
38625
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38626
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38627
|
+
...receiptFragment
|
38638
38628
|
}
|
38639
38629
|
}
|
38640
|
-
${
|
38630
|
+
${ReceiptFragmentFragmentDoc}`;
|
38641
38631
|
var SubmitDocument = lib_default2`
|
38642
38632
|
mutation submit($encodedTransaction: HexString!) {
|
38643
38633
|
submit(tx: $encodedTransaction) {
|
@@ -38720,12 +38710,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38720
38710
|
getBalance(variables, options) {
|
38721
38711
|
return requester(GetBalanceDocument, variables, options);
|
38722
38712
|
},
|
38723
|
-
getLatestGasPrice(variables, options) {
|
38724
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38725
|
-
},
|
38726
|
-
estimateGasPrice(variables, options) {
|
38727
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38728
|
-
},
|
38729
38713
|
getBalances(variables, options) {
|
38730
38714
|
return requester(GetBalancesDocument, variables, options);
|
38731
38715
|
},
|
@@ -38900,6 +38884,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38900
38884
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38901
38885
|
},
|
38902
38886
|
witnessIndex: value.witnessIndex,
|
38887
|
+
maturity: value.maturity ?? 0,
|
38903
38888
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38904
38889
|
predicateLength: predicate.length,
|
38905
38890
|
predicateDataLength: predicateData.length,
|
@@ -39094,8 +39079,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39094
39079
|
case "CALL" /* Call */: {
|
39095
39080
|
const callReceipt = {
|
39096
39081
|
type: ReceiptType.Call,
|
39097
|
-
from: hexOrZero(receipt.id
|
39098
|
-
to: hexOrZero(receipt?.to),
|
39082
|
+
from: hexOrZero(receipt.contract?.id),
|
39083
|
+
to: hexOrZero(receipt?.to?.id),
|
39099
39084
|
amount: bn(receipt.amount),
|
39100
39085
|
assetId: hexOrZero(receipt.assetId),
|
39101
39086
|
gas: bn(receipt.gas),
|
@@ -39109,7 +39094,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39109
39094
|
case "RETURN" /* Return */: {
|
39110
39095
|
const returnReceipt = {
|
39111
39096
|
type: ReceiptType.Return,
|
39112
|
-
id: hexOrZero(receipt.id
|
39097
|
+
id: hexOrZero(receipt.contract?.id),
|
39113
39098
|
val: bn(receipt.val),
|
39114
39099
|
pc: bn(receipt.pc),
|
39115
39100
|
is: bn(receipt.is)
|
@@ -39119,7 +39104,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39119
39104
|
case "RETURN_DATA" /* ReturnData */: {
|
39120
39105
|
const returnDataReceipt = {
|
39121
39106
|
type: ReceiptType.ReturnData,
|
39122
|
-
id: hexOrZero(receipt.id
|
39107
|
+
id: hexOrZero(receipt.contract?.id),
|
39123
39108
|
ptr: bn(receipt.ptr),
|
39124
39109
|
len: bn(receipt.len),
|
39125
39110
|
digest: hexOrZero(receipt.digest),
|
@@ -39131,7 +39116,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39131
39116
|
case "PANIC" /* Panic */: {
|
39132
39117
|
const panicReceipt = {
|
39133
39118
|
type: ReceiptType.Panic,
|
39134
|
-
id: hexOrZero(receipt.id),
|
39119
|
+
id: hexOrZero(receipt.contract?.id),
|
39135
39120
|
reason: bn(receipt.reason),
|
39136
39121
|
pc: bn(receipt.pc),
|
39137
39122
|
is: bn(receipt.is),
|
@@ -39142,7 +39127,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39142
39127
|
case "REVERT" /* Revert */: {
|
39143
39128
|
const revertReceipt = {
|
39144
39129
|
type: ReceiptType.Revert,
|
39145
|
-
id: hexOrZero(receipt.id
|
39130
|
+
id: hexOrZero(receipt.contract?.id),
|
39146
39131
|
val: bn(receipt.ra),
|
39147
39132
|
pc: bn(receipt.pc),
|
39148
39133
|
is: bn(receipt.is)
|
@@ -39152,7 +39137,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39152
39137
|
case "LOG" /* Log */: {
|
39153
39138
|
const logReceipt = {
|
39154
39139
|
type: ReceiptType.Log,
|
39155
|
-
id: hexOrZero(receipt.id
|
39140
|
+
id: hexOrZero(receipt.contract?.id),
|
39156
39141
|
val0: bn(receipt.ra),
|
39157
39142
|
val1: bn(receipt.rb),
|
39158
39143
|
val2: bn(receipt.rc),
|
@@ -39165,7 +39150,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39165
39150
|
case "LOG_DATA" /* LogData */: {
|
39166
39151
|
const logDataReceipt = {
|
39167
39152
|
type: ReceiptType.LogData,
|
39168
|
-
id: hexOrZero(receipt.id
|
39153
|
+
id: hexOrZero(receipt.contract?.id),
|
39169
39154
|
val0: bn(receipt.ra),
|
39170
39155
|
val1: bn(receipt.rb),
|
39171
39156
|
ptr: bn(receipt.ptr),
|
@@ -39179,8 +39164,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39179
39164
|
case "TRANSFER" /* Transfer */: {
|
39180
39165
|
const transferReceipt = {
|
39181
39166
|
type: ReceiptType.Transfer,
|
39182
|
-
from: hexOrZero(receipt.id
|
39183
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39167
|
+
from: hexOrZero(receipt.contract?.id),
|
39168
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39184
39169
|
amount: bn(receipt.amount),
|
39185
39170
|
assetId: hexOrZero(receipt.assetId),
|
39186
39171
|
pc: bn(receipt.pc),
|
@@ -39191,8 +39176,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39191
39176
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39192
39177
|
const transferOutReceipt = {
|
39193
39178
|
type: ReceiptType.TransferOut,
|
39194
|
-
from: hexOrZero(receipt.id
|
39195
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39179
|
+
from: hexOrZero(receipt.contract?.id),
|
39180
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39196
39181
|
amount: bn(receipt.amount),
|
39197
39182
|
assetId: hexOrZero(receipt.assetId),
|
39198
39183
|
pc: bn(receipt.pc),
|
@@ -39235,7 +39220,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39235
39220
|
return receiptMessageOut;
|
39236
39221
|
}
|
39237
39222
|
case "MINT" /* Mint */: {
|
39238
|
-
const contractId = hexOrZero(receipt.id
|
39223
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39239
39224
|
const subId = hexOrZero(receipt.subId);
|
39240
39225
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39241
39226
|
const mintReceipt = {
|
@@ -39250,7 +39235,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39250
39235
|
return mintReceipt;
|
39251
39236
|
}
|
39252
39237
|
case "BURN" /* Burn */: {
|
39253
|
-
const contractId = hexOrZero(receipt.id
|
39238
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39254
39239
|
const subId = hexOrZero(receipt.subId);
|
39255
39240
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39256
39241
|
const burnReceipt = {
|
@@ -39331,6 +39316,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39331
39316
|
};
|
39332
39317
|
|
39333
39318
|
// src/providers/utils/gas.ts
|
39319
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39334
39320
|
var getGasUsedFromReceipts = (receipts) => {
|
39335
39321
|
const scriptResult = receipts.filter(
|
39336
39322
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39351,28 +39337,18 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39351
39337
|
}
|
39352
39338
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39353
39339
|
const witnessCache = [];
|
39354
|
-
const
|
39355
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39356
|
-
if (isCoinOrMessage) {
|
39357
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39358
|
-
return true;
|
39359
|
-
}
|
39360
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39361
|
-
witnessCache.push(input.witnessIndex);
|
39362
|
-
return true;
|
39363
|
-
}
|
39364
|
-
}
|
39365
|
-
return false;
|
39366
|
-
});
|
39367
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39368
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39340
|
+
const totalGas = inputs.reduce((total, input) => {
|
39369
39341
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39370
39342
|
return total.add(
|
39371
|
-
|
39343
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39372
39344
|
);
|
39373
39345
|
}
|
39374
|
-
|
39375
|
-
|
39346
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39347
|
+
witnessCache.push(input.witnessIndex);
|
39348
|
+
return total.add(gasCosts.ecr1);
|
39349
|
+
}
|
39350
|
+
return total;
|
39351
|
+
}, bn());
|
39376
39352
|
return totalGas;
|
39377
39353
|
}
|
39378
39354
|
function getMinGas(params) {
|
@@ -39384,20 +39360,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39384
39360
|
return minGas;
|
39385
39361
|
}
|
39386
39362
|
function getMaxGas(params) {
|
39387
|
-
const {
|
39388
|
-
gasPerByte,
|
39389
|
-
witnessesLength,
|
39390
|
-
witnessLimit,
|
39391
|
-
minGas,
|
39392
|
-
gasLimit = bn(0),
|
39393
|
-
maxGasPerTx
|
39394
|
-
} = params;
|
39363
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39395
39364
|
let remainingAllowedWitnessGas = bn(0);
|
39396
39365
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39397
39366
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39398
39367
|
}
|
39399
|
-
|
39400
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39368
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39401
39369
|
}
|
39402
39370
|
function calculateMetadataGasForTxCreate({
|
39403
39371
|
gasCosts,
|
@@ -39419,10 +39387,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39419
39387
|
}) {
|
39420
39388
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39421
39389
|
}
|
39422
|
-
var calculateGasFee = (params) => {
|
39423
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39424
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39425
|
-
};
|
39426
39390
|
|
39427
39391
|
// src/providers/utils/json.ts
|
39428
39392
|
function normalize2(object) {
|
@@ -39564,7 +39528,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39564
39528
|
// src/providers/transaction-request/transaction-request.ts
|
39565
39529
|
var BaseTransactionRequest = class {
|
39566
39530
|
/** Gas price for transaction */
|
39567
|
-
|
39531
|
+
gasPrice;
|
39568
39532
|
/** Block until which tx cannot be included */
|
39569
39533
|
maturity;
|
39570
39534
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39583,7 +39547,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39583
39547
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39584
39548
|
*/
|
39585
39549
|
constructor({
|
39586
|
-
|
39550
|
+
gasPrice,
|
39587
39551
|
maturity,
|
39588
39552
|
maxFee,
|
39589
39553
|
witnessLimit,
|
@@ -39591,7 +39555,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39591
39555
|
outputs,
|
39592
39556
|
witnesses
|
39593
39557
|
} = {}) {
|
39594
|
-
this.
|
39558
|
+
this.gasPrice = bn(gasPrice);
|
39595
39559
|
this.maturity = maturity ?? 0;
|
39596
39560
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39597
39561
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -39602,9 +39566,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39602
39566
|
static getPolicyMeta(req) {
|
39603
39567
|
let policyTypes = 0;
|
39604
39568
|
const policies = [];
|
39605
|
-
if (req.
|
39606
|
-
policyTypes += PolicyType.
|
39607
|
-
policies.push({ data: req.
|
39569
|
+
if (req.gasPrice) {
|
39570
|
+
policyTypes += PolicyType.GasPrice;
|
39571
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39608
39572
|
}
|
39609
39573
|
if (req.witnessLimit) {
|
39610
39574
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39791,10 +39755,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39791
39755
|
* @param predicate - Predicate bytes.
|
39792
39756
|
* @param predicateData - Predicate data bytes.
|
39793
39757
|
*/
|
39794
|
-
addCoinInput(coin) {
|
39758
|
+
addCoinInput(coin, predicate) {
|
39795
39759
|
const { assetId, owner, amount } = coin;
|
39796
39760
|
let witnessIndex;
|
39797
|
-
if (
|
39761
|
+
if (predicate) {
|
39798
39762
|
witnessIndex = 0;
|
39799
39763
|
} else {
|
39800
39764
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39809,7 +39773,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39809
39773
|
amount,
|
39810
39774
|
assetId,
|
39811
39775
|
txPointer: "0x00000000000000000000000000000000",
|
39812
|
-
witnessIndex
|
39776
|
+
witnessIndex,
|
39777
|
+
predicate: predicate?.bytes,
|
39778
|
+
predicateData: predicate?.predicateDataBytes
|
39813
39779
|
};
|
39814
39780
|
this.pushInput(input);
|
39815
39781
|
this.addChangeOutput(owner, assetId);
|
@@ -39822,11 +39788,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39822
39788
|
* @param predicate - Predicate bytes.
|
39823
39789
|
* @param predicateData - Predicate data bytes.
|
39824
39790
|
*/
|
39825
|
-
addMessageInput(message) {
|
39791
|
+
addMessageInput(message, predicate) {
|
39826
39792
|
const { recipient, sender, amount } = message;
|
39827
39793
|
const assetId = BaseAssetId;
|
39828
39794
|
let witnessIndex;
|
39829
|
-
if (
|
39795
|
+
if (predicate) {
|
39830
39796
|
witnessIndex = 0;
|
39831
39797
|
} else {
|
39832
39798
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39840,7 +39806,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39840
39806
|
sender: sender.toB256(),
|
39841
39807
|
recipient: recipient.toB256(),
|
39842
39808
|
amount,
|
39843
|
-
witnessIndex
|
39809
|
+
witnessIndex,
|
39810
|
+
predicate: predicate?.bytes,
|
39811
|
+
predicateData: predicate?.predicateDataBytes
|
39844
39812
|
};
|
39845
39813
|
this.pushInput(input);
|
39846
39814
|
this.addChangeOutput(recipient, assetId);
|
@@ -39871,6 +39839,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39871
39839
|
resources.forEach((resource) => this.addResource(resource));
|
39872
39840
|
return this;
|
39873
39841
|
}
|
39842
|
+
/**
|
39843
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39844
|
+
* outputs from the related assetIds.
|
39845
|
+
*
|
39846
|
+
* @param resources - The resources to add.
|
39847
|
+
* @returns This transaction.
|
39848
|
+
*/
|
39849
|
+
addPredicateResource(resource, predicate) {
|
39850
|
+
if (isCoin(resource)) {
|
39851
|
+
this.addCoinInput(resource, predicate);
|
39852
|
+
} else {
|
39853
|
+
this.addMessageInput(resource, predicate);
|
39854
|
+
}
|
39855
|
+
return this;
|
39856
|
+
}
|
39857
|
+
/**
|
39858
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39859
|
+
* from the related assetIds.
|
39860
|
+
*
|
39861
|
+
* @param resources - The resources to add.
|
39862
|
+
* @returns This transaction.
|
39863
|
+
*/
|
39864
|
+
addPredicateResources(resources, predicate) {
|
39865
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39866
|
+
return this;
|
39867
|
+
}
|
39874
39868
|
/**
|
39875
39869
|
* Adds a coin output to the transaction.
|
39876
39870
|
*
|
@@ -39950,7 +39944,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39950
39944
|
}
|
39951
39945
|
calculateMaxGas(chainInfo, minGas) {
|
39952
39946
|
const { consensusParameters } = chainInfo;
|
39953
|
-
const { gasPerByte
|
39947
|
+
const { gasPerByte } = consensusParameters;
|
39954
39948
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
39955
39949
|
(acc, wit) => acc + wit.dataLength,
|
39956
39950
|
0
|
@@ -39959,8 +39953,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39959
39953
|
gasPerByte,
|
39960
39954
|
minGas,
|
39961
39955
|
witnessesLength,
|
39962
|
-
witnessLimit: this.witnessLimit
|
39963
|
-
maxGasPerTx
|
39956
|
+
witnessLimit: this.witnessLimit
|
39964
39957
|
});
|
39965
39958
|
}
|
39966
39959
|
/**
|
@@ -39970,6 +39963,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39970
39963
|
* @param quantities - CoinQuantity Array.
|
39971
39964
|
*/
|
39972
39965
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39966
|
+
let idCounter = 0;
|
39967
|
+
const generateId = () => {
|
39968
|
+
const counterString = String(idCounter++);
|
39969
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39970
|
+
return id;
|
39971
|
+
};
|
39973
39972
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39974
39973
|
if ("assetId" in input) {
|
39975
39974
|
return input.assetId === assetId;
|
@@ -39978,20 +39977,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39978
39977
|
});
|
39979
39978
|
const updateAssetInput = (assetId, quantity) => {
|
39980
39979
|
const assetInput = findAssetInput(assetId);
|
39981
|
-
let usedQuantity = quantity;
|
39982
|
-
if (assetId === BaseAssetId) {
|
39983
|
-
usedQuantity = bn("1000000000000000000");
|
39984
|
-
}
|
39985
39980
|
if (assetInput && "assetId" in assetInput) {
|
39986
|
-
assetInput.id =
|
39987
|
-
assetInput.amount =
|
39981
|
+
assetInput.id = generateId();
|
39982
|
+
assetInput.amount = quantity;
|
39988
39983
|
} else {
|
39989
39984
|
this.addResources([
|
39990
39985
|
{
|
39991
|
-
id:
|
39992
|
-
amount:
|
39986
|
+
id: generateId(),
|
39987
|
+
amount: quantity,
|
39993
39988
|
assetId,
|
39994
39989
|
owner: resourcesOwner || Address.fromRandom(),
|
39990
|
+
maturity: 0,
|
39995
39991
|
blockCreated: bn(1),
|
39996
39992
|
txCreatedIdx: bn(1)
|
39997
39993
|
}
|
@@ -40023,7 +40019,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40023
40019
|
toJSON() {
|
40024
40020
|
return normalizeJSON(this);
|
40025
40021
|
}
|
40026
|
-
|
40022
|
+
updatePredicateInputs(inputs) {
|
40027
40023
|
this.inputs.forEach((i) => {
|
40028
40024
|
let correspondingInput;
|
40029
40025
|
switch (i.type) {
|
@@ -40045,15 +40041,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40045
40041
|
}
|
40046
40042
|
});
|
40047
40043
|
}
|
40048
|
-
shiftPredicateData() {
|
40049
|
-
this.inputs.forEach((input) => {
|
40050
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40051
|
-
input.predicateData = input.paddPredicateData(
|
40052
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40053
|
-
);
|
40054
|
-
}
|
40055
|
-
});
|
40056
|
-
}
|
40057
40044
|
};
|
40058
40045
|
|
40059
40046
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40368,7 +40355,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40368
40355
|
}
|
40369
40356
|
calculateMaxGas(chainInfo, minGas) {
|
40370
40357
|
const { consensusParameters } = chainInfo;
|
40371
|
-
const { gasPerByte
|
40358
|
+
const { gasPerByte } = consensusParameters;
|
40372
40359
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40373
40360
|
(acc, wit) => acc + wit.dataLength,
|
40374
40361
|
0
|
@@ -40378,8 +40365,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40378
40365
|
minGas,
|
40379
40366
|
witnessesLength,
|
40380
40367
|
witnessLimit: this.witnessLimit,
|
40381
|
-
gasLimit: this.gasLimit
|
40382
|
-
maxGasPerTx
|
40368
|
+
gasLimit: this.gasLimit
|
40383
40369
|
});
|
40384
40370
|
}
|
40385
40371
|
/**
|
@@ -40452,29 +40438,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40452
40438
|
}
|
40453
40439
|
}
|
40454
40440
|
};
|
40455
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40456
|
-
(acc, input) => {
|
40457
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40458
|
-
acc.utxos.push(input.id);
|
40459
|
-
}
|
40460
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40461
|
-
acc.messages.push(input.nonce);
|
40462
|
-
}
|
40463
|
-
return acc;
|
40464
|
-
},
|
40465
|
-
{
|
40466
|
-
utxos: [],
|
40467
|
-
messages: []
|
40468
|
-
}
|
40469
|
-
);
|
40470
40441
|
|
40471
40442
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40472
40443
|
var calculateTransactionFee = (params) => {
|
40473
40444
|
const {
|
40474
|
-
|
40445
|
+
gasUsed,
|
40475
40446
|
rawPayload,
|
40476
|
-
|
40477
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40447
|
+
consensusParameters: { gasCosts, feeParams }
|
40478
40448
|
} = params;
|
40479
40449
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40480
40450
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40484,7 +40454,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40484
40454
|
return {
|
40485
40455
|
fee: bn(0),
|
40486
40456
|
minFee: bn(0),
|
40487
|
-
maxFee: bn(0)
|
40457
|
+
maxFee: bn(0),
|
40458
|
+
feeFromGasUsed: bn(0)
|
40488
40459
|
};
|
40489
40460
|
}
|
40490
40461
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40516,6 +40487,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40516
40487
|
metadataGas,
|
40517
40488
|
txBytesSize: transactionBytes.length
|
40518
40489
|
});
|
40490
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40519
40491
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40520
40492
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40521
40493
|
const maxGas = getMaxGas({
|
@@ -40523,25 +40495,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40523
40495
|
minGas,
|
40524
40496
|
witnessesLength,
|
40525
40497
|
gasLimit,
|
40526
|
-
witnessLimit
|
40527
|
-
maxGasPerTx
|
40528
|
-
});
|
40529
|
-
const minFee = calculateGasFee({
|
40530
|
-
gasPrice,
|
40531
|
-
gas: minGas,
|
40532
|
-
priceFactor: gasPriceFactor,
|
40533
|
-
tip
|
40534
|
-
});
|
40535
|
-
const maxFee = calculateGasFee({
|
40536
|
-
gasPrice,
|
40537
|
-
gas: maxGas,
|
40538
|
-
priceFactor: gasPriceFactor,
|
40539
|
-
tip
|
40498
|
+
witnessLimit
|
40540
40499
|
});
|
40500
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40501
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40502
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40503
|
+
const fee = minFee.add(feeFromGasUsed);
|
40541
40504
|
return {
|
40505
|
+
fee,
|
40542
40506
|
minFee,
|
40543
40507
|
maxFee,
|
40544
|
-
|
40508
|
+
feeFromGasUsed
|
40545
40509
|
};
|
40546
40510
|
};
|
40547
40511
|
|
@@ -41142,9 +41106,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41142
41106
|
gqlTransactionStatus,
|
41143
41107
|
abiMap = {},
|
41144
41108
|
maxInputs,
|
41145
|
-
gasCosts
|
41146
|
-
maxGasPerTx,
|
41147
|
-
gasPrice
|
41109
|
+
gasCosts
|
41148
41110
|
} = params;
|
41149
41111
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41150
41112
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41158,14 +41120,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41158
41120
|
maxInputs
|
41159
41121
|
});
|
41160
41122
|
const typeName = getTransactionTypeName(transaction.type);
|
41161
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41162
41123
|
const { fee } = calculateTransactionFee({
|
41163
|
-
|
41124
|
+
gasUsed,
|
41164
41125
|
rawPayload,
|
41165
|
-
tip,
|
41166
41126
|
consensusParameters: {
|
41167
41127
|
gasCosts,
|
41168
|
-
maxGasPerTx,
|
41169
41128
|
feeParams: {
|
41170
41129
|
gasPerByte,
|
41171
41130
|
gasPriceFactor
|
@@ -41301,13 +41260,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41301
41260
|
const decodedTransaction = this.decodeTransaction(
|
41302
41261
|
transaction
|
41303
41262
|
);
|
41304
|
-
|
41305
|
-
|
41306
|
-
txReceipts = transaction.status.receipts;
|
41307
|
-
}
|
41308
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41309
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41310
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41263
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41264
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41311
41265
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41312
41266
|
const transactionSummary = assembleTransactionSummary({
|
41313
41267
|
id: this.id,
|
@@ -41319,9 +41273,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41319
41273
|
gasPriceFactor,
|
41320
41274
|
abiMap: contractsAbiMap,
|
41321
41275
|
maxInputs,
|
41322
|
-
gasCosts
|
41323
|
-
maxGasPerTx,
|
41324
|
-
gasPrice
|
41276
|
+
gasCosts
|
41325
41277
|
});
|
41326
41278
|
return transactionSummary;
|
41327
41279
|
}
|
@@ -41470,7 +41422,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41470
41422
|
gasCosts,
|
41471
41423
|
latestBlock: {
|
41472
41424
|
id: latestBlock.id,
|
41473
|
-
height: bn(latestBlock.height),
|
41425
|
+
height: bn(latestBlock.header.height),
|
41474
41426
|
time: latestBlock.header.time,
|
41475
41427
|
transactions: latestBlock.transactions.map((i) => ({
|
41476
41428
|
id: i.id
|
@@ -41665,7 +41617,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41665
41617
|
*/
|
41666
41618
|
async getBlockNumber() {
|
41667
41619
|
const { chain } = await this.operations.getChain();
|
41668
|
-
return bn(chain.latestBlock.height, 10);
|
41620
|
+
return bn(chain.latestBlock.header.height, 10);
|
41669
41621
|
}
|
41670
41622
|
/**
|
41671
41623
|
* Returns the chain information.
|
@@ -41680,7 +41632,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41680
41632
|
minGasPrice: bn(nodeInfo.minGasPrice),
|
41681
41633
|
nodeVersion: nodeInfo.nodeVersion,
|
41682
41634
|
utxoValidation: nodeInfo.utxoValidation,
|
41683
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41635
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41636
|
+
peers: nodeInfo.peers
|
41684
41637
|
};
|
41685
41638
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41686
41639
|
return processedNodeInfo;
|
@@ -41766,13 +41719,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41766
41719
|
return this.estimateTxDependencies(transactionRequest);
|
41767
41720
|
}
|
41768
41721
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41769
|
-
const { dryRun:
|
41770
|
-
|
41722
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41723
|
+
encodedTransaction,
|
41771
41724
|
utxoValidation: utxoValidation || false
|
41772
41725
|
});
|
41773
|
-
const
|
41774
|
-
|
41775
|
-
|
41726
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41727
|
+
return {
|
41728
|
+
receipts
|
41729
|
+
};
|
41776
41730
|
}
|
41777
41731
|
/**
|
41778
41732
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41811,6 +41765,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41811
41765
|
* If there are missing variable outputs,
|
41812
41766
|
* `addVariableOutputs` is called on the transaction.
|
41813
41767
|
*
|
41768
|
+
* @privateRemarks
|
41769
|
+
* TODO: Investigate support for missing contract IDs
|
41770
|
+
* TODO: Add support for missing output messages
|
41814
41771
|
*
|
41815
41772
|
* @param transactionRequest - The transaction request object.
|
41816
41773
|
* @returns A promise.
|
@@ -41823,19 +41780,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41823
41780
|
missingContractIds: []
|
41824
41781
|
};
|
41825
41782
|
}
|
41783
|
+
await this.estimatePredicates(transactionRequest);
|
41826
41784
|
let receipts = [];
|
41827
41785
|
const missingContractIds = [];
|
41828
41786
|
let outputVariables = 0;
|
41829
|
-
let dryrunStatus;
|
41830
41787
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41831
|
-
const {
|
41832
|
-
|
41833
|
-
} = await this.operations.dryRun({
|
41834
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41788
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41789
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41835
41790
|
utxoValidation: false
|
41836
41791
|
});
|
41837
|
-
receipts =
|
41838
|
-
dryrunStatus = status;
|
41792
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41839
41793
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41840
41794
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41841
41795
|
if (hasMissingOutputs) {
|
@@ -41845,11 +41799,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41845
41799
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41846
41800
|
missingContractIds.push(contractId);
|
41847
41801
|
});
|
41848
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41849
|
-
transactionRequest,
|
41850
|
-
optimizeGas: false
|
41851
|
-
});
|
41852
|
-
transactionRequest.maxFee = maxFee;
|
41853
41802
|
} else {
|
41854
41803
|
break;
|
41855
41804
|
}
|
@@ -41857,133 +41806,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41857
41806
|
return {
|
41858
41807
|
receipts,
|
41859
41808
|
outputVariables,
|
41860
|
-
missingContractIds
|
41861
|
-
dryrunStatus
|
41862
|
-
};
|
41863
|
-
}
|
41864
|
-
/**
|
41865
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41866
|
-
*
|
41867
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41868
|
-
* further modifications are identified. The method iteratively updates these transactions
|
41869
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41870
|
-
*
|
41871
|
-
* @param transactionRequests - Array of transaction request objects.
|
41872
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
41873
|
-
*/
|
41874
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41875
|
-
const results = transactionRequests.map(() => ({
|
41876
|
-
receipts: [],
|
41877
|
-
outputVariables: 0,
|
41878
|
-
missingContractIds: [],
|
41879
|
-
dryrunStatus: void 0
|
41880
|
-
}));
|
41881
|
-
const allRequests = clone_default(transactionRequests);
|
41882
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41883
|
-
allRequests.forEach((req, index) => {
|
41884
|
-
if (req.type === TransactionType.Script) {
|
41885
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41886
|
-
}
|
41887
|
-
});
|
41888
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41889
|
-
let attempt = 0;
|
41890
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41891
|
-
const encodedTransactions = transactionsToProcess.map(
|
41892
|
-
(index) => serializedTransactionsMap.get(index)
|
41893
|
-
);
|
41894
|
-
const dryRunResults = await this.operations.dryRun({
|
41895
|
-
encodedTransactions,
|
41896
|
-
utxoValidation: false
|
41897
|
-
});
|
41898
|
-
const nextRoundTransactions = [];
|
41899
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41900
|
-
const currentResultIndex = transactionsToProcess[i];
|
41901
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41902
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41903
|
-
results[currentResultIndex].dryrunStatus = status;
|
41904
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41905
|
-
results[currentResultIndex].receipts
|
41906
|
-
);
|
41907
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41908
|
-
const requestToProcess = allRequests[currentResultIndex];
|
41909
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41910
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41911
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41912
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41913
|
-
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41914
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
41915
|
-
});
|
41916
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41917
|
-
transactionRequest: requestToProcess,
|
41918
|
-
optimizeGas: false
|
41919
|
-
});
|
41920
|
-
requestToProcess.maxFee = maxFee;
|
41921
|
-
serializedTransactionsMap.set(
|
41922
|
-
currentResultIndex,
|
41923
|
-
hexlify(requestToProcess.toTransactionBytes())
|
41924
|
-
);
|
41925
|
-
nextRoundTransactions.push(currentResultIndex);
|
41926
|
-
allRequests[currentResultIndex] = requestToProcess;
|
41927
|
-
}
|
41928
|
-
}
|
41929
|
-
transactionsToProcess = nextRoundTransactions;
|
41930
|
-
attempt += 1;
|
41931
|
-
}
|
41932
|
-
return results;
|
41933
|
-
}
|
41934
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41935
|
-
if (estimateTxDependencies) {
|
41936
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
41937
|
-
}
|
41938
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
41939
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41940
|
-
encodedTransactions,
|
41941
|
-
utxoValidation: utxoValidation || false
|
41942
|
-
});
|
41943
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
41944
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
41945
|
-
return { receipts, dryrunStatus: status };
|
41946
|
-
});
|
41947
|
-
return results;
|
41948
|
-
}
|
41949
|
-
async estimateTxGasAndFee(params) {
|
41950
|
-
const { transactionRequest, totalGasUsedByPredicates = bn(0), optimizeGas = true } = params;
|
41951
|
-
let { gasPrice } = params;
|
41952
|
-
const chainInfo = this.getChain();
|
41953
|
-
const { gasPriceFactor } = this.getGasConfig();
|
41954
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41955
|
-
if (!gasPrice) {
|
41956
|
-
gasPrice = await this.estimateGasPrice(10);
|
41957
|
-
}
|
41958
|
-
const shouldSetGaslimit = transactionRequest.type === TransactionType.Script && !optimizeGas;
|
41959
|
-
const minFee = calculateGasFee({
|
41960
|
-
gasPrice: bn(gasPrice),
|
41961
|
-
gas: minGas,
|
41962
|
-
priceFactor: gasPriceFactor,
|
41963
|
-
tip: transactionRequest.tip
|
41964
|
-
}).add(1);
|
41965
|
-
if (shouldSetGaslimit) {
|
41966
|
-
transactionRequest.gasLimit = chainInfo.consensusParameters.maxGasPerTx.sub(
|
41967
|
-
minGas.add(totalGasUsedByPredicates)
|
41968
|
-
);
|
41969
|
-
}
|
41970
|
-
let maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41971
|
-
const maxFee = calculateGasFee({
|
41972
|
-
gasPrice: bn(gasPrice),
|
41973
|
-
gas: maxGas,
|
41974
|
-
priceFactor: gasPriceFactor,
|
41975
|
-
tip: transactionRequest.tip
|
41976
|
-
}).add(1);
|
41977
|
-
if (shouldSetGaslimit) {
|
41978
|
-
maxGas = chainInfo.consensusParameters.maxGasPerTx.sub(maxFee);
|
41979
|
-
transactionRequest.gasLimit = maxGas;
|
41980
|
-
}
|
41981
|
-
return {
|
41982
|
-
minGas,
|
41983
|
-
minFee,
|
41984
|
-
maxGas,
|
41985
|
-
maxFee,
|
41986
|
-
gasPrice
|
41809
|
+
missingContractIds
|
41987
41810
|
};
|
41988
41811
|
}
|
41989
41812
|
/**
|
@@ -42001,17 +41824,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42001
41824
|
if (estimateTxDependencies) {
|
42002
41825
|
return this.estimateTxDependencies(transactionRequest);
|
42003
41826
|
}
|
42004
|
-
const
|
42005
|
-
const { dryRun:
|
42006
|
-
|
41827
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41828
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41829
|
+
encodedTransaction,
|
42007
41830
|
utxoValidation: true
|
42008
41831
|
});
|
42009
|
-
const
|
42010
|
-
|
42011
|
-
|
42012
|
-
|
42013
|
-
});
|
42014
|
-
return { receipts: callResult[0].receipts };
|
41832
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41833
|
+
return {
|
41834
|
+
receipts
|
41835
|
+
};
|
42015
41836
|
}
|
42016
41837
|
/**
|
42017
41838
|
* Returns a transaction cost to enable user
|
@@ -42028,80 +41849,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42028
41849
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42029
41850
|
* @returns A promise that resolves to the transaction cost object.
|
42030
41851
|
*/
|
42031
|
-
async getTransactionCost(transactionRequestLike,
|
41852
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41853
|
+
estimateTxDependencies = true,
|
41854
|
+
estimatePredicates = true,
|
41855
|
+
resourcesOwner,
|
41856
|
+
signatureCallback
|
41857
|
+
} = {}) {
|
42032
41858
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41859
|
+
const chainInfo = this.getChain();
|
41860
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41861
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42033
41862
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42034
41863
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42035
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41864
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42036
41865
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42037
|
-
|
42038
|
-
|
42039
|
-
|
42040
|
-
|
42041
|
-
|
42042
|
-
|
41866
|
+
if (estimatePredicates) {
|
41867
|
+
if (isScriptTransaction) {
|
41868
|
+
txRequestClone.gasLimit = bn(0);
|
41869
|
+
}
|
41870
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41871
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41872
|
+
}
|
41873
|
+
await this.estimatePredicates(txRequestClone);
|
42043
41874
|
}
|
42044
|
-
const signedRequest = clone_default(txRequestClone);
|
42045
|
-
let addedSignatures = 0;
|
42046
41875
|
if (signatureCallback && isScriptTransaction) {
|
42047
|
-
|
42048
|
-
|
42049
|
-
|
42050
|
-
|
42051
|
-
await this.estimatePredicates(signedRequest);
|
42052
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42053
|
-
transactionRequest: signedRequest,
|
42054
|
-
optimizeGas: false
|
42055
|
-
});
|
42056
|
-
txRequestClone.maxFee = maxFee;
|
41876
|
+
await signatureCallback(txRequestClone);
|
41877
|
+
}
|
41878
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41879
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
42057
41880
|
let receipts = [];
|
42058
41881
|
let missingContractIds = [];
|
42059
41882
|
let outputVariables = 0;
|
42060
|
-
|
42061
|
-
|
42062
|
-
|
42063
|
-
if (signatureCallback) {
|
42064
|
-
await signatureCallback(txRequestClone);
|
42065
|
-
}
|
42066
|
-
txRequestClone.gasLimit = maxGas;
|
41883
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41884
|
+
txRequestClone.gasPrice = bn(0);
|
41885
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
42067
41886
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42068
41887
|
receipts = result.receipts;
|
42069
41888
|
outputVariables = result.outputVariables;
|
42070
41889
|
missingContractIds = result.missingContractIds;
|
42071
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
42072
|
-
txRequestClone.gasLimit = gasUsed;
|
42073
|
-
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42074
|
-
transactionRequest: txRequestClone,
|
42075
|
-
gasPrice
|
42076
|
-
}));
|
42077
41890
|
}
|
41891
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41892
|
+
const usedFee = calculatePriceWithFactor(
|
41893
|
+
gasUsed,
|
41894
|
+
gasPrice,
|
41895
|
+
gasPriceFactor
|
41896
|
+
).normalizeZeroToOne();
|
41897
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41898
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42078
41899
|
return {
|
42079
41900
|
requiredQuantities: allQuantities,
|
42080
41901
|
receipts,
|
42081
41902
|
gasUsed,
|
41903
|
+
minGasPrice,
|
42082
41904
|
gasPrice,
|
42083
41905
|
minGas,
|
42084
41906
|
maxGas,
|
41907
|
+
usedFee,
|
42085
41908
|
minFee,
|
42086
41909
|
maxFee,
|
41910
|
+
estimatedInputs: txRequestClone.inputs,
|
42087
41911
|
outputVariables,
|
42088
|
-
missingContractIds
|
42089
|
-
addedSignatures,
|
42090
|
-
estimatedPredicates: txRequestClone.inputs
|
41912
|
+
missingContractIds
|
42091
41913
|
};
|
42092
41914
|
}
|
42093
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41915
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42094
41916
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42095
41917
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42096
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42097
|
-
quantitiesToContract
|
42098
|
-
});
|
41918
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42099
41919
|
transactionRequest.addResources(
|
42100
41920
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42101
41921
|
);
|
42102
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42103
|
-
|
42104
|
-
|
41922
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41923
|
+
transactionRequest,
|
41924
|
+
forwardingQuantities
|
41925
|
+
);
|
42105
41926
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42106
41927
|
return {
|
42107
41928
|
resources,
|
@@ -42125,6 +41946,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42125
41946
|
assetId: coin.assetId,
|
42126
41947
|
amount: bn(coin.amount),
|
42127
41948
|
owner: Address.fromAddressOrString(coin.owner),
|
41949
|
+
maturity: bn(coin.maturity).toNumber(),
|
42128
41950
|
blockCreated: bn(coin.blockCreated),
|
42129
41951
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42130
41952
|
}));
|
@@ -42176,6 +41998,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42176
41998
|
amount: bn(coin.amount),
|
42177
41999
|
assetId: coin.assetId,
|
42178
42000
|
owner: Address.fromAddressOrString(coin.owner),
|
42001
|
+
maturity: bn(coin.maturity).toNumber(),
|
42179
42002
|
blockCreated: bn(coin.blockCreated),
|
42180
42003
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42181
42004
|
};
|
@@ -42208,7 +42031,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42208
42031
|
}
|
42209
42032
|
return {
|
42210
42033
|
id: block2.id,
|
42211
|
-
height: bn(block2.height),
|
42034
|
+
height: bn(block2.header.height),
|
42212
42035
|
time: block2.header.time,
|
42213
42036
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42214
42037
|
};
|
@@ -42223,7 +42046,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42223
42046
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42224
42047
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42225
42048
|
id: block2.id,
|
42226
|
-
height: bn(block2.height),
|
42049
|
+
height: bn(block2.header.height),
|
42227
42050
|
time: block2.header.time,
|
42228
42051
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42229
42052
|
}));
|
@@ -42250,7 +42073,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42250
42073
|
}
|
42251
42074
|
return {
|
42252
42075
|
id: block2.id,
|
42253
|
-
height: bn(block2.height, 10),
|
42076
|
+
height: bn(block2.header.height, 10),
|
42254
42077
|
time: block2.header.time,
|
42255
42078
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42256
42079
|
transactions: block2.transactions.map(
|
@@ -42452,16 +42275,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42452
42275
|
data
|
42453
42276
|
};
|
42454
42277
|
}
|
42455
|
-
async getLatestGasPrice() {
|
42456
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42457
|
-
return bn(latestGasPrice.gasPrice);
|
42458
|
-
}
|
42459
|
-
async estimateGasPrice(blockHorizon) {
|
42460
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42461
|
-
blockHorizon: String(blockHorizon)
|
42462
|
-
});
|
42463
|
-
return bn(estimateGasPrice.gasPrice);
|
42464
|
-
}
|
42465
42278
|
/**
|
42466
42279
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42467
42280
|
*
|
@@ -42522,15 +42335,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42522
42335
|
arrayify(gqlTransaction.rawPayload),
|
42523
42336
|
0
|
42524
42337
|
);
|
42525
|
-
|
42526
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42527
|
-
txReceipts = gqlTransaction.status.receipts;
|
42528
|
-
}
|
42529
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42338
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42530
42339
|
const {
|
42531
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42340
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42532
42341
|
} = provider.getChain();
|
42533
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42534
42342
|
const transactionInfo = assembleTransactionSummary({
|
42535
42343
|
id: gqlTransaction.id,
|
42536
42344
|
receipts,
|
@@ -42541,9 +42349,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42541
42349
|
gasPriceFactor: bn(gasPriceFactor),
|
42542
42350
|
abiMap,
|
42543
42351
|
maxInputs,
|
42544
|
-
gasCosts
|
42545
|
-
maxGasPerTx,
|
42546
|
-
gasPrice
|
42352
|
+
gasCosts
|
42547
42353
|
});
|
42548
42354
|
return {
|
42549
42355
|
gqlTransaction,
|
@@ -42553,11 +42359,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42553
42359
|
async function getTransactionSummaryFromRequest(params) {
|
42554
42360
|
const { provider, transactionRequest, abiMap } = params;
|
42555
42361
|
const { receipts } = await provider.call(transactionRequest);
|
42556
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42362
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42557
42363
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42558
42364
|
const transaction = transactionRequest.toTransaction();
|
42559
42365
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42560
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42561
42366
|
const transactionSummary = assembleTransactionSummary({
|
42562
42367
|
receipts,
|
42563
42368
|
transaction,
|
@@ -42566,9 +42371,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42566
42371
|
gasPerByte,
|
42567
42372
|
gasPriceFactor,
|
42568
42373
|
maxInputs,
|
42569
|
-
gasCosts
|
42570
|
-
maxGasPerTx,
|
42571
|
-
gasPrice
|
42374
|
+
gasCosts
|
42572
42375
|
});
|
42573
42376
|
return transactionSummary;
|
42574
42377
|
}
|
@@ -42577,18 +42380,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42577
42380
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42578
42381
|
const { edges, pageInfo } = transactionsByOwner;
|
42579
42382
|
const {
|
42580
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42383
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42581
42384
|
} = provider.getChain();
|
42582
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42583
42385
|
const transactions = edges.map((edge) => {
|
42584
42386
|
const { node: gqlTransaction } = edge;
|
42585
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42387
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42586
42388
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42587
|
-
|
42588
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42589
|
-
txReceipts = gqlTransaction.status.receipts;
|
42590
|
-
}
|
42591
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42389
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42592
42390
|
const transactionSummary = assembleTransactionSummary({
|
42593
42391
|
id,
|
42594
42392
|
receipts,
|
@@ -42599,9 +42397,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42599
42397
|
gasPerByte,
|
42600
42398
|
gasPriceFactor,
|
42601
42399
|
maxInputs,
|
42602
|
-
gasCosts
|
42603
|
-
maxGasPerTx,
|
42604
|
-
gasPrice
|
42400
|
+
gasCosts
|
42605
42401
|
});
|
42606
42402
|
const output3 = {
|
42607
42403
|
gqlTransaction,
|
@@ -42930,33 +42726,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42930
42726
|
* @param fee - The estimated transaction fee.
|
42931
42727
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42932
42728
|
*/
|
42933
|
-
async fund(request,
|
42934
|
-
const
|
42935
|
-
const txRequest = request;
|
42936
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42729
|
+
async fund(request, coinQuantities, fee) {
|
42730
|
+
const updatedQuantities = addAmountToAsset({
|
42937
42731
|
amount: bn(fee),
|
42938
42732
|
assetId: BaseAssetId,
|
42939
|
-
coinQuantities
|
42733
|
+
coinQuantities
|
42940
42734
|
});
|
42941
42735
|
const quantitiesDict = {};
|
42942
|
-
|
42736
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
42943
42737
|
quantitiesDict[assetId] = {
|
42944
42738
|
required: amount,
|
42945
42739
|
owned: bn(0)
|
42946
42740
|
};
|
42947
42741
|
});
|
42948
|
-
|
42742
|
+
const cachedUtxos = [];
|
42743
|
+
const cachedMessages = [];
|
42744
|
+
const owner = this.address.toB256();
|
42745
|
+
request.inputs.forEach((input) => {
|
42949
42746
|
const isResource = "amount" in input;
|
42950
42747
|
if (isResource) {
|
42951
42748
|
const isCoin2 = "owner" in input;
|
42952
42749
|
if (isCoin2) {
|
42953
42750
|
const assetId = String(input.assetId);
|
42954
|
-
if (quantitiesDict[assetId]) {
|
42751
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
42955
42752
|
const amount = bn(input.amount);
|
42956
42753
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42754
|
+
cachedUtxos.push(input.id);
|
42957
42755
|
}
|
42958
|
-
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
42756
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42959
42757
|
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42758
|
+
cachedMessages.push(input.nonce);
|
42960
42759
|
}
|
42961
42760
|
}
|
42962
42761
|
});
|
@@ -42971,23 +42770,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42971
42770
|
});
|
42972
42771
|
const needsToBeFunded = missingQuantities.length;
|
42973
42772
|
if (needsToBeFunded) {
|
42974
|
-
const
|
42975
|
-
|
42976
|
-
|
42977
|
-
|
42978
|
-
|
42979
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
42980
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
42981
|
-
if (addedSignatures) {
|
42982
|
-
Array.from({ length: addedSignatures }).forEach(
|
42983
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
42984
|
-
);
|
42773
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42774
|
+
messages: cachedMessages,
|
42775
|
+
utxos: cachedUtxos
|
42776
|
+
});
|
42777
|
+
request.addResources(resources);
|
42985
42778
|
}
|
42986
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
42987
|
-
transactionRequest: requestToBeReEstimate
|
42988
|
-
});
|
42989
|
-
txRequest.maxFee = maxFee;
|
42990
|
-
return txRequest;
|
42991
42779
|
}
|
42992
42780
|
/**
|
42993
42781
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -42995,25 +42783,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42995
42783
|
* @param destination - The address of the destination.
|
42996
42784
|
* @param amount - The amount of coins to transfer.
|
42997
42785
|
* @param assetId - The asset ID of the coins to transfer.
|
42998
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42786
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42999
42787
|
* @returns A promise that resolves to the prepared transaction request.
|
43000
42788
|
*/
|
43001
42789
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43002
|
-
const
|
42790
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42791
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42792
|
+
const request = new ScriptTransactionRequest(params);
|
43003
42793
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43004
|
-
const
|
42794
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43005
42795
|
estimateTxDependencies: true,
|
43006
42796
|
resourcesOwner: this
|
43007
42797
|
});
|
43008
|
-
|
43009
|
-
|
43010
|
-
|
43011
|
-
|
43012
|
-
|
43013
|
-
|
43014
|
-
|
43015
|
-
|
43016
|
-
await this.fund(request,
|
42798
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42799
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42800
|
+
this.validateGas({
|
42801
|
+
gasUsed,
|
42802
|
+
gasPrice: request.gasPrice,
|
42803
|
+
gasLimit: request.gasLimit,
|
42804
|
+
minGasPrice
|
42805
|
+
});
|
42806
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42807
|
+
request.updatePredicateInputs(estimatedInputs);
|
43017
42808
|
return request;
|
43018
42809
|
}
|
43019
42810
|
/**
|
@@ -43052,30 +42843,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43052
42843
|
);
|
43053
42844
|
}
|
43054
42845
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42846
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42847
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
43055
42848
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43056
42849
|
hexlifiedContractId: contractAddress.toB256(),
|
43057
42850
|
amountToTransfer: bn(amount),
|
43058
42851
|
assetId
|
43059
42852
|
});
|
43060
42853
|
const request = new ScriptTransactionRequest({
|
43061
|
-
...
|
42854
|
+
...params,
|
43062
42855
|
script,
|
43063
42856
|
scriptData
|
43064
42857
|
});
|
43065
42858
|
request.addContractInputAndOutput(contractAddress);
|
43066
|
-
const
|
43067
|
-
|
43068
|
-
|
42859
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42860
|
+
request,
|
42861
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42862
|
+
);
|
42863
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42864
|
+
this.validateGas({
|
42865
|
+
gasUsed,
|
42866
|
+
gasPrice: request.gasPrice,
|
42867
|
+
gasLimit: request.gasLimit,
|
42868
|
+
minGasPrice
|
43069
42869
|
});
|
43070
|
-
|
43071
|
-
this.validateGas({
|
43072
|
-
gasUsed: txCost.gasUsed,
|
43073
|
-
gasLimit: request.gasLimit
|
43074
|
-
});
|
43075
|
-
}
|
43076
|
-
request.gasLimit = txCost.gasUsed;
|
43077
|
-
request.maxFee = txCost.maxFee;
|
43078
|
-
await this.fund(request, txCost);
|
42870
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43079
42871
|
return this.sendTransaction(request);
|
43080
42872
|
}
|
43081
42873
|
/**
|
@@ -43087,6 +42879,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43087
42879
|
* @returns A promise that resolves to the transaction response.
|
43088
42880
|
*/
|
43089
42881
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42882
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
43090
42883
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43091
42884
|
const recipientDataArray = arrayify(
|
43092
42885
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43099,19 +42892,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43099
42892
|
...recipientDataArray,
|
43100
42893
|
...amountDataArray
|
43101
42894
|
]);
|
43102
|
-
const params = { script, ...txParams };
|
42895
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
43103
42896
|
const request = new ScriptTransactionRequest(params);
|
43104
|
-
const
|
43105
|
-
const
|
43106
|
-
|
43107
|
-
|
43108
|
-
|
43109
|
-
|
43110
|
-
|
43111
|
-
|
43112
|
-
|
43113
|
-
|
43114
|
-
|
42897
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42898
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42899
|
+
request,
|
42900
|
+
forwardingQuantities
|
42901
|
+
);
|
42902
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42903
|
+
this.validateGas({
|
42904
|
+
gasUsed,
|
42905
|
+
gasPrice: request.gasPrice,
|
42906
|
+
gasLimit: request.gasLimit,
|
42907
|
+
minGasPrice
|
42908
|
+
});
|
42909
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43115
42910
|
return this.sendTransaction(request);
|
43116
42911
|
}
|
43117
42912
|
async signMessage(message) {
|
@@ -43169,7 +42964,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43169
42964
|
}
|
43170
42965
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43171
42966
|
}
|
43172
|
-
validateGas({
|
42967
|
+
validateGas({
|
42968
|
+
gasUsed,
|
42969
|
+
gasPrice,
|
42970
|
+
gasLimit,
|
42971
|
+
minGasPrice
|
42972
|
+
}) {
|
42973
|
+
if (minGasPrice.gt(gasPrice)) {
|
42974
|
+
throw new FuelError(
|
42975
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
42976
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
42977
|
+
);
|
42978
|
+
}
|
43173
42979
|
if (gasUsed.gt(gasLimit)) {
|
43174
42980
|
throw new FuelError(
|
43175
42981
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44552,12 +44358,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44552
44358
|
};
|
44553
44359
|
|
44554
44360
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44555
|
-
var
|
44361
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44556
44362
|
var rnds8Pool = new Uint8Array(256);
|
44557
44363
|
var poolPtr = rnds8Pool.length;
|
44558
44364
|
function rng() {
|
44559
44365
|
if (poolPtr > rnds8Pool.length - 16) {
|
44560
|
-
|
44366
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44561
44367
|
poolPtr = 0;
|
44562
44368
|
}
|
44563
44369
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44573,9 +44379,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44573
44379
|
}
|
44574
44380
|
|
44575
44381
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44576
|
-
var
|
44382
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44577
44383
|
var native_default = {
|
44578
|
-
randomUUID:
|
44384
|
+
randomUUID: import_crypto16.default.randomUUID
|
44579
44385
|
};
|
44580
44386
|
|
44581
44387
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -44758,7 +44564,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44758
44564
|
* @param transactionRequestLike - The transaction request to send.
|
44759
44565
|
* @returns A promise that resolves to the TransactionResponse object.
|
44760
44566
|
*/
|
44761
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44567
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44762
44568
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44763
44569
|
if (estimateTxDependencies) {
|
44764
44570
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48024,7 +47830,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48024
47830
|
this.interface = predicateInterface;
|
48025
47831
|
if (inputData !== void 0 && inputData.length > 0) {
|
48026
47832
|
this.predicateData = inputData;
|
48027
|
-
this.predicateDataBytes = this.getPredicateData(0);
|
48028
47833
|
}
|
48029
47834
|
}
|
48030
47835
|
/**
|
@@ -48038,8 +47843,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48038
47843
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48039
47844
|
request.inputs?.forEach((input) => {
|
48040
47845
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
48041
|
-
input.predicate =
|
48042
|
-
input.predicateData =
|
47846
|
+
input.predicate = this.bytes;
|
47847
|
+
input.predicateData = this.getPredicateData(policies.length);
|
48043
47848
|
}
|
48044
47849
|
});
|
48045
47850
|
return request;
|
@@ -48054,7 +47859,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48054
47859
|
* @returns A promise that resolves to the prepared transaction request.
|
48055
47860
|
*/
|
48056
47861
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
48057
|
-
|
47862
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47863
|
+
return this.populateTransactionPredicateData(request);
|
48058
47864
|
}
|
48059
47865
|
/**
|
48060
47866
|
* Sends a transaction with the populated predicate data.
|
@@ -48062,9 +47868,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48062
47868
|
* @param transactionRequestLike - The transaction request-like object.
|
48063
47869
|
* @returns A promise that resolves to the transaction response.
|
48064
47870
|
*/
|
48065
|
-
sendTransaction(transactionRequestLike) {
|
48066
|
-
const transactionRequest =
|
48067
|
-
return super.sendTransaction(transactionRequest,
|
47871
|
+
sendTransaction(transactionRequestLike, options) {
|
47872
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47873
|
+
return super.sendTransaction(transactionRequest, options);
|
48068
47874
|
}
|
48069
47875
|
/**
|
48070
47876
|
* Simulates a transaction with the populated predicate data.
|
@@ -48073,8 +47879,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48073
47879
|
* @returns A promise that resolves to the call result.
|
48074
47880
|
*/
|
48075
47881
|
simulateTransaction(transactionRequestLike) {
|
48076
|
-
const transactionRequest =
|
48077
|
-
return super.simulateTransaction(transactionRequest
|
47882
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47883
|
+
return super.simulateTransaction(transactionRequest);
|
48078
47884
|
}
|
48079
47885
|
getPredicateData(policiesLength) {
|
48080
47886
|
if (!this.predicateData.length) {
|
@@ -48120,26 +47926,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48120
47926
|
predicateInterface: abiInterface
|
48121
47927
|
};
|
48122
47928
|
}
|
48123
|
-
/**
|
48124
|
-
* Retrieves resources satisfying the spend query for the account.
|
48125
|
-
*
|
48126
|
-
* @param quantities - IDs of coins to exclude.
|
48127
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48128
|
-
* @returns A promise that resolves to an array of Resources.
|
48129
|
-
*/
|
48130
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48131
|
-
const resources = await this.provider.getResourcesToSpend(
|
48132
|
-
this.address,
|
48133
|
-
quantities,
|
48134
|
-
excludedIds
|
48135
|
-
);
|
48136
|
-
return resources.map((resource) => ({
|
48137
|
-
...resource,
|
48138
|
-
predicate: hexlify(this.bytes),
|
48139
|
-
predicateData: hexlify(this.predicateDataBytes),
|
48140
|
-
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48141
|
-
}));
|
48142
|
-
}
|
48143
47929
|
/**
|
48144
47930
|
* Sets the configurable constants for the predicate.
|
48145
47931
|
*
|