@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-2021-20240411141803
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 +5 -4
- 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 +844 -560
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +786 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +666 -399
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +888 -322
- 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 -1
- 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 +2 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +45 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/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 +6 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1562 -1046
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +764 -499
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +660 -395
- 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 max(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone3(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone3(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,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.51.1",
|
28956
|
+
FUEL_CORE: "0.24.2",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29245,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29245
29245
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29246
29246
|
|
29247
29247
|
// ../crypto/dist/index.mjs
|
29248
|
-
var
|
29248
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
29249
29249
|
|
29250
29250
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29251
29251
|
var version = "6.7.1";
|
@@ -30317,6 +30317,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30317
30317
|
};
|
30318
30318
|
Object.freeze(pbkdf22);
|
30319
30319
|
|
30320
|
+
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30321
|
+
var locked5 = false;
|
30322
|
+
var _randomBytes = function(length) {
|
30323
|
+
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30324
|
+
};
|
30325
|
+
var __randomBytes = _randomBytes;
|
30326
|
+
function randomBytes3(length) {
|
30327
|
+
return __randomBytes(length);
|
30328
|
+
}
|
30329
|
+
randomBytes3._ = _randomBytes;
|
30330
|
+
randomBytes3.lock = function() {
|
30331
|
+
locked5 = true;
|
30332
|
+
};
|
30333
|
+
randomBytes3.register = function(func) {
|
30334
|
+
if (locked5) {
|
30335
|
+
throw new Error("randomBytes is locked");
|
30336
|
+
}
|
30337
|
+
__randomBytes = func;
|
30338
|
+
};
|
30339
|
+
Object.freeze(randomBytes3);
|
30340
|
+
|
30320
30341
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30321
30342
|
var BN_03 = BigInt(0);
|
30322
30343
|
var BN_36 = BigInt(36);
|
@@ -30901,8 +30922,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30901
30922
|
}
|
30902
30923
|
|
30903
30924
|
// ../crypto/dist/index.mjs
|
30904
|
-
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30905
30925
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30926
|
+
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30906
30927
|
var scrypt3 = (params) => {
|
30907
30928
|
const { password, salt, n, p, r, dklen } = params;
|
30908
30929
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30911,7 +30932,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30911
30932
|
var keccak2562 = (data) => keccak_256(data);
|
30912
30933
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30913
30934
|
var randomBytes4 = (length) => {
|
30914
|
-
const randomValues = Uint8Array.from(
|
30935
|
+
const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
|
30915
30936
|
return randomValues;
|
30916
30937
|
};
|
30917
30938
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30926,7 +30947,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30926
30947
|
const salt = randomBytes4(32);
|
30927
30948
|
const secret = keyFromPassword(password, salt);
|
30928
30949
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30929
|
-
const cipher = await
|
30950
|
+
const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
|
30930
30951
|
let cipherData = cipher.update(dataBuffer);
|
30931
30952
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30932
30953
|
return {
|
@@ -30940,7 +30961,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30940
30961
|
const salt = bufferFromString(keystore.salt);
|
30941
30962
|
const secret = keyFromPassword(password, salt);
|
30942
30963
|
const encryptedText = bufferFromString(keystore.data);
|
30943
|
-
const decipher = await
|
30964
|
+
const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
|
30944
30965
|
const decrypted = decipher.update(encryptedText);
|
30945
30966
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30946
30967
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30951,12 +30972,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30951
30972
|
}
|
30952
30973
|
};
|
30953
30974
|
async function encryptJsonWalletData(data, key, iv) {
|
30954
|
-
const cipher = await
|
30975
|
+
const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30955
30976
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30956
30977
|
return new Uint8Array(encrypted);
|
30957
30978
|
}
|
30958
30979
|
async function decryptJsonWalletData(data, key, iv) {
|
30959
|
-
const decipher =
|
30980
|
+
const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30960
30981
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30961
30982
|
return new Uint8Array(decrypted);
|
30962
30983
|
}
|
@@ -31495,32 +31516,182 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31495
31516
|
function toBytes3(value, bytesPadding) {
|
31496
31517
|
return bn(value).toBytes(bytesPadding);
|
31497
31518
|
}
|
31498
|
-
|
31499
|
-
|
31519
|
+
|
31520
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
31521
|
+
function _isPlaceholder(a) {
|
31522
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31523
|
+
}
|
31524
|
+
|
31525
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31526
|
+
function _curry1(fn) {
|
31527
|
+
return function f1(a) {
|
31528
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31529
|
+
return f1;
|
31530
|
+
} else {
|
31531
|
+
return fn.apply(this, arguments);
|
31532
|
+
}
|
31533
|
+
};
|
31534
|
+
}
|
31535
|
+
|
31536
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31537
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
31538
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31539
|
+
};
|
31540
|
+
|
31541
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31542
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31543
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31544
|
+
});
|
31545
|
+
var type_default = type;
|
31546
|
+
|
31547
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31548
|
+
var pad = function pad2(n) {
|
31549
|
+
return (n < 10 ? "0" : "") + n;
|
31550
|
+
};
|
31551
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31552
|
+
return d.toISOString();
|
31553
|
+
} : function _toISOString3(d) {
|
31554
|
+
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";
|
31555
|
+
};
|
31556
|
+
|
31557
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31558
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31559
|
+
return n << 0 === n;
|
31560
|
+
};
|
31561
|
+
|
31562
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31563
|
+
function _cloneRegExp(pattern) {
|
31564
|
+
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" : ""));
|
31565
|
+
}
|
31566
|
+
|
31567
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31568
|
+
function _clone(value, deep, map) {
|
31569
|
+
map || (map = new _ObjectMap());
|
31570
|
+
if (_isPrimitive(value)) {
|
31571
|
+
return value;
|
31572
|
+
}
|
31573
|
+
var copy = function copy2(copiedValue) {
|
31574
|
+
var cachedCopy = map.get(value);
|
31575
|
+
if (cachedCopy) {
|
31576
|
+
return cachedCopy;
|
31577
|
+
}
|
31578
|
+
map.set(value, copiedValue);
|
31579
|
+
for (var key in value) {
|
31580
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31581
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31582
|
+
}
|
31583
|
+
}
|
31584
|
+
return copiedValue;
|
31585
|
+
};
|
31586
|
+
switch (type_default(value)) {
|
31587
|
+
case "Object":
|
31588
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
31589
|
+
case "Array":
|
31590
|
+
return copy([]);
|
31591
|
+
case "Date":
|
31592
|
+
return new Date(value.valueOf());
|
31593
|
+
case "RegExp":
|
31594
|
+
return _cloneRegExp(value);
|
31595
|
+
case "Int8Array":
|
31596
|
+
case "Uint8Array":
|
31597
|
+
case "Uint8ClampedArray":
|
31598
|
+
case "Int16Array":
|
31599
|
+
case "Uint16Array":
|
31600
|
+
case "Int32Array":
|
31601
|
+
case "Uint32Array":
|
31602
|
+
case "Float32Array":
|
31603
|
+
case "Float64Array":
|
31604
|
+
case "BigInt64Array":
|
31605
|
+
case "BigUint64Array":
|
31606
|
+
return value.slice();
|
31607
|
+
default:
|
31608
|
+
return value;
|
31609
|
+
}
|
31610
|
+
}
|
31611
|
+
function _isPrimitive(param) {
|
31612
|
+
var type3 = typeof param;
|
31613
|
+
return param == null || type3 != "object" && type3 != "function";
|
31500
31614
|
}
|
31615
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
31616
|
+
function _ObjectMap2() {
|
31617
|
+
this.map = {};
|
31618
|
+
this.length = 0;
|
31619
|
+
}
|
31620
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
31621
|
+
const hashedKey = this.hash(key);
|
31622
|
+
let bucket = this.map[hashedKey];
|
31623
|
+
if (!bucket) {
|
31624
|
+
this.map[hashedKey] = bucket = [];
|
31625
|
+
}
|
31626
|
+
bucket.push([key, value]);
|
31627
|
+
this.length += 1;
|
31628
|
+
};
|
31629
|
+
_ObjectMap2.prototype.hash = function(key) {
|
31630
|
+
let hashedKey = [];
|
31631
|
+
for (var value in key) {
|
31632
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31633
|
+
}
|
31634
|
+
return hashedKey.join();
|
31635
|
+
};
|
31636
|
+
_ObjectMap2.prototype.get = function(key) {
|
31637
|
+
if (this.length <= 180) {
|
31638
|
+
for (const p in this.map) {
|
31639
|
+
const bucket2 = this.map[p];
|
31640
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
31641
|
+
const element = bucket2[i];
|
31642
|
+
if (element[0] === key) {
|
31643
|
+
return element[1];
|
31644
|
+
}
|
31645
|
+
}
|
31646
|
+
}
|
31647
|
+
return;
|
31648
|
+
}
|
31649
|
+
const hashedKey = this.hash(key);
|
31650
|
+
const bucket = this.map[hashedKey];
|
31651
|
+
if (!bucket) {
|
31652
|
+
return;
|
31653
|
+
}
|
31654
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
31655
|
+
const element = bucket[i];
|
31656
|
+
if (element[0] === key) {
|
31657
|
+
return element[1];
|
31658
|
+
}
|
31659
|
+
}
|
31660
|
+
};
|
31661
|
+
return _ObjectMap2;
|
31662
|
+
}();
|
31663
|
+
|
31664
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31665
|
+
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31666
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31667
|
+
});
|
31668
|
+
var clone_default = clone;
|
31669
|
+
|
31670
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31671
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31501
31672
|
|
31502
31673
|
// src/providers/coin-quantity.ts
|
31503
31674
|
var coinQuantityfy = (coinQuantityLike) => {
|
31504
31675
|
let assetId;
|
31505
31676
|
let amount;
|
31506
|
-
let
|
31677
|
+
let max;
|
31507
31678
|
if (Array.isArray(coinQuantityLike)) {
|
31508
31679
|
amount = coinQuantityLike[0];
|
31509
31680
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31510
|
-
|
31681
|
+
max = coinQuantityLike[2] ?? void 0;
|
31511
31682
|
} else {
|
31512
31683
|
amount = coinQuantityLike.amount;
|
31513
31684
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31514
|
-
|
31685
|
+
max = coinQuantityLike.max ?? void 0;
|
31515
31686
|
}
|
31516
31687
|
const bnAmount = bn(amount);
|
31517
31688
|
return {
|
31518
31689
|
assetId: hexlify(assetId),
|
31519
31690
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31520
|
-
max:
|
31691
|
+
max: max ? bn(max) : void 0
|
31521
31692
|
};
|
31522
31693
|
};
|
31523
|
-
var
|
31694
|
+
var addAmountToCoinQuantities = (params) => {
|
31524
31695
|
const { amount, assetId } = params;
|
31525
31696
|
const coinQuantities = [...params.coinQuantities];
|
31526
31697
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31612,9 +31783,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31612
31783
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31613
31784
|
var MAX_BYTES = 2 ** 32 - 1;
|
31614
31785
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31615
|
-
|
31786
|
+
ASSET_ID_LEN + // Base asset ID
|
31616
31787
|
// Asset ID/Balance coin input pairs
|
31617
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31788
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
|
31618
31789
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31619
31790
|
WORD_SIZE + // Gas limit
|
31620
31791
|
WORD_SIZE + // Script size
|
@@ -31632,7 +31803,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31632
31803
|
ASSET_ID_LEN + // Asset id
|
31633
31804
|
TX_POINTER_LEN + // TxPointer
|
31634
31805
|
WORD_SIZE + // Witnesses index
|
31635
|
-
WORD_SIZE + // Maturity
|
31636
31806
|
WORD_SIZE + // Predicate size
|
31637
31807
|
WORD_SIZE + // Predicate data size
|
31638
31808
|
WORD_SIZE;
|
@@ -31954,7 +32124,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31954
32124
|
constructor(name, coders) {
|
31955
32125
|
const caseIndexCoder = new BigNumberCoder("u64");
|
31956
32126
|
const encodedValueSize = Object.values(coders).reduce(
|
31957
|
-
(
|
32127
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
31958
32128
|
0
|
31959
32129
|
);
|
31960
32130
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32658,7 +32828,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32658
32828
|
constructor(name, coders) {
|
32659
32829
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32660
32830
|
const encodedValueSize = Object.values(coders).reduce(
|
32661
|
-
(
|
32831
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
32662
32832
|
0
|
32663
32833
|
);
|
32664
32834
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33370,18 +33540,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33370
33540
|
encode(value) {
|
33371
33541
|
const parts = [];
|
33372
33542
|
parts.push(new B256Coder().encode(value.txID));
|
33373
|
-
parts.push(new NumberCoder("
|
33543
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33374
33544
|
parts.push(new B256Coder().encode(value.owner));
|
33375
33545
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33376
33546
|
parts.push(new B256Coder().encode(value.assetId));
|
33377
33547
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33378
|
-
parts.push(new NumberCoder("
|
33379
|
-
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33548
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33380
33549
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33381
|
-
parts.push(new
|
33382
|
-
parts.push(new
|
33383
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33384
|
-
parts.push(
|
33550
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33551
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33552
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33553
|
+
parts.push(
|
33554
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33555
|
+
);
|
33385
33556
|
return concat(parts);
|
33386
33557
|
}
|
33387
33558
|
decode(data, offset) {
|
@@ -33389,7 +33560,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33389
33560
|
let o = offset;
|
33390
33561
|
[decoded, o] = new B256Coder().decode(data, o);
|
33391
33562
|
const txID = decoded;
|
33392
|
-
[decoded, o] = new NumberCoder("
|
33563
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33393
33564
|
const outputIndex = decoded;
|
33394
33565
|
[decoded, o] = new B256Coder().decode(data, o);
|
33395
33566
|
const owner = decoded;
|
@@ -33399,19 +33570,17 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33399
33570
|
const assetId = decoded;
|
33400
33571
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33401
33572
|
const txPointer = decoded;
|
33402
|
-
[decoded, o] = new NumberCoder("
|
33573
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33403
33574
|
const witnessIndex = Number(decoded);
|
33404
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33405
|
-
const maturity = decoded;
|
33406
33575
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33407
33576
|
const predicateGasUsed = decoded;
|
33408
|
-
[decoded, o] = new
|
33577
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33409
33578
|
const predicateLength = decoded;
|
33410
|
-
[decoded, o] = new
|
33579
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33411
33580
|
const predicateDataLength = decoded;
|
33412
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33581
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33413
33582
|
const predicate = decoded;
|
33414
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33583
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33415
33584
|
const predicateData = decoded;
|
33416
33585
|
return [
|
33417
33586
|
{
|
@@ -33423,7 +33592,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33423
33592
|
assetId,
|
33424
33593
|
txPointer,
|
33425
33594
|
witnessIndex,
|
33426
|
-
maturity,
|
33427
33595
|
predicateGasUsed,
|
33428
33596
|
predicateLength,
|
33429
33597
|
predicateDataLength,
|
@@ -33441,7 +33609,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33441
33609
|
encode(value) {
|
33442
33610
|
const parts = [];
|
33443
33611
|
parts.push(new B256Coder().encode(value.txID));
|
33444
|
-
parts.push(new NumberCoder("
|
33612
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33445
33613
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33446
33614
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33447
33615
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33453,7 +33621,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33453
33621
|
let o = offset;
|
33454
33622
|
[decoded, o] = new B256Coder().decode(data, o);
|
33455
33623
|
const txID = decoded;
|
33456
|
-
[decoded, o] = new NumberCoder("
|
33624
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33457
33625
|
const outputIndex = decoded;
|
33458
33626
|
[decoded, o] = new B256Coder().decode(data, o);
|
33459
33627
|
const balanceRoot = decoded;
|
@@ -33502,14 +33670,16 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33502
33670
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33503
33671
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33504
33672
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33505
|
-
parts.push(new NumberCoder("
|
33673
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33506
33674
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33507
|
-
parts.push(new
|
33508
|
-
parts.push(new
|
33509
|
-
parts.push(new
|
33675
|
+
parts.push(new BigNumberCoder("u64").encode(data.length));
|
33676
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33677
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33510
33678
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33511
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33512
|
-
parts.push(
|
33679
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33680
|
+
parts.push(
|
33681
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33682
|
+
);
|
33513
33683
|
return concat(parts);
|
33514
33684
|
}
|
33515
33685
|
static decodeData(messageData) {
|
@@ -33529,21 +33699,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33529
33699
|
const amount = decoded;
|
33530
33700
|
[decoded, o] = new B256Coder().decode(data, o);
|
33531
33701
|
const nonce = decoded;
|
33532
|
-
[decoded, o] = new NumberCoder("
|
33702
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33533
33703
|
const witnessIndex = Number(decoded);
|
33534
33704
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33535
33705
|
const predicateGasUsed = decoded;
|
33536
33706
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33537
33707
|
const dataLength2 = decoded;
|
33538
|
-
[decoded, o] = new
|
33708
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33539
33709
|
const predicateLength = decoded;
|
33540
|
-
[decoded, o] = new
|
33710
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33541
33711
|
const predicateDataLength = decoded;
|
33542
33712
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33543
33713
|
const messageData = decoded;
|
33544
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33714
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33545
33715
|
const predicate = decoded;
|
33546
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33716
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33547
33717
|
const predicateData = decoded;
|
33548
33718
|
return [
|
33549
33719
|
{
|
@@ -33855,7 +34025,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33855
34025
|
}
|
33856
34026
|
};
|
33857
34027
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
33858
|
-
PolicyType2[PolicyType2["
|
34028
|
+
PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
|
33859
34029
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
33860
34030
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
33861
34031
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -33903,9 +34073,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33903
34073
|
let o = offset;
|
33904
34074
|
const policies = [];
|
33905
34075
|
if (policyTypes & 1) {
|
33906
|
-
const [
|
34076
|
+
const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
33907
34077
|
o = nextOffset;
|
33908
|
-
policies.push({ type: 1, data:
|
34078
|
+
policies.push({ type: 1, data: tip });
|
33909
34079
|
}
|
33910
34080
|
if (policyTypes & 2) {
|
33911
34081
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34137,15 +34307,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34137
34307
|
encode(value) {
|
34138
34308
|
const parts = [];
|
34139
34309
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34140
|
-
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34141
|
-
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34142
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34143
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34144
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34145
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34146
34310
|
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34147
|
-
parts.push(new
|
34148
|
-
parts.push(new
|
34311
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
|
34312
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34313
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34314
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34315
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34316
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34317
|
+
parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
|
34318
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
|
34149
34319
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34150
34320
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34151
34321
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34157,23 +34327,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34157
34327
|
let o = offset;
|
34158
34328
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34159
34329
|
const scriptGasLimit = decoded;
|
34160
|
-
[decoded, o] = new
|
34330
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34331
|
+
const receiptsRoot = decoded;
|
34332
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34161
34333
|
const scriptLength = decoded;
|
34162
|
-
[decoded, o] = new
|
34334
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34163
34335
|
const scriptDataLength = decoded;
|
34164
34336
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34165
34337
|
const policyTypes = decoded;
|
34166
|
-
[decoded, o] = new NumberCoder("
|
34338
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34167
34339
|
const inputsCount = decoded;
|
34168
|
-
[decoded, o] = new NumberCoder("
|
34340
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34169
34341
|
const outputsCount = decoded;
|
34170
|
-
[decoded, o] = new NumberCoder("
|
34342
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34171
34343
|
const witnessesCount = decoded;
|
34172
|
-
[decoded, o] = new
|
34173
|
-
const receiptsRoot = decoded;
|
34174
|
-
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34344
|
+
[decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
|
34175
34345
|
const script = decoded;
|
34176
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34346
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
|
34177
34347
|
const scriptData = decoded;
|
34178
34348
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34179
34349
|
const policies = decoded;
|
@@ -34211,18 +34381,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34211
34381
|
}
|
34212
34382
|
encode(value) {
|
34213
34383
|
const parts = [];
|
34214
|
-
parts.push(new NumberCoder("
|
34215
|
-
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34216
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34217
|
-
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34218
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34219
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34220
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34384
|
+
parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
|
34221
34385
|
parts.push(new B256Coder().encode(value.salt));
|
34222
|
-
parts.push(new
|
34386
|
+
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34387
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34388
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34389
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34390
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34223
34391
|
parts.push(
|
34224
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(
|
34392
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
|
34393
|
+
value.storageSlots
|
34394
|
+
)
|
34225
34395
|
);
|
34396
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34226
34397
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34227
34398
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34228
34399
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34231,26 +34402,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34231
34402
|
decode(data, offset) {
|
34232
34403
|
let decoded;
|
34233
34404
|
let o = offset;
|
34234
|
-
[decoded, o] = new NumberCoder("
|
34235
|
-
const bytecodeLength = decoded;
|
34236
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34405
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34237
34406
|
const bytecodeWitnessIndex = decoded;
|
34407
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34408
|
+
const salt = decoded;
|
34409
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34410
|
+
const storageSlotsCount = decoded;
|
34238
34411
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34239
34412
|
const policyTypes = decoded;
|
34240
34413
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34241
|
-
const storageSlotsCount = decoded;
|
34242
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34243
34414
|
const inputsCount = decoded;
|
34244
|
-
[decoded, o] = new NumberCoder("
|
34415
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34245
34416
|
const outputsCount = decoded;
|
34246
|
-
[decoded, o] = new NumberCoder("
|
34417
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34247
34418
|
const witnessesCount = decoded;
|
34248
|
-
[decoded, o] = new
|
34249
|
-
|
34419
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
|
34420
|
+
data,
|
34421
|
+
o
|
34422
|
+
);
|
34423
|
+
const storageSlots = decoded;
|
34250
34424
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34251
34425
|
const policies = decoded;
|
34252
|
-
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34253
|
-
const storageSlots = decoded;
|
34254
34426
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34255
34427
|
const inputs = decoded;
|
34256
34428
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34260,7 +34432,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34260
34432
|
return [
|
34261
34433
|
{
|
34262
34434
|
type: 1,
|
34263
|
-
bytecodeLength,
|
34264
34435
|
bytecodeWitnessIndex,
|
34265
34436
|
policyTypes,
|
34266
34437
|
storageSlotsCount,
|
@@ -34289,6 +34460,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34289
34460
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34290
34461
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34291
34462
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34463
|
+
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34292
34464
|
return concat(parts);
|
34293
34465
|
}
|
34294
34466
|
decode(data, offset) {
|
@@ -34304,6 +34476,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34304
34476
|
const mintAmount = decoded;
|
34305
34477
|
[decoded, o] = new B256Coder().decode(data, o);
|
34306
34478
|
const mintAssetId = decoded;
|
34479
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34480
|
+
const gasPrice = decoded;
|
34307
34481
|
return [
|
34308
34482
|
{
|
34309
34483
|
type: 2,
|
@@ -34311,7 +34485,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34311
34485
|
inputContract,
|
34312
34486
|
outputContract,
|
34313
34487
|
mintAmount,
|
34314
|
-
mintAssetId
|
34488
|
+
mintAssetId,
|
34489
|
+
gasPrice
|
34315
34490
|
},
|
34316
34491
|
o
|
34317
34492
|
];
|
@@ -34618,159 +34793,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34618
34793
|
// src/providers/provider.ts
|
34619
34794
|
var import_graphql_request = __toESM(require_dist2());
|
34620
34795
|
|
34621
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34622
|
-
function _isPlaceholder(a) {
|
34623
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34624
|
-
}
|
34625
|
-
|
34626
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34627
|
-
function _curry1(fn) {
|
34628
|
-
return function f1(a) {
|
34629
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34630
|
-
return f1;
|
34631
|
-
} else {
|
34632
|
-
return fn.apply(this, arguments);
|
34633
|
-
}
|
34634
|
-
};
|
34635
|
-
}
|
34636
|
-
|
34637
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34638
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
34639
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34640
|
-
};
|
34641
|
-
|
34642
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34643
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34644
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34645
|
-
});
|
34646
|
-
var type_default = type;
|
34647
|
-
|
34648
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34649
|
-
var pad = function pad2(n) {
|
34650
|
-
return (n < 10 ? "0" : "") + n;
|
34651
|
-
};
|
34652
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34653
|
-
return d.toISOString();
|
34654
|
-
} : function _toISOString3(d) {
|
34655
|
-
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";
|
34656
|
-
};
|
34657
|
-
|
34658
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34659
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34660
|
-
return n << 0 === n;
|
34661
|
-
};
|
34662
|
-
|
34663
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34664
|
-
function _cloneRegExp(pattern) {
|
34665
|
-
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" : ""));
|
34666
|
-
}
|
34667
|
-
|
34668
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34669
|
-
function _clone(value, deep, map) {
|
34670
|
-
map || (map = new _ObjectMap());
|
34671
|
-
if (_isPrimitive(value)) {
|
34672
|
-
return value;
|
34673
|
-
}
|
34674
|
-
var copy = function copy2(copiedValue) {
|
34675
|
-
var cachedCopy = map.get(value);
|
34676
|
-
if (cachedCopy) {
|
34677
|
-
return cachedCopy;
|
34678
|
-
}
|
34679
|
-
map.set(value, copiedValue);
|
34680
|
-
for (var key in value) {
|
34681
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34682
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34683
|
-
}
|
34684
|
-
}
|
34685
|
-
return copiedValue;
|
34686
|
-
};
|
34687
|
-
switch (type_default(value)) {
|
34688
|
-
case "Object":
|
34689
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
34690
|
-
case "Array":
|
34691
|
-
return copy([]);
|
34692
|
-
case "Date":
|
34693
|
-
return new Date(value.valueOf());
|
34694
|
-
case "RegExp":
|
34695
|
-
return _cloneRegExp(value);
|
34696
|
-
case "Int8Array":
|
34697
|
-
case "Uint8Array":
|
34698
|
-
case "Uint8ClampedArray":
|
34699
|
-
case "Int16Array":
|
34700
|
-
case "Uint16Array":
|
34701
|
-
case "Int32Array":
|
34702
|
-
case "Uint32Array":
|
34703
|
-
case "Float32Array":
|
34704
|
-
case "Float64Array":
|
34705
|
-
case "BigInt64Array":
|
34706
|
-
case "BigUint64Array":
|
34707
|
-
return value.slice();
|
34708
|
-
default:
|
34709
|
-
return value;
|
34710
|
-
}
|
34711
|
-
}
|
34712
|
-
function _isPrimitive(param) {
|
34713
|
-
var type3 = typeof param;
|
34714
|
-
return param == null || type3 != "object" && type3 != "function";
|
34715
|
-
}
|
34716
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
34717
|
-
function _ObjectMap2() {
|
34718
|
-
this.map = {};
|
34719
|
-
this.length = 0;
|
34720
|
-
}
|
34721
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
34722
|
-
const hashedKey = this.hash(key);
|
34723
|
-
let bucket = this.map[hashedKey];
|
34724
|
-
if (!bucket) {
|
34725
|
-
this.map[hashedKey] = bucket = [];
|
34726
|
-
}
|
34727
|
-
bucket.push([key, value]);
|
34728
|
-
this.length += 1;
|
34729
|
-
};
|
34730
|
-
_ObjectMap2.prototype.hash = function(key) {
|
34731
|
-
let hashedKey = [];
|
34732
|
-
for (var value in key) {
|
34733
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34734
|
-
}
|
34735
|
-
return hashedKey.join();
|
34736
|
-
};
|
34737
|
-
_ObjectMap2.prototype.get = function(key) {
|
34738
|
-
if (this.length <= 180) {
|
34739
|
-
for (const p in this.map) {
|
34740
|
-
const bucket2 = this.map[p];
|
34741
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
34742
|
-
const element = bucket2[i];
|
34743
|
-
if (element[0] === key) {
|
34744
|
-
return element[1];
|
34745
|
-
}
|
34746
|
-
}
|
34747
|
-
}
|
34748
|
-
return;
|
34749
|
-
}
|
34750
|
-
const hashedKey = this.hash(key);
|
34751
|
-
const bucket = this.map[hashedKey];
|
34752
|
-
if (!bucket) {
|
34753
|
-
return;
|
34754
|
-
}
|
34755
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
34756
|
-
const element = bucket[i];
|
34757
|
-
if (element[0] === key) {
|
34758
|
-
return element[1];
|
34759
|
-
}
|
34760
|
-
}
|
34761
|
-
};
|
34762
|
-
return _ObjectMap2;
|
34763
|
-
}();
|
34764
|
-
|
34765
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34766
|
-
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34767
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34768
|
-
});
|
34769
|
-
var clone_default = clone2;
|
34770
|
-
|
34771
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34772
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34773
|
-
|
34774
34796
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34775
34797
|
var __assign = function() {
|
34776
34798
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37938,14 +37960,10 @@ spurious results.`);
|
|
37938
37960
|
// src/providers/__generated__/operations.ts
|
37939
37961
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37940
37962
|
fragment receiptFragment on Receipt {
|
37941
|
-
|
37942
|
-
id
|
37943
|
-
}
|
37963
|
+
id
|
37944
37964
|
pc
|
37945
37965
|
is
|
37946
|
-
to
|
37947
|
-
id
|
37948
|
-
}
|
37966
|
+
to
|
37949
37967
|
toAddress
|
37950
37968
|
amount
|
37951
37969
|
assetId
|
@@ -37983,10 +38001,16 @@ spurious results.`);
|
|
37983
38001
|
id
|
37984
38002
|
}
|
37985
38003
|
time
|
38004
|
+
receipts {
|
38005
|
+
...receiptFragment
|
38006
|
+
}
|
37986
38007
|
programState {
|
37987
38008
|
returnType
|
37988
38009
|
data
|
37989
38010
|
}
|
38011
|
+
receipts {
|
38012
|
+
...receiptFragment
|
38013
|
+
}
|
37990
38014
|
}
|
37991
38015
|
... on FailureStatus {
|
37992
38016
|
block {
|
@@ -37994,26 +38018,24 @@ spurious results.`);
|
|
37994
38018
|
}
|
37995
38019
|
time
|
37996
38020
|
reason
|
38021
|
+
receipts {
|
38022
|
+
...receiptFragment
|
38023
|
+
}
|
37997
38024
|
}
|
37998
38025
|
... on SqueezedOutStatus {
|
37999
38026
|
reason
|
38000
38027
|
}
|
38001
38028
|
}
|
38002
|
-
`;
|
38029
|
+
${ReceiptFragmentFragmentDoc}`;
|
38003
38030
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38004
38031
|
fragment transactionFragment on Transaction {
|
38005
38032
|
id
|
38006
38033
|
rawPayload
|
38007
|
-
gasPrice
|
38008
|
-
receipts {
|
38009
|
-
...receiptFragment
|
38010
|
-
}
|
38011
38034
|
status {
|
38012
38035
|
...transactionStatusFragment
|
38013
38036
|
}
|
38014
38037
|
}
|
38015
|
-
${
|
38016
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
38038
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38017
38039
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38018
38040
|
fragment inputEstimatePredicatesFragment on Input {
|
38019
38041
|
... on InputCoin {
|
@@ -38031,6 +38053,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38031
38053
|
}
|
38032
38054
|
}
|
38033
38055
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38056
|
+
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38057
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38058
|
+
reason
|
38059
|
+
programState {
|
38060
|
+
returnType
|
38061
|
+
data
|
38062
|
+
}
|
38063
|
+
}
|
38064
|
+
`;
|
38065
|
+
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38066
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38067
|
+
programState {
|
38068
|
+
returnType
|
38069
|
+
data
|
38070
|
+
}
|
38071
|
+
}
|
38072
|
+
`;
|
38073
|
+
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38074
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38075
|
+
... on DryRunFailureStatus {
|
38076
|
+
...dryRunFailureStatusFragment
|
38077
|
+
}
|
38078
|
+
... on DryRunSuccessStatus {
|
38079
|
+
...dryRunSuccessStatusFragment
|
38080
|
+
}
|
38081
|
+
}
|
38082
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
38083
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38084
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38085
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38086
|
+
id
|
38087
|
+
status {
|
38088
|
+
...dryRunTransactionStatusFragment
|
38089
|
+
}
|
38090
|
+
receipts {
|
38091
|
+
...receiptFragment
|
38092
|
+
}
|
38093
|
+
}
|
38094
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
38095
|
+
${ReceiptFragmentFragmentDoc}`;
|
38034
38096
|
var CoinFragmentFragmentDoc = lib_default2`
|
38035
38097
|
fragment coinFragment on Coin {
|
38036
38098
|
__typename
|
@@ -38038,7 +38100,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38038
38100
|
owner
|
38039
38101
|
amount
|
38040
38102
|
assetId
|
38041
|
-
maturity
|
38042
38103
|
blockCreated
|
38043
38104
|
txCreatedIdx
|
38044
38105
|
}
|
@@ -38083,7 +38144,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38083
38144
|
prevRoot
|
38084
38145
|
time
|
38085
38146
|
applicationHash
|
38086
|
-
messageReceiptRoot
|
38087
38147
|
messageReceiptCount
|
38088
38148
|
}
|
38089
38149
|
commitBlockHeader {
|
@@ -38095,7 +38155,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38095
38155
|
prevRoot
|
38096
38156
|
time
|
38097
38157
|
applicationHash
|
38098
|
-
messageReceiptRoot
|
38099
38158
|
messageReceiptCount
|
38100
38159
|
}
|
38101
38160
|
sender
|
@@ -38115,8 +38174,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38115
38174
|
var BlockFragmentFragmentDoc = lib_default2`
|
38116
38175
|
fragment blockFragment on Block {
|
38117
38176
|
id
|
38177
|
+
height
|
38118
38178
|
header {
|
38119
|
-
height
|
38120
38179
|
time
|
38121
38180
|
}
|
38122
38181
|
transactions {
|
@@ -38174,6 +38233,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38174
38233
|
`;
|
38175
38234
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38176
38235
|
fragment GasCostsFragment on GasCosts {
|
38236
|
+
version {
|
38237
|
+
... on Version {
|
38238
|
+
value
|
38239
|
+
}
|
38240
|
+
}
|
38177
38241
|
add
|
38178
38242
|
addi
|
38179
38243
|
aloc
|
@@ -38186,7 +38250,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38186
38250
|
cb
|
38187
38251
|
cfei
|
38188
38252
|
cfsi
|
38189
|
-
croo
|
38190
38253
|
div
|
38191
38254
|
divi
|
38192
38255
|
ecr1
|
@@ -38269,6 +38332,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38269
38332
|
ccp {
|
38270
38333
|
...DependentCostFragment
|
38271
38334
|
}
|
38335
|
+
croo {
|
38336
|
+
...DependentCostFragment
|
38337
|
+
}
|
38272
38338
|
csiz {
|
38273
38339
|
...DependentCostFragment
|
38274
38340
|
}
|
@@ -38328,6 +38394,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38328
38394
|
${DependentCostFragmentFragmentDoc}`;
|
38329
38395
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38330
38396
|
fragment consensusParametersFragment on ConsensusParameters {
|
38397
|
+
version {
|
38398
|
+
... on Version {
|
38399
|
+
value
|
38400
|
+
}
|
38401
|
+
}
|
38331
38402
|
txParams {
|
38332
38403
|
...TxParametersFragment
|
38333
38404
|
}
|
@@ -38387,18 +38458,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38387
38458
|
fragment nodeInfoFragment on NodeInfo {
|
38388
38459
|
utxoValidation
|
38389
38460
|
vmBacktrace
|
38390
|
-
minGasPrice
|
38391
38461
|
maxTx
|
38392
38462
|
maxDepth
|
38393
38463
|
nodeVersion
|
38394
|
-
peers {
|
38395
|
-
id
|
38396
|
-
addresses
|
38397
|
-
clientVersion
|
38398
|
-
blockHeight
|
38399
|
-
lastHeartbeatMs
|
38400
|
-
appScore
|
38401
|
-
}
|
38402
38464
|
}
|
38403
38465
|
`;
|
38404
38466
|
var GetVersionDocument = lib_default2`
|
@@ -38433,13 +38495,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38433
38495
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38434
38496
|
transaction(id: $transactionId) {
|
38435
38497
|
...transactionFragment
|
38436
|
-
receipts {
|
38437
|
-
...receiptFragment
|
38438
|
-
}
|
38439
38498
|
}
|
38440
38499
|
}
|
38441
|
-
${TransactionFragmentFragmentDoc}
|
38442
|
-
${ReceiptFragmentFragmentDoc}`;
|
38500
|
+
${TransactionFragmentFragmentDoc}`;
|
38443
38501
|
var GetTransactionsDocument = lib_default2`
|
38444
38502
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38445
38503
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38567,6 +38625,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38567
38625
|
}
|
38568
38626
|
}
|
38569
38627
|
${BalanceFragmentFragmentDoc}`;
|
38628
|
+
var GetLatestGasPriceDocument = lib_default2`
|
38629
|
+
query getLatestGasPrice {
|
38630
|
+
latestGasPrice {
|
38631
|
+
gasPrice
|
38632
|
+
}
|
38633
|
+
}
|
38634
|
+
`;
|
38635
|
+
var EstimateGasPriceDocument = lib_default2`
|
38636
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
38637
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38638
|
+
gasPrice
|
38639
|
+
}
|
38640
|
+
}
|
38641
|
+
`;
|
38570
38642
|
var GetBalancesDocument = lib_default2`
|
38571
38643
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38572
38644
|
balances(
|
@@ -38621,12 +38693,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38621
38693
|
}
|
38622
38694
|
`;
|
38623
38695
|
var DryRunDocument = lib_default2`
|
38624
|
-
mutation dryRun($
|
38625
|
-
dryRun(
|
38626
|
-
...
|
38696
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
38697
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
38698
|
+
...dryRunTransactionExecutionStatusFragment
|
38627
38699
|
}
|
38628
38700
|
}
|
38629
|
-
${
|
38701
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
38630
38702
|
var SubmitDocument = lib_default2`
|
38631
38703
|
mutation submit($encodedTransaction: HexString!) {
|
38632
38704
|
submit(tx: $encodedTransaction) {
|
@@ -38709,6 +38781,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38709
38781
|
getBalance(variables, options) {
|
38710
38782
|
return requester(GetBalanceDocument, variables, options);
|
38711
38783
|
},
|
38784
|
+
getLatestGasPrice(variables, options) {
|
38785
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
38786
|
+
},
|
38787
|
+
estimateGasPrice(variables, options) {
|
38788
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
38789
|
+
},
|
38712
38790
|
getBalances(variables, options) {
|
38713
38791
|
return requester(GetBalancesDocument, variables, options);
|
38714
38792
|
},
|
@@ -38776,11 +38854,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38776
38854
|
let data;
|
38777
38855
|
let errors;
|
38778
38856
|
try {
|
38779
|
-
|
38857
|
+
const sanitizedText = text.replace(/\s/g, "");
|
38858
|
+
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
38780
38859
|
} catch (e) {
|
38781
38860
|
throw new FuelError(
|
38782
38861
|
ErrorCode.STREAM_PARSING_ERROR,
|
38783
|
-
`Error while parsing stream data response: ${text}
|
38862
|
+
`Error while parsing stream data response: ${text}
|
38863
|
+
|
38864
|
+
Thrown error: ${e}`
|
38784
38865
|
);
|
38785
38866
|
}
|
38786
38867
|
if (Array.isArray(errors)) {
|
@@ -38874,7 +38955,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38874
38955
|
return {
|
38875
38956
|
type: InputType.Coin,
|
38876
38957
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38877
|
-
outputIndex: arrayify(value.id)
|
38958
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 34)),
|
38878
38959
|
owner: hexlify(value.owner),
|
38879
38960
|
amount: bn(value.amount),
|
38880
38961
|
assetId: hexlify(value.assetId),
|
@@ -38883,10 +38964,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38883
38964
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38884
38965
|
},
|
38885
38966
|
witnessIndex: value.witnessIndex,
|
38886
|
-
maturity: value.maturity ?? 0,
|
38887
38967
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38888
|
-
predicateLength: predicate.length,
|
38889
|
-
predicateDataLength: predicateData.length,
|
38968
|
+
predicateLength: bn(predicate.length),
|
38969
|
+
predicateDataLength: bn(predicateData.length),
|
38890
38970
|
predicate: hexlify(predicate),
|
38891
38971
|
predicateData: hexlify(predicateData)
|
38892
38972
|
};
|
@@ -38917,8 +38997,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38917
38997
|
nonce: hexlify(value.nonce),
|
38918
38998
|
witnessIndex: value.witnessIndex,
|
38919
38999
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38920
|
-
predicateLength: predicate.length,
|
38921
|
-
predicateDataLength: predicateData.length,
|
39000
|
+
predicateLength: bn(predicate.length),
|
39001
|
+
predicateDataLength: bn(predicateData.length),
|
38922
39002
|
predicate: hexlify(predicate),
|
38923
39003
|
predicateData: hexlify(predicateData),
|
38924
39004
|
data: hexlify(data),
|
@@ -39078,8 +39158,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39078
39158
|
case "CALL" /* Call */: {
|
39079
39159
|
const callReceipt = {
|
39080
39160
|
type: ReceiptType.Call,
|
39081
|
-
from: hexOrZero(receipt.
|
39082
|
-
to: hexOrZero(receipt?.to
|
39161
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39162
|
+
to: hexOrZero(receipt?.to),
|
39083
39163
|
amount: bn(receipt.amount),
|
39084
39164
|
assetId: hexOrZero(receipt.assetId),
|
39085
39165
|
gas: bn(receipt.gas),
|
@@ -39093,7 +39173,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39093
39173
|
case "RETURN" /* Return */: {
|
39094
39174
|
const returnReceipt = {
|
39095
39175
|
type: ReceiptType.Return,
|
39096
|
-
id: hexOrZero(receipt.
|
39176
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39097
39177
|
val: bn(receipt.val),
|
39098
39178
|
pc: bn(receipt.pc),
|
39099
39179
|
is: bn(receipt.is)
|
@@ -39103,7 +39183,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39103
39183
|
case "RETURN_DATA" /* ReturnData */: {
|
39104
39184
|
const returnDataReceipt = {
|
39105
39185
|
type: ReceiptType.ReturnData,
|
39106
|
-
id: hexOrZero(receipt.
|
39186
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39107
39187
|
ptr: bn(receipt.ptr),
|
39108
39188
|
len: bn(receipt.len),
|
39109
39189
|
digest: hexOrZero(receipt.digest),
|
@@ -39115,7 +39195,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39115
39195
|
case "PANIC" /* Panic */: {
|
39116
39196
|
const panicReceipt = {
|
39117
39197
|
type: ReceiptType.Panic,
|
39118
|
-
id: hexOrZero(receipt.
|
39198
|
+
id: hexOrZero(receipt.id),
|
39119
39199
|
reason: bn(receipt.reason),
|
39120
39200
|
pc: bn(receipt.pc),
|
39121
39201
|
is: bn(receipt.is),
|
@@ -39126,7 +39206,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39126
39206
|
case "REVERT" /* Revert */: {
|
39127
39207
|
const revertReceipt = {
|
39128
39208
|
type: ReceiptType.Revert,
|
39129
|
-
id: hexOrZero(receipt.
|
39209
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39130
39210
|
val: bn(receipt.ra),
|
39131
39211
|
pc: bn(receipt.pc),
|
39132
39212
|
is: bn(receipt.is)
|
@@ -39136,7 +39216,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39136
39216
|
case "LOG" /* Log */: {
|
39137
39217
|
const logReceipt = {
|
39138
39218
|
type: ReceiptType.Log,
|
39139
|
-
id: hexOrZero(receipt.
|
39219
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39140
39220
|
val0: bn(receipt.ra),
|
39141
39221
|
val1: bn(receipt.rb),
|
39142
39222
|
val2: bn(receipt.rc),
|
@@ -39149,7 +39229,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39149
39229
|
case "LOG_DATA" /* LogData */: {
|
39150
39230
|
const logDataReceipt = {
|
39151
39231
|
type: ReceiptType.LogData,
|
39152
|
-
id: hexOrZero(receipt.
|
39232
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39153
39233
|
val0: bn(receipt.ra),
|
39154
39234
|
val1: bn(receipt.rb),
|
39155
39235
|
ptr: bn(receipt.ptr),
|
@@ -39163,8 +39243,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39163
39243
|
case "TRANSFER" /* Transfer */: {
|
39164
39244
|
const transferReceipt = {
|
39165
39245
|
type: ReceiptType.Transfer,
|
39166
|
-
from: hexOrZero(receipt.
|
39167
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
39246
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39247
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39168
39248
|
amount: bn(receipt.amount),
|
39169
39249
|
assetId: hexOrZero(receipt.assetId),
|
39170
39250
|
pc: bn(receipt.pc),
|
@@ -39175,8 +39255,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39175
39255
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39176
39256
|
const transferOutReceipt = {
|
39177
39257
|
type: ReceiptType.TransferOut,
|
39178
|
-
from: hexOrZero(receipt.
|
39179
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
39258
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39259
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
39180
39260
|
amount: bn(receipt.amount),
|
39181
39261
|
assetId: hexOrZero(receipt.assetId),
|
39182
39262
|
pc: bn(receipt.pc),
|
@@ -39219,7 +39299,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39219
39299
|
return receiptMessageOut;
|
39220
39300
|
}
|
39221
39301
|
case "MINT" /* Mint */: {
|
39222
|
-
const contractId = hexOrZero(receipt.
|
39302
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39223
39303
|
const subId = hexOrZero(receipt.subId);
|
39224
39304
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39225
39305
|
const mintReceipt = {
|
@@ -39234,7 +39314,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39234
39314
|
return mintReceipt;
|
39235
39315
|
}
|
39236
39316
|
case "BURN" /* Burn */: {
|
39237
|
-
const contractId = hexOrZero(receipt.
|
39317
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39238
39318
|
const subId = hexOrZero(receipt.subId);
|
39239
39319
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39240
39320
|
const burnReceipt = {
|
@@ -39315,7 +39395,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39315
39395
|
};
|
39316
39396
|
|
39317
39397
|
// src/providers/utils/gas.ts
|
39318
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39319
39398
|
var getGasUsedFromReceipts = (receipts) => {
|
39320
39399
|
const scriptResult = receipts.filter(
|
39321
39400
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39336,18 +39415,28 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39336
39415
|
}
|
39337
39416
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39338
39417
|
const witnessCache = [];
|
39339
|
-
const
|
39418
|
+
const chargeableInputs = inputs.filter((input) => {
|
39419
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39420
|
+
if (isCoinOrMessage) {
|
39421
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39422
|
+
return true;
|
39423
|
+
}
|
39424
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
39425
|
+
witnessCache.push(input.witnessIndex);
|
39426
|
+
return true;
|
39427
|
+
}
|
39428
|
+
}
|
39429
|
+
return false;
|
39430
|
+
});
|
39431
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39432
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
39340
39433
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39341
39434
|
return total.add(
|
39342
|
-
|
39435
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39343
39436
|
);
|
39344
39437
|
}
|
39345
|
-
|
39346
|
-
|
39347
|
-
return total.add(gasCosts.ecr1);
|
39348
|
-
}
|
39349
|
-
return total;
|
39350
|
-
}, bn());
|
39438
|
+
return total.add(gasCosts.ecr1);
|
39439
|
+
}, bn(0));
|
39351
39440
|
return totalGas;
|
39352
39441
|
}
|
39353
39442
|
function getMinGas(params) {
|
@@ -39359,12 +39448,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39359
39448
|
return minGas;
|
39360
39449
|
}
|
39361
39450
|
function getMaxGas(params) {
|
39362
|
-
const {
|
39451
|
+
const {
|
39452
|
+
gasPerByte,
|
39453
|
+
witnessesLength,
|
39454
|
+
witnessLimit,
|
39455
|
+
minGas,
|
39456
|
+
gasLimit = bn(0),
|
39457
|
+
maxGasPerTx
|
39458
|
+
} = params;
|
39363
39459
|
let remainingAllowedWitnessGas = bn(0);
|
39364
39460
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39365
39461
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39366
39462
|
}
|
39367
|
-
|
39463
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39464
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39368
39465
|
}
|
39369
39466
|
function calculateMetadataGasForTxCreate({
|
39370
39467
|
gasCosts,
|
@@ -39386,6 +39483,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39386
39483
|
}) {
|
39387
39484
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39388
39485
|
}
|
39486
|
+
var calculateGasFee = (params) => {
|
39487
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
39488
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39489
|
+
};
|
39389
39490
|
|
39390
39491
|
// src/providers/utils/json.ts
|
39391
39492
|
function normalize2(object) {
|
@@ -39527,7 +39628,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39527
39628
|
// src/providers/transaction-request/transaction-request.ts
|
39528
39629
|
var BaseTransactionRequest = class {
|
39529
39630
|
/** Gas price for transaction */
|
39530
|
-
|
39631
|
+
tip;
|
39531
39632
|
/** Block until which tx cannot be included */
|
39532
39633
|
maturity;
|
39533
39634
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39546,7 +39647,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39546
39647
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39547
39648
|
*/
|
39548
39649
|
constructor({
|
39549
|
-
|
39650
|
+
tip,
|
39550
39651
|
maturity,
|
39551
39652
|
maxFee,
|
39552
39653
|
witnessLimit,
|
@@ -39554,7 +39655,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39554
39655
|
outputs,
|
39555
39656
|
witnesses
|
39556
39657
|
} = {}) {
|
39557
|
-
this.
|
39658
|
+
this.tip = bn(tip);
|
39558
39659
|
this.maturity = maturity ?? 0;
|
39559
39660
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39560
39661
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
@@ -39565,9 +39666,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39565
39666
|
static getPolicyMeta(req) {
|
39566
39667
|
let policyTypes = 0;
|
39567
39668
|
const policies = [];
|
39568
|
-
if (req.
|
39569
|
-
policyTypes += PolicyType.
|
39570
|
-
policies.push({ data: req.
|
39669
|
+
if (req.tip) {
|
39670
|
+
policyTypes += PolicyType.Tip;
|
39671
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
39571
39672
|
}
|
39572
39673
|
if (req.witnessLimit) {
|
39573
39674
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39755,9 +39856,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39755
39856
|
* @param predicateData - Predicate data bytes.
|
39756
39857
|
*/
|
39757
39858
|
addCoinInput(coin) {
|
39758
|
-
const { assetId, owner, amount
|
39859
|
+
const { assetId, owner, amount } = coin;
|
39759
39860
|
let witnessIndex;
|
39760
|
-
if (predicate) {
|
39861
|
+
if (coin.predicate) {
|
39761
39862
|
witnessIndex = 0;
|
39762
39863
|
} else {
|
39763
39864
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39766,14 +39867,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39766
39867
|
}
|
39767
39868
|
}
|
39768
39869
|
const input = {
|
39769
|
-
|
39870
|
+
...coin,
|
39770
39871
|
type: InputType.Coin,
|
39771
39872
|
owner: owner.toB256(),
|
39772
39873
|
amount,
|
39773
39874
|
assetId,
|
39774
39875
|
txPointer: "0x00000000000000000000000000000000",
|
39775
|
-
witnessIndex
|
39776
|
-
predicate
|
39876
|
+
witnessIndex
|
39777
39877
|
};
|
39778
39878
|
this.pushInput(input);
|
39779
39879
|
this.addChangeOutput(owner, assetId);
|
@@ -39787,10 +39887,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39787
39887
|
* @param predicateData - Predicate data bytes.
|
39788
39888
|
*/
|
39789
39889
|
addMessageInput(message) {
|
39790
|
-
const { recipient, sender, amount
|
39890
|
+
const { recipient, sender, amount } = message;
|
39791
39891
|
const assetId = BaseAssetId;
|
39792
39892
|
let witnessIndex;
|
39793
|
-
if (predicate) {
|
39893
|
+
if (message.predicate) {
|
39794
39894
|
witnessIndex = 0;
|
39795
39895
|
} else {
|
39796
39896
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39799,13 +39899,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39799
39899
|
}
|
39800
39900
|
}
|
39801
39901
|
const input = {
|
39802
|
-
|
39902
|
+
...message,
|
39803
39903
|
type: InputType.Message,
|
39804
39904
|
sender: sender.toB256(),
|
39805
39905
|
recipient: recipient.toB256(),
|
39806
39906
|
amount,
|
39807
|
-
witnessIndex
|
39808
|
-
predicate
|
39907
|
+
witnessIndex
|
39809
39908
|
};
|
39810
39909
|
this.pushInput(input);
|
39811
39910
|
this.addChangeOutput(recipient, assetId);
|
@@ -39915,7 +40014,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39915
40014
|
}
|
39916
40015
|
calculateMaxGas(chainInfo, minGas) {
|
39917
40016
|
const { consensusParameters } = chainInfo;
|
39918
|
-
const { gasPerByte } = consensusParameters;
|
40017
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
39919
40018
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
39920
40019
|
(acc, wit) => acc + wit.dataLength,
|
39921
40020
|
0
|
@@ -39924,7 +40023,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39924
40023
|
gasPerByte,
|
39925
40024
|
minGas,
|
39926
40025
|
witnessesLength,
|
39927
|
-
witnessLimit: this.witnessLimit
|
40026
|
+
witnessLimit: this.witnessLimit,
|
40027
|
+
maxGasPerTx
|
39928
40028
|
});
|
39929
40029
|
}
|
39930
40030
|
/**
|
@@ -39934,12 +40034,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39934
40034
|
* @param quantities - CoinQuantity Array.
|
39935
40035
|
*/
|
39936
40036
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39937
|
-
let idCounter = 0;
|
39938
|
-
const generateId = () => {
|
39939
|
-
const counterString = String(idCounter++);
|
39940
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39941
|
-
return id;
|
39942
|
-
};
|
39943
40037
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39944
40038
|
if ("assetId" in input) {
|
39945
40039
|
return input.assetId === assetId;
|
@@ -39948,17 +40042,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39948
40042
|
});
|
39949
40043
|
const updateAssetInput = (assetId, quantity) => {
|
39950
40044
|
const assetInput = findAssetInput(assetId);
|
40045
|
+
let usedQuantity = quantity;
|
40046
|
+
if (assetId === BaseAssetId) {
|
40047
|
+
usedQuantity = bn("1000000000000000000");
|
40048
|
+
}
|
39951
40049
|
if (assetInput && "assetId" in assetInput) {
|
39952
|
-
assetInput.id =
|
39953
|
-
assetInput.amount =
|
40050
|
+
assetInput.id = hexlify(randomBytes3(34));
|
40051
|
+
assetInput.amount = usedQuantity;
|
39954
40052
|
} else {
|
39955
40053
|
this.addResources([
|
39956
40054
|
{
|
39957
|
-
id:
|
39958
|
-
amount:
|
40055
|
+
id: hexlify(randomBytes3(34)),
|
40056
|
+
amount: usedQuantity,
|
39959
40057
|
assetId,
|
39960
40058
|
owner: resourcesOwner || Address.fromRandom(),
|
39961
|
-
maturity: 0,
|
39962
40059
|
blockCreated: bn(1),
|
39963
40060
|
txCreatedIdx: bn(1)
|
39964
40061
|
}
|
@@ -39990,7 +40087,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39990
40087
|
toJSON() {
|
39991
40088
|
return normalizeJSON(this);
|
39992
40089
|
}
|
39993
|
-
|
40090
|
+
updatePredicateGasUsed(inputs) {
|
39994
40091
|
this.inputs.forEach((i) => {
|
39995
40092
|
let correspondingInput;
|
39996
40093
|
switch (i.type) {
|
@@ -40012,6 +40109,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40012
40109
|
}
|
40013
40110
|
});
|
40014
40111
|
}
|
40112
|
+
shiftPredicateData() {
|
40113
|
+
this.inputs.forEach((input) => {
|
40114
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40115
|
+
input.predicateData = input.paddPredicateData(
|
40116
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40117
|
+
);
|
40118
|
+
}
|
40119
|
+
});
|
40120
|
+
}
|
40015
40121
|
};
|
40016
40122
|
|
40017
40123
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40145,9 +40251,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40145
40251
|
return {
|
40146
40252
|
type: TransactionType.Create,
|
40147
40253
|
...baseTransaction,
|
40148
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40149
40254
|
bytecodeWitnessIndex,
|
40150
|
-
storageSlotsCount: storageSlots.length,
|
40255
|
+
storageSlotsCount: bn(storageSlots.length),
|
40151
40256
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40152
40257
|
storageSlots
|
40153
40258
|
};
|
@@ -40261,8 +40366,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40261
40366
|
type: TransactionType.Script,
|
40262
40367
|
scriptGasLimit: this.gasLimit,
|
40263
40368
|
...super.getBaseTransaction(),
|
40264
|
-
scriptLength: script.length,
|
40265
|
-
scriptDataLength: scriptData.length,
|
40369
|
+
scriptLength: bn(script.length),
|
40370
|
+
scriptDataLength: bn(scriptData.length),
|
40266
40371
|
receiptsRoot: ZeroBytes32,
|
40267
40372
|
script: hexlify(script),
|
40268
40373
|
scriptData: hexlify(scriptData)
|
@@ -40326,7 +40431,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40326
40431
|
}
|
40327
40432
|
calculateMaxGas(chainInfo, minGas) {
|
40328
40433
|
const { consensusParameters } = chainInfo;
|
40329
|
-
const { gasPerByte } = consensusParameters;
|
40434
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
40330
40435
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40331
40436
|
(acc, wit) => acc + wit.dataLength,
|
40332
40437
|
0
|
@@ -40336,7 +40441,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40336
40441
|
minGas,
|
40337
40442
|
witnessesLength,
|
40338
40443
|
witnessLimit: this.witnessLimit,
|
40339
|
-
gasLimit: this.gasLimit
|
40444
|
+
gasLimit: this.gasLimit,
|
40445
|
+
maxGasPerTx
|
40340
40446
|
});
|
40341
40447
|
}
|
40342
40448
|
/**
|
@@ -40409,13 +40515,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40409
40515
|
}
|
40410
40516
|
}
|
40411
40517
|
};
|
40518
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40519
|
+
(acc, input) => {
|
40520
|
+
if (input.type === InputType.Coin && input.owner === owner) {
|
40521
|
+
acc.utxos.push(input.id);
|
40522
|
+
}
|
40523
|
+
if (input.type === InputType.Message && input.recipient === owner) {
|
40524
|
+
acc.messages.push(input.nonce);
|
40525
|
+
}
|
40526
|
+
return acc;
|
40527
|
+
},
|
40528
|
+
{
|
40529
|
+
utxos: [],
|
40530
|
+
messages: []
|
40531
|
+
}
|
40532
|
+
);
|
40412
40533
|
|
40413
40534
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40414
40535
|
var calculateTransactionFee = (params) => {
|
40415
40536
|
const {
|
40416
|
-
|
40537
|
+
gasPrice,
|
40417
40538
|
rawPayload,
|
40418
|
-
|
40539
|
+
tip,
|
40540
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40419
40541
|
} = params;
|
40420
40542
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40421
40543
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40425,8 +40547,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40425
40547
|
return {
|
40426
40548
|
fee: bn(0),
|
40427
40549
|
minFee: bn(0),
|
40428
|
-
maxFee: bn(0)
|
40429
|
-
feeFromGasUsed: bn(0)
|
40550
|
+
maxFee: bn(0)
|
40430
40551
|
};
|
40431
40552
|
}
|
40432
40553
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40458,7 +40579,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40458
40579
|
metadataGas,
|
40459
40580
|
txBytesSize: transactionBytes.length
|
40460
40581
|
});
|
40461
|
-
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40462
40582
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40463
40583
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40464
40584
|
const maxGas = getMaxGas({
|
@@ -40466,17 +40586,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40466
40586
|
minGas,
|
40467
40587
|
witnessesLength,
|
40468
40588
|
gasLimit,
|
40469
|
-
witnessLimit
|
40589
|
+
witnessLimit,
|
40590
|
+
maxGasPerTx
|
40591
|
+
});
|
40592
|
+
const minFee = calculateGasFee({
|
40593
|
+
gasPrice,
|
40594
|
+
gas: minGas,
|
40595
|
+
priceFactor: gasPriceFactor,
|
40596
|
+
tip
|
40597
|
+
});
|
40598
|
+
const maxFee = calculateGasFee({
|
40599
|
+
gasPrice,
|
40600
|
+
gas: maxGas,
|
40601
|
+
priceFactor: gasPriceFactor,
|
40602
|
+
tip
|
40470
40603
|
});
|
40471
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40472
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40473
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40474
|
-
const fee = minFee.add(feeFromGasUsed);
|
40475
40604
|
return {
|
40476
|
-
fee,
|
40477
40605
|
minFee,
|
40478
40606
|
maxFee,
|
40479
|
-
|
40607
|
+
fee: maxFee
|
40480
40608
|
};
|
40481
40609
|
};
|
40482
40610
|
|
@@ -41077,7 +41205,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41077
41205
|
gqlTransactionStatus,
|
41078
41206
|
abiMap = {},
|
41079
41207
|
maxInputs,
|
41080
|
-
gasCosts
|
41208
|
+
gasCosts,
|
41209
|
+
maxGasPerTx,
|
41210
|
+
gasPrice
|
41081
41211
|
} = params;
|
41082
41212
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41083
41213
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41091,11 +41221,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41091
41221
|
maxInputs
|
41092
41222
|
});
|
41093
41223
|
const typeName = getTransactionTypeName(transaction.type);
|
41224
|
+
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41094
41225
|
const { fee } = calculateTransactionFee({
|
41095
|
-
|
41226
|
+
gasPrice,
|
41096
41227
|
rawPayload,
|
41228
|
+
tip,
|
41097
41229
|
consensusParameters: {
|
41098
41230
|
gasCosts,
|
41231
|
+
maxGasPerTx,
|
41099
41232
|
feeParams: {
|
41100
41233
|
gasPerByte,
|
41101
41234
|
gasPriceFactor
|
@@ -41231,8 +41364,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41231
41364
|
const decodedTransaction = this.decodeTransaction(
|
41232
41365
|
transaction
|
41233
41366
|
);
|
41234
|
-
|
41235
|
-
|
41367
|
+
let txReceipts = [];
|
41368
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
41369
|
+
txReceipts = transaction.status.receipts;
|
41370
|
+
}
|
41371
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41372
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41373
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
41236
41374
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41237
41375
|
const transactionSummary = assembleTransactionSummary({
|
41238
41376
|
id: this.id,
|
@@ -41244,7 +41382,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41244
41382
|
gasPriceFactor,
|
41245
41383
|
abiMap: contractsAbiMap,
|
41246
41384
|
maxInputs,
|
41247
|
-
gasCosts
|
41385
|
+
gasCosts,
|
41386
|
+
maxGasPerTx,
|
41387
|
+
gasPrice
|
41248
41388
|
});
|
41249
41389
|
return transactionSummary;
|
41250
41390
|
}
|
@@ -41393,7 +41533,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41393
41533
|
gasCosts,
|
41394
41534
|
latestBlock: {
|
41395
41535
|
id: latestBlock.id,
|
41396
|
-
height: bn(latestBlock.
|
41536
|
+
height: bn(latestBlock.height),
|
41397
41537
|
time: latestBlock.header.time,
|
41398
41538
|
transactions: latestBlock.transactions.map((i) => ({
|
41399
41539
|
id: i.id
|
@@ -41487,10 +41627,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41487
41627
|
* Returns some helpful parameters related to gas fees.
|
41488
41628
|
*/
|
41489
41629
|
getGasConfig() {
|
41490
|
-
const { minGasPrice } = this.getNode();
|
41491
41630
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41492
41631
|
return {
|
41493
|
-
minGasPrice,
|
41494
41632
|
maxGasPerTx,
|
41495
41633
|
maxGasPerPredicate,
|
41496
41634
|
gasPriceFactor,
|
@@ -41588,7 +41726,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41588
41726
|
*/
|
41589
41727
|
async getBlockNumber() {
|
41590
41728
|
const { chain } = await this.operations.getChain();
|
41591
|
-
return bn(chain.latestBlock.
|
41729
|
+
return bn(chain.latestBlock.height, 10);
|
41592
41730
|
}
|
41593
41731
|
/**
|
41594
41732
|
* Returns the chain information.
|
@@ -41600,11 +41738,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41600
41738
|
const processedNodeInfo = {
|
41601
41739
|
maxDepth: bn(nodeInfo.maxDepth),
|
41602
41740
|
maxTx: bn(nodeInfo.maxTx),
|
41603
|
-
minGasPrice: bn(nodeInfo.minGasPrice),
|
41604
41741
|
nodeVersion: nodeInfo.nodeVersion,
|
41605
41742
|
utxoValidation: nodeInfo.utxoValidation,
|
41606
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41607
|
-
peers: nodeInfo.peers
|
41743
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
41608
41744
|
};
|
41609
41745
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41610
41746
|
return processedNodeInfo;
|
@@ -41690,14 +41826,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41690
41826
|
return this.estimateTxDependencies(transactionRequest);
|
41691
41827
|
}
|
41692
41828
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41693
|
-
const { dryRun:
|
41694
|
-
encodedTransaction,
|
41829
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41830
|
+
encodedTransactions: encodedTransaction,
|
41695
41831
|
utxoValidation: utxoValidation || false
|
41696
41832
|
});
|
41697
|
-
const receipts =
|
41698
|
-
|
41699
|
-
|
41700
|
-
};
|
41833
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
41834
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
41835
|
+
return { receipts, dryrunStatus: status };
|
41701
41836
|
}
|
41702
41837
|
/**
|
41703
41838
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41736,9 +41871,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41736
41871
|
* If there are missing variable outputs,
|
41737
41872
|
* `addVariableOutputs` is called on the transaction.
|
41738
41873
|
*
|
41739
|
-
* @privateRemarks
|
41740
|
-
* TODO: Investigate support for missing contract IDs
|
41741
|
-
* TODO: Add support for missing output messages
|
41742
41874
|
*
|
41743
41875
|
* @param transactionRequest - The transaction request object.
|
41744
41876
|
* @returns A promise.
|
@@ -41751,16 +41883,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41751
41883
|
missingContractIds: []
|
41752
41884
|
};
|
41753
41885
|
}
|
41754
|
-
await this.estimatePredicates(transactionRequest);
|
41755
41886
|
let receipts = [];
|
41756
41887
|
const missingContractIds = [];
|
41757
41888
|
let outputVariables = 0;
|
41889
|
+
let dryrunStatus;
|
41758
41890
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41759
|
-
const {
|
41760
|
-
|
41891
|
+
const {
|
41892
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
41893
|
+
} = await this.operations.dryRun({
|
41894
|
+
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41761
41895
|
utxoValidation: false
|
41762
41896
|
});
|
41763
|
-
receipts =
|
41897
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
41898
|
+
dryrunStatus = status;
|
41764
41899
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41765
41900
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41766
41901
|
if (hasMissingOutputs) {
|
@@ -41770,6 +41905,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41770
41905
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41771
41906
|
missingContractIds.push(contractId);
|
41772
41907
|
});
|
41908
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41909
|
+
transactionRequest,
|
41910
|
+
optimizeGas: false
|
41911
|
+
});
|
41912
|
+
transactionRequest.maxFee = maxFee;
|
41773
41913
|
} else {
|
41774
41914
|
break;
|
41775
41915
|
}
|
@@ -41777,7 +41917,133 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41777
41917
|
return {
|
41778
41918
|
receipts,
|
41779
41919
|
outputVariables,
|
41780
|
-
missingContractIds
|
41920
|
+
missingContractIds,
|
41921
|
+
dryrunStatus
|
41922
|
+
};
|
41923
|
+
}
|
41924
|
+
/**
|
41925
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41926
|
+
*
|
41927
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41928
|
+
* further modifications are identified. The method iteratively updates these transactions
|
41929
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41930
|
+
*
|
41931
|
+
* @param transactionRequests - Array of transaction request objects.
|
41932
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
41933
|
+
*/
|
41934
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
41935
|
+
const results = transactionRequests.map(() => ({
|
41936
|
+
receipts: [],
|
41937
|
+
outputVariables: 0,
|
41938
|
+
missingContractIds: [],
|
41939
|
+
dryrunStatus: void 0
|
41940
|
+
}));
|
41941
|
+
const allRequests = clone_default(transactionRequests);
|
41942
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41943
|
+
allRequests.forEach((req, index) => {
|
41944
|
+
if (req.type === TransactionType.Script) {
|
41945
|
+
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41946
|
+
}
|
41947
|
+
});
|
41948
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41949
|
+
let attempt = 0;
|
41950
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41951
|
+
const encodedTransactions = transactionsToProcess.map(
|
41952
|
+
(index) => serializedTransactionsMap.get(index)
|
41953
|
+
);
|
41954
|
+
const dryRunResults = await this.operations.dryRun({
|
41955
|
+
encodedTransactions,
|
41956
|
+
utxoValidation: false
|
41957
|
+
});
|
41958
|
+
const nextRoundTransactions = [];
|
41959
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41960
|
+
const currentResultIndex = transactionsToProcess[i];
|
41961
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41962
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41963
|
+
results[currentResultIndex].dryrunStatus = status;
|
41964
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41965
|
+
results[currentResultIndex].receipts
|
41966
|
+
);
|
41967
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41968
|
+
const requestToProcess = allRequests[currentResultIndex];
|
41969
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41970
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41971
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41972
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
41973
|
+
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41974
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
41975
|
+
});
|
41976
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41977
|
+
transactionRequest: requestToProcess,
|
41978
|
+
optimizeGas: false
|
41979
|
+
});
|
41980
|
+
requestToProcess.maxFee = maxFee;
|
41981
|
+
serializedTransactionsMap.set(
|
41982
|
+
currentResultIndex,
|
41983
|
+
hexlify(requestToProcess.toTransactionBytes())
|
41984
|
+
);
|
41985
|
+
nextRoundTransactions.push(currentResultIndex);
|
41986
|
+
allRequests[currentResultIndex] = requestToProcess;
|
41987
|
+
}
|
41988
|
+
}
|
41989
|
+
transactionsToProcess = nextRoundTransactions;
|
41990
|
+
attempt += 1;
|
41991
|
+
}
|
41992
|
+
return results;
|
41993
|
+
}
|
41994
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41995
|
+
if (estimateTxDependencies) {
|
41996
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
41997
|
+
}
|
41998
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
41999
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42000
|
+
encodedTransactions,
|
42001
|
+
utxoValidation: utxoValidation || false
|
42002
|
+
});
|
42003
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42004
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
42005
|
+
return { receipts, dryrunStatus: status };
|
42006
|
+
});
|
42007
|
+
return results;
|
42008
|
+
}
|
42009
|
+
async estimateTxGasAndFee(params) {
|
42010
|
+
const { transactionRequest, optimizeGas = true } = params;
|
42011
|
+
let { gasPrice } = params;
|
42012
|
+
const chainInfo = this.getChain();
|
42013
|
+
const { gasPriceFactor } = this.getGasConfig();
|
42014
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42015
|
+
if (!gasPrice) {
|
42016
|
+
gasPrice = await this.estimateGasPrice(10);
|
42017
|
+
}
|
42018
|
+
const minFee = calculateGasFee({
|
42019
|
+
gasPrice: bn(gasPrice),
|
42020
|
+
gas: minGas,
|
42021
|
+
priceFactor: gasPriceFactor,
|
42022
|
+
tip: transactionRequest.tip
|
42023
|
+
}).add(1);
|
42024
|
+
let gasLimit = bn(0);
|
42025
|
+
if (transactionRequest.type === TransactionType.Script) {
|
42026
|
+
gasLimit = transactionRequest.gasLimit;
|
42027
|
+
if (!optimizeGas) {
|
42028
|
+
transactionRequest.gasLimit = minGas;
|
42029
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42030
|
+
transactionRequest.gasLimit = gasLimit;
|
42031
|
+
}
|
42032
|
+
}
|
42033
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42034
|
+
const maxFee = calculateGasFee({
|
42035
|
+
gasPrice: bn(gasPrice),
|
42036
|
+
gas: maxGas,
|
42037
|
+
priceFactor: gasPriceFactor,
|
42038
|
+
tip: transactionRequest.tip
|
42039
|
+
}).add(1);
|
42040
|
+
return {
|
42041
|
+
minGas,
|
42042
|
+
minFee,
|
42043
|
+
maxGas,
|
42044
|
+
maxFee,
|
42045
|
+
gasPrice,
|
42046
|
+
gasLimit
|
41781
42047
|
};
|
41782
42048
|
}
|
41783
42049
|
/**
|
@@ -41795,15 +42061,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41795
42061
|
if (estimateTxDependencies) {
|
41796
42062
|
return this.estimateTxDependencies(transactionRequest);
|
41797
42063
|
}
|
41798
|
-
const
|
41799
|
-
const { dryRun:
|
41800
|
-
|
42064
|
+
const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
|
42065
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42066
|
+
encodedTransactions,
|
41801
42067
|
utxoValidation: true
|
41802
42068
|
});
|
41803
|
-
const
|
41804
|
-
|
41805
|
-
receipts
|
41806
|
-
|
42069
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
42070
|
+
const { id, receipts, status } = dryRunStatus;
|
42071
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
42072
|
+
return { id, receipts: processedReceipts, status };
|
42073
|
+
});
|
42074
|
+
return { receipts: callResult[0].receipts };
|
41807
42075
|
}
|
41808
42076
|
/**
|
41809
42077
|
* Returns a transaction cost to enable user
|
@@ -41820,80 +42088,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41820
42088
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
41821
42089
|
* @returns A promise that resolves to the transaction cost object.
|
41822
42090
|
*/
|
41823
|
-
async getTransactionCost(transactionRequestLike,
|
41824
|
-
estimateTxDependencies = true,
|
41825
|
-
estimatePredicates = true,
|
41826
|
-
resourcesOwner,
|
41827
|
-
signatureCallback
|
41828
|
-
} = {}) {
|
42091
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
41829
42092
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41830
|
-
const chainInfo = this.getChain();
|
41831
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41832
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41833
42093
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41834
42094
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41835
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
42095
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
41836
42096
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41837
|
-
|
41838
|
-
|
41839
|
-
|
41840
|
-
}
|
41841
|
-
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41842
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41843
|
-
}
|
41844
|
-
await this.estimatePredicates(txRequestClone);
|
42097
|
+
txRequestClone.maxFee = bn(0);
|
42098
|
+
if (isScriptTransaction) {
|
42099
|
+
txRequestClone.gasLimit = bn(0);
|
41845
42100
|
}
|
41846
|
-
if (
|
41847
|
-
|
42101
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
42102
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41848
42103
|
}
|
41849
|
-
const
|
41850
|
-
|
42104
|
+
const signedRequest = clone_default(txRequestClone);
|
42105
|
+
let addedSignatures = 0;
|
42106
|
+
if (signatureCallback && isScriptTransaction) {
|
42107
|
+
const lengthBefore = signedRequest.witnesses.length;
|
42108
|
+
await signatureCallback(signedRequest);
|
42109
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
42110
|
+
}
|
42111
|
+
await this.estimatePredicates(signedRequest);
|
42112
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42113
|
+
transactionRequest: signedRequest,
|
42114
|
+
optimizeGas: false
|
42115
|
+
});
|
42116
|
+
txRequestClone.maxFee = maxFee;
|
41851
42117
|
let receipts = [];
|
41852
42118
|
let missingContractIds = [];
|
41853
42119
|
let outputVariables = 0;
|
41854
|
-
|
41855
|
-
|
41856
|
-
|
42120
|
+
let gasUsed = bn(0);
|
42121
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
42122
|
+
if (isScriptTransaction) {
|
42123
|
+
if (signatureCallback) {
|
42124
|
+
await signatureCallback(txRequestClone);
|
42125
|
+
}
|
42126
|
+
txRequestClone.gasLimit = gasLimit;
|
41857
42127
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41858
42128
|
receipts = result.receipts;
|
41859
42129
|
outputVariables = result.outputVariables;
|
41860
42130
|
missingContractIds = result.missingContractIds;
|
42131
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
42132
|
+
txRequestClone.gasLimit = gasUsed;
|
42133
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42134
|
+
transactionRequest: txRequestClone,
|
42135
|
+
gasPrice
|
42136
|
+
}));
|
41861
42137
|
}
|
41862
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41863
|
-
const usedFee = calculatePriceWithFactor(
|
41864
|
-
gasUsed,
|
41865
|
-
gasPrice,
|
41866
|
-
gasPriceFactor
|
41867
|
-
).normalizeZeroToOne();
|
41868
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41869
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41870
42138
|
return {
|
41871
42139
|
requiredQuantities: allQuantities,
|
41872
42140
|
receipts,
|
41873
42141
|
gasUsed,
|
41874
|
-
minGasPrice,
|
41875
42142
|
gasPrice,
|
41876
42143
|
minGas,
|
41877
42144
|
maxGas,
|
41878
|
-
usedFee,
|
41879
42145
|
minFee,
|
41880
42146
|
maxFee,
|
41881
|
-
estimatedInputs: txRequestClone.inputs,
|
41882
42147
|
outputVariables,
|
41883
|
-
missingContractIds
|
42148
|
+
missingContractIds,
|
42149
|
+
addedSignatures,
|
42150
|
+
estimatedPredicates: txRequestClone.inputs
|
41884
42151
|
};
|
41885
42152
|
}
|
41886
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
42153
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
41887
42154
|
const ownerAddress = Address.fromAddressOrString(owner);
|
41888
42155
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
41889
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42156
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
42157
|
+
quantitiesToContract
|
42158
|
+
});
|
41890
42159
|
transactionRequest.addResources(
|
41891
42160
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
41892
42161
|
);
|
41893
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41894
|
-
|
41895
|
-
|
41896
|
-
);
|
42162
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
42163
|
+
quantitiesToContract
|
42164
|
+
});
|
41897
42165
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
41898
42166
|
return {
|
41899
42167
|
resources,
|
@@ -41917,7 +42185,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41917
42185
|
assetId: coin.assetId,
|
41918
42186
|
amount: bn(coin.amount),
|
41919
42187
|
owner: Address.fromAddressOrString(coin.owner),
|
41920
|
-
maturity: bn(coin.maturity).toNumber(),
|
41921
42188
|
blockCreated: bn(coin.blockCreated),
|
41922
42189
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
41923
42190
|
}));
|
@@ -41969,7 +42236,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41969
42236
|
amount: bn(coin.amount),
|
41970
42237
|
assetId: coin.assetId,
|
41971
42238
|
owner: Address.fromAddressOrString(coin.owner),
|
41972
|
-
maturity: bn(coin.maturity).toNumber(),
|
41973
42239
|
blockCreated: bn(coin.blockCreated),
|
41974
42240
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
41975
42241
|
};
|
@@ -42002,7 +42268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42002
42268
|
}
|
42003
42269
|
return {
|
42004
42270
|
id: block2.id,
|
42005
|
-
height: bn(block2.
|
42271
|
+
height: bn(block2.height),
|
42006
42272
|
time: block2.header.time,
|
42007
42273
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42008
42274
|
};
|
@@ -42017,7 +42283,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42017
42283
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42018
42284
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42019
42285
|
id: block2.id,
|
42020
|
-
height: bn(block2.
|
42286
|
+
height: bn(block2.height),
|
42021
42287
|
time: block2.header.time,
|
42022
42288
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42023
42289
|
}));
|
@@ -42044,7 +42310,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42044
42310
|
}
|
42045
42311
|
return {
|
42046
42312
|
id: block2.id,
|
42047
|
-
height: bn(block2.
|
42313
|
+
height: bn(block2.height, 10),
|
42048
42314
|
time: block2.header.time,
|
42049
42315
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42050
42316
|
transactions: block2.transactions.map(
|
@@ -42224,7 +42490,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42224
42490
|
prevRoot: messageBlockHeader.prevRoot,
|
42225
42491
|
time: messageBlockHeader.time,
|
42226
42492
|
applicationHash: messageBlockHeader.applicationHash,
|
42227
|
-
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42228
42493
|
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42229
42494
|
},
|
42230
42495
|
commitBlockHeader: {
|
@@ -42236,7 +42501,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42236
42501
|
prevRoot: commitBlockHeader.prevRoot,
|
42237
42502
|
time: commitBlockHeader.time,
|
42238
42503
|
applicationHash: commitBlockHeader.applicationHash,
|
42239
|
-
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42240
42504
|
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42241
42505
|
},
|
42242
42506
|
sender: Address.fromAddressOrString(sender),
|
@@ -42246,6 +42510,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42246
42510
|
data
|
42247
42511
|
};
|
42248
42512
|
}
|
42513
|
+
async getLatestGasPrice() {
|
42514
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42515
|
+
return bn(latestGasPrice.gasPrice);
|
42516
|
+
}
|
42517
|
+
async estimateGasPrice(blockHorizon) {
|
42518
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42519
|
+
blockHorizon: String(blockHorizon)
|
42520
|
+
});
|
42521
|
+
return bn(estimateGasPrice.gasPrice);
|
42522
|
+
}
|
42249
42523
|
/**
|
42250
42524
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42251
42525
|
*
|
@@ -42306,10 +42580,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42306
42580
|
arrayify(gqlTransaction.rawPayload),
|
42307
42581
|
0
|
42308
42582
|
);
|
42309
|
-
|
42583
|
+
let txReceipts = [];
|
42584
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42585
|
+
txReceipts = gqlTransaction.status.receipts;
|
42586
|
+
}
|
42587
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42310
42588
|
const {
|
42311
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42589
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42312
42590
|
} = provider.getChain();
|
42591
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42313
42592
|
const transactionInfo = assembleTransactionSummary({
|
42314
42593
|
id: gqlTransaction.id,
|
42315
42594
|
receipts,
|
@@ -42320,7 +42599,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42320
42599
|
gasPriceFactor: bn(gasPriceFactor),
|
42321
42600
|
abiMap,
|
42322
42601
|
maxInputs,
|
42323
|
-
gasCosts
|
42602
|
+
gasCosts,
|
42603
|
+
maxGasPerTx,
|
42604
|
+
gasPrice
|
42324
42605
|
});
|
42325
42606
|
return {
|
42326
42607
|
gqlTransaction,
|
@@ -42330,10 +42611,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42330
42611
|
async function getTransactionSummaryFromRequest(params) {
|
42331
42612
|
const { provider, transactionRequest, abiMap } = params;
|
42332
42613
|
const { receipts } = await provider.call(transactionRequest);
|
42333
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42614
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
42334
42615
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42335
42616
|
const transaction = transactionRequest.toTransaction();
|
42336
42617
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42618
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42337
42619
|
const transactionSummary = assembleTransactionSummary({
|
42338
42620
|
receipts,
|
42339
42621
|
transaction,
|
@@ -42342,7 +42624,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42342
42624
|
gasPerByte,
|
42343
42625
|
gasPriceFactor,
|
42344
42626
|
maxInputs,
|
42345
|
-
gasCosts
|
42627
|
+
gasCosts,
|
42628
|
+
maxGasPerTx,
|
42629
|
+
gasPrice
|
42346
42630
|
});
|
42347
42631
|
return transactionSummary;
|
42348
42632
|
}
|
@@ -42351,13 +42635,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42351
42635
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42352
42636
|
const { edges, pageInfo } = transactionsByOwner;
|
42353
42637
|
const {
|
42354
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42638
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42355
42639
|
} = provider.getChain();
|
42640
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42356
42641
|
const transactions = edges.map((edge) => {
|
42357
42642
|
const { node: gqlTransaction } = edge;
|
42358
|
-
const { id, rawPayload,
|
42643
|
+
const { id, rawPayload, status } = gqlTransaction;
|
42359
42644
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42360
|
-
|
42645
|
+
let txReceipts = [];
|
42646
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42647
|
+
txReceipts = gqlTransaction.status.receipts;
|
42648
|
+
}
|
42649
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42361
42650
|
const transactionSummary = assembleTransactionSummary({
|
42362
42651
|
id,
|
42363
42652
|
receipts,
|
@@ -42368,7 +42657,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42368
42657
|
gasPerByte,
|
42369
42658
|
gasPriceFactor,
|
42370
42659
|
maxInputs,
|
42371
|
-
gasCosts
|
42660
|
+
gasCosts,
|
42661
|
+
maxGasPerTx,
|
42662
|
+
gasPrice
|
42372
42663
|
});
|
42373
42664
|
const output3 = {
|
42374
42665
|
gqlTransaction,
|
@@ -42697,36 +42988,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42697
42988
|
* @param fee - The estimated transaction fee.
|
42698
42989
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42699
42990
|
*/
|
42700
|
-
async fund(request,
|
42701
|
-
const
|
42991
|
+
async fund(request, params) {
|
42992
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
42993
|
+
const txRequest = request;
|
42994
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42702
42995
|
amount: bn(fee),
|
42703
42996
|
assetId: BaseAssetId,
|
42704
|
-
coinQuantities
|
42997
|
+
coinQuantities: requiredQuantities
|
42705
42998
|
});
|
42706
42999
|
const quantitiesDict = {};
|
42707
|
-
|
43000
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
42708
43001
|
quantitiesDict[assetId] = {
|
42709
43002
|
required: amount,
|
42710
43003
|
owned: bn(0)
|
42711
43004
|
};
|
42712
43005
|
});
|
42713
|
-
|
42714
|
-
const cachedMessages = [];
|
42715
|
-
const owner = this.address.toB256();
|
42716
|
-
request.inputs.forEach((input) => {
|
43006
|
+
txRequest.inputs.forEach((input) => {
|
42717
43007
|
const isResource = "amount" in input;
|
42718
43008
|
if (isResource) {
|
42719
43009
|
const isCoin2 = "owner" in input;
|
42720
43010
|
if (isCoin2) {
|
42721
43011
|
const assetId = String(input.assetId);
|
42722
|
-
if (
|
43012
|
+
if (quantitiesDict[assetId]) {
|
42723
43013
|
const amount = bn(input.amount);
|
42724
43014
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42725
|
-
cachedUtxos.push(input.id);
|
42726
43015
|
}
|
42727
|
-
} else if (input.
|
43016
|
+
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
42728
43017
|
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42729
|
-
cachedMessages.push(input.nonce);
|
42730
43018
|
}
|
42731
43019
|
}
|
42732
43020
|
});
|
@@ -42741,12 +43029,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42741
43029
|
});
|
42742
43030
|
const needsToBeFunded = missingQuantities.length;
|
42743
43031
|
if (needsToBeFunded) {
|
42744
|
-
const
|
42745
|
-
|
42746
|
-
|
42747
|
-
|
42748
|
-
|
43032
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
43033
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
43034
|
+
txRequest.addResources(resources);
|
43035
|
+
}
|
43036
|
+
txRequest.shiftPredicateData();
|
43037
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43038
|
+
const requestToBeReEstimate = clone_default(txRequest);
|
43039
|
+
if (addedSignatures) {
|
43040
|
+
Array.from({ length: addedSignatures }).forEach(
|
43041
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
43042
|
+
);
|
42749
43043
|
}
|
43044
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43045
|
+
transactionRequest: requestToBeReEstimate
|
43046
|
+
});
|
43047
|
+
txRequest.maxFee = maxFee;
|
43048
|
+
return txRequest;
|
42750
43049
|
}
|
42751
43050
|
/**
|
42752
43051
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -42754,28 +43053,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42754
43053
|
* @param destination - The address of the destination.
|
42755
43054
|
* @param amount - The amount of coins to transfer.
|
42756
43055
|
* @param assetId - The asset ID of the coins to transfer.
|
42757
|
-
* @param txParams - The transaction parameters (gasLimit,
|
43056
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
42758
43057
|
* @returns A promise that resolves to the prepared transaction request.
|
42759
43058
|
*/
|
42760
43059
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42761
|
-
const
|
42762
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
42763
|
-
const request = new ScriptTransactionRequest(params);
|
43060
|
+
const request = new ScriptTransactionRequest(txParams);
|
42764
43061
|
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42765
|
-
const
|
43062
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
42766
43063
|
estimateTxDependencies: true,
|
42767
43064
|
resourcesOwner: this
|
42768
43065
|
});
|
42769
|
-
|
42770
|
-
|
42771
|
-
|
42772
|
-
|
42773
|
-
|
42774
|
-
|
42775
|
-
|
42776
|
-
|
42777
|
-
await this.fund(request,
|
42778
|
-
request.updatePredicateInputs(estimatedInputs);
|
43066
|
+
if ("gasLimit" in txParams) {
|
43067
|
+
this.validateGas({
|
43068
|
+
gasUsed: txCost.gasUsed,
|
43069
|
+
gasLimit: request.gasLimit
|
43070
|
+
});
|
43071
|
+
}
|
43072
|
+
request.gasLimit = txCost.gasUsed;
|
43073
|
+
request.maxFee = txCost.maxFee;
|
43074
|
+
await this.fund(request, txCost);
|
42779
43075
|
return request;
|
42780
43076
|
}
|
42781
43077
|
/**
|
@@ -42814,31 +43110,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42814
43110
|
);
|
42815
43111
|
}
|
42816
43112
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42817
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42818
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
42819
43113
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42820
43114
|
hexlifiedContractId: contractAddress.toB256(),
|
42821
43115
|
amountToTransfer: bn(amount),
|
42822
43116
|
assetId
|
42823
43117
|
});
|
42824
43118
|
const request = new ScriptTransactionRequest({
|
42825
|
-
...
|
43119
|
+
...txParams,
|
42826
43120
|
script,
|
42827
43121
|
scriptData
|
42828
43122
|
});
|
42829
43123
|
request.addContractInputAndOutput(contractAddress);
|
42830
|
-
const
|
42831
|
-
|
42832
|
-
[{ amount: bn(amount), assetId: String(assetId) }]
|
42833
|
-
);
|
42834
|
-
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42835
|
-
this.validateGas({
|
42836
|
-
gasUsed,
|
42837
|
-
gasPrice: request.gasPrice,
|
42838
|
-
gasLimit: request.gasLimit,
|
42839
|
-
minGasPrice
|
43124
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
43125
|
+
resourcesOwner: this,
|
43126
|
+
quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
|
42840
43127
|
});
|
42841
|
-
|
43128
|
+
if (txParams.gasLimit) {
|
43129
|
+
this.validateGas({
|
43130
|
+
gasUsed: txCost.gasUsed,
|
43131
|
+
gasLimit: request.gasLimit
|
43132
|
+
});
|
43133
|
+
}
|
43134
|
+
request.gasLimit = txCost.gasUsed;
|
43135
|
+
request.maxFee = txCost.maxFee;
|
43136
|
+
await this.fund(request, txCost);
|
42842
43137
|
return this.sendTransaction(request);
|
42843
43138
|
}
|
42844
43139
|
/**
|
@@ -42850,7 +43145,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42850
43145
|
* @returns A promise that resolves to the transaction response.
|
42851
43146
|
*/
|
42852
43147
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42853
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42854
43148
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42855
43149
|
const recipientDataArray = arrayify(
|
42856
43150
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42863,21 +43157,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42863
43157
|
...recipientDataArray,
|
42864
43158
|
...amountDataArray
|
42865
43159
|
]);
|
42866
|
-
const params = { script,
|
43160
|
+
const params = { script, ...txParams };
|
42867
43161
|
const request = new ScriptTransactionRequest(params);
|
42868
|
-
const
|
42869
|
-
const
|
42870
|
-
|
42871
|
-
|
42872
|
-
|
42873
|
-
|
42874
|
-
|
42875
|
-
|
42876
|
-
|
42877
|
-
|
42878
|
-
|
42879
|
-
});
|
42880
|
-
await this.fund(request, requiredQuantities, maxFee);
|
43162
|
+
const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
|
43163
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
43164
|
+
if (txParams.gasLimit) {
|
43165
|
+
this.validateGas({
|
43166
|
+
gasUsed: txCost.gasUsed,
|
43167
|
+
gasLimit: request.gasLimit
|
43168
|
+
});
|
43169
|
+
}
|
43170
|
+
request.maxFee = txCost.maxFee;
|
43171
|
+
request.gasLimit = txCost.gasUsed;
|
43172
|
+
await this.fund(request, txCost);
|
42881
43173
|
return this.sendTransaction(request);
|
42882
43174
|
}
|
42883
43175
|
async signMessage(message) {
|
@@ -42935,18 +43227,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42935
43227
|
}
|
42936
43228
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
42937
43229
|
}
|
42938
|
-
validateGas({
|
42939
|
-
gasUsed,
|
42940
|
-
gasPrice,
|
42941
|
-
gasLimit,
|
42942
|
-
minGasPrice
|
42943
|
-
}) {
|
42944
|
-
if (minGasPrice.gt(gasPrice)) {
|
42945
|
-
throw new FuelError(
|
42946
|
-
ErrorCode.GAS_PRICE_TOO_LOW,
|
42947
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
42948
|
-
);
|
42949
|
-
}
|
43230
|
+
validateGas({ gasUsed, gasLimit }) {
|
42950
43231
|
if (gasUsed.gt(gasLimit)) {
|
42951
43232
|
throw new FuelError(
|
42952
43233
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44329,12 +44610,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44329
44610
|
};
|
44330
44611
|
|
44331
44612
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44332
|
-
var
|
44613
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44333
44614
|
var rnds8Pool = new Uint8Array(256);
|
44334
44615
|
var poolPtr = rnds8Pool.length;
|
44335
44616
|
function rng() {
|
44336
44617
|
if (poolPtr > rnds8Pool.length - 16) {
|
44337
|
-
|
44618
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44338
44619
|
poolPtr = 0;
|
44339
44620
|
}
|
44340
44621
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44350,9 +44631,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44350
44631
|
}
|
44351
44632
|
|
44352
44633
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44353
|
-
var
|
44634
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44354
44635
|
var native_default = {
|
44355
|
-
randomUUID:
|
44636
|
+
randomUUID: import_crypto17.default.randomUUID
|
44356
44637
|
};
|
44357
44638
|
|
44358
44639
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -44535,7 +44816,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44535
44816
|
* @param transactionRequestLike - The transaction request to send.
|
44536
44817
|
* @returns A promise that resolves to the TransactionResponse object.
|
44537
44818
|
*/
|
44538
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44819
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
44539
44820
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44540
44821
|
if (estimateTxDependencies) {
|
44541
44822
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -47813,9 +48094,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47813
48094
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47814
48095
|
request.inputs?.forEach((input) => {
|
47815
48096
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47816
|
-
input.predicate = this.bytes;
|
47817
|
-
input.predicateData = this.getPredicateData(policies.length);
|
47818
|
-
input.witnessIndex = 0;
|
48097
|
+
input.predicate = hexlify(this.bytes);
|
48098
|
+
input.predicateData = hexlify(this.getPredicateData(policies.length));
|
47819
48099
|
}
|
47820
48100
|
});
|
47821
48101
|
return request;
|
@@ -47830,8 +48110,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47830
48110
|
* @returns A promise that resolves to the prepared transaction request.
|
47831
48111
|
*/
|
47832
48112
|
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47833
|
-
|
47834
|
-
return this.populateTransactionPredicateData(request);
|
48113
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
47835
48114
|
}
|
47836
48115
|
/**
|
47837
48116
|
* Sends a transaction with the populated predicate data.
|
@@ -47839,9 +48118,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47839
48118
|
* @param transactionRequestLike - The transaction request-like object.
|
47840
48119
|
* @returns A promise that resolves to the transaction response.
|
47841
48120
|
*/
|
47842
|
-
sendTransaction(transactionRequestLike
|
47843
|
-
const transactionRequest =
|
47844
|
-
return super.sendTransaction(transactionRequest,
|
48121
|
+
sendTransaction(transactionRequestLike) {
|
48122
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48123
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
47845
48124
|
}
|
47846
48125
|
/**
|
47847
48126
|
* Simulates a transaction with the populated predicate data.
|
@@ -47850,22 +48129,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47850
48129
|
* @returns A promise that resolves to the call result.
|
47851
48130
|
*/
|
47852
48131
|
simulateTransaction(transactionRequestLike) {
|
47853
|
-
const transactionRequest =
|
47854
|
-
return super.simulateTransaction(transactionRequest);
|
47855
|
-
}
|
47856
|
-
/**
|
47857
|
-
* Retrieves resources satisfying the spend query for the account.
|
47858
|
-
*
|
47859
|
-
* @param quantities - IDs of coins to exclude.
|
47860
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
47861
|
-
* @returns A promise that resolves to an array of Resources.
|
47862
|
-
*/
|
47863
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
47864
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47865
|
-
return resources.map((resource) => ({
|
47866
|
-
...resource,
|
47867
|
-
predicate: hexlify(this.bytes)
|
47868
|
-
}));
|
48132
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48133
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
47869
48134
|
}
|
47870
48135
|
getPredicateData(policiesLength) {
|
47871
48136
|
if (!this.predicateData.length) {
|
@@ -47911,6 +48176,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47911
48176
|
predicateInterface: abiInterface
|
47912
48177
|
};
|
47913
48178
|
}
|
48179
|
+
/**
|
48180
|
+
* Retrieves resources satisfying the spend query for the account.
|
48181
|
+
*
|
48182
|
+
* @param quantities - IDs of coins to exclude.
|
48183
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
48184
|
+
* @returns A promise that resolves to an array of Resources.
|
48185
|
+
*/
|
48186
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
48187
|
+
const resources = await this.provider.getResourcesToSpend(
|
48188
|
+
this.address,
|
48189
|
+
quantities,
|
48190
|
+
excludedIds
|
48191
|
+
);
|
48192
|
+
return resources.map((resource) => ({
|
48193
|
+
...resource,
|
48194
|
+
predicate: hexlify(this.bytes),
|
48195
|
+
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48196
|
+
}));
|
48197
|
+
}
|
47914
48198
|
/**
|
47915
48199
|
* Sets the configurable constants for the predicate.
|
47916
48200
|
*
|