@fuel-ts/account 0.0.0-rc-2021-20240409152935 → 0.0.0-rc-1976-20240410103621
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +678 -946
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +611 -850
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +454 -692
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +328 -894
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +3 -3
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -3
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +34 -45
- 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 +29 -9
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1179 -1661
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +608 -826
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +466 -684
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max2(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,8 +28952,8 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
|
+
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29015,6 +29015,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29015
29015
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
29016
29016
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
29017
29017
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
29018
|
+
ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
|
29018
29019
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
29019
29020
|
ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
|
29020
29021
|
ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
|
@@ -29244,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29244
29245
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29245
29246
|
|
29246
29247
|
// ../crypto/dist/index.mjs
|
29247
|
-
var
|
29248
|
+
var import_crypto8 = __toESM(__require("crypto"), 1);
|
29248
29249
|
|
29249
29250
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29250
29251
|
var version = "6.7.1";
|
@@ -30316,27 +30317,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30316
30317
|
};
|
30317
30318
|
Object.freeze(pbkdf22);
|
30318
30319
|
|
30319
|
-
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30320
|
-
var locked5 = false;
|
30321
|
-
var _randomBytes = function(length) {
|
30322
|
-
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30323
|
-
};
|
30324
|
-
var __randomBytes = _randomBytes;
|
30325
|
-
function randomBytes3(length) {
|
30326
|
-
return __randomBytes(length);
|
30327
|
-
}
|
30328
|
-
randomBytes3._ = _randomBytes;
|
30329
|
-
randomBytes3.lock = function() {
|
30330
|
-
locked5 = true;
|
30331
|
-
};
|
30332
|
-
randomBytes3.register = function(func) {
|
30333
|
-
if (locked5) {
|
30334
|
-
throw new Error("randomBytes is locked");
|
30335
|
-
}
|
30336
|
-
__randomBytes = func;
|
30337
|
-
};
|
30338
|
-
Object.freeze(randomBytes3);
|
30339
|
-
|
30340
30320
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30341
30321
|
var BN_03 = BigInt(0);
|
30342
30322
|
var BN_36 = BigInt(36);
|
@@ -30921,8 +30901,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30921
30901
|
}
|
30922
30902
|
|
30923
30903
|
// ../crypto/dist/index.mjs
|
30904
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30924
30905
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30925
|
-
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30926
30906
|
var scrypt3 = (params) => {
|
30927
30907
|
const { password, salt, n, p, r, dklen } = params;
|
30928
30908
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30931,7 +30911,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30931
30911
|
var keccak2562 = (data) => keccak_256(data);
|
30932
30912
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30933
30913
|
var randomBytes4 = (length) => {
|
30934
|
-
const randomValues = Uint8Array.from(
|
30914
|
+
const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
|
30935
30915
|
return randomValues;
|
30936
30916
|
};
|
30937
30917
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30946,7 +30926,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30946
30926
|
const salt = randomBytes4(32);
|
30947
30927
|
const secret = keyFromPassword(password, salt);
|
30948
30928
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30949
|
-
const cipher = await
|
30929
|
+
const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
|
30950
30930
|
let cipherData = cipher.update(dataBuffer);
|
30951
30931
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30952
30932
|
return {
|
@@ -30960,7 +30940,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30960
30940
|
const salt = bufferFromString(keystore.salt);
|
30961
30941
|
const secret = keyFromPassword(password, salt);
|
30962
30942
|
const encryptedText = bufferFromString(keystore.data);
|
30963
|
-
const decipher = await
|
30943
|
+
const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
|
30964
30944
|
const decrypted = decipher.update(encryptedText);
|
30965
30945
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30966
30946
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30971,12 +30951,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30971
30951
|
}
|
30972
30952
|
};
|
30973
30953
|
async function encryptJsonWalletData(data, key, iv) {
|
30974
|
-
const cipher = await
|
30954
|
+
const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30975
30955
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30976
30956
|
return new Uint8Array(encrypted);
|
30977
30957
|
}
|
30978
30958
|
async function decryptJsonWalletData(data, key, iv) {
|
30979
|
-
const decipher =
|
30959
|
+
const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30980
30960
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30981
30961
|
return new Uint8Array(decrypted);
|
30982
30962
|
}
|
@@ -31292,10 +31272,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31292
31272
|
}
|
31293
31273
|
};
|
31294
31274
|
|
31295
|
-
// ../address/dist/configs.mjs
|
31296
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31297
|
-
var BaseAssetId = ZeroBytes32;
|
31298
|
-
|
31299
31275
|
// ../math/dist/index.mjs
|
31300
31276
|
var import_bn = __toESM(require_bn(), 1);
|
31301
31277
|
var DEFAULT_PRECISION = 9;
|
@@ -31515,182 +31491,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31515
31491
|
function toBytes3(value, bytesPadding) {
|
31516
31492
|
return bn(value).toBytes(bytesPadding);
|
31517
31493
|
}
|
31518
|
-
|
31519
|
-
|
31520
|
-
function _isPlaceholder(a) {
|
31521
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31522
|
-
}
|
31523
|
-
|
31524
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31525
|
-
function _curry1(fn) {
|
31526
|
-
return function f1(a) {
|
31527
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31528
|
-
return f1;
|
31529
|
-
} else {
|
31530
|
-
return fn.apply(this, arguments);
|
31531
|
-
}
|
31532
|
-
};
|
31533
|
-
}
|
31534
|
-
|
31535
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31536
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
31537
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31538
|
-
};
|
31539
|
-
|
31540
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31541
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31542
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31543
|
-
});
|
31544
|
-
var type_default = type;
|
31545
|
-
|
31546
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31547
|
-
var pad = function pad2(n) {
|
31548
|
-
return (n < 10 ? "0" : "") + n;
|
31549
|
-
};
|
31550
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31551
|
-
return d.toISOString();
|
31552
|
-
} : function _toISOString3(d) {
|
31553
|
-
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
31554
|
-
};
|
31555
|
-
|
31556
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31557
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31558
|
-
return n << 0 === n;
|
31559
|
-
};
|
31560
|
-
|
31561
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31562
|
-
function _cloneRegExp(pattern) {
|
31563
|
-
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
31494
|
+
function max(...numbers) {
|
31495
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31564
31496
|
}
|
31565
31497
|
|
31566
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31567
|
-
function _clone(value, deep, map) {
|
31568
|
-
map || (map = new _ObjectMap());
|
31569
|
-
if (_isPrimitive(value)) {
|
31570
|
-
return value;
|
31571
|
-
}
|
31572
|
-
var copy = function copy2(copiedValue) {
|
31573
|
-
var cachedCopy = map.get(value);
|
31574
|
-
if (cachedCopy) {
|
31575
|
-
return cachedCopy;
|
31576
|
-
}
|
31577
|
-
map.set(value, copiedValue);
|
31578
|
-
for (var key in value) {
|
31579
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31580
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31581
|
-
}
|
31582
|
-
}
|
31583
|
-
return copiedValue;
|
31584
|
-
};
|
31585
|
-
switch (type_default(value)) {
|
31586
|
-
case "Object":
|
31587
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31588
|
-
case "Array":
|
31589
|
-
return copy([]);
|
31590
|
-
case "Date":
|
31591
|
-
return new Date(value.valueOf());
|
31592
|
-
case "RegExp":
|
31593
|
-
return _cloneRegExp(value);
|
31594
|
-
case "Int8Array":
|
31595
|
-
case "Uint8Array":
|
31596
|
-
case "Uint8ClampedArray":
|
31597
|
-
case "Int16Array":
|
31598
|
-
case "Uint16Array":
|
31599
|
-
case "Int32Array":
|
31600
|
-
case "Uint32Array":
|
31601
|
-
case "Float32Array":
|
31602
|
-
case "Float64Array":
|
31603
|
-
case "BigInt64Array":
|
31604
|
-
case "BigUint64Array":
|
31605
|
-
return value.slice();
|
31606
|
-
default:
|
31607
|
-
return value;
|
31608
|
-
}
|
31609
|
-
}
|
31610
|
-
function _isPrimitive(param) {
|
31611
|
-
var type3 = typeof param;
|
31612
|
-
return param == null || type3 != "object" && type3 != "function";
|
31613
|
-
}
|
31614
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
31615
|
-
function _ObjectMap2() {
|
31616
|
-
this.map = {};
|
31617
|
-
this.length = 0;
|
31618
|
-
}
|
31619
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
31620
|
-
const hashedKey = this.hash(key);
|
31621
|
-
let bucket = this.map[hashedKey];
|
31622
|
-
if (!bucket) {
|
31623
|
-
this.map[hashedKey] = bucket = [];
|
31624
|
-
}
|
31625
|
-
bucket.push([key, value]);
|
31626
|
-
this.length += 1;
|
31627
|
-
};
|
31628
|
-
_ObjectMap2.prototype.hash = function(key) {
|
31629
|
-
let hashedKey = [];
|
31630
|
-
for (var value in key) {
|
31631
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31632
|
-
}
|
31633
|
-
return hashedKey.join();
|
31634
|
-
};
|
31635
|
-
_ObjectMap2.prototype.get = function(key) {
|
31636
|
-
if (this.length <= 180) {
|
31637
|
-
for (const p in this.map) {
|
31638
|
-
const bucket2 = this.map[p];
|
31639
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
31640
|
-
const element = bucket2[i];
|
31641
|
-
if (element[0] === key) {
|
31642
|
-
return element[1];
|
31643
|
-
}
|
31644
|
-
}
|
31645
|
-
}
|
31646
|
-
return;
|
31647
|
-
}
|
31648
|
-
const hashedKey = this.hash(key);
|
31649
|
-
const bucket = this.map[hashedKey];
|
31650
|
-
if (!bucket) {
|
31651
|
-
return;
|
31652
|
-
}
|
31653
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
31654
|
-
const element = bucket[i];
|
31655
|
-
if (element[0] === key) {
|
31656
|
-
return element[1];
|
31657
|
-
}
|
31658
|
-
}
|
31659
|
-
};
|
31660
|
-
return _ObjectMap2;
|
31661
|
-
}();
|
31662
|
-
|
31663
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31664
|
-
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31665
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31666
|
-
});
|
31667
|
-
var clone_default = clone;
|
31668
|
-
|
31669
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31670
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31671
|
-
|
31672
31498
|
// src/providers/coin-quantity.ts
|
31673
31499
|
var coinQuantityfy = (coinQuantityLike) => {
|
31674
31500
|
let assetId;
|
31675
31501
|
let amount;
|
31676
|
-
let
|
31502
|
+
let max2;
|
31677
31503
|
if (Array.isArray(coinQuantityLike)) {
|
31678
31504
|
amount = coinQuantityLike[0];
|
31679
|
-
assetId = coinQuantityLike[1]
|
31680
|
-
|
31505
|
+
assetId = coinQuantityLike[1];
|
31506
|
+
max2 = coinQuantityLike[2];
|
31681
31507
|
} else {
|
31682
31508
|
amount = coinQuantityLike.amount;
|
31683
|
-
assetId = coinQuantityLike.assetId
|
31684
|
-
|
31509
|
+
assetId = coinQuantityLike.assetId;
|
31510
|
+
max2 = coinQuantityLike.max ?? void 0;
|
31685
31511
|
}
|
31686
31512
|
const bnAmount = bn(amount);
|
31687
31513
|
return {
|
31688
31514
|
assetId: hexlify(assetId),
|
31689
31515
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31690
|
-
max:
|
31516
|
+
max: max2 ? bn(max2) : void 0
|
31691
31517
|
};
|
31692
31518
|
};
|
31693
|
-
var
|
31519
|
+
var addAmountToAsset = (params) => {
|
31694
31520
|
const { amount, assetId } = params;
|
31695
31521
|
const coinQuantities = [...params.coinQuantities];
|
31696
31522
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31782,9 +31608,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31782
31608
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31783
31609
|
var MAX_BYTES = 2 ** 32 - 1;
|
31784
31610
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31785
|
-
|
31611
|
+
WORD_SIZE + // Tx size
|
31786
31612
|
// Asset ID/Balance coin input pairs
|
31787
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE)
|
31613
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31788
31614
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31789
31615
|
WORD_SIZE + // Gas limit
|
31790
31616
|
WORD_SIZE + // Script size
|
@@ -31802,6 +31628,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31802
31628
|
ASSET_ID_LEN + // Asset id
|
31803
31629
|
TX_POINTER_LEN + // TxPointer
|
31804
31630
|
WORD_SIZE + // Witnesses index
|
31631
|
+
WORD_SIZE + // Maturity
|
31805
31632
|
WORD_SIZE + // Predicate size
|
31806
31633
|
WORD_SIZE + // Predicate data size
|
31807
31634
|
WORD_SIZE;
|
@@ -31924,15 +31751,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31924
31751
|
}
|
31925
31752
|
};
|
31926
31753
|
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
31927
|
-
function findOrThrow(arr, predicate, throwFn = () => {
|
31928
|
-
throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
|
31929
|
-
}) {
|
31930
|
-
const found = arr.find(predicate);
|
31931
|
-
if (found === void 0) {
|
31932
|
-
throwFn();
|
31933
|
-
}
|
31934
|
-
return found;
|
31935
|
-
}
|
31936
31754
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31937
31755
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31938
31756
|
var rightPadToWordSize = (encoded) => {
|
@@ -32131,7 +31949,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32131
31949
|
constructor(name, coders) {
|
32132
31950
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32133
31951
|
const encodedValueSize = Object.values(coders).reduce(
|
32134
|
-
(
|
31952
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32135
31953
|
0
|
32136
31954
|
);
|
32137
31955
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32515,6 +32333,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32515
32333
|
];
|
32516
32334
|
}
|
32517
32335
|
};
|
32336
|
+
var findFunctionByName = (abi, name) => {
|
32337
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
32338
|
+
if (!fn) {
|
32339
|
+
throw new FuelError(
|
32340
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
32341
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
32342
|
+
);
|
32343
|
+
}
|
32344
|
+
return fn;
|
32345
|
+
};
|
32346
|
+
var findTypeById = (abi, typeId) => {
|
32347
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
32348
|
+
if (!type3) {
|
32349
|
+
throw new FuelError(
|
32350
|
+
ErrorCode.TYPE_NOT_FOUND,
|
32351
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
32352
|
+
);
|
32353
|
+
}
|
32354
|
+
return type3;
|
32355
|
+
};
|
32356
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
32357
|
+
var findVectorBufferArgument = (components) => {
|
32358
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
32359
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
32360
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
32361
|
+
throw new FuelError(
|
32362
|
+
ErrorCode.INVALID_COMPONENT,
|
32363
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
32364
|
+
);
|
32365
|
+
}
|
32366
|
+
return bufferTypeArgument;
|
32367
|
+
};
|
32518
32368
|
var ResolvedAbiType = class {
|
32519
32369
|
abi;
|
32520
32370
|
name;
|
@@ -32523,20 +32373,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32523
32373
|
components;
|
32524
32374
|
constructor(abi, argument) {
|
32525
32375
|
this.abi = abi;
|
32526
|
-
const type3 = findOrThrow(
|
32527
|
-
abi.types,
|
32528
|
-
(t) => t.typeId === argument.type,
|
32529
|
-
() => {
|
32530
|
-
throw new FuelError(
|
32531
|
-
ErrorCode.TYPE_NOT_FOUND,
|
32532
|
-
`Type does not exist in the provided abi: ${JSON.stringify({
|
32533
|
-
argument,
|
32534
|
-
abi: this.abi
|
32535
|
-
})}`
|
32536
|
-
);
|
32537
|
-
}
|
32538
|
-
);
|
32539
32376
|
this.name = argument.name;
|
32377
|
+
const type3 = findTypeById(abi, argument.type);
|
32540
32378
|
this.type = type3.type;
|
32541
32379
|
this.originalTypeArguments = argument.typeArguments;
|
32542
32380
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -32588,7 +32426,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32588
32426
|
)
|
32589
32427
|
};
|
32590
32428
|
}
|
32591
|
-
const argType =
|
32429
|
+
const argType = findTypeById(abi, arg.type);
|
32592
32430
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
32593
32431
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
32594
32432
|
return {
|
@@ -32605,7 +32443,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32605
32443
|
}
|
32606
32444
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32607
32445
|
args.forEach((a) => {
|
32608
|
-
const argType =
|
32446
|
+
const argType = findTypeById(abi, a.type);
|
32609
32447
|
if (genericRegEx.test(argType.type)) {
|
32610
32448
|
implicitGenericParameters.push(argType.typeId);
|
32611
32449
|
return;
|
@@ -32714,13 +32552,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32714
32552
|
return new ArrayCoder(arrayElementCoder, length);
|
32715
32553
|
}
|
32716
32554
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32717
|
-
const arg =
|
32718
|
-
if (!arg) {
|
32719
|
-
throw new FuelError(
|
32720
|
-
ErrorCode.INVALID_COMPONENT,
|
32721
|
-
`The provided Vec type is missing the 'type argument'.`
|
32722
|
-
);
|
32723
|
-
}
|
32555
|
+
const arg = findVectorBufferArgument(components);
|
32724
32556
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32725
32557
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32726
32558
|
return new VecCoder(itemCoder);
|
@@ -32818,7 +32650,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32818
32650
|
constructor(name, coders) {
|
32819
32651
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32820
32652
|
const encodedValueSize = Object.values(coders).reduce(
|
32821
|
-
(
|
32653
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32822
32654
|
0
|
32823
32655
|
);
|
32824
32656
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33189,13 +33021,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33189
33021
|
return new ArrayCoder(arrayElementCoder, length);
|
33190
33022
|
}
|
33191
33023
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
33192
|
-
const arg =
|
33193
|
-
if (!arg) {
|
33194
|
-
throw new FuelError(
|
33195
|
-
ErrorCode.INVALID_COMPONENT,
|
33196
|
-
`The provided Vec type is missing the 'type argument'.`
|
33197
|
-
);
|
33198
|
-
}
|
33024
|
+
const arg = findVectorBufferArgument(components);
|
33199
33025
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
33200
33026
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
33201
33027
|
return new VecCoder2(itemCoder);
|
@@ -33266,7 +33092,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33266
33092
|
jsonAbi;
|
33267
33093
|
constructor(jsonAbi, name) {
|
33268
33094
|
this.jsonAbi = jsonAbi;
|
33269
|
-
this.jsonFn =
|
33095
|
+
this.jsonFn = findFunctionByName(this.jsonAbi, name);
|
33270
33096
|
this.name = name;
|
33271
33097
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33272
33098
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
@@ -33290,13 +33116,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33290
33116
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
33291
33117
|
}
|
33292
33118
|
#isInputDataPointer() {
|
33293
|
-
const inputTypes = this.jsonFn.inputs.map(
|
33294
|
-
(i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
|
33295
|
-
);
|
33119
|
+
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
33296
33120
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
33297
33121
|
}
|
33298
33122
|
#isOutputDataHeap() {
|
33299
|
-
const outputType =
|
33123
|
+
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33300
33124
|
return isHeapType(outputType?.type || "");
|
33301
33125
|
}
|
33302
33126
|
#getOutputEncodedLength() {
|
@@ -33316,9 +33140,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33316
33140
|
encodeArguments(values, offset = 0) {
|
33317
33141
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
33318
33142
|
const shallowCopyValues = values.slice();
|
33319
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33320
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33321
|
-
);
|
33143
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33322
33144
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
33323
33145
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
33324
33146
|
shallowCopyValues.fill(void 0, values.length);
|
@@ -33339,7 +33161,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33339
33161
|
if (args.length === inputs.length) {
|
33340
33162
|
return;
|
33341
33163
|
}
|
33342
|
-
const inputTypes = inputs.map((
|
33164
|
+
const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
|
33343
33165
|
const optionalInputs = inputTypes.filter(
|
33344
33166
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
33345
33167
|
);
|
@@ -33354,9 +33176,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33354
33176
|
}
|
33355
33177
|
decodeArguments(data) {
|
33356
33178
|
const bytes3 = arrayify(data);
|
33357
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33358
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33359
|
-
);
|
33179
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33360
33180
|
if (nonEmptyInputs.length === 0) {
|
33361
33181
|
if (bytes3.length === 0) {
|
33362
33182
|
return void 0;
|
@@ -33391,10 +33211,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33391
33211
|
return result.decoded;
|
33392
33212
|
}
|
33393
33213
|
decodeOutput(data) {
|
33394
|
-
const outputAbiType =
|
33395
|
-
this.jsonAbi.types,
|
33396
|
-
(t) => t.typeId === this.jsonFn.output.type
|
33397
|
-
);
|
33214
|
+
const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33398
33215
|
if (outputAbiType.type === "()") {
|
33399
33216
|
return [void 0, 0];
|
33400
33217
|
}
|
@@ -33446,38 +33263,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33446
33263
|
return fragment.decodeOutput(data);
|
33447
33264
|
}
|
33448
33265
|
decodeLog(data, logId) {
|
33449
|
-
const
|
33450
|
-
|
33266
|
+
const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
|
33267
|
+
if (!loggedType) {
|
33268
|
+
throw new FuelError(
|
33269
|
+
ErrorCode.LOG_TYPE_NOT_FOUND,
|
33270
|
+
`Log type with logId '${logId}' doesn't exist in the ABI.`
|
33271
|
+
);
|
33272
|
+
}
|
33273
|
+
return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
|
33451
33274
|
encoding: this.jsonAbi.encoding
|
33452
33275
|
});
|
33453
33276
|
}
|
33454
33277
|
encodeConfigurable(name, value) {
|
33455
|
-
const configurable =
|
33456
|
-
|
33457
|
-
|
33458
|
-
|
33459
|
-
|
33460
|
-
|
33461
|
-
|
33462
|
-
);
|
33463
|
-
}
|
33464
|
-
);
|
33278
|
+
const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
|
33279
|
+
if (!configurable) {
|
33280
|
+
throw new FuelError(
|
33281
|
+
ErrorCode.CONFIGURABLE_NOT_FOUND,
|
33282
|
+
`A configurable with the '${name}' was not found in the ABI.`
|
33283
|
+
);
|
33284
|
+
}
|
33465
33285
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33466
33286
|
isRightPadded: true,
|
33467
33287
|
encoding: this.jsonAbi.encoding
|
33468
33288
|
});
|
33469
33289
|
}
|
33470
33290
|
getTypeById(typeId) {
|
33471
|
-
return
|
33472
|
-
this.jsonAbi.types,
|
33473
|
-
(t) => t.typeId === typeId,
|
33474
|
-
() => {
|
33475
|
-
throw new FuelError(
|
33476
|
-
ErrorCode.TYPE_NOT_FOUND,
|
33477
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
33478
|
-
);
|
33479
|
-
}
|
33480
|
-
);
|
33291
|
+
return findTypeById(this.jsonAbi, typeId);
|
33481
33292
|
}
|
33482
33293
|
};
|
33483
33294
|
|
@@ -33541,19 +33352,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33541
33352
|
encode(value) {
|
33542
33353
|
const parts = [];
|
33543
33354
|
parts.push(new B256Coder().encode(value.txID));
|
33544
|
-
parts.push(new NumberCoder("
|
33355
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33545
33356
|
parts.push(new B256Coder().encode(value.owner));
|
33546
33357
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33547
33358
|
parts.push(new B256Coder().encode(value.assetId));
|
33548
33359
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33549
|
-
parts.push(new NumberCoder("
|
33360
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33361
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33550
33362
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33551
|
-
parts.push(new
|
33552
|
-
parts.push(new
|
33553
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33554
|
-
parts.push(
|
33555
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33556
|
-
);
|
33363
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33364
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33365
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33366
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33557
33367
|
return concat(parts);
|
33558
33368
|
}
|
33559
33369
|
decode(data, offset) {
|
@@ -33561,7 +33371,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33561
33371
|
let o = offset;
|
33562
33372
|
[decoded, o] = new B256Coder().decode(data, o);
|
33563
33373
|
const txID = decoded;
|
33564
|
-
[decoded, o] = new NumberCoder("
|
33374
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33565
33375
|
const outputIndex = decoded;
|
33566
33376
|
[decoded, o] = new B256Coder().decode(data, o);
|
33567
33377
|
const owner = decoded;
|
@@ -33571,17 +33381,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33571
33381
|
const assetId = decoded;
|
33572
33382
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33573
33383
|
const txPointer = decoded;
|
33574
|
-
[decoded, o] = new NumberCoder("
|
33384
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33575
33385
|
const witnessIndex = Number(decoded);
|
33386
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33387
|
+
const maturity = decoded;
|
33576
33388
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33577
33389
|
const predicateGasUsed = decoded;
|
33578
|
-
[decoded, o] = new
|
33390
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33579
33391
|
const predicateLength = decoded;
|
33580
|
-
[decoded, o] = new
|
33392
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33581
33393
|
const predicateDataLength = decoded;
|
33582
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33394
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33583
33395
|
const predicate = decoded;
|
33584
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33396
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33585
33397
|
const predicateData = decoded;
|
33586
33398
|
return [
|
33587
33399
|
{
|
@@ -33593,6 +33405,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33593
33405
|
assetId,
|
33594
33406
|
txPointer,
|
33595
33407
|
witnessIndex,
|
33408
|
+
maturity,
|
33596
33409
|
predicateGasUsed,
|
33597
33410
|
predicateLength,
|
33598
33411
|
predicateDataLength,
|
@@ -33610,7 +33423,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33610
33423
|
encode(value) {
|
33611
33424
|
const parts = [];
|
33612
33425
|
parts.push(new B256Coder().encode(value.txID));
|
33613
|
-
parts.push(new NumberCoder("
|
33426
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33614
33427
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33615
33428
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33616
33429
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33622,7 +33435,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33622
33435
|
let o = offset;
|
33623
33436
|
[decoded, o] = new B256Coder().decode(data, o);
|
33624
33437
|
const txID = decoded;
|
33625
|
-
[decoded, o] = new NumberCoder("
|
33438
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33626
33439
|
const outputIndex = decoded;
|
33627
33440
|
[decoded, o] = new B256Coder().decode(data, o);
|
33628
33441
|
const balanceRoot = decoded;
|
@@ -33671,16 +33484,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33671
33484
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33672
33485
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33673
33486
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33674
|
-
parts.push(new NumberCoder("
|
33487
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33675
33488
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33676
|
-
parts.push(new
|
33677
|
-
parts.push(new
|
33678
|
-
parts.push(new
|
33489
|
+
parts.push(new NumberCoder("u32").encode(data.length));
|
33490
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33491
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33679
33492
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33680
|
-
parts.push(new ByteArrayCoder(value.predicateLength
|
33681
|
-
parts.push(
|
33682
|
-
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33683
|
-
);
|
33493
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33494
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33684
33495
|
return concat(parts);
|
33685
33496
|
}
|
33686
33497
|
static decodeData(messageData) {
|
@@ -33700,21 +33511,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33700
33511
|
const amount = decoded;
|
33701
33512
|
[decoded, o] = new B256Coder().decode(data, o);
|
33702
33513
|
const nonce = decoded;
|
33703
|
-
[decoded, o] = new NumberCoder("
|
33514
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33704
33515
|
const witnessIndex = Number(decoded);
|
33705
33516
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33706
33517
|
const predicateGasUsed = decoded;
|
33707
33518
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33708
33519
|
const dataLength2 = decoded;
|
33709
|
-
[decoded, o] = new
|
33520
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33710
33521
|
const predicateLength = decoded;
|
33711
|
-
[decoded, o] = new
|
33522
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33712
33523
|
const predicateDataLength = decoded;
|
33713
33524
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33714
33525
|
const messageData = decoded;
|
33715
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33526
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33716
33527
|
const predicate = decoded;
|
33717
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33528
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33718
33529
|
const predicateData = decoded;
|
33719
33530
|
return [
|
33720
33531
|
{
|
@@ -34026,7 +33837,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34026
33837
|
}
|
34027
33838
|
};
|
34028
33839
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
34029
|
-
PolicyType2[PolicyType2["
|
33840
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
34030
33841
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
34031
33842
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
34032
33843
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34074,9 +33885,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34074
33885
|
let o = offset;
|
34075
33886
|
const policies = [];
|
34076
33887
|
if (policyTypes & 1) {
|
34077
|
-
const [
|
33888
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34078
33889
|
o = nextOffset;
|
34079
|
-
policies.push({ type: 1, data:
|
33890
|
+
policies.push({ type: 1, data: gasPrice });
|
34080
33891
|
}
|
34081
33892
|
if (policyTypes & 2) {
|
34082
33893
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34308,15 +34119,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34308
34119
|
encode(value) {
|
34309
34120
|
const parts = [];
|
34310
34121
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34311
|
-
parts.push(new
|
34312
|
-
parts.push(new
|
34313
|
-
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34122
|
+
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34123
|
+
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34314
34124
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34315
|
-
parts.push(new NumberCoder("
|
34316
|
-
parts.push(new NumberCoder("
|
34317
|
-
parts.push(new NumberCoder("
|
34318
|
-
parts.push(new
|
34319
|
-
parts.push(new ByteArrayCoder(value.
|
34125
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34126
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34127
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34128
|
+
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34129
|
+
parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
|
34130
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
|
34320
34131
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34321
34132
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34322
34133
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34328,23 +34139,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34328
34139
|
let o = offset;
|
34329
34140
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34330
34141
|
const scriptGasLimit = decoded;
|
34331
|
-
[decoded, o] = new
|
34332
|
-
const receiptsRoot = decoded;
|
34333
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34142
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34334
34143
|
const scriptLength = decoded;
|
34335
|
-
[decoded, o] = new
|
34144
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34336
34145
|
const scriptDataLength = decoded;
|
34337
34146
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34338
34147
|
const policyTypes = decoded;
|
34339
|
-
[decoded, o] = new NumberCoder("
|
34148
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34340
34149
|
const inputsCount = decoded;
|
34341
|
-
[decoded, o] = new NumberCoder("
|
34150
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34342
34151
|
const outputsCount = decoded;
|
34343
|
-
[decoded, o] = new NumberCoder("
|
34152
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34344
34153
|
const witnessesCount = decoded;
|
34345
|
-
[decoded, o] = new
|
34154
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34155
|
+
const receiptsRoot = decoded;
|
34156
|
+
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34346
34157
|
const script = decoded;
|
34347
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength
|
34158
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34348
34159
|
const scriptData = decoded;
|
34349
34160
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34350
34161
|
const policies = decoded;
|
@@ -34382,19 +34193,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34382
34193
|
}
|
34383
34194
|
encode(value) {
|
34384
34195
|
const parts = [];
|
34385
|
-
parts.push(new NumberCoder("
|
34386
|
-
parts.push(new
|
34387
|
-
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34196
|
+
parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
|
34197
|
+
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34388
34198
|
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34389
|
-
parts.push(new NumberCoder("u16").encode(value.
|
34390
|
-
parts.push(new NumberCoder("
|
34391
|
-
parts.push(new NumberCoder("
|
34199
|
+
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34200
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34201
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34202
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34203
|
+
parts.push(new B256Coder().encode(value.salt));
|
34204
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34392
34205
|
parts.push(
|
34393
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount
|
34394
|
-
value.storageSlots
|
34395
|
-
)
|
34206
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
|
34396
34207
|
);
|
34397
|
-
parts.push(new PoliciesCoder().encode(value.policies));
|
34398
34208
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34399
34209
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34400
34210
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34403,27 +34213,26 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34403
34213
|
decode(data, offset) {
|
34404
34214
|
let decoded;
|
34405
34215
|
let o = offset;
|
34406
|
-
[decoded, o] = new NumberCoder("
|
34216
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34217
|
+
const bytecodeLength = decoded;
|
34218
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34407
34219
|
const bytecodeWitnessIndex = decoded;
|
34408
|
-
[decoded, o] = new B256Coder().decode(data, o);
|
34409
|
-
const salt = decoded;
|
34410
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34411
|
-
const storageSlotsCount = decoded;
|
34412
34220
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34413
34221
|
const policyTypes = decoded;
|
34414
34222
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34223
|
+
const storageSlotsCount = decoded;
|
34224
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34415
34225
|
const inputsCount = decoded;
|
34416
|
-
[decoded, o] = new NumberCoder("
|
34226
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34417
34227
|
const outputsCount = decoded;
|
34418
|
-
[decoded, o] = new NumberCoder("
|
34228
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34419
34229
|
const witnessesCount = decoded;
|
34420
|
-
[decoded, o] = new
|
34421
|
-
|
34422
|
-
o
|
34423
|
-
);
|
34424
|
-
const storageSlots = decoded;
|
34230
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34231
|
+
const salt = decoded;
|
34425
34232
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34426
34233
|
const policies = decoded;
|
34234
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34235
|
+
const storageSlots = decoded;
|
34427
34236
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34428
34237
|
const inputs = decoded;
|
34429
34238
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34433,6 +34242,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34433
34242
|
return [
|
34434
34243
|
{
|
34435
34244
|
type: 1,
|
34245
|
+
bytecodeLength,
|
34436
34246
|
bytecodeWitnessIndex,
|
34437
34247
|
policyTypes,
|
34438
34248
|
storageSlotsCount,
|
@@ -34461,7 +34271,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34461
34271
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34462
34272
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34463
34273
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34464
|
-
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34465
34274
|
return concat(parts);
|
34466
34275
|
}
|
34467
34276
|
decode(data, offset) {
|
@@ -34477,8 +34286,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34477
34286
|
const mintAmount = decoded;
|
34478
34287
|
[decoded, o] = new B256Coder().decode(data, o);
|
34479
34288
|
const mintAssetId = decoded;
|
34480
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34481
|
-
const gasPrice = decoded;
|
34482
34289
|
return [
|
34483
34290
|
{
|
34484
34291
|
type: 2,
|
@@ -34486,8 +34293,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34486
34293
|
inputContract,
|
34487
34294
|
outputContract,
|
34488
34295
|
mintAmount,
|
34489
|
-
mintAssetId
|
34490
|
-
gasPrice
|
34296
|
+
mintAssetId
|
34491
34297
|
},
|
34492
34298
|
o
|
34493
34299
|
];
|
@@ -34794,6 +34600,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34794
34600
|
// src/providers/provider.ts
|
34795
34601
|
var import_graphql_request = __toESM(require_dist2());
|
34796
34602
|
|
34603
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34604
|
+
function _isPlaceholder(a) {
|
34605
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34606
|
+
}
|
34607
|
+
|
34608
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34609
|
+
function _curry1(fn) {
|
34610
|
+
return function f1(a) {
|
34611
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34612
|
+
return f1;
|
34613
|
+
} else {
|
34614
|
+
return fn.apply(this, arguments);
|
34615
|
+
}
|
34616
|
+
};
|
34617
|
+
}
|
34618
|
+
|
34619
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34620
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
34621
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34622
|
+
};
|
34623
|
+
|
34624
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34625
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34626
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34627
|
+
});
|
34628
|
+
var type_default = type;
|
34629
|
+
|
34630
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34631
|
+
var pad = function pad2(n) {
|
34632
|
+
return (n < 10 ? "0" : "") + n;
|
34633
|
+
};
|
34634
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34635
|
+
return d.toISOString();
|
34636
|
+
} : function _toISOString3(d) {
|
34637
|
+
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";
|
34638
|
+
};
|
34639
|
+
|
34640
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34641
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34642
|
+
return n << 0 === n;
|
34643
|
+
};
|
34644
|
+
|
34645
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34646
|
+
function _cloneRegExp(pattern) {
|
34647
|
+
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" : ""));
|
34648
|
+
}
|
34649
|
+
|
34650
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34651
|
+
function _clone(value, deep, map) {
|
34652
|
+
map || (map = new _ObjectMap());
|
34653
|
+
if (_isPrimitive(value)) {
|
34654
|
+
return value;
|
34655
|
+
}
|
34656
|
+
var copy = function copy2(copiedValue) {
|
34657
|
+
var cachedCopy = map.get(value);
|
34658
|
+
if (cachedCopy) {
|
34659
|
+
return cachedCopy;
|
34660
|
+
}
|
34661
|
+
map.set(value, copiedValue);
|
34662
|
+
for (var key in value) {
|
34663
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34664
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34665
|
+
}
|
34666
|
+
}
|
34667
|
+
return copiedValue;
|
34668
|
+
};
|
34669
|
+
switch (type_default(value)) {
|
34670
|
+
case "Object":
|
34671
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
34672
|
+
case "Array":
|
34673
|
+
return copy([]);
|
34674
|
+
case "Date":
|
34675
|
+
return new Date(value.valueOf());
|
34676
|
+
case "RegExp":
|
34677
|
+
return _cloneRegExp(value);
|
34678
|
+
case "Int8Array":
|
34679
|
+
case "Uint8Array":
|
34680
|
+
case "Uint8ClampedArray":
|
34681
|
+
case "Int16Array":
|
34682
|
+
case "Uint16Array":
|
34683
|
+
case "Int32Array":
|
34684
|
+
case "Uint32Array":
|
34685
|
+
case "Float32Array":
|
34686
|
+
case "Float64Array":
|
34687
|
+
case "BigInt64Array":
|
34688
|
+
case "BigUint64Array":
|
34689
|
+
return value.slice();
|
34690
|
+
default:
|
34691
|
+
return value;
|
34692
|
+
}
|
34693
|
+
}
|
34694
|
+
function _isPrimitive(param) {
|
34695
|
+
var type3 = typeof param;
|
34696
|
+
return param == null || type3 != "object" && type3 != "function";
|
34697
|
+
}
|
34698
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
34699
|
+
function _ObjectMap2() {
|
34700
|
+
this.map = {};
|
34701
|
+
this.length = 0;
|
34702
|
+
}
|
34703
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
34704
|
+
const hashedKey = this.hash(key);
|
34705
|
+
let bucket = this.map[hashedKey];
|
34706
|
+
if (!bucket) {
|
34707
|
+
this.map[hashedKey] = bucket = [];
|
34708
|
+
}
|
34709
|
+
bucket.push([key, value]);
|
34710
|
+
this.length += 1;
|
34711
|
+
};
|
34712
|
+
_ObjectMap2.prototype.hash = function(key) {
|
34713
|
+
let hashedKey = [];
|
34714
|
+
for (var value in key) {
|
34715
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34716
|
+
}
|
34717
|
+
return hashedKey.join();
|
34718
|
+
};
|
34719
|
+
_ObjectMap2.prototype.get = function(key) {
|
34720
|
+
if (this.length <= 180) {
|
34721
|
+
for (const p in this.map) {
|
34722
|
+
const bucket2 = this.map[p];
|
34723
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
34724
|
+
const element = bucket2[i];
|
34725
|
+
if (element[0] === key) {
|
34726
|
+
return element[1];
|
34727
|
+
}
|
34728
|
+
}
|
34729
|
+
}
|
34730
|
+
return;
|
34731
|
+
}
|
34732
|
+
const hashedKey = this.hash(key);
|
34733
|
+
const bucket = this.map[hashedKey];
|
34734
|
+
if (!bucket) {
|
34735
|
+
return;
|
34736
|
+
}
|
34737
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
34738
|
+
const element = bucket[i];
|
34739
|
+
if (element[0] === key) {
|
34740
|
+
return element[1];
|
34741
|
+
}
|
34742
|
+
}
|
34743
|
+
};
|
34744
|
+
return _ObjectMap2;
|
34745
|
+
}();
|
34746
|
+
|
34747
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34748
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34749
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34750
|
+
});
|
34751
|
+
var clone_default = clone2;
|
34752
|
+
|
34753
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34754
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34755
|
+
|
34797
34756
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34798
34757
|
var __assign = function() {
|
34799
34758
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37961,10 +37920,14 @@ spurious results.`);
|
|
37961
37920
|
// src/providers/__generated__/operations.ts
|
37962
37921
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37963
37922
|
fragment receiptFragment on Receipt {
|
37964
|
-
|
37923
|
+
contract {
|
37924
|
+
id
|
37925
|
+
}
|
37965
37926
|
pc
|
37966
37927
|
is
|
37967
|
-
to
|
37928
|
+
to {
|
37929
|
+
id
|
37930
|
+
}
|
37968
37931
|
toAddress
|
37969
37932
|
amount
|
37970
37933
|
assetId
|
@@ -38002,16 +37965,10 @@ spurious results.`);
|
|
38002
37965
|
id
|
38003
37966
|
}
|
38004
37967
|
time
|
38005
|
-
receipts {
|
38006
|
-
...receiptFragment
|
38007
|
-
}
|
38008
37968
|
programState {
|
38009
37969
|
returnType
|
38010
37970
|
data
|
38011
37971
|
}
|
38012
|
-
receipts {
|
38013
|
-
...receiptFragment
|
38014
|
-
}
|
38015
37972
|
}
|
38016
37973
|
... on FailureStatus {
|
38017
37974
|
block {
|
@@ -38019,24 +37976,26 @@ spurious results.`);
|
|
38019
37976
|
}
|
38020
37977
|
time
|
38021
37978
|
reason
|
38022
|
-
receipts {
|
38023
|
-
...receiptFragment
|
38024
|
-
}
|
38025
37979
|
}
|
38026
37980
|
... on SqueezedOutStatus {
|
38027
37981
|
reason
|
38028
37982
|
}
|
38029
37983
|
}
|
38030
|
-
|
37984
|
+
`;
|
38031
37985
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38032
37986
|
fragment transactionFragment on Transaction {
|
38033
37987
|
id
|
38034
37988
|
rawPayload
|
37989
|
+
gasPrice
|
37990
|
+
receipts {
|
37991
|
+
...receiptFragment
|
37992
|
+
}
|
38035
37993
|
status {
|
38036
37994
|
...transactionStatusFragment
|
38037
37995
|
}
|
38038
37996
|
}
|
38039
|
-
${
|
37997
|
+
${ReceiptFragmentFragmentDoc}
|
37998
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38040
37999
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38041
38000
|
fragment inputEstimatePredicatesFragment on Input {
|
38042
38001
|
... on InputCoin {
|
@@ -38054,46 +38013,6 @@ spurious results.`);
|
|
38054
38013
|
}
|
38055
38014
|
}
|
38056
38015
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38057
|
-
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38058
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38059
|
-
reason
|
38060
|
-
programState {
|
38061
|
-
returnType
|
38062
|
-
data
|
38063
|
-
}
|
38064
|
-
}
|
38065
|
-
`;
|
38066
|
-
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38067
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38068
|
-
programState {
|
38069
|
-
returnType
|
38070
|
-
data
|
38071
|
-
}
|
38072
|
-
}
|
38073
|
-
`;
|
38074
|
-
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38075
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38076
|
-
... on DryRunFailureStatus {
|
38077
|
-
...dryRunFailureStatusFragment
|
38078
|
-
}
|
38079
|
-
... on DryRunSuccessStatus {
|
38080
|
-
...dryRunSuccessStatusFragment
|
38081
|
-
}
|
38082
|
-
}
|
38083
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
38084
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38085
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38086
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38087
|
-
id
|
38088
|
-
status {
|
38089
|
-
...dryRunTransactionStatusFragment
|
38090
|
-
}
|
38091
|
-
receipts {
|
38092
|
-
...receiptFragment
|
38093
|
-
}
|
38094
|
-
}
|
38095
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
38096
|
-
${ReceiptFragmentFragmentDoc}`;
|
38097
38016
|
var CoinFragmentFragmentDoc = lib_default2`
|
38098
38017
|
fragment coinFragment on Coin {
|
38099
38018
|
__typename
|
@@ -38101,6 +38020,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38101
38020
|
owner
|
38102
38021
|
amount
|
38103
38022
|
assetId
|
38023
|
+
maturity
|
38104
38024
|
blockCreated
|
38105
38025
|
txCreatedIdx
|
38106
38026
|
}
|
@@ -38145,6 +38065,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38145
38065
|
prevRoot
|
38146
38066
|
time
|
38147
38067
|
applicationHash
|
38068
|
+
messageReceiptRoot
|
38148
38069
|
messageReceiptCount
|
38149
38070
|
}
|
38150
38071
|
commitBlockHeader {
|
@@ -38156,6 +38077,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38156
38077
|
prevRoot
|
38157
38078
|
time
|
38158
38079
|
applicationHash
|
38080
|
+
messageReceiptRoot
|
38159
38081
|
messageReceiptCount
|
38160
38082
|
}
|
38161
38083
|
sender
|
@@ -38175,8 +38097,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38175
38097
|
var BlockFragmentFragmentDoc = lib_default2`
|
38176
38098
|
fragment blockFragment on Block {
|
38177
38099
|
id
|
38178
|
-
height
|
38179
38100
|
header {
|
38101
|
+
height
|
38180
38102
|
time
|
38181
38103
|
}
|
38182
38104
|
transactions {
|
@@ -38234,11 +38156,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38234
38156
|
`;
|
38235
38157
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38236
38158
|
fragment GasCostsFragment on GasCosts {
|
38237
|
-
version {
|
38238
|
-
... on Version {
|
38239
|
-
value
|
38240
|
-
}
|
38241
|
-
}
|
38242
38159
|
add
|
38243
38160
|
addi
|
38244
38161
|
aloc
|
@@ -38251,6 +38168,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38251
38168
|
cb
|
38252
38169
|
cfei
|
38253
38170
|
cfsi
|
38171
|
+
croo
|
38254
38172
|
div
|
38255
38173
|
divi
|
38256
38174
|
ecr1
|
@@ -38333,9 +38251,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38333
38251
|
ccp {
|
38334
38252
|
...DependentCostFragment
|
38335
38253
|
}
|
38336
|
-
croo {
|
38337
|
-
...DependentCostFragment
|
38338
|
-
}
|
38339
38254
|
csiz {
|
38340
38255
|
...DependentCostFragment
|
38341
38256
|
}
|
@@ -38395,11 +38310,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38395
38310
|
${DependentCostFragmentFragmentDoc}`;
|
38396
38311
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38397
38312
|
fragment consensusParametersFragment on ConsensusParameters {
|
38398
|
-
version {
|
38399
|
-
... on Version {
|
38400
|
-
value
|
38401
|
-
}
|
38402
|
-
}
|
38403
38313
|
txParams {
|
38404
38314
|
...TxParametersFragment
|
38405
38315
|
}
|
@@ -38459,9 +38369,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38459
38369
|
fragment nodeInfoFragment on NodeInfo {
|
38460
38370
|
utxoValidation
|
38461
38371
|
vmBacktrace
|
38372
|
+
minGasPrice
|
38462
38373
|
maxTx
|
38463
38374
|
maxDepth
|
38464
38375
|
nodeVersion
|
38376
|
+
peers {
|
38377
|
+
id
|
38378
|
+
addresses
|
38379
|
+
clientVersion
|
38380
|
+
blockHeight
|
38381
|
+
lastHeartbeatMs
|
38382
|
+
appScore
|
38383
|
+
}
|
38465
38384
|
}
|
38466
38385
|
`;
|
38467
38386
|
var GetVersionDocument = lib_default2`
|
@@ -38496,9 +38415,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38496
38415
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38497
38416
|
transaction(id: $transactionId) {
|
38498
38417
|
...transactionFragment
|
38418
|
+
receipts {
|
38419
|
+
...receiptFragment
|
38420
|
+
}
|
38499
38421
|
}
|
38500
38422
|
}
|
38501
|
-
${TransactionFragmentFragmentDoc}
|
38423
|
+
${TransactionFragmentFragmentDoc}
|
38424
|
+
${ReceiptFragmentFragmentDoc}`;
|
38502
38425
|
var GetTransactionsDocument = lib_default2`
|
38503
38426
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38504
38427
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38626,20 +38549,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38626
38549
|
}
|
38627
38550
|
}
|
38628
38551
|
${BalanceFragmentFragmentDoc}`;
|
38629
|
-
var GetLatestGasPriceDocument = lib_default2`
|
38630
|
-
query getLatestGasPrice {
|
38631
|
-
latestGasPrice {
|
38632
|
-
gasPrice
|
38633
|
-
}
|
38634
|
-
}
|
38635
|
-
`;
|
38636
|
-
var EstimateGasPriceDocument = lib_default2`
|
38637
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
38638
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38639
|
-
gasPrice
|
38640
|
-
}
|
38641
|
-
}
|
38642
|
-
`;
|
38643
38552
|
var GetBalancesDocument = lib_default2`
|
38644
38553
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38645
38554
|
balances(
|
@@ -38694,12 +38603,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38694
38603
|
}
|
38695
38604
|
`;
|
38696
38605
|
var DryRunDocument = lib_default2`
|
38697
|
-
mutation dryRun($
|
38698
|
-
dryRun(
|
38699
|
-
...
|
38606
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38607
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38608
|
+
...receiptFragment
|
38700
38609
|
}
|
38701
38610
|
}
|
38702
|
-
${
|
38611
|
+
${ReceiptFragmentFragmentDoc}`;
|
38703
38612
|
var SubmitDocument = lib_default2`
|
38704
38613
|
mutation submit($encodedTransaction: HexString!) {
|
38705
38614
|
submit(tx: $encodedTransaction) {
|
@@ -38782,12 +38691,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38782
38691
|
getBalance(variables, options) {
|
38783
38692
|
return requester(GetBalanceDocument, variables, options);
|
38784
38693
|
},
|
38785
|
-
getLatestGasPrice(variables, options) {
|
38786
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38787
|
-
},
|
38788
|
-
estimateGasPrice(variables, options) {
|
38789
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38790
|
-
},
|
38791
38694
|
getBalances(variables, options) {
|
38792
38695
|
return requester(GetBalancesDocument, variables, options);
|
38793
38696
|
},
|
@@ -38855,14 +38758,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38855
38758
|
let data;
|
38856
38759
|
let errors;
|
38857
38760
|
try {
|
38858
|
-
|
38859
|
-
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
38761
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
38860
38762
|
} catch (e) {
|
38861
38763
|
throw new FuelError(
|
38862
38764
|
ErrorCode.STREAM_PARSING_ERROR,
|
38863
|
-
`Error while parsing stream data response: ${text}
|
38864
|
-
|
38865
|
-
Thrown error: ${e}`
|
38765
|
+
`Error while parsing stream data response: ${text}`
|
38866
38766
|
);
|
38867
38767
|
}
|
38868
38768
|
if (Array.isArray(errors)) {
|
@@ -38946,6 +38846,9 @@ Thrown error: ${e}`
|
|
38946
38846
|
}
|
38947
38847
|
};
|
38948
38848
|
|
38849
|
+
// ../address/dist/configs.mjs
|
38850
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38851
|
+
|
38949
38852
|
// src/providers/transaction-request/input.ts
|
38950
38853
|
var inputify = (value) => {
|
38951
38854
|
const { type: type3 } = value;
|
@@ -38956,7 +38859,7 @@ Thrown error: ${e}`
|
|
38956
38859
|
return {
|
38957
38860
|
type: InputType.Coin,
|
38958
38861
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38959
|
-
outputIndex:
|
38862
|
+
outputIndex: arrayify(value.id)[32],
|
38960
38863
|
owner: hexlify(value.owner),
|
38961
38864
|
amount: bn(value.amount),
|
38962
38865
|
assetId: hexlify(value.assetId),
|
@@ -38965,9 +38868,10 @@ Thrown error: ${e}`
|
|
38965
38868
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38966
38869
|
},
|
38967
38870
|
witnessIndex: value.witnessIndex,
|
38871
|
+
maturity: value.maturity ?? 0,
|
38968
38872
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38969
|
-
predicateLength:
|
38970
|
-
predicateDataLength:
|
38873
|
+
predicateLength: predicate.length,
|
38874
|
+
predicateDataLength: predicateData.length,
|
38971
38875
|
predicate: hexlify(predicate),
|
38972
38876
|
predicateData: hexlify(predicateData)
|
38973
38877
|
};
|
@@ -38998,8 +38902,8 @@ Thrown error: ${e}`
|
|
38998
38902
|
nonce: hexlify(value.nonce),
|
38999
38903
|
witnessIndex: value.witnessIndex,
|
39000
38904
|
predicateGasUsed: bn(value.predicateGasUsed),
|
39001
|
-
predicateLength:
|
39002
|
-
predicateDataLength:
|
38905
|
+
predicateLength: predicate.length,
|
38906
|
+
predicateDataLength: predicateData.length,
|
39003
38907
|
predicate: hexlify(predicate),
|
39004
38908
|
predicateData: hexlify(predicateData),
|
39005
38909
|
data: hexlify(data),
|
@@ -39159,8 +39063,8 @@ Thrown error: ${e}`
|
|
39159
39063
|
case "CALL" /* Call */: {
|
39160
39064
|
const callReceipt = {
|
39161
39065
|
type: ReceiptType.Call,
|
39162
|
-
from: hexOrZero(receipt.id
|
39163
|
-
to: hexOrZero(receipt?.to),
|
39066
|
+
from: hexOrZero(receipt.contract?.id),
|
39067
|
+
to: hexOrZero(receipt?.to?.id),
|
39164
39068
|
amount: bn(receipt.amount),
|
39165
39069
|
assetId: hexOrZero(receipt.assetId),
|
39166
39070
|
gas: bn(receipt.gas),
|
@@ -39174,7 +39078,7 @@ Thrown error: ${e}`
|
|
39174
39078
|
case "RETURN" /* Return */: {
|
39175
39079
|
const returnReceipt = {
|
39176
39080
|
type: ReceiptType.Return,
|
39177
|
-
id: hexOrZero(receipt.id
|
39081
|
+
id: hexOrZero(receipt.contract?.id),
|
39178
39082
|
val: bn(receipt.val),
|
39179
39083
|
pc: bn(receipt.pc),
|
39180
39084
|
is: bn(receipt.is)
|
@@ -39184,7 +39088,7 @@ Thrown error: ${e}`
|
|
39184
39088
|
case "RETURN_DATA" /* ReturnData */: {
|
39185
39089
|
const returnDataReceipt = {
|
39186
39090
|
type: ReceiptType.ReturnData,
|
39187
|
-
id: hexOrZero(receipt.id
|
39091
|
+
id: hexOrZero(receipt.contract?.id),
|
39188
39092
|
ptr: bn(receipt.ptr),
|
39189
39093
|
len: bn(receipt.len),
|
39190
39094
|
digest: hexOrZero(receipt.digest),
|
@@ -39196,7 +39100,7 @@ Thrown error: ${e}`
|
|
39196
39100
|
case "PANIC" /* Panic */: {
|
39197
39101
|
const panicReceipt = {
|
39198
39102
|
type: ReceiptType.Panic,
|
39199
|
-
id: hexOrZero(receipt.id),
|
39103
|
+
id: hexOrZero(receipt.contract?.id),
|
39200
39104
|
reason: bn(receipt.reason),
|
39201
39105
|
pc: bn(receipt.pc),
|
39202
39106
|
is: bn(receipt.is),
|
@@ -39207,7 +39111,7 @@ Thrown error: ${e}`
|
|
39207
39111
|
case "REVERT" /* Revert */: {
|
39208
39112
|
const revertReceipt = {
|
39209
39113
|
type: ReceiptType.Revert,
|
39210
|
-
id: hexOrZero(receipt.id
|
39114
|
+
id: hexOrZero(receipt.contract?.id),
|
39211
39115
|
val: bn(receipt.ra),
|
39212
39116
|
pc: bn(receipt.pc),
|
39213
39117
|
is: bn(receipt.is)
|
@@ -39217,7 +39121,7 @@ Thrown error: ${e}`
|
|
39217
39121
|
case "LOG" /* Log */: {
|
39218
39122
|
const logReceipt = {
|
39219
39123
|
type: ReceiptType.Log,
|
39220
|
-
id: hexOrZero(receipt.id
|
39124
|
+
id: hexOrZero(receipt.contract?.id),
|
39221
39125
|
val0: bn(receipt.ra),
|
39222
39126
|
val1: bn(receipt.rb),
|
39223
39127
|
val2: bn(receipt.rc),
|
@@ -39230,7 +39134,7 @@ Thrown error: ${e}`
|
|
39230
39134
|
case "LOG_DATA" /* LogData */: {
|
39231
39135
|
const logDataReceipt = {
|
39232
39136
|
type: ReceiptType.LogData,
|
39233
|
-
id: hexOrZero(receipt.id
|
39137
|
+
id: hexOrZero(receipt.contract?.id),
|
39234
39138
|
val0: bn(receipt.ra),
|
39235
39139
|
val1: bn(receipt.rb),
|
39236
39140
|
ptr: bn(receipt.ptr),
|
@@ -39244,8 +39148,8 @@ Thrown error: ${e}`
|
|
39244
39148
|
case "TRANSFER" /* Transfer */: {
|
39245
39149
|
const transferReceipt = {
|
39246
39150
|
type: ReceiptType.Transfer,
|
39247
|
-
from: hexOrZero(receipt.id
|
39248
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39151
|
+
from: hexOrZero(receipt.contract?.id),
|
39152
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39249
39153
|
amount: bn(receipt.amount),
|
39250
39154
|
assetId: hexOrZero(receipt.assetId),
|
39251
39155
|
pc: bn(receipt.pc),
|
@@ -39256,8 +39160,8 @@ Thrown error: ${e}`
|
|
39256
39160
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39257
39161
|
const transferOutReceipt = {
|
39258
39162
|
type: ReceiptType.TransferOut,
|
39259
|
-
from: hexOrZero(receipt.id
|
39260
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39163
|
+
from: hexOrZero(receipt.contract?.id),
|
39164
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39261
39165
|
amount: bn(receipt.amount),
|
39262
39166
|
assetId: hexOrZero(receipt.assetId),
|
39263
39167
|
pc: bn(receipt.pc),
|
@@ -39300,7 +39204,7 @@ Thrown error: ${e}`
|
|
39300
39204
|
return receiptMessageOut;
|
39301
39205
|
}
|
39302
39206
|
case "MINT" /* Mint */: {
|
39303
|
-
const contractId = hexOrZero(receipt.id
|
39207
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39304
39208
|
const subId = hexOrZero(receipt.subId);
|
39305
39209
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39306
39210
|
const mintReceipt = {
|
@@ -39315,7 +39219,7 @@ Thrown error: ${e}`
|
|
39315
39219
|
return mintReceipt;
|
39316
39220
|
}
|
39317
39221
|
case "BURN" /* Burn */: {
|
39318
|
-
const contractId = hexOrZero(receipt.id
|
39222
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39319
39223
|
const subId = hexOrZero(receipt.subId);
|
39320
39224
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39321
39225
|
const burnReceipt = {
|
@@ -39396,6 +39300,7 @@ Thrown error: ${e}`
|
|
39396
39300
|
};
|
39397
39301
|
|
39398
39302
|
// src/providers/utils/gas.ts
|
39303
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39399
39304
|
var getGasUsedFromReceipts = (receipts) => {
|
39400
39305
|
const scriptResult = receipts.filter(
|
39401
39306
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39416,28 +39321,18 @@ Thrown error: ${e}`
|
|
39416
39321
|
}
|
39417
39322
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39418
39323
|
const witnessCache = [];
|
39419
|
-
const
|
39420
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39421
|
-
if (isCoinOrMessage) {
|
39422
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39423
|
-
return true;
|
39424
|
-
}
|
39425
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39426
|
-
witnessCache.push(input.witnessIndex);
|
39427
|
-
return true;
|
39428
|
-
}
|
39429
|
-
}
|
39430
|
-
return false;
|
39431
|
-
});
|
39432
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39433
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39324
|
+
const totalGas = inputs.reduce((total, input) => {
|
39434
39325
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39435
39326
|
return total.add(
|
39436
|
-
|
39327
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39437
39328
|
);
|
39438
39329
|
}
|
39439
|
-
|
39440
|
-
|
39330
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39331
|
+
witnessCache.push(input.witnessIndex);
|
39332
|
+
return total.add(gasCosts.ecr1);
|
39333
|
+
}
|
39334
|
+
return total;
|
39335
|
+
}, bn());
|
39441
39336
|
return totalGas;
|
39442
39337
|
}
|
39443
39338
|
function getMinGas(params) {
|
@@ -39449,20 +39344,12 @@ Thrown error: ${e}`
|
|
39449
39344
|
return minGas;
|
39450
39345
|
}
|
39451
39346
|
function getMaxGas(params) {
|
39452
|
-
const {
|
39453
|
-
gasPerByte,
|
39454
|
-
witnessesLength,
|
39455
|
-
witnessLimit,
|
39456
|
-
minGas,
|
39457
|
-
gasLimit = bn(0),
|
39458
|
-
maxGasPerTx
|
39459
|
-
} = params;
|
39347
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39460
39348
|
let remainingAllowedWitnessGas = bn(0);
|
39461
39349
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39462
39350
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39463
39351
|
}
|
39464
|
-
|
39465
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39352
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39466
39353
|
}
|
39467
39354
|
function calculateMetadataGasForTxCreate({
|
39468
39355
|
gasCosts,
|
@@ -39484,10 +39371,6 @@ Thrown error: ${e}`
|
|
39484
39371
|
}) {
|
39485
39372
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39486
39373
|
}
|
39487
|
-
var calculateGasFee = (params) => {
|
39488
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39489
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39490
|
-
};
|
39491
39374
|
|
39492
39375
|
// src/providers/utils/json.ts
|
39493
39376
|
function normalize2(object) {
|
@@ -39629,7 +39512,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39629
39512
|
// src/providers/transaction-request/transaction-request.ts
|
39630
39513
|
var BaseTransactionRequest = class {
|
39631
39514
|
/** Gas price for transaction */
|
39632
|
-
|
39515
|
+
gasPrice;
|
39633
39516
|
/** Block until which tx cannot be included */
|
39634
39517
|
maturity;
|
39635
39518
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39642,34 +39525,38 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39642
39525
|
outputs = [];
|
39643
39526
|
/** List of witnesses */
|
39644
39527
|
witnesses = [];
|
39528
|
+
/** Base asset ID - should be fetched from the chain */
|
39529
|
+
baseAssetId = ZeroBytes32;
|
39645
39530
|
/**
|
39646
39531
|
* Constructor for initializing a base transaction request.
|
39647
39532
|
*
|
39648
39533
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39649
39534
|
*/
|
39650
39535
|
constructor({
|
39651
|
-
|
39536
|
+
gasPrice,
|
39652
39537
|
maturity,
|
39653
39538
|
maxFee,
|
39654
39539
|
witnessLimit,
|
39655
39540
|
inputs,
|
39656
39541
|
outputs,
|
39657
|
-
witnesses
|
39542
|
+
witnesses,
|
39543
|
+
baseAssetId
|
39658
39544
|
} = {}) {
|
39659
|
-
this.
|
39545
|
+
this.gasPrice = bn(gasPrice);
|
39660
39546
|
this.maturity = maturity ?? 0;
|
39661
39547
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39662
39548
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
39663
39549
|
this.inputs = inputs ?? [];
|
39664
39550
|
this.outputs = outputs ?? [];
|
39665
39551
|
this.witnesses = witnesses ?? [];
|
39552
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39666
39553
|
}
|
39667
39554
|
static getPolicyMeta(req) {
|
39668
39555
|
let policyTypes = 0;
|
39669
39556
|
const policies = [];
|
39670
|
-
if (req.
|
39671
|
-
policyTypes += PolicyType.
|
39672
|
-
policies.push({ data: req.
|
39557
|
+
if (req.gasPrice) {
|
39558
|
+
policyTypes += PolicyType.GasPrice;
|
39559
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39673
39560
|
}
|
39674
39561
|
if (req.witnessLimit) {
|
39675
39562
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39856,10 +39743,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39856
39743
|
* @param predicate - Predicate bytes.
|
39857
39744
|
* @param predicateData - Predicate data bytes.
|
39858
39745
|
*/
|
39859
|
-
addCoinInput(coin) {
|
39746
|
+
addCoinInput(coin, predicate) {
|
39860
39747
|
const { assetId, owner, amount } = coin;
|
39861
39748
|
let witnessIndex;
|
39862
|
-
if (
|
39749
|
+
if (predicate) {
|
39863
39750
|
witnessIndex = 0;
|
39864
39751
|
} else {
|
39865
39752
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39874,7 +39761,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39874
39761
|
amount,
|
39875
39762
|
assetId,
|
39876
39763
|
txPointer: "0x00000000000000000000000000000000",
|
39877
|
-
witnessIndex
|
39764
|
+
witnessIndex,
|
39765
|
+
predicate: predicate?.bytes,
|
39766
|
+
predicateData: predicate?.predicateDataBytes
|
39878
39767
|
};
|
39879
39768
|
this.pushInput(input);
|
39880
39769
|
this.addChangeOutput(owner, assetId);
|
@@ -39885,13 +39774,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39885
39774
|
*
|
39886
39775
|
* @param message - Message resource.
|
39887
39776
|
* @param predicate - Predicate bytes.
|
39888
|
-
* @param predicateData - Predicate data bytes.
|
39889
39777
|
*/
|
39890
|
-
addMessageInput(message) {
|
39778
|
+
addMessageInput(message, predicate) {
|
39891
39779
|
const { recipient, sender, amount } = message;
|
39892
|
-
const assetId = BaseAssetId;
|
39893
39780
|
let witnessIndex;
|
39894
|
-
if (
|
39781
|
+
if (predicate) {
|
39895
39782
|
witnessIndex = 0;
|
39896
39783
|
} else {
|
39897
39784
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39905,10 +39792,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39905
39792
|
sender: sender.toB256(),
|
39906
39793
|
recipient: recipient.toB256(),
|
39907
39794
|
amount,
|
39908
|
-
witnessIndex
|
39795
|
+
witnessIndex,
|
39796
|
+
predicate: predicate?.bytes,
|
39797
|
+
predicateData: predicate?.predicateDataBytes
|
39909
39798
|
};
|
39910
39799
|
this.pushInput(input);
|
39911
|
-
this.addChangeOutput(recipient,
|
39800
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39912
39801
|
}
|
39913
39802
|
/**
|
39914
39803
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39936,6 +39825,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39936
39825
|
resources.forEach((resource) => this.addResource(resource));
|
39937
39826
|
return this;
|
39938
39827
|
}
|
39828
|
+
/**
|
39829
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39830
|
+
* outputs from the related assetIds.
|
39831
|
+
*
|
39832
|
+
* @param resources - The resources to add.
|
39833
|
+
* @returns This transaction.
|
39834
|
+
*/
|
39835
|
+
addPredicateResource(resource, predicate) {
|
39836
|
+
if (isCoin(resource)) {
|
39837
|
+
this.addCoinInput(resource, predicate);
|
39838
|
+
} else {
|
39839
|
+
this.addMessageInput(resource, predicate);
|
39840
|
+
}
|
39841
|
+
return this;
|
39842
|
+
}
|
39843
|
+
/**
|
39844
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39845
|
+
* from the related assetIds.
|
39846
|
+
*
|
39847
|
+
* @param resources - The resources to add.
|
39848
|
+
* @returns This transaction.
|
39849
|
+
*/
|
39850
|
+
addPredicateResources(resources, predicate) {
|
39851
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39852
|
+
return this;
|
39853
|
+
}
|
39939
39854
|
/**
|
39940
39855
|
* Adds a coin output to the transaction.
|
39941
39856
|
*
|
@@ -39943,12 +39858,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39943
39858
|
* @param amount - Amount of coin.
|
39944
39859
|
* @param assetId - Asset ID of coin.
|
39945
39860
|
*/
|
39946
|
-
addCoinOutput(to, amount, assetId
|
39861
|
+
addCoinOutput(to, amount, assetId) {
|
39947
39862
|
this.pushOutput({
|
39948
39863
|
type: OutputType.Coin,
|
39949
39864
|
to: addressify(to).toB256(),
|
39950
39865
|
amount,
|
39951
|
-
assetId
|
39866
|
+
assetId: assetId ?? this.baseAssetId
|
39952
39867
|
});
|
39953
39868
|
return this;
|
39954
39869
|
}
|
@@ -39975,7 +39890,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39975
39890
|
* @param to - Address of the owner.
|
39976
39891
|
* @param assetId - Asset ID of coin.
|
39977
39892
|
*/
|
39978
|
-
addChangeOutput(to, assetId
|
39893
|
+
addChangeOutput(to, assetId) {
|
39979
39894
|
const changeOutput = this.getChangeOutputs().find(
|
39980
39895
|
(output3) => hexlify(output3.assetId) === assetId
|
39981
39896
|
);
|
@@ -39983,7 +39898,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39983
39898
|
this.pushOutput({
|
39984
39899
|
type: OutputType.Change,
|
39985
39900
|
to: addressify(to).toB256(),
|
39986
|
-
assetId
|
39901
|
+
assetId: assetId ?? this.baseAssetId
|
39987
39902
|
});
|
39988
39903
|
}
|
39989
39904
|
}
|
@@ -40015,7 +39930,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40015
39930
|
}
|
40016
39931
|
calculateMaxGas(chainInfo, minGas) {
|
40017
39932
|
const { consensusParameters } = chainInfo;
|
40018
|
-
const { gasPerByte
|
39933
|
+
const { gasPerByte } = consensusParameters;
|
40019
39934
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40020
39935
|
(acc, wit) => acc + wit.dataLength,
|
40021
39936
|
0
|
@@ -40024,8 +39939,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40024
39939
|
gasPerByte,
|
40025
39940
|
minGas,
|
40026
39941
|
witnessesLength,
|
40027
|
-
witnessLimit: this.witnessLimit
|
40028
|
-
maxGasPerTx
|
39942
|
+
witnessLimit: this.witnessLimit
|
40029
39943
|
});
|
40030
39944
|
}
|
40031
39945
|
/**
|
@@ -40035,6 +39949,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40035
39949
|
* @param quantities - CoinQuantity Array.
|
40036
39950
|
*/
|
40037
39951
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39952
|
+
let idCounter = 0;
|
39953
|
+
const generateId = () => {
|
39954
|
+
const counterString = String(idCounter++);
|
39955
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39956
|
+
return id;
|
39957
|
+
};
|
40038
39958
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
40039
39959
|
if ("assetId" in input) {
|
40040
39960
|
return input.assetId === assetId;
|
@@ -40043,27 +39963,24 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40043
39963
|
});
|
40044
39964
|
const updateAssetInput = (assetId, quantity) => {
|
40045
39965
|
const assetInput = findAssetInput(assetId);
|
40046
|
-
let usedQuantity = quantity;
|
40047
|
-
if (assetId === BaseAssetId) {
|
40048
|
-
usedQuantity = bn("1000000000000000000");
|
40049
|
-
}
|
40050
39966
|
if (assetInput && "assetId" in assetInput) {
|
40051
|
-
assetInput.id =
|
40052
|
-
assetInput.amount =
|
39967
|
+
assetInput.id = generateId();
|
39968
|
+
assetInput.amount = quantity;
|
40053
39969
|
} else {
|
40054
39970
|
this.addResources([
|
40055
39971
|
{
|
40056
|
-
id:
|
40057
|
-
amount:
|
39972
|
+
id: generateId(),
|
39973
|
+
amount: quantity,
|
40058
39974
|
assetId,
|
40059
39975
|
owner: resourcesOwner || Address.fromRandom(),
|
39976
|
+
maturity: 0,
|
40060
39977
|
blockCreated: bn(1),
|
40061
39978
|
txCreatedIdx: bn(1)
|
40062
39979
|
}
|
40063
39980
|
]);
|
40064
39981
|
}
|
40065
39982
|
};
|
40066
|
-
updateAssetInput(
|
39983
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
40067
39984
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40068
39985
|
}
|
40069
39986
|
/**
|
@@ -40088,7 +40005,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40088
40005
|
toJSON() {
|
40089
40006
|
return normalizeJSON(this);
|
40090
40007
|
}
|
40091
|
-
|
40008
|
+
updatePredicateInputs(inputs) {
|
40092
40009
|
this.inputs.forEach((i) => {
|
40093
40010
|
let correspondingInput;
|
40094
40011
|
switch (i.type) {
|
@@ -40110,15 +40027,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40110
40027
|
}
|
40111
40028
|
});
|
40112
40029
|
}
|
40113
|
-
shiftPredicateData() {
|
40114
|
-
this.inputs.forEach((input) => {
|
40115
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40116
|
-
input.predicateData = input.paddPredicateData(
|
40117
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40118
|
-
);
|
40119
|
-
}
|
40120
|
-
});
|
40121
|
-
}
|
40122
40030
|
};
|
40123
40031
|
|
40124
40032
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40252,8 +40160,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40252
40160
|
return {
|
40253
40161
|
type: TransactionType.Create,
|
40254
40162
|
...baseTransaction,
|
40163
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40255
40164
|
bytecodeWitnessIndex,
|
40256
|
-
storageSlotsCount:
|
40165
|
+
storageSlotsCount: storageSlots.length,
|
40257
40166
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40258
40167
|
storageSlots
|
40259
40168
|
};
|
@@ -40367,8 +40276,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40367
40276
|
type: TransactionType.Script,
|
40368
40277
|
scriptGasLimit: this.gasLimit,
|
40369
40278
|
...super.getBaseTransaction(),
|
40370
|
-
scriptLength:
|
40371
|
-
scriptDataLength:
|
40279
|
+
scriptLength: script.length,
|
40280
|
+
scriptDataLength: scriptData.length,
|
40372
40281
|
receiptsRoot: ZeroBytes32,
|
40373
40282
|
script: hexlify(script),
|
40374
40283
|
scriptData: hexlify(scriptData)
|
@@ -40432,7 +40341,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40432
40341
|
}
|
40433
40342
|
calculateMaxGas(chainInfo, minGas) {
|
40434
40343
|
const { consensusParameters } = chainInfo;
|
40435
|
-
const { gasPerByte
|
40344
|
+
const { gasPerByte } = consensusParameters;
|
40436
40345
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40437
40346
|
(acc, wit) => acc + wit.dataLength,
|
40438
40347
|
0
|
@@ -40442,8 +40351,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40442
40351
|
minGas,
|
40443
40352
|
witnessesLength,
|
40444
40353
|
witnessLimit: this.witnessLimit,
|
40445
|
-
gasLimit: this.gasLimit
|
40446
|
-
maxGasPerTx
|
40354
|
+
gasLimit: this.gasLimit
|
40447
40355
|
});
|
40448
40356
|
}
|
40449
40357
|
/**
|
@@ -40516,29 +40424,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40516
40424
|
}
|
40517
40425
|
}
|
40518
40426
|
};
|
40519
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40520
|
-
(acc, input) => {
|
40521
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40522
|
-
acc.utxos.push(input.id);
|
40523
|
-
}
|
40524
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40525
|
-
acc.messages.push(input.nonce);
|
40526
|
-
}
|
40527
|
-
return acc;
|
40528
|
-
},
|
40529
|
-
{
|
40530
|
-
utxos: [],
|
40531
|
-
messages: []
|
40532
|
-
}
|
40533
|
-
);
|
40534
40427
|
|
40535
40428
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40536
40429
|
var calculateTransactionFee = (params) => {
|
40537
40430
|
const {
|
40538
|
-
|
40431
|
+
gasUsed,
|
40539
40432
|
rawPayload,
|
40540
|
-
|
40541
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40433
|
+
consensusParameters: { gasCosts, feeParams }
|
40542
40434
|
} = params;
|
40543
40435
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40544
40436
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40548,7 +40440,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40548
40440
|
return {
|
40549
40441
|
fee: bn(0),
|
40550
40442
|
minFee: bn(0),
|
40551
|
-
maxFee: bn(0)
|
40443
|
+
maxFee: bn(0),
|
40444
|
+
feeFromGasUsed: bn(0)
|
40552
40445
|
};
|
40553
40446
|
}
|
40554
40447
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40580,6 +40473,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40580
40473
|
metadataGas,
|
40581
40474
|
txBytesSize: transactionBytes.length
|
40582
40475
|
});
|
40476
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40583
40477
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40584
40478
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40585
40479
|
const maxGas = getMaxGas({
|
@@ -40587,25 +40481,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40587
40481
|
minGas,
|
40588
40482
|
witnessesLength,
|
40589
40483
|
gasLimit,
|
40590
|
-
witnessLimit
|
40591
|
-
maxGasPerTx
|
40592
|
-
});
|
40593
|
-
const minFee = calculateGasFee({
|
40594
|
-
gasPrice,
|
40595
|
-
gas: minGas,
|
40596
|
-
priceFactor: gasPriceFactor,
|
40597
|
-
tip
|
40598
|
-
});
|
40599
|
-
const maxFee = calculateGasFee({
|
40600
|
-
gasPrice,
|
40601
|
-
gas: maxGas,
|
40602
|
-
priceFactor: gasPriceFactor,
|
40603
|
-
tip
|
40484
|
+
witnessLimit
|
40604
40485
|
});
|
40486
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40487
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40488
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40489
|
+
const fee = minFee.add(feeFromGasUsed);
|
40605
40490
|
return {
|
40491
|
+
fee,
|
40606
40492
|
minFee,
|
40607
40493
|
maxFee,
|
40608
|
-
|
40494
|
+
feeFromGasUsed
|
40609
40495
|
};
|
40610
40496
|
};
|
40611
40497
|
|
@@ -41206,9 +41092,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41206
41092
|
gqlTransactionStatus,
|
41207
41093
|
abiMap = {},
|
41208
41094
|
maxInputs,
|
41209
|
-
gasCosts
|
41210
|
-
maxGasPerTx,
|
41211
|
-
gasPrice
|
41095
|
+
gasCosts
|
41212
41096
|
} = params;
|
41213
41097
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41214
41098
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41222,14 +41106,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41222
41106
|
maxInputs
|
41223
41107
|
});
|
41224
41108
|
const typeName = getTransactionTypeName(transaction.type);
|
41225
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41226
41109
|
const { fee } = calculateTransactionFee({
|
41227
|
-
|
41110
|
+
gasUsed,
|
41228
41111
|
rawPayload,
|
41229
|
-
tip,
|
41230
41112
|
consensusParameters: {
|
41231
41113
|
gasCosts,
|
41232
|
-
maxGasPerTx,
|
41233
41114
|
feeParams: {
|
41234
41115
|
gasPerByte,
|
41235
41116
|
gasPriceFactor
|
@@ -41365,13 +41246,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41365
41246
|
const decodedTransaction = this.decodeTransaction(
|
41366
41247
|
transaction
|
41367
41248
|
);
|
41368
|
-
|
41369
|
-
|
41370
|
-
txReceipts = transaction.status.receipts;
|
41371
|
-
}
|
41372
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41373
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41374
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41249
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41250
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41375
41251
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41376
41252
|
const transactionSummary = assembleTransactionSummary({
|
41377
41253
|
id: this.id,
|
@@ -41383,9 +41259,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41383
41259
|
gasPriceFactor,
|
41384
41260
|
abiMap: contractsAbiMap,
|
41385
41261
|
maxInputs,
|
41386
|
-
gasCosts
|
41387
|
-
maxGasPerTx,
|
41388
|
-
gasPrice
|
41262
|
+
gasCosts
|
41389
41263
|
});
|
41390
41264
|
return transactionSummary;
|
41391
41265
|
}
|
@@ -41529,12 +41403,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41529
41403
|
gasPerByte: bn(feeParams.gasPerByte),
|
41530
41404
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41531
41405
|
chainId: bn(consensusParameters.chainId),
|
41406
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41532
41407
|
gasCosts
|
41533
41408
|
},
|
41534
41409
|
gasCosts,
|
41535
41410
|
latestBlock: {
|
41536
41411
|
id: latestBlock.id,
|
41537
|
-
height: bn(latestBlock.height),
|
41412
|
+
height: bn(latestBlock.header.height),
|
41538
41413
|
time: latestBlock.header.time,
|
41539
41414
|
transactions: latestBlock.transactions.map((i) => ({
|
41540
41415
|
id: i.id
|
@@ -41628,8 +41503,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41628
41503
|
* Returns some helpful parameters related to gas fees.
|
41629
41504
|
*/
|
41630
41505
|
getGasConfig() {
|
41506
|
+
const { minGasPrice } = this.getNode();
|
41631
41507
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41632
41508
|
return {
|
41509
|
+
minGasPrice,
|
41633
41510
|
maxGasPerTx,
|
41634
41511
|
maxGasPerPredicate,
|
41635
41512
|
gasPriceFactor,
|
@@ -41727,7 +41604,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41727
41604
|
*/
|
41728
41605
|
async getBlockNumber() {
|
41729
41606
|
const { chain } = await this.operations.getChain();
|
41730
|
-
return bn(chain.latestBlock.height, 10);
|
41607
|
+
return bn(chain.latestBlock.header.height, 10);
|
41731
41608
|
}
|
41732
41609
|
/**
|
41733
41610
|
* Returns the chain information.
|
@@ -41739,9 +41616,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41739
41616
|
const processedNodeInfo = {
|
41740
41617
|
maxDepth: bn(nodeInfo.maxDepth),
|
41741
41618
|
maxTx: bn(nodeInfo.maxTx),
|
41619
|
+
minGasPrice: bn(nodeInfo.minGasPrice),
|
41742
41620
|
nodeVersion: nodeInfo.nodeVersion,
|
41743
41621
|
utxoValidation: nodeInfo.utxoValidation,
|
41744
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41622
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41623
|
+
peers: nodeInfo.peers
|
41745
41624
|
};
|
41746
41625
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41747
41626
|
return processedNodeInfo;
|
@@ -41767,6 +41646,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41767
41646
|
} = this.getChain();
|
41768
41647
|
return chainId.toNumber();
|
41769
41648
|
}
|
41649
|
+
/**
|
41650
|
+
* Returns the base asset ID
|
41651
|
+
*
|
41652
|
+
* @returns A promise that resolves to the base asset ID
|
41653
|
+
*/
|
41654
|
+
getBaseAssetId() {
|
41655
|
+
const {
|
41656
|
+
consensusParameters: { baseAssetId }
|
41657
|
+
} = this.getChain();
|
41658
|
+
return baseAssetId;
|
41659
|
+
}
|
41770
41660
|
/**
|
41771
41661
|
* Submits a transaction to the chain to be executed.
|
41772
41662
|
*
|
@@ -41827,13 +41717,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41827
41717
|
return this.estimateTxDependencies(transactionRequest);
|
41828
41718
|
}
|
41829
41719
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41830
|
-
const { dryRun:
|
41831
|
-
|
41720
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41721
|
+
encodedTransaction,
|
41832
41722
|
utxoValidation: utxoValidation || false
|
41833
41723
|
});
|
41834
|
-
const
|
41835
|
-
|
41836
|
-
|
41724
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41725
|
+
return {
|
41726
|
+
receipts
|
41727
|
+
};
|
41837
41728
|
}
|
41838
41729
|
/**
|
41839
41730
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41872,6 +41763,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41872
41763
|
* If there are missing variable outputs,
|
41873
41764
|
* `addVariableOutputs` is called on the transaction.
|
41874
41765
|
*
|
41766
|
+
* @privateRemarks
|
41767
|
+
* TODO: Investigate support for missing contract IDs
|
41768
|
+
* TODO: Add support for missing output messages
|
41875
41769
|
*
|
41876
41770
|
* @param transactionRequest - The transaction request object.
|
41877
41771
|
* @returns A promise.
|
@@ -41884,19 +41778,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41884
41778
|
missingContractIds: []
|
41885
41779
|
};
|
41886
41780
|
}
|
41781
|
+
await this.estimatePredicates(transactionRequest);
|
41887
41782
|
let receipts = [];
|
41888
41783
|
const missingContractIds = [];
|
41889
41784
|
let outputVariables = 0;
|
41890
|
-
let dryrunStatus;
|
41891
41785
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41892
|
-
const {
|
41893
|
-
|
41894
|
-
} = await this.operations.dryRun({
|
41895
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41786
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41787
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41896
41788
|
utxoValidation: false
|
41897
41789
|
});
|
41898
|
-
receipts =
|
41899
|
-
dryrunStatus = status;
|
41790
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41900
41791
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41901
41792
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41902
41793
|
if (hasMissingOutputs) {
|
@@ -41906,11 +41797,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41906
41797
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41907
41798
|
missingContractIds.push(contractId);
|
41908
41799
|
});
|
41909
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41910
|
-
transactionRequest,
|
41911
|
-
optimizeGas: false
|
41912
|
-
});
|
41913
|
-
transactionRequest.maxFee = maxFee;
|
41914
41800
|
} else {
|
41915
41801
|
break;
|
41916
41802
|
}
|
@@ -41918,133 +41804,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41918
41804
|
return {
|
41919
41805
|
receipts,
|
41920
41806
|
outputVariables,
|
41921
|
-
missingContractIds
|
41922
|
-
dryrunStatus
|
41923
|
-
};
|
41924
|
-
}
|
41925
|
-
/**
|
41926
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41927
|
-
*
|
41928
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41929
|
-
* further modifications are identified. The method iteratively updates these transactions
|
41930
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41931
|
-
*
|
41932
|
-
* @param transactionRequests - Array of transaction request objects.
|
41933
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
41934
|
-
*/
|
41935
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41936
|
-
const results = transactionRequests.map(() => ({
|
41937
|
-
receipts: [],
|
41938
|
-
outputVariables: 0,
|
41939
|
-
missingContractIds: [],
|
41940
|
-
dryrunStatus: void 0
|
41941
|
-
}));
|
41942
|
-
const allRequests = clone_default(transactionRequests);
|
41943
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41944
|
-
allRequests.forEach((req, index) => {
|
41945
|
-
if (req.type === TransactionType.Script) {
|
41946
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41947
|
-
}
|
41948
|
-
});
|
41949
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41950
|
-
let attempt = 0;
|
41951
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41952
|
-
const encodedTransactions = transactionsToProcess.map(
|
41953
|
-
(index) => serializedTransactionsMap.get(index)
|
41954
|
-
);
|
41955
|
-
const dryRunResults = await this.operations.dryRun({
|
41956
|
-
encodedTransactions,
|
41957
|
-
utxoValidation: false
|
41958
|
-
});
|
41959
|
-
const nextRoundTransactions = [];
|
41960
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41961
|
-
const currentResultIndex = transactionsToProcess[i];
|
41962
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41963
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41964
|
-
results[currentResultIndex].dryrunStatus = status;
|
41965
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41966
|
-
results[currentResultIndex].receipts
|
41967
|
-
);
|
41968
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41969
|
-
const requestToProcess = allRequests[currentResultIndex];
|
41970
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41971
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41972
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41973
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41974
|
-
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41975
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
41976
|
-
});
|
41977
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41978
|
-
transactionRequest: requestToProcess,
|
41979
|
-
optimizeGas: false
|
41980
|
-
});
|
41981
|
-
requestToProcess.maxFee = maxFee;
|
41982
|
-
serializedTransactionsMap.set(
|
41983
|
-
currentResultIndex,
|
41984
|
-
hexlify(requestToProcess.toTransactionBytes())
|
41985
|
-
);
|
41986
|
-
nextRoundTransactions.push(currentResultIndex);
|
41987
|
-
allRequests[currentResultIndex] = requestToProcess;
|
41988
|
-
}
|
41989
|
-
}
|
41990
|
-
transactionsToProcess = nextRoundTransactions;
|
41991
|
-
attempt += 1;
|
41992
|
-
}
|
41993
|
-
return results;
|
41994
|
-
}
|
41995
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41996
|
-
if (estimateTxDependencies) {
|
41997
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
41998
|
-
}
|
41999
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
42000
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42001
|
-
encodedTransactions,
|
42002
|
-
utxoValidation: utxoValidation || false
|
42003
|
-
});
|
42004
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42005
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
42006
|
-
return { receipts, dryrunStatus: status };
|
42007
|
-
});
|
42008
|
-
return results;
|
42009
|
-
}
|
42010
|
-
async estimateTxGasAndFee(params) {
|
42011
|
-
const { transactionRequest, optimizeGas = true } = params;
|
42012
|
-
let { gasPrice } = params;
|
42013
|
-
const chainInfo = this.getChain();
|
42014
|
-
const { gasPriceFactor } = this.getGasConfig();
|
42015
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42016
|
-
if (!gasPrice) {
|
42017
|
-
gasPrice = await this.estimateGasPrice(10);
|
42018
|
-
}
|
42019
|
-
const minFee = calculateGasFee({
|
42020
|
-
gasPrice: bn(gasPrice),
|
42021
|
-
gas: minGas,
|
42022
|
-
priceFactor: gasPriceFactor,
|
42023
|
-
tip: transactionRequest.tip
|
42024
|
-
}).add(1);
|
42025
|
-
let gasLimit = bn(0);
|
42026
|
-
if (transactionRequest.type === TransactionType.Script) {
|
42027
|
-
gasLimit = transactionRequest.gasLimit;
|
42028
|
-
if (!optimizeGas) {
|
42029
|
-
transactionRequest.gasLimit = minGas;
|
42030
|
-
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42031
|
-
transactionRequest.gasLimit = gasLimit;
|
42032
|
-
}
|
42033
|
-
}
|
42034
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42035
|
-
const maxFee = calculateGasFee({
|
42036
|
-
gasPrice: bn(gasPrice),
|
42037
|
-
gas: maxGas,
|
42038
|
-
priceFactor: gasPriceFactor,
|
42039
|
-
tip: transactionRequest.tip
|
42040
|
-
}).add(1);
|
42041
|
-
return {
|
42042
|
-
minGas,
|
42043
|
-
minFee,
|
42044
|
-
maxGas,
|
42045
|
-
maxFee,
|
42046
|
-
gasPrice,
|
42047
|
-
gasLimit
|
41807
|
+
missingContractIds
|
42048
41808
|
};
|
42049
41809
|
}
|
42050
41810
|
/**
|
@@ -42062,17 +41822,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42062
41822
|
if (estimateTxDependencies) {
|
42063
41823
|
return this.estimateTxDependencies(transactionRequest);
|
42064
41824
|
}
|
42065
|
-
const
|
42066
|
-
const { dryRun:
|
42067
|
-
|
41825
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41826
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41827
|
+
encodedTransaction,
|
42068
41828
|
utxoValidation: true
|
42069
41829
|
});
|
42070
|
-
const
|
42071
|
-
|
42072
|
-
|
42073
|
-
|
42074
|
-
});
|
42075
|
-
return { receipts: callResult[0].receipts };
|
41830
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41831
|
+
return {
|
41832
|
+
receipts
|
41833
|
+
};
|
42076
41834
|
}
|
42077
41835
|
/**
|
42078
41836
|
* Returns a transaction cost to enable user
|
@@ -42089,80 +41847,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42089
41847
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42090
41848
|
* @returns A promise that resolves to the transaction cost object.
|
42091
41849
|
*/
|
42092
|
-
async getTransactionCost(transactionRequestLike,
|
41850
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41851
|
+
estimateTxDependencies = true,
|
41852
|
+
estimatePredicates = true,
|
41853
|
+
resourcesOwner,
|
41854
|
+
signatureCallback
|
41855
|
+
} = {}) {
|
42093
41856
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41857
|
+
const chainInfo = this.getChain();
|
41858
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41859
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42094
41860
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42095
41861
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42096
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41862
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42097
41863
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42098
|
-
|
42099
|
-
|
42100
|
-
|
42101
|
-
|
42102
|
-
|
42103
|
-
|
41864
|
+
if (estimatePredicates) {
|
41865
|
+
if (isScriptTransaction) {
|
41866
|
+
txRequestClone.gasLimit = bn(0);
|
41867
|
+
}
|
41868
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41869
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41870
|
+
}
|
41871
|
+
await this.estimatePredicates(txRequestClone);
|
42104
41872
|
}
|
42105
|
-
const signedRequest = clone_default(txRequestClone);
|
42106
|
-
let addedSignatures = 0;
|
42107
41873
|
if (signatureCallback && isScriptTransaction) {
|
42108
|
-
|
42109
|
-
|
42110
|
-
|
42111
|
-
|
42112
|
-
await this.estimatePredicates(signedRequest);
|
42113
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42114
|
-
transactionRequest: signedRequest,
|
42115
|
-
optimizeGas: false
|
42116
|
-
});
|
42117
|
-
txRequestClone.maxFee = maxFee;
|
41874
|
+
await signatureCallback(txRequestClone);
|
41875
|
+
}
|
41876
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41877
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
42118
41878
|
let receipts = [];
|
42119
41879
|
let missingContractIds = [];
|
42120
41880
|
let outputVariables = 0;
|
42121
|
-
|
42122
|
-
|
42123
|
-
|
42124
|
-
if (signatureCallback) {
|
42125
|
-
await signatureCallback(txRequestClone);
|
42126
|
-
}
|
42127
|
-
txRequestClone.gasLimit = gasLimit;
|
41881
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41882
|
+
txRequestClone.gasPrice = bn(0);
|
41883
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
42128
41884
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42129
41885
|
receipts = result.receipts;
|
42130
41886
|
outputVariables = result.outputVariables;
|
42131
41887
|
missingContractIds = result.missingContractIds;
|
42132
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
42133
|
-
txRequestClone.gasLimit = gasUsed;
|
42134
|
-
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42135
|
-
transactionRequest: txRequestClone,
|
42136
|
-
gasPrice
|
42137
|
-
}));
|
42138
41888
|
}
|
41889
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41890
|
+
const usedFee = calculatePriceWithFactor(
|
41891
|
+
gasUsed,
|
41892
|
+
gasPrice,
|
41893
|
+
gasPriceFactor
|
41894
|
+
).normalizeZeroToOne();
|
41895
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41896
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42139
41897
|
return {
|
42140
41898
|
requiredQuantities: allQuantities,
|
42141
41899
|
receipts,
|
42142
41900
|
gasUsed,
|
41901
|
+
minGasPrice,
|
42143
41902
|
gasPrice,
|
42144
41903
|
minGas,
|
42145
41904
|
maxGas,
|
41905
|
+
usedFee,
|
42146
41906
|
minFee,
|
42147
41907
|
maxFee,
|
41908
|
+
estimatedInputs: txRequestClone.inputs,
|
42148
41909
|
outputVariables,
|
42149
|
-
missingContractIds
|
42150
|
-
addedSignatures,
|
42151
|
-
estimatedPredicates: txRequestClone.inputs
|
41910
|
+
missingContractIds
|
42152
41911
|
};
|
42153
41912
|
}
|
42154
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41913
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42155
41914
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42156
41915
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42157
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42158
|
-
quantitiesToContract
|
42159
|
-
});
|
41916
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42160
41917
|
transactionRequest.addResources(
|
42161
41918
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42162
41919
|
);
|
42163
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42164
|
-
|
42165
|
-
|
41920
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41921
|
+
transactionRequest,
|
41922
|
+
forwardingQuantities
|
41923
|
+
);
|
42166
41924
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42167
41925
|
return {
|
42168
41926
|
resources,
|
@@ -42186,6 +41944,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42186
41944
|
assetId: coin.assetId,
|
42187
41945
|
amount: bn(coin.amount),
|
42188
41946
|
owner: Address.fromAddressOrString(coin.owner),
|
41947
|
+
maturity: bn(coin.maturity).toNumber(),
|
42189
41948
|
blockCreated: bn(coin.blockCreated),
|
42190
41949
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42191
41950
|
}));
|
@@ -42237,6 +41996,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42237
41996
|
amount: bn(coin.amount),
|
42238
41997
|
assetId: coin.assetId,
|
42239
41998
|
owner: Address.fromAddressOrString(coin.owner),
|
41999
|
+
maturity: bn(coin.maturity).toNumber(),
|
42240
42000
|
blockCreated: bn(coin.blockCreated),
|
42241
42001
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42242
42002
|
};
|
@@ -42269,7 +42029,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42269
42029
|
}
|
42270
42030
|
return {
|
42271
42031
|
id: block2.id,
|
42272
|
-
height: bn(block2.height),
|
42032
|
+
height: bn(block2.header.height),
|
42273
42033
|
time: block2.header.time,
|
42274
42034
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42275
42035
|
};
|
@@ -42284,7 +42044,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42284
42044
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42285
42045
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42286
42046
|
id: block2.id,
|
42287
|
-
height: bn(block2.height),
|
42047
|
+
height: bn(block2.header.height),
|
42288
42048
|
time: block2.header.time,
|
42289
42049
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42290
42050
|
}));
|
@@ -42311,7 +42071,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42311
42071
|
}
|
42312
42072
|
return {
|
42313
42073
|
id: block2.id,
|
42314
|
-
height: bn(block2.height, 10),
|
42074
|
+
height: bn(block2.header.height, 10),
|
42315
42075
|
time: block2.header.time,
|
42316
42076
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42317
42077
|
transactions: block2.transactions.map(
|
@@ -42491,6 +42251,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42491
42251
|
prevRoot: messageBlockHeader.prevRoot,
|
42492
42252
|
time: messageBlockHeader.time,
|
42493
42253
|
applicationHash: messageBlockHeader.applicationHash,
|
42254
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42494
42255
|
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42495
42256
|
},
|
42496
42257
|
commitBlockHeader: {
|
@@ -42502,6 +42263,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42502
42263
|
prevRoot: commitBlockHeader.prevRoot,
|
42503
42264
|
time: commitBlockHeader.time,
|
42504
42265
|
applicationHash: commitBlockHeader.applicationHash,
|
42266
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42505
42267
|
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42506
42268
|
},
|
42507
42269
|
sender: Address.fromAddressOrString(sender),
|
@@ -42511,16 +42273,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42511
42273
|
data
|
42512
42274
|
};
|
42513
42275
|
}
|
42514
|
-
async getLatestGasPrice() {
|
42515
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42516
|
-
return bn(latestGasPrice.gasPrice);
|
42517
|
-
}
|
42518
|
-
async estimateGasPrice(blockHorizon) {
|
42519
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42520
|
-
blockHorizon: String(blockHorizon)
|
42521
|
-
});
|
42522
|
-
return bn(estimateGasPrice.gasPrice);
|
42523
|
-
}
|
42524
42276
|
/**
|
42525
42277
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42526
42278
|
*
|
@@ -42581,15 +42333,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42581
42333
|
arrayify(gqlTransaction.rawPayload),
|
42582
42334
|
0
|
42583
42335
|
);
|
42584
|
-
|
42585
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42586
|
-
txReceipts = gqlTransaction.status.receipts;
|
42587
|
-
}
|
42588
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42336
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42589
42337
|
const {
|
42590
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42338
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42591
42339
|
} = provider.getChain();
|
42592
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42593
42340
|
const transactionInfo = assembleTransactionSummary({
|
42594
42341
|
id: gqlTransaction.id,
|
42595
42342
|
receipts,
|
@@ -42600,9 +42347,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42600
42347
|
gasPriceFactor: bn(gasPriceFactor),
|
42601
42348
|
abiMap,
|
42602
42349
|
maxInputs,
|
42603
|
-
gasCosts
|
42604
|
-
maxGasPerTx,
|
42605
|
-
gasPrice
|
42350
|
+
gasCosts
|
42606
42351
|
});
|
42607
42352
|
return {
|
42608
42353
|
gqlTransaction,
|
@@ -42612,11 +42357,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42612
42357
|
async function getTransactionSummaryFromRequest(params) {
|
42613
42358
|
const { provider, transactionRequest, abiMap } = params;
|
42614
42359
|
const { receipts } = await provider.call(transactionRequest);
|
42615
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42360
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42616
42361
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42617
42362
|
const transaction = transactionRequest.toTransaction();
|
42618
42363
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42619
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42620
42364
|
const transactionSummary = assembleTransactionSummary({
|
42621
42365
|
receipts,
|
42622
42366
|
transaction,
|
@@ -42625,9 +42369,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42625
42369
|
gasPerByte,
|
42626
42370
|
gasPriceFactor,
|
42627
42371
|
maxInputs,
|
42628
|
-
gasCosts
|
42629
|
-
maxGasPerTx,
|
42630
|
-
gasPrice
|
42372
|
+
gasCosts
|
42631
42373
|
});
|
42632
42374
|
return transactionSummary;
|
42633
42375
|
}
|
@@ -42636,18 +42378,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42636
42378
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42637
42379
|
const { edges, pageInfo } = transactionsByOwner;
|
42638
42380
|
const {
|
42639
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42381
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42640
42382
|
} = provider.getChain();
|
42641
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42642
42383
|
const transactions = edges.map((edge) => {
|
42643
42384
|
const { node: gqlTransaction } = edge;
|
42644
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42385
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42645
42386
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42646
|
-
|
42647
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42648
|
-
txReceipts = gqlTransaction.status.receipts;
|
42649
|
-
}
|
42650
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42387
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42651
42388
|
const transactionSummary = assembleTransactionSummary({
|
42652
42389
|
id,
|
42653
42390
|
receipts,
|
@@ -42658,9 +42395,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42658
42395
|
gasPerByte,
|
42659
42396
|
gasPriceFactor,
|
42660
42397
|
maxInputs,
|
42661
|
-
gasCosts
|
42662
|
-
maxGasPerTx,
|
42663
|
-
gasPrice
|
42398
|
+
gasCosts
|
42664
42399
|
});
|
42665
42400
|
const output3 = {
|
42666
42401
|
gqlTransaction,
|
@@ -42951,8 +42686,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42951
42686
|
* @param assetId - The asset ID to check the balance for.
|
42952
42687
|
* @returns A promise that resolves to the balance amount.
|
42953
42688
|
*/
|
42954
|
-
async getBalance(assetId
|
42955
|
-
const
|
42689
|
+
async getBalance(assetId) {
|
42690
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42691
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42956
42692
|
return amount;
|
42957
42693
|
}
|
42958
42694
|
/**
|
@@ -42989,33 +42725,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42989
42725
|
* @param fee - The estimated transaction fee.
|
42990
42726
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42991
42727
|
*/
|
42992
|
-
async fund(request,
|
42993
|
-
const
|
42994
|
-
const
|
42995
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42728
|
+
async fund(request, coinQuantities, fee) {
|
42729
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42730
|
+
const updatedQuantities = addAmountToAsset({
|
42996
42731
|
amount: bn(fee),
|
42997
|
-
assetId:
|
42998
|
-
coinQuantities
|
42732
|
+
assetId: baseAssetId,
|
42733
|
+
coinQuantities
|
42999
42734
|
});
|
43000
42735
|
const quantitiesDict = {};
|
43001
|
-
|
42736
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
43002
42737
|
quantitiesDict[assetId] = {
|
43003
42738
|
required: amount,
|
43004
42739
|
owned: bn(0)
|
43005
42740
|
};
|
43006
42741
|
});
|
43007
|
-
|
42742
|
+
const cachedUtxos = [];
|
42743
|
+
const cachedMessages = [];
|
42744
|
+
const owner = this.address.toB256();
|
42745
|
+
request.inputs.forEach((input) => {
|
43008
42746
|
const isResource = "amount" in input;
|
43009
42747
|
if (isResource) {
|
43010
42748
|
const isCoin2 = "owner" in input;
|
43011
42749
|
if (isCoin2) {
|
43012
42750
|
const assetId = String(input.assetId);
|
43013
|
-
if (quantitiesDict[assetId]) {
|
42751
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
43014
42752
|
const amount = bn(input.amount);
|
43015
42753
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42754
|
+
cachedUtxos.push(input.id);
|
43016
42755
|
}
|
43017
|
-
} else if (input.amount && quantitiesDict[
|
43018
|
-
quantitiesDict[
|
42756
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42757
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42758
|
+
cachedMessages.push(input.nonce);
|
43019
42759
|
}
|
43020
42760
|
}
|
43021
42761
|
});
|
@@ -43030,23 +42770,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43030
42770
|
});
|
43031
42771
|
const needsToBeFunded = missingQuantities.length;
|
43032
42772
|
if (needsToBeFunded) {
|
43033
|
-
const
|
43034
|
-
|
43035
|
-
|
43036
|
-
|
43037
|
-
|
43038
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43039
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
43040
|
-
if (addedSignatures) {
|
43041
|
-
Array.from({ length: addedSignatures }).forEach(
|
43042
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
43043
|
-
);
|
42773
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42774
|
+
messages: cachedMessages,
|
42775
|
+
utxos: cachedUtxos
|
42776
|
+
});
|
42777
|
+
request.addResources(resources);
|
43044
42778
|
}
|
43045
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43046
|
-
transactionRequest: requestToBeReEstimate
|
43047
|
-
});
|
43048
|
-
txRequest.maxFee = maxFee;
|
43049
|
-
return txRequest;
|
43050
42779
|
}
|
43051
42780
|
/**
|
43052
42781
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -43054,25 +42783,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43054
42783
|
* @param destination - The address of the destination.
|
43055
42784
|
* @param amount - The amount of coins to transfer.
|
43056
42785
|
* @param assetId - The asset ID of the coins to transfer.
|
43057
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42786
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43058
42787
|
* @returns A promise that resolves to the prepared transaction request.
|
43059
42788
|
*/
|
43060
|
-
async createTransfer(destination, amount, assetId
|
43061
|
-
const
|
43062
|
-
|
43063
|
-
const
|
42789
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42790
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42791
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42792
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42793
|
+
const request = new ScriptTransactionRequest(params);
|
42794
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42795
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43064
42796
|
estimateTxDependencies: true,
|
43065
42797
|
resourcesOwner: this
|
43066
42798
|
});
|
43067
|
-
|
43068
|
-
|
43069
|
-
|
43070
|
-
|
43071
|
-
|
43072
|
-
|
43073
|
-
|
43074
|
-
|
43075
|
-
await this.fund(request,
|
42799
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42800
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42801
|
+
this.validateGas({
|
42802
|
+
gasUsed,
|
42803
|
+
gasPrice: request.gasPrice,
|
42804
|
+
gasLimit: request.gasLimit,
|
42805
|
+
minGasPrice
|
42806
|
+
});
|
42807
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42808
|
+
request.updatePredicateInputs(estimatedInputs);
|
43076
42809
|
return request;
|
43077
42810
|
}
|
43078
42811
|
/**
|
@@ -43084,14 +42817,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43084
42817
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43085
42818
|
* @returns A promise that resolves to the transaction response.
|
43086
42819
|
*/
|
43087
|
-
async transfer(destination, amount, assetId
|
42820
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
43088
42821
|
if (bn(amount).lte(0)) {
|
43089
42822
|
throw new FuelError(
|
43090
42823
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
43091
42824
|
"Transfer amount must be a positive number."
|
43092
42825
|
);
|
43093
42826
|
}
|
43094
|
-
const
|
42827
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42828
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
43095
42829
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
43096
42830
|
}
|
43097
42831
|
/**
|
@@ -43103,7 +42837,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43103
42837
|
* @param txParams - The optional transaction parameters.
|
43104
42838
|
* @returns A promise that resolves to the transaction response.
|
43105
42839
|
*/
|
43106
|
-
async transferToContract(contractId, amount, assetId
|
42840
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
43107
42841
|
if (bn(amount).lte(0)) {
|
43108
42842
|
throw new FuelError(
|
43109
42843
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -43111,30 +42845,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43111
42845
|
);
|
43112
42846
|
}
|
43113
42847
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42848
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42849
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42850
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
43114
42851
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43115
42852
|
hexlifiedContractId: contractAddress.toB256(),
|
43116
42853
|
amountToTransfer: bn(amount),
|
43117
|
-
assetId
|
42854
|
+
assetId: assetIdToTransfer
|
43118
42855
|
});
|
43119
42856
|
const request = new ScriptTransactionRequest({
|
43120
|
-
...
|
42857
|
+
...params,
|
43121
42858
|
script,
|
43122
42859
|
scriptData
|
43123
42860
|
});
|
43124
42861
|
request.addContractInputAndOutput(contractAddress);
|
43125
|
-
const
|
43126
|
-
|
43127
|
-
|
42862
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42863
|
+
request,
|
42864
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42865
|
+
);
|
42866
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42867
|
+
this.validateGas({
|
42868
|
+
gasUsed,
|
42869
|
+
gasPrice: request.gasPrice,
|
42870
|
+
gasLimit: request.gasLimit,
|
42871
|
+
minGasPrice
|
43128
42872
|
});
|
43129
|
-
|
43130
|
-
this.validateGas({
|
43131
|
-
gasUsed: txCost.gasUsed,
|
43132
|
-
gasLimit: request.gasLimit
|
43133
|
-
});
|
43134
|
-
}
|
43135
|
-
request.gasLimit = txCost.gasUsed;
|
43136
|
-
request.maxFee = txCost.maxFee;
|
43137
|
-
await this.fund(request, txCost);
|
42873
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43138
42874
|
return this.sendTransaction(request);
|
43139
42875
|
}
|
43140
42876
|
/**
|
@@ -43146,6 +42882,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43146
42882
|
* @returns A promise that resolves to the transaction response.
|
43147
42883
|
*/
|
43148
42884
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42885
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42886
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
43149
42887
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43150
42888
|
const recipientDataArray = arrayify(
|
43151
42889
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43158,19 +42896,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43158
42896
|
...recipientDataArray,
|
43159
42897
|
...amountDataArray
|
43160
42898
|
]);
|
43161
|
-
const params = { script, ...txParams };
|
42899
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
43162
42900
|
const request = new ScriptTransactionRequest(params);
|
43163
|
-
const
|
43164
|
-
const
|
43165
|
-
|
43166
|
-
|
43167
|
-
|
43168
|
-
|
43169
|
-
|
43170
|
-
|
43171
|
-
|
43172
|
-
|
43173
|
-
|
42901
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42902
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42903
|
+
request,
|
42904
|
+
forwardingQuantities
|
42905
|
+
);
|
42906
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42907
|
+
this.validateGas({
|
42908
|
+
gasUsed,
|
42909
|
+
gasPrice: request.gasPrice,
|
42910
|
+
gasLimit: request.gasLimit,
|
42911
|
+
minGasPrice
|
42912
|
+
});
|
42913
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43174
42914
|
return this.sendTransaction(request);
|
43175
42915
|
}
|
43176
42916
|
async signMessage(message) {
|
@@ -43228,7 +42968,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43228
42968
|
}
|
43229
42969
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43230
42970
|
}
|
43231
|
-
validateGas({
|
42971
|
+
validateGas({
|
42972
|
+
gasUsed,
|
42973
|
+
gasPrice,
|
42974
|
+
gasLimit,
|
42975
|
+
minGasPrice
|
42976
|
+
}) {
|
42977
|
+
if (minGasPrice.gt(gasPrice)) {
|
42978
|
+
throw new FuelError(
|
42979
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
42980
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
42981
|
+
);
|
42982
|
+
}
|
43232
42983
|
if (gasUsed.gt(gasLimit)) {
|
43233
42984
|
throw new FuelError(
|
43234
42985
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44611,12 +44362,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44611
44362
|
};
|
44612
44363
|
|
44613
44364
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44614
|
-
var
|
44365
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44615
44366
|
var rnds8Pool = new Uint8Array(256);
|
44616
44367
|
var poolPtr = rnds8Pool.length;
|
44617
44368
|
function rng() {
|
44618
44369
|
if (poolPtr > rnds8Pool.length - 16) {
|
44619
|
-
|
44370
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44620
44371
|
poolPtr = 0;
|
44621
44372
|
}
|
44622
44373
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44632,9 +44383,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44632
44383
|
}
|
44633
44384
|
|
44634
44385
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44635
|
-
var
|
44386
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44636
44387
|
var native_default = {
|
44637
|
-
randomUUID:
|
44388
|
+
randomUUID: import_crypto16.default.randomUUID
|
44638
44389
|
};
|
44639
44390
|
|
44640
44391
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -44817,7 +44568,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44817
44568
|
* @param transactionRequestLike - The transaction request to send.
|
44818
44569
|
* @returns A promise that resolves to the TransactionResponse object.
|
44819
44570
|
*/
|
44820
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44571
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44821
44572
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44822
44573
|
if (estimateTxDependencies) {
|
44823
44574
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48083,7 +47834,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48083
47834
|
this.interface = predicateInterface;
|
48084
47835
|
if (inputData !== void 0 && inputData.length > 0) {
|
48085
47836
|
this.predicateData = inputData;
|
48086
|
-
this.predicateDataBytes = this.getPredicateData(0);
|
48087
47837
|
}
|
48088
47838
|
}
|
48089
47839
|
/**
|
@@ -48097,8 +47847,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48097
47847
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48098
47848
|
request.inputs?.forEach((input) => {
|
48099
47849
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
48100
|
-
input.predicate =
|
48101
|
-
input.predicateData =
|
47850
|
+
input.predicate = this.bytes;
|
47851
|
+
input.predicateData = this.getPredicateData(policies.length);
|
48102
47852
|
}
|
48103
47853
|
});
|
48104
47854
|
return request;
|
@@ -48112,8 +47862,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48112
47862
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
48113
47863
|
* @returns A promise that resolves to the prepared transaction request.
|
48114
47864
|
*/
|
48115
|
-
async createTransfer(destination, amount, assetId
|
48116
|
-
|
47865
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47866
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47867
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47868
|
+
return this.populateTransactionPredicateData(request);
|
48117
47869
|
}
|
48118
47870
|
/**
|
48119
47871
|
* Sends a transaction with the populated predicate data.
|
@@ -48121,9 +47873,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48121
47873
|
* @param transactionRequestLike - The transaction request-like object.
|
48122
47874
|
* @returns A promise that resolves to the transaction response.
|
48123
47875
|
*/
|
48124
|
-
sendTransaction(transactionRequestLike) {
|
48125
|
-
const transactionRequest =
|
48126
|
-
return super.sendTransaction(transactionRequest,
|
47876
|
+
sendTransaction(transactionRequestLike, options) {
|
47877
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47878
|
+
return super.sendTransaction(transactionRequest, options);
|
48127
47879
|
}
|
48128
47880
|
/**
|
48129
47881
|
* Simulates a transaction with the populated predicate data.
|
@@ -48132,8 +47884,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48132
47884
|
* @returns A promise that resolves to the call result.
|
48133
47885
|
*/
|
48134
47886
|
simulateTransaction(transactionRequestLike) {
|
48135
|
-
const transactionRequest =
|
48136
|
-
return super.simulateTransaction(transactionRequest
|
47887
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47888
|
+
return super.simulateTransaction(transactionRequest);
|
48137
47889
|
}
|
48138
47890
|
getPredicateData(policiesLength) {
|
48139
47891
|
if (!this.predicateData.length) {
|
@@ -48179,26 +47931,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48179
47931
|
predicateInterface: abiInterface
|
48180
47932
|
};
|
48181
47933
|
}
|
48182
|
-
/**
|
48183
|
-
* Retrieves resources satisfying the spend query for the account.
|
48184
|
-
*
|
48185
|
-
* @param quantities - IDs of coins to exclude.
|
48186
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48187
|
-
* @returns A promise that resolves to an array of Resources.
|
48188
|
-
*/
|
48189
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48190
|
-
const resources = await this.provider.getResourcesToSpend(
|
48191
|
-
this.address,
|
48192
|
-
quantities,
|
48193
|
-
excludedIds
|
48194
|
-
);
|
48195
|
-
return resources.map((resource) => ({
|
48196
|
-
...resource,
|
48197
|
-
predicate: hexlify(this.bytes),
|
48198
|
-
predicateData: hexlify(this.predicateDataBytes),
|
48199
|
-
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48200
|
-
}));
|
48201
|
-
}
|
48202
47934
|
/**
|
48203
47935
|
* Sets the configurable constants for the predicate.
|
48204
47936
|
*
|