@fuel-ts/account 0.0.0-rc-2021-20240409111335 → 0.0.0-rc-1976-20240409134753
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 +616 -868
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +610 -848
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +453 -690
- 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 +1117 -1583
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +607 -824
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +465 -682
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max2(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,8 +28952,8 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
|
+
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29244,7 +29244,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29244
29244
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29245
29245
|
|
29246
29246
|
// ../crypto/dist/index.mjs
|
29247
|
-
var
|
29247
|
+
var import_crypto8 = __toESM(__require("crypto"), 1);
|
29248
29248
|
|
29249
29249
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29250
29250
|
var version = "6.7.1";
|
@@ -30316,27 +30316,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30316
30316
|
};
|
30317
30317
|
Object.freeze(pbkdf22);
|
30318
30318
|
|
30319
|
-
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30320
|
-
var locked5 = false;
|
30321
|
-
var _randomBytes = function(length) {
|
30322
|
-
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30323
|
-
};
|
30324
|
-
var __randomBytes = _randomBytes;
|
30325
|
-
function randomBytes3(length) {
|
30326
|
-
return __randomBytes(length);
|
30327
|
-
}
|
30328
|
-
randomBytes3._ = _randomBytes;
|
30329
|
-
randomBytes3.lock = function() {
|
30330
|
-
locked5 = true;
|
30331
|
-
};
|
30332
|
-
randomBytes3.register = function(func) {
|
30333
|
-
if (locked5) {
|
30334
|
-
throw new Error("randomBytes is locked");
|
30335
|
-
}
|
30336
|
-
__randomBytes = func;
|
30337
|
-
};
|
30338
|
-
Object.freeze(randomBytes3);
|
30339
|
-
|
30340
30319
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30341
30320
|
var BN_03 = BigInt(0);
|
30342
30321
|
var BN_36 = BigInt(36);
|
@@ -30921,8 +30900,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30921
30900
|
}
|
30922
30901
|
|
30923
30902
|
// ../crypto/dist/index.mjs
|
30903
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30924
30904
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30925
|
-
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30926
30905
|
var scrypt3 = (params) => {
|
30927
30906
|
const { password, salt, n, p, r, dklen } = params;
|
30928
30907
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30931,7 +30910,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30931
30910
|
var keccak2562 = (data) => keccak_256(data);
|
30932
30911
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30933
30912
|
var randomBytes4 = (length) => {
|
30934
|
-
const randomValues = Uint8Array.from(
|
30913
|
+
const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
|
30935
30914
|
return randomValues;
|
30936
30915
|
};
|
30937
30916
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30946,7 +30925,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30946
30925
|
const salt = randomBytes4(32);
|
30947
30926
|
const secret = keyFromPassword(password, salt);
|
30948
30927
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30949
|
-
const cipher = await
|
30928
|
+
const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
|
30950
30929
|
let cipherData = cipher.update(dataBuffer);
|
30951
30930
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30952
30931
|
return {
|
@@ -30960,7 +30939,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30960
30939
|
const salt = bufferFromString(keystore.salt);
|
30961
30940
|
const secret = keyFromPassword(password, salt);
|
30962
30941
|
const encryptedText = bufferFromString(keystore.data);
|
30963
|
-
const decipher = await
|
30942
|
+
const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
|
30964
30943
|
const decrypted = decipher.update(encryptedText);
|
30965
30944
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30966
30945
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30971,12 +30950,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30971
30950
|
}
|
30972
30951
|
};
|
30973
30952
|
async function encryptJsonWalletData(data, key, iv) {
|
30974
|
-
const cipher = await
|
30953
|
+
const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30975
30954
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30976
30955
|
return new Uint8Array(encrypted);
|
30977
30956
|
}
|
30978
30957
|
async function decryptJsonWalletData(data, key, iv) {
|
30979
|
-
const decipher =
|
30958
|
+
const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30980
30959
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30981
30960
|
return new Uint8Array(decrypted);
|
30982
30961
|
}
|
@@ -31292,10 +31271,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31292
31271
|
}
|
31293
31272
|
};
|
31294
31273
|
|
31295
|
-
// ../address/dist/configs.mjs
|
31296
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31297
|
-
var BaseAssetId = ZeroBytes32;
|
31298
|
-
|
31299
31274
|
// ../math/dist/index.mjs
|
31300
31275
|
var import_bn = __toESM(require_bn(), 1);
|
31301
31276
|
var DEFAULT_PRECISION = 9;
|
@@ -31515,182 +31490,32 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31515
31490
|
function toBytes3(value, bytesPadding) {
|
31516
31491
|
return bn(value).toBytes(bytesPadding);
|
31517
31492
|
}
|
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" : ""));
|
31564
|
-
}
|
31565
|
-
|
31566
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31567
|
-
function _clone(value, deep, map) {
|
31568
|
-
map || (map = new _ObjectMap());
|
31569
|
-
if (_isPrimitive(value)) {
|
31570
|
-
return value;
|
31571
|
-
}
|
31572
|
-
var copy = function copy2(copiedValue) {
|
31573
|
-
var cachedCopy = map.get(value);
|
31574
|
-
if (cachedCopy) {
|
31575
|
-
return cachedCopy;
|
31576
|
-
}
|
31577
|
-
map.set(value, copiedValue);
|
31578
|
-
for (var key in value) {
|
31579
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31580
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31581
|
-
}
|
31582
|
-
}
|
31583
|
-
return copiedValue;
|
31584
|
-
};
|
31585
|
-
switch (type_default(value)) {
|
31586
|
-
case "Object":
|
31587
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
31588
|
-
case "Array":
|
31589
|
-
return copy([]);
|
31590
|
-
case "Date":
|
31591
|
-
return new Date(value.valueOf());
|
31592
|
-
case "RegExp":
|
31593
|
-
return _cloneRegExp(value);
|
31594
|
-
case "Int8Array":
|
31595
|
-
case "Uint8Array":
|
31596
|
-
case "Uint8ClampedArray":
|
31597
|
-
case "Int16Array":
|
31598
|
-
case "Uint16Array":
|
31599
|
-
case "Int32Array":
|
31600
|
-
case "Uint32Array":
|
31601
|
-
case "Float32Array":
|
31602
|
-
case "Float64Array":
|
31603
|
-
case "BigInt64Array":
|
31604
|
-
case "BigUint64Array":
|
31605
|
-
return value.slice();
|
31606
|
-
default:
|
31607
|
-
return value;
|
31608
|
-
}
|
31609
|
-
}
|
31610
|
-
function _isPrimitive(param) {
|
31611
|
-
var type3 = typeof param;
|
31612
|
-
return param == null || type3 != "object" && type3 != "function";
|
31493
|
+
function max(...numbers) {
|
31494
|
+
return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
|
31613
31495
|
}
|
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
31496
|
|
31672
31497
|
// src/providers/coin-quantity.ts
|
31673
31498
|
var coinQuantityfy = (coinQuantityLike) => {
|
31674
31499
|
let assetId;
|
31675
31500
|
let amount;
|
31676
|
-
let
|
31501
|
+
let max2;
|
31677
31502
|
if (Array.isArray(coinQuantityLike)) {
|
31678
31503
|
amount = coinQuantityLike[0];
|
31679
|
-
assetId = coinQuantityLike[1]
|
31680
|
-
|
31504
|
+
assetId = coinQuantityLike[1];
|
31505
|
+
max2 = coinQuantityLike[2];
|
31681
31506
|
} else {
|
31682
31507
|
amount = coinQuantityLike.amount;
|
31683
|
-
assetId = coinQuantityLike.assetId
|
31684
|
-
|
31508
|
+
assetId = coinQuantityLike.assetId;
|
31509
|
+
max2 = coinQuantityLike.max ?? void 0;
|
31685
31510
|
}
|
31686
31511
|
const bnAmount = bn(amount);
|
31687
31512
|
return {
|
31688
31513
|
assetId: hexlify(assetId),
|
31689
31514
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31690
|
-
max:
|
31515
|
+
max: max2 ? bn(max2) : void 0
|
31691
31516
|
};
|
31692
31517
|
};
|
31693
|
-
var
|
31518
|
+
var addAmountToAsset = (params) => {
|
31694
31519
|
const { amount, assetId } = params;
|
31695
31520
|
const coinQuantities = [...params.coinQuantities];
|
31696
31521
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31782,9 +31607,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31782
31607
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31783
31608
|
var MAX_BYTES = 2 ** 32 - 1;
|
31784
31609
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31785
|
-
|
31610
|
+
WORD_SIZE + // Tx size
|
31786
31611
|
// Asset ID/Balance coin input pairs
|
31787
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE)
|
31612
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31788
31613
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31789
31614
|
WORD_SIZE + // Gas limit
|
31790
31615
|
WORD_SIZE + // Script size
|
@@ -31802,6 +31627,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31802
31627
|
ASSET_ID_LEN + // Asset id
|
31803
31628
|
TX_POINTER_LEN + // TxPointer
|
31804
31629
|
WORD_SIZE + // Witnesses index
|
31630
|
+
WORD_SIZE + // Maturity
|
31805
31631
|
WORD_SIZE + // Predicate size
|
31806
31632
|
WORD_SIZE + // Predicate data size
|
31807
31633
|
WORD_SIZE;
|
@@ -32131,7 +31957,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32131
31957
|
constructor(name, coders) {
|
32132
31958
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32133
31959
|
const encodedValueSize = Object.values(coders).reduce(
|
32134
|
-
(
|
31960
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32135
31961
|
0
|
32136
31962
|
);
|
32137
31963
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32818,7 +32644,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32818
32644
|
constructor(name, coders) {
|
32819
32645
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32820
32646
|
const encodedValueSize = Object.values(coders).reduce(
|
32821
|
-
(
|
32647
|
+
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32822
32648
|
0
|
32823
32649
|
);
|
32824
32650
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33541,19 +33367,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33541
33367
|
encode(value) {
|
33542
33368
|
const parts = [];
|
33543
33369
|
parts.push(new B256Coder().encode(value.txID));
|
33544
|
-
parts.push(new NumberCoder("
|
33370
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33545
33371
|
parts.push(new B256Coder().encode(value.owner));
|
33546
33372
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33547
33373
|
parts.push(new B256Coder().encode(value.assetId));
|
33548
33374
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33549
|
-
parts.push(new NumberCoder("
|
33375
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33376
|
+
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33550
33377
|
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
|
-
);
|
33378
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33379
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33380
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33381
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33557
33382
|
return concat(parts);
|
33558
33383
|
}
|
33559
33384
|
decode(data, offset) {
|
@@ -33561,7 +33386,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33561
33386
|
let o = offset;
|
33562
33387
|
[decoded, o] = new B256Coder().decode(data, o);
|
33563
33388
|
const txID = decoded;
|
33564
|
-
[decoded, o] = new NumberCoder("
|
33389
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33565
33390
|
const outputIndex = decoded;
|
33566
33391
|
[decoded, o] = new B256Coder().decode(data, o);
|
33567
33392
|
const owner = decoded;
|
@@ -33571,17 +33396,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33571
33396
|
const assetId = decoded;
|
33572
33397
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33573
33398
|
const txPointer = decoded;
|
33574
|
-
[decoded, o] = new NumberCoder("
|
33399
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33575
33400
|
const witnessIndex = Number(decoded);
|
33401
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33402
|
+
const maturity = decoded;
|
33576
33403
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33577
33404
|
const predicateGasUsed = decoded;
|
33578
|
-
[decoded, o] = new
|
33405
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33579
33406
|
const predicateLength = decoded;
|
33580
|
-
[decoded, o] = new
|
33407
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33581
33408
|
const predicateDataLength = decoded;
|
33582
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33409
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33583
33410
|
const predicate = decoded;
|
33584
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33411
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33585
33412
|
const predicateData = decoded;
|
33586
33413
|
return [
|
33587
33414
|
{
|
@@ -33593,6 +33420,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33593
33420
|
assetId,
|
33594
33421
|
txPointer,
|
33595
33422
|
witnessIndex,
|
33423
|
+
maturity,
|
33596
33424
|
predicateGasUsed,
|
33597
33425
|
predicateLength,
|
33598
33426
|
predicateDataLength,
|
@@ -33610,7 +33438,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33610
33438
|
encode(value) {
|
33611
33439
|
const parts = [];
|
33612
33440
|
parts.push(new B256Coder().encode(value.txID));
|
33613
|
-
parts.push(new NumberCoder("
|
33441
|
+
parts.push(new NumberCoder("u8").encode(value.outputIndex));
|
33614
33442
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33615
33443
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33616
33444
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33622,7 +33450,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33622
33450
|
let o = offset;
|
33623
33451
|
[decoded, o] = new B256Coder().decode(data, o);
|
33624
33452
|
const txID = decoded;
|
33625
|
-
[decoded, o] = new NumberCoder("
|
33453
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33626
33454
|
const outputIndex = decoded;
|
33627
33455
|
[decoded, o] = new B256Coder().decode(data, o);
|
33628
33456
|
const balanceRoot = decoded;
|
@@ -33671,16 +33499,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33671
33499
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33672
33500
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33673
33501
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33674
|
-
parts.push(new NumberCoder("
|
33502
|
+
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
33675
33503
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33676
|
-
parts.push(new
|
33677
|
-
parts.push(new
|
33678
|
-
parts.push(new
|
33504
|
+
parts.push(new NumberCoder("u32").encode(data.length));
|
33505
|
+
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
33506
|
+
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
33679
33507
|
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
|
-
);
|
33508
|
+
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33509
|
+
parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
|
33684
33510
|
return concat(parts);
|
33685
33511
|
}
|
33686
33512
|
static decodeData(messageData) {
|
@@ -33700,21 +33526,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33700
33526
|
const amount = decoded;
|
33701
33527
|
[decoded, o] = new B256Coder().decode(data, o);
|
33702
33528
|
const nonce = decoded;
|
33703
|
-
[decoded, o] = new NumberCoder("
|
33529
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33704
33530
|
const witnessIndex = Number(decoded);
|
33705
33531
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33706
33532
|
const predicateGasUsed = decoded;
|
33707
33533
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33708
33534
|
const dataLength2 = decoded;
|
33709
|
-
[decoded, o] = new
|
33535
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33710
33536
|
const predicateLength = decoded;
|
33711
|
-
[decoded, o] = new
|
33537
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33712
33538
|
const predicateDataLength = decoded;
|
33713
33539
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33714
33540
|
const messageData = decoded;
|
33715
|
-
[decoded, o] = new ByteArrayCoder(predicateLength
|
33541
|
+
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33716
33542
|
const predicate = decoded;
|
33717
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength
|
33543
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33718
33544
|
const predicateData = decoded;
|
33719
33545
|
return [
|
33720
33546
|
{
|
@@ -34026,7 +33852,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34026
33852
|
}
|
34027
33853
|
};
|
34028
33854
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
34029
|
-
PolicyType2[PolicyType2["
|
33855
|
+
PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
|
34030
33856
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
34031
33857
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
34032
33858
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -34074,9 +33900,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34074
33900
|
let o = offset;
|
34075
33901
|
const policies = [];
|
34076
33902
|
if (policyTypes & 1) {
|
34077
|
-
const [
|
33903
|
+
const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
34078
33904
|
o = nextOffset;
|
34079
|
-
policies.push({ type: 1, data:
|
33905
|
+
policies.push({ type: 1, data: gasPrice });
|
34080
33906
|
}
|
34081
33907
|
if (policyTypes & 2) {
|
34082
33908
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34308,15 +34134,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34308
34134
|
encode(value) {
|
34309
34135
|
const parts = [];
|
34310
34136
|
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));
|
34137
|
+
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34138
|
+
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34314
34139
|
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.
|
34140
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34141
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34142
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34143
|
+
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34144
|
+
parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
|
34145
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
|
34320
34146
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34321
34147
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34322
34148
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34328,23 +34154,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34328
34154
|
let o = offset;
|
34329
34155
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34330
34156
|
const scriptGasLimit = decoded;
|
34331
|
-
[decoded, o] = new
|
34332
|
-
const receiptsRoot = decoded;
|
34333
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34157
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34334
34158
|
const scriptLength = decoded;
|
34335
|
-
[decoded, o] = new
|
34159
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34336
34160
|
const scriptDataLength = decoded;
|
34337
34161
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34338
34162
|
const policyTypes = decoded;
|
34339
|
-
[decoded, o] = new NumberCoder("
|
34163
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34340
34164
|
const inputsCount = decoded;
|
34341
|
-
[decoded, o] = new NumberCoder("
|
34165
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34342
34166
|
const outputsCount = decoded;
|
34343
|
-
[decoded, o] = new NumberCoder("
|
34167
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34344
34168
|
const witnessesCount = decoded;
|
34345
|
-
[decoded, o] = new
|
34169
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34170
|
+
const receiptsRoot = decoded;
|
34171
|
+
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34346
34172
|
const script = decoded;
|
34347
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength
|
34173
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34348
34174
|
const scriptData = decoded;
|
34349
34175
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34350
34176
|
const policies = decoded;
|
@@ -34382,19 +34208,18 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34382
34208
|
}
|
34383
34209
|
encode(value) {
|
34384
34210
|
const parts = [];
|
34385
|
-
parts.push(new NumberCoder("
|
34386
|
-
parts.push(new
|
34387
|
-
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34211
|
+
parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
|
34212
|
+
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34388
34213
|
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("
|
34214
|
+
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34215
|
+
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34216
|
+
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34217
|
+
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34218
|
+
parts.push(new B256Coder().encode(value.salt));
|
34219
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34392
34220
|
parts.push(
|
34393
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount
|
34394
|
-
value.storageSlots
|
34395
|
-
)
|
34221
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
|
34396
34222
|
);
|
34397
|
-
parts.push(new PoliciesCoder().encode(value.policies));
|
34398
34223
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34399
34224
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34400
34225
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34403,27 +34228,26 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34403
34228
|
decode(data, offset) {
|
34404
34229
|
let decoded;
|
34405
34230
|
let o = offset;
|
34406
|
-
[decoded, o] = new NumberCoder("
|
34231
|
+
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34232
|
+
const bytecodeLength = decoded;
|
34233
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34407
34234
|
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
34235
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34413
34236
|
const policyTypes = decoded;
|
34414
34237
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34238
|
+
const storageSlotsCount = decoded;
|
34239
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34415
34240
|
const inputsCount = decoded;
|
34416
|
-
[decoded, o] = new NumberCoder("
|
34241
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34417
34242
|
const outputsCount = decoded;
|
34418
|
-
[decoded, o] = new NumberCoder("
|
34243
|
+
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34419
34244
|
const witnessesCount = decoded;
|
34420
|
-
[decoded, o] = new
|
34421
|
-
|
34422
|
-
o
|
34423
|
-
);
|
34424
|
-
const storageSlots = decoded;
|
34245
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34246
|
+
const salt = decoded;
|
34425
34247
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34426
34248
|
const policies = decoded;
|
34249
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34250
|
+
const storageSlots = decoded;
|
34427
34251
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34428
34252
|
const inputs = decoded;
|
34429
34253
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34433,6 +34257,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34433
34257
|
return [
|
34434
34258
|
{
|
34435
34259
|
type: 1,
|
34260
|
+
bytecodeLength,
|
34436
34261
|
bytecodeWitnessIndex,
|
34437
34262
|
policyTypes,
|
34438
34263
|
storageSlotsCount,
|
@@ -34461,7 +34286,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34461
34286
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34462
34287
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34463
34288
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34464
|
-
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34465
34289
|
return concat(parts);
|
34466
34290
|
}
|
34467
34291
|
decode(data, offset) {
|
@@ -34477,8 +34301,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34477
34301
|
const mintAmount = decoded;
|
34478
34302
|
[decoded, o] = new B256Coder().decode(data, o);
|
34479
34303
|
const mintAssetId = decoded;
|
34480
|
-
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34481
|
-
const gasPrice = decoded;
|
34482
34304
|
return [
|
34483
34305
|
{
|
34484
34306
|
type: 2,
|
@@ -34486,8 +34308,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34486
34308
|
inputContract,
|
34487
34309
|
outputContract,
|
34488
34310
|
mintAmount,
|
34489
|
-
mintAssetId
|
34490
|
-
gasPrice
|
34311
|
+
mintAssetId
|
34491
34312
|
},
|
34492
34313
|
o
|
34493
34314
|
];
|
@@ -34794,6 +34615,159 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34794
34615
|
// src/providers/provider.ts
|
34795
34616
|
var import_graphql_request = __toESM(require_dist2());
|
34796
34617
|
|
34618
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34619
|
+
function _isPlaceholder(a) {
|
34620
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34621
|
+
}
|
34622
|
+
|
34623
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34624
|
+
function _curry1(fn) {
|
34625
|
+
return function f1(a) {
|
34626
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34627
|
+
return f1;
|
34628
|
+
} else {
|
34629
|
+
return fn.apply(this, arguments);
|
34630
|
+
}
|
34631
|
+
};
|
34632
|
+
}
|
34633
|
+
|
34634
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34635
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
34636
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34637
|
+
};
|
34638
|
+
|
34639
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34640
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34641
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34642
|
+
});
|
34643
|
+
var type_default = type;
|
34644
|
+
|
34645
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34646
|
+
var pad = function pad2(n) {
|
34647
|
+
return (n < 10 ? "0" : "") + n;
|
34648
|
+
};
|
34649
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34650
|
+
return d.toISOString();
|
34651
|
+
} : function _toISOString3(d) {
|
34652
|
+
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";
|
34653
|
+
};
|
34654
|
+
|
34655
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34656
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34657
|
+
return n << 0 === n;
|
34658
|
+
};
|
34659
|
+
|
34660
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34661
|
+
function _cloneRegExp(pattern) {
|
34662
|
+
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" : ""));
|
34663
|
+
}
|
34664
|
+
|
34665
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34666
|
+
function _clone(value, deep, map) {
|
34667
|
+
map || (map = new _ObjectMap());
|
34668
|
+
if (_isPrimitive(value)) {
|
34669
|
+
return value;
|
34670
|
+
}
|
34671
|
+
var copy = function copy2(copiedValue) {
|
34672
|
+
var cachedCopy = map.get(value);
|
34673
|
+
if (cachedCopy) {
|
34674
|
+
return cachedCopy;
|
34675
|
+
}
|
34676
|
+
map.set(value, copiedValue);
|
34677
|
+
for (var key in value) {
|
34678
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34679
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34680
|
+
}
|
34681
|
+
}
|
34682
|
+
return copiedValue;
|
34683
|
+
};
|
34684
|
+
switch (type_default(value)) {
|
34685
|
+
case "Object":
|
34686
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
34687
|
+
case "Array":
|
34688
|
+
return copy([]);
|
34689
|
+
case "Date":
|
34690
|
+
return new Date(value.valueOf());
|
34691
|
+
case "RegExp":
|
34692
|
+
return _cloneRegExp(value);
|
34693
|
+
case "Int8Array":
|
34694
|
+
case "Uint8Array":
|
34695
|
+
case "Uint8ClampedArray":
|
34696
|
+
case "Int16Array":
|
34697
|
+
case "Uint16Array":
|
34698
|
+
case "Int32Array":
|
34699
|
+
case "Uint32Array":
|
34700
|
+
case "Float32Array":
|
34701
|
+
case "Float64Array":
|
34702
|
+
case "BigInt64Array":
|
34703
|
+
case "BigUint64Array":
|
34704
|
+
return value.slice();
|
34705
|
+
default:
|
34706
|
+
return value;
|
34707
|
+
}
|
34708
|
+
}
|
34709
|
+
function _isPrimitive(param) {
|
34710
|
+
var type3 = typeof param;
|
34711
|
+
return param == null || type3 != "object" && type3 != "function";
|
34712
|
+
}
|
34713
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
34714
|
+
function _ObjectMap2() {
|
34715
|
+
this.map = {};
|
34716
|
+
this.length = 0;
|
34717
|
+
}
|
34718
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
34719
|
+
const hashedKey = this.hash(key);
|
34720
|
+
let bucket = this.map[hashedKey];
|
34721
|
+
if (!bucket) {
|
34722
|
+
this.map[hashedKey] = bucket = [];
|
34723
|
+
}
|
34724
|
+
bucket.push([key, value]);
|
34725
|
+
this.length += 1;
|
34726
|
+
};
|
34727
|
+
_ObjectMap2.prototype.hash = function(key) {
|
34728
|
+
let hashedKey = [];
|
34729
|
+
for (var value in key) {
|
34730
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34731
|
+
}
|
34732
|
+
return hashedKey.join();
|
34733
|
+
};
|
34734
|
+
_ObjectMap2.prototype.get = function(key) {
|
34735
|
+
if (this.length <= 180) {
|
34736
|
+
for (const p in this.map) {
|
34737
|
+
const bucket2 = this.map[p];
|
34738
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
34739
|
+
const element = bucket2[i];
|
34740
|
+
if (element[0] === key) {
|
34741
|
+
return element[1];
|
34742
|
+
}
|
34743
|
+
}
|
34744
|
+
}
|
34745
|
+
return;
|
34746
|
+
}
|
34747
|
+
const hashedKey = this.hash(key);
|
34748
|
+
const bucket = this.map[hashedKey];
|
34749
|
+
if (!bucket) {
|
34750
|
+
return;
|
34751
|
+
}
|
34752
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
34753
|
+
const element = bucket[i];
|
34754
|
+
if (element[0] === key) {
|
34755
|
+
return element[1];
|
34756
|
+
}
|
34757
|
+
}
|
34758
|
+
};
|
34759
|
+
return _ObjectMap2;
|
34760
|
+
}();
|
34761
|
+
|
34762
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34763
|
+
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34764
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34765
|
+
});
|
34766
|
+
var clone_default = clone2;
|
34767
|
+
|
34768
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34769
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34770
|
+
|
34797
34771
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34798
34772
|
var __assign = function() {
|
34799
34773
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37961,10 +37935,14 @@ spurious results.`);
|
|
37961
37935
|
// src/providers/__generated__/operations.ts
|
37962
37936
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37963
37937
|
fragment receiptFragment on Receipt {
|
37964
|
-
|
37938
|
+
contract {
|
37939
|
+
id
|
37940
|
+
}
|
37965
37941
|
pc
|
37966
37942
|
is
|
37967
|
-
to
|
37943
|
+
to {
|
37944
|
+
id
|
37945
|
+
}
|
37968
37946
|
toAddress
|
37969
37947
|
amount
|
37970
37948
|
assetId
|
@@ -38002,16 +37980,10 @@ spurious results.`);
|
|
38002
37980
|
id
|
38003
37981
|
}
|
38004
37982
|
time
|
38005
|
-
receipts {
|
38006
|
-
...receiptFragment
|
38007
|
-
}
|
38008
37983
|
programState {
|
38009
37984
|
returnType
|
38010
37985
|
data
|
38011
37986
|
}
|
38012
|
-
receipts {
|
38013
|
-
...receiptFragment
|
38014
|
-
}
|
38015
37987
|
}
|
38016
37988
|
... on FailureStatus {
|
38017
37989
|
block {
|
@@ -38019,24 +37991,26 @@ spurious results.`);
|
|
38019
37991
|
}
|
38020
37992
|
time
|
38021
37993
|
reason
|
38022
|
-
receipts {
|
38023
|
-
...receiptFragment
|
38024
|
-
}
|
38025
37994
|
}
|
38026
37995
|
... on SqueezedOutStatus {
|
38027
37996
|
reason
|
38028
37997
|
}
|
38029
37998
|
}
|
38030
|
-
|
37999
|
+
`;
|
38031
38000
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38032
38001
|
fragment transactionFragment on Transaction {
|
38033
38002
|
id
|
38034
38003
|
rawPayload
|
38004
|
+
gasPrice
|
38005
|
+
receipts {
|
38006
|
+
...receiptFragment
|
38007
|
+
}
|
38035
38008
|
status {
|
38036
38009
|
...transactionStatusFragment
|
38037
38010
|
}
|
38038
38011
|
}
|
38039
|
-
${
|
38012
|
+
${ReceiptFragmentFragmentDoc}
|
38013
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38040
38014
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38041
38015
|
fragment inputEstimatePredicatesFragment on Input {
|
38042
38016
|
... on InputCoin {
|
@@ -38054,46 +38028,6 @@ spurious results.`);
|
|
38054
38028
|
}
|
38055
38029
|
}
|
38056
38030
|
${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
38031
|
var CoinFragmentFragmentDoc = lib_default2`
|
38098
38032
|
fragment coinFragment on Coin {
|
38099
38033
|
__typename
|
@@ -38101,6 +38035,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38101
38035
|
owner
|
38102
38036
|
amount
|
38103
38037
|
assetId
|
38038
|
+
maturity
|
38104
38039
|
blockCreated
|
38105
38040
|
txCreatedIdx
|
38106
38041
|
}
|
@@ -38145,6 +38080,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38145
38080
|
prevRoot
|
38146
38081
|
time
|
38147
38082
|
applicationHash
|
38083
|
+
messageReceiptRoot
|
38148
38084
|
messageReceiptCount
|
38149
38085
|
}
|
38150
38086
|
commitBlockHeader {
|
@@ -38156,6 +38092,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38156
38092
|
prevRoot
|
38157
38093
|
time
|
38158
38094
|
applicationHash
|
38095
|
+
messageReceiptRoot
|
38159
38096
|
messageReceiptCount
|
38160
38097
|
}
|
38161
38098
|
sender
|
@@ -38175,8 +38112,8 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38175
38112
|
var BlockFragmentFragmentDoc = lib_default2`
|
38176
38113
|
fragment blockFragment on Block {
|
38177
38114
|
id
|
38178
|
-
height
|
38179
38115
|
header {
|
38116
|
+
height
|
38180
38117
|
time
|
38181
38118
|
}
|
38182
38119
|
transactions {
|
@@ -38234,11 +38171,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38234
38171
|
`;
|
38235
38172
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38236
38173
|
fragment GasCostsFragment on GasCosts {
|
38237
|
-
version {
|
38238
|
-
... on Version {
|
38239
|
-
value
|
38240
|
-
}
|
38241
|
-
}
|
38242
38174
|
add
|
38243
38175
|
addi
|
38244
38176
|
aloc
|
@@ -38251,6 +38183,7 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38251
38183
|
cb
|
38252
38184
|
cfei
|
38253
38185
|
cfsi
|
38186
|
+
croo
|
38254
38187
|
div
|
38255
38188
|
divi
|
38256
38189
|
ecr1
|
@@ -38333,9 +38266,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38333
38266
|
ccp {
|
38334
38267
|
...DependentCostFragment
|
38335
38268
|
}
|
38336
|
-
croo {
|
38337
|
-
...DependentCostFragment
|
38338
|
-
}
|
38339
38269
|
csiz {
|
38340
38270
|
...DependentCostFragment
|
38341
38271
|
}
|
@@ -38395,11 +38325,6 @@ ${ReceiptFragmentFragmentDoc}`;
|
|
38395
38325
|
${DependentCostFragmentFragmentDoc}`;
|
38396
38326
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38397
38327
|
fragment consensusParametersFragment on ConsensusParameters {
|
38398
|
-
version {
|
38399
|
-
... on Version {
|
38400
|
-
value
|
38401
|
-
}
|
38402
|
-
}
|
38403
38328
|
txParams {
|
38404
38329
|
...TxParametersFragment
|
38405
38330
|
}
|
@@ -38459,9 +38384,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38459
38384
|
fragment nodeInfoFragment on NodeInfo {
|
38460
38385
|
utxoValidation
|
38461
38386
|
vmBacktrace
|
38387
|
+
minGasPrice
|
38462
38388
|
maxTx
|
38463
38389
|
maxDepth
|
38464
38390
|
nodeVersion
|
38391
|
+
peers {
|
38392
|
+
id
|
38393
|
+
addresses
|
38394
|
+
clientVersion
|
38395
|
+
blockHeight
|
38396
|
+
lastHeartbeatMs
|
38397
|
+
appScore
|
38398
|
+
}
|
38465
38399
|
}
|
38466
38400
|
`;
|
38467
38401
|
var GetVersionDocument = lib_default2`
|
@@ -38496,9 +38430,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38496
38430
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38497
38431
|
transaction(id: $transactionId) {
|
38498
38432
|
...transactionFragment
|
38433
|
+
receipts {
|
38434
|
+
...receiptFragment
|
38435
|
+
}
|
38499
38436
|
}
|
38500
38437
|
}
|
38501
|
-
${TransactionFragmentFragmentDoc}
|
38438
|
+
${TransactionFragmentFragmentDoc}
|
38439
|
+
${ReceiptFragmentFragmentDoc}`;
|
38502
38440
|
var GetTransactionsDocument = lib_default2`
|
38503
38441
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38504
38442
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38626,20 +38564,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38626
38564
|
}
|
38627
38565
|
}
|
38628
38566
|
${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
38567
|
var GetBalancesDocument = lib_default2`
|
38644
38568
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38645
38569
|
balances(
|
@@ -38694,12 +38618,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38694
38618
|
}
|
38695
38619
|
`;
|
38696
38620
|
var DryRunDocument = lib_default2`
|
38697
|
-
mutation dryRun($
|
38698
|
-
dryRun(
|
38699
|
-
...
|
38621
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
38622
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
38623
|
+
...receiptFragment
|
38700
38624
|
}
|
38701
38625
|
}
|
38702
|
-
${
|
38626
|
+
${ReceiptFragmentFragmentDoc}`;
|
38703
38627
|
var SubmitDocument = lib_default2`
|
38704
38628
|
mutation submit($encodedTransaction: HexString!) {
|
38705
38629
|
submit(tx: $encodedTransaction) {
|
@@ -38782,12 +38706,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38782
38706
|
getBalance(variables, options) {
|
38783
38707
|
return requester(GetBalanceDocument, variables, options);
|
38784
38708
|
},
|
38785
|
-
getLatestGasPrice(variables, options) {
|
38786
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
38787
|
-
},
|
38788
|
-
estimateGasPrice(variables, options) {
|
38789
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
38790
|
-
},
|
38791
38709
|
getBalances(variables, options) {
|
38792
38710
|
return requester(GetBalancesDocument, variables, options);
|
38793
38711
|
},
|
@@ -38859,9 +38777,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38859
38777
|
} catch (e) {
|
38860
38778
|
throw new FuelError(
|
38861
38779
|
ErrorCode.STREAM_PARSING_ERROR,
|
38862
|
-
`Error while parsing stream data response: ${text}
|
38863
|
-
|
38864
|
-
Thrown error: ${e}`
|
38780
|
+
`Error while parsing stream data response: ${text}`
|
38865
38781
|
);
|
38866
38782
|
}
|
38867
38783
|
if (Array.isArray(errors)) {
|
@@ -38945,6 +38861,9 @@ Thrown error: ${e}`
|
|
38945
38861
|
}
|
38946
38862
|
};
|
38947
38863
|
|
38864
|
+
// ../address/dist/configs.mjs
|
38865
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38866
|
+
|
38948
38867
|
// src/providers/transaction-request/input.ts
|
38949
38868
|
var inputify = (value) => {
|
38950
38869
|
const { type: type3 } = value;
|
@@ -38955,7 +38874,7 @@ Thrown error: ${e}`
|
|
38955
38874
|
return {
|
38956
38875
|
type: InputType.Coin,
|
38957
38876
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38958
|
-
outputIndex:
|
38877
|
+
outputIndex: arrayify(value.id)[32],
|
38959
38878
|
owner: hexlify(value.owner),
|
38960
38879
|
amount: bn(value.amount),
|
38961
38880
|
assetId: hexlify(value.assetId),
|
@@ -38964,9 +38883,10 @@ Thrown error: ${e}`
|
|
38964
38883
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38965
38884
|
},
|
38966
38885
|
witnessIndex: value.witnessIndex,
|
38886
|
+
maturity: value.maturity ?? 0,
|
38967
38887
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38968
|
-
predicateLength:
|
38969
|
-
predicateDataLength:
|
38888
|
+
predicateLength: predicate.length,
|
38889
|
+
predicateDataLength: predicateData.length,
|
38970
38890
|
predicate: hexlify(predicate),
|
38971
38891
|
predicateData: hexlify(predicateData)
|
38972
38892
|
};
|
@@ -38997,8 +38917,8 @@ Thrown error: ${e}`
|
|
38997
38917
|
nonce: hexlify(value.nonce),
|
38998
38918
|
witnessIndex: value.witnessIndex,
|
38999
38919
|
predicateGasUsed: bn(value.predicateGasUsed),
|
39000
|
-
predicateLength:
|
39001
|
-
predicateDataLength:
|
38920
|
+
predicateLength: predicate.length,
|
38921
|
+
predicateDataLength: predicateData.length,
|
39002
38922
|
predicate: hexlify(predicate),
|
39003
38923
|
predicateData: hexlify(predicateData),
|
39004
38924
|
data: hexlify(data),
|
@@ -39158,8 +39078,8 @@ Thrown error: ${e}`
|
|
39158
39078
|
case "CALL" /* Call */: {
|
39159
39079
|
const callReceipt = {
|
39160
39080
|
type: ReceiptType.Call,
|
39161
|
-
from: hexOrZero(receipt.id
|
39162
|
-
to: hexOrZero(receipt?.to),
|
39081
|
+
from: hexOrZero(receipt.contract?.id),
|
39082
|
+
to: hexOrZero(receipt?.to?.id),
|
39163
39083
|
amount: bn(receipt.amount),
|
39164
39084
|
assetId: hexOrZero(receipt.assetId),
|
39165
39085
|
gas: bn(receipt.gas),
|
@@ -39173,7 +39093,7 @@ Thrown error: ${e}`
|
|
39173
39093
|
case "RETURN" /* Return */: {
|
39174
39094
|
const returnReceipt = {
|
39175
39095
|
type: ReceiptType.Return,
|
39176
|
-
id: hexOrZero(receipt.id
|
39096
|
+
id: hexOrZero(receipt.contract?.id),
|
39177
39097
|
val: bn(receipt.val),
|
39178
39098
|
pc: bn(receipt.pc),
|
39179
39099
|
is: bn(receipt.is)
|
@@ -39183,7 +39103,7 @@ Thrown error: ${e}`
|
|
39183
39103
|
case "RETURN_DATA" /* ReturnData */: {
|
39184
39104
|
const returnDataReceipt = {
|
39185
39105
|
type: ReceiptType.ReturnData,
|
39186
|
-
id: hexOrZero(receipt.id
|
39106
|
+
id: hexOrZero(receipt.contract?.id),
|
39187
39107
|
ptr: bn(receipt.ptr),
|
39188
39108
|
len: bn(receipt.len),
|
39189
39109
|
digest: hexOrZero(receipt.digest),
|
@@ -39195,7 +39115,7 @@ Thrown error: ${e}`
|
|
39195
39115
|
case "PANIC" /* Panic */: {
|
39196
39116
|
const panicReceipt = {
|
39197
39117
|
type: ReceiptType.Panic,
|
39198
|
-
id: hexOrZero(receipt.id),
|
39118
|
+
id: hexOrZero(receipt.contract?.id),
|
39199
39119
|
reason: bn(receipt.reason),
|
39200
39120
|
pc: bn(receipt.pc),
|
39201
39121
|
is: bn(receipt.is),
|
@@ -39206,7 +39126,7 @@ Thrown error: ${e}`
|
|
39206
39126
|
case "REVERT" /* Revert */: {
|
39207
39127
|
const revertReceipt = {
|
39208
39128
|
type: ReceiptType.Revert,
|
39209
|
-
id: hexOrZero(receipt.id
|
39129
|
+
id: hexOrZero(receipt.contract?.id),
|
39210
39130
|
val: bn(receipt.ra),
|
39211
39131
|
pc: bn(receipt.pc),
|
39212
39132
|
is: bn(receipt.is)
|
@@ -39216,7 +39136,7 @@ Thrown error: ${e}`
|
|
39216
39136
|
case "LOG" /* Log */: {
|
39217
39137
|
const logReceipt = {
|
39218
39138
|
type: ReceiptType.Log,
|
39219
|
-
id: hexOrZero(receipt.id
|
39139
|
+
id: hexOrZero(receipt.contract?.id),
|
39220
39140
|
val0: bn(receipt.ra),
|
39221
39141
|
val1: bn(receipt.rb),
|
39222
39142
|
val2: bn(receipt.rc),
|
@@ -39229,7 +39149,7 @@ Thrown error: ${e}`
|
|
39229
39149
|
case "LOG_DATA" /* LogData */: {
|
39230
39150
|
const logDataReceipt = {
|
39231
39151
|
type: ReceiptType.LogData,
|
39232
|
-
id: hexOrZero(receipt.id
|
39152
|
+
id: hexOrZero(receipt.contract?.id),
|
39233
39153
|
val0: bn(receipt.ra),
|
39234
39154
|
val1: bn(receipt.rb),
|
39235
39155
|
ptr: bn(receipt.ptr),
|
@@ -39243,8 +39163,8 @@ Thrown error: ${e}`
|
|
39243
39163
|
case "TRANSFER" /* Transfer */: {
|
39244
39164
|
const transferReceipt = {
|
39245
39165
|
type: ReceiptType.Transfer,
|
39246
|
-
from: hexOrZero(receipt.id
|
39247
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39166
|
+
from: hexOrZero(receipt.contract?.id),
|
39167
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
39248
39168
|
amount: bn(receipt.amount),
|
39249
39169
|
assetId: hexOrZero(receipt.assetId),
|
39250
39170
|
pc: bn(receipt.pc),
|
@@ -39255,8 +39175,8 @@ Thrown error: ${e}`
|
|
39255
39175
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39256
39176
|
const transferOutReceipt = {
|
39257
39177
|
type: ReceiptType.TransferOut,
|
39258
|
-
from: hexOrZero(receipt.id
|
39259
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
39178
|
+
from: hexOrZero(receipt.contract?.id),
|
39179
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
39260
39180
|
amount: bn(receipt.amount),
|
39261
39181
|
assetId: hexOrZero(receipt.assetId),
|
39262
39182
|
pc: bn(receipt.pc),
|
@@ -39299,7 +39219,7 @@ Thrown error: ${e}`
|
|
39299
39219
|
return receiptMessageOut;
|
39300
39220
|
}
|
39301
39221
|
case "MINT" /* Mint */: {
|
39302
|
-
const contractId = hexOrZero(receipt.id
|
39222
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39303
39223
|
const subId = hexOrZero(receipt.subId);
|
39304
39224
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39305
39225
|
const mintReceipt = {
|
@@ -39314,7 +39234,7 @@ Thrown error: ${e}`
|
|
39314
39234
|
return mintReceipt;
|
39315
39235
|
}
|
39316
39236
|
case "BURN" /* Burn */: {
|
39317
|
-
const contractId = hexOrZero(receipt.id
|
39237
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
39318
39238
|
const subId = hexOrZero(receipt.subId);
|
39319
39239
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39320
39240
|
const burnReceipt = {
|
@@ -39395,6 +39315,7 @@ Thrown error: ${e}`
|
|
39395
39315
|
};
|
39396
39316
|
|
39397
39317
|
// src/providers/utils/gas.ts
|
39318
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39398
39319
|
var getGasUsedFromReceipts = (receipts) => {
|
39399
39320
|
const scriptResult = receipts.filter(
|
39400
39321
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39415,28 +39336,18 @@ Thrown error: ${e}`
|
|
39415
39336
|
}
|
39416
39337
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39417
39338
|
const witnessCache = [];
|
39418
|
-
const
|
39419
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39420
|
-
if (isCoinOrMessage) {
|
39421
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39422
|
-
return true;
|
39423
|
-
}
|
39424
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
39425
|
-
witnessCache.push(input.witnessIndex);
|
39426
|
-
return true;
|
39427
|
-
}
|
39428
|
-
}
|
39429
|
-
return false;
|
39430
|
-
});
|
39431
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39432
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
39339
|
+
const totalGas = inputs.reduce((total, input) => {
|
39433
39340
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39434
39341
|
return total.add(
|
39435
|
-
|
39342
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39436
39343
|
);
|
39437
39344
|
}
|
39438
|
-
|
39439
|
-
|
39345
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
39346
|
+
witnessCache.push(input.witnessIndex);
|
39347
|
+
return total.add(gasCosts.ecr1);
|
39348
|
+
}
|
39349
|
+
return total;
|
39350
|
+
}, bn());
|
39440
39351
|
return totalGas;
|
39441
39352
|
}
|
39442
39353
|
function getMinGas(params) {
|
@@ -39448,20 +39359,12 @@ Thrown error: ${e}`
|
|
39448
39359
|
return minGas;
|
39449
39360
|
}
|
39450
39361
|
function getMaxGas(params) {
|
39451
|
-
const {
|
39452
|
-
gasPerByte,
|
39453
|
-
witnessesLength,
|
39454
|
-
witnessLimit,
|
39455
|
-
minGas,
|
39456
|
-
gasLimit = bn(0),
|
39457
|
-
maxGasPerTx
|
39458
|
-
} = params;
|
39362
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
|
39459
39363
|
let remainingAllowedWitnessGas = bn(0);
|
39460
39364
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39461
39365
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39462
39366
|
}
|
39463
|
-
|
39464
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39367
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39465
39368
|
}
|
39466
39369
|
function calculateMetadataGasForTxCreate({
|
39467
39370
|
gasCosts,
|
@@ -39483,10 +39386,6 @@ Thrown error: ${e}`
|
|
39483
39386
|
}) {
|
39484
39387
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39485
39388
|
}
|
39486
|
-
var calculateGasFee = (params) => {
|
39487
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
39488
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39489
|
-
};
|
39490
39389
|
|
39491
39390
|
// src/providers/utils/json.ts
|
39492
39391
|
function normalize2(object) {
|
@@ -39628,7 +39527,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39628
39527
|
// src/providers/transaction-request/transaction-request.ts
|
39629
39528
|
var BaseTransactionRequest = class {
|
39630
39529
|
/** Gas price for transaction */
|
39631
|
-
|
39530
|
+
gasPrice;
|
39632
39531
|
/** Block until which tx cannot be included */
|
39633
39532
|
maturity;
|
39634
39533
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39641,34 +39540,38 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39641
39540
|
outputs = [];
|
39642
39541
|
/** List of witnesses */
|
39643
39542
|
witnesses = [];
|
39543
|
+
/** Base asset ID - should be fetched from the chain */
|
39544
|
+
baseAssetId = ZeroBytes32;
|
39644
39545
|
/**
|
39645
39546
|
* Constructor for initializing a base transaction request.
|
39646
39547
|
*
|
39647
39548
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39648
39549
|
*/
|
39649
39550
|
constructor({
|
39650
|
-
|
39551
|
+
gasPrice,
|
39651
39552
|
maturity,
|
39652
39553
|
maxFee,
|
39653
39554
|
witnessLimit,
|
39654
39555
|
inputs,
|
39655
39556
|
outputs,
|
39656
|
-
witnesses
|
39557
|
+
witnesses,
|
39558
|
+
baseAssetId
|
39657
39559
|
} = {}) {
|
39658
|
-
this.
|
39560
|
+
this.gasPrice = bn(gasPrice);
|
39659
39561
|
this.maturity = maturity ?? 0;
|
39660
39562
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39661
39563
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
39662
39564
|
this.inputs = inputs ?? [];
|
39663
39565
|
this.outputs = outputs ?? [];
|
39664
39566
|
this.witnesses = witnesses ?? [];
|
39567
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
39665
39568
|
}
|
39666
39569
|
static getPolicyMeta(req) {
|
39667
39570
|
let policyTypes = 0;
|
39668
39571
|
const policies = [];
|
39669
|
-
if (req.
|
39670
|
-
policyTypes += PolicyType.
|
39671
|
-
policies.push({ data: req.
|
39572
|
+
if (req.gasPrice) {
|
39573
|
+
policyTypes += PolicyType.GasPrice;
|
39574
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
39672
39575
|
}
|
39673
39576
|
if (req.witnessLimit) {
|
39674
39577
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39855,10 +39758,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39855
39758
|
* @param predicate - Predicate bytes.
|
39856
39759
|
* @param predicateData - Predicate data bytes.
|
39857
39760
|
*/
|
39858
|
-
addCoinInput(coin) {
|
39761
|
+
addCoinInput(coin, predicate) {
|
39859
39762
|
const { assetId, owner, amount } = coin;
|
39860
39763
|
let witnessIndex;
|
39861
|
-
if (
|
39764
|
+
if (predicate) {
|
39862
39765
|
witnessIndex = 0;
|
39863
39766
|
} else {
|
39864
39767
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39873,7 +39776,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39873
39776
|
amount,
|
39874
39777
|
assetId,
|
39875
39778
|
txPointer: "0x00000000000000000000000000000000",
|
39876
|
-
witnessIndex
|
39779
|
+
witnessIndex,
|
39780
|
+
predicate: predicate?.bytes,
|
39781
|
+
predicateData: predicate?.predicateDataBytes
|
39877
39782
|
};
|
39878
39783
|
this.pushInput(input);
|
39879
39784
|
this.addChangeOutput(owner, assetId);
|
@@ -39884,13 +39789,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39884
39789
|
*
|
39885
39790
|
* @param message - Message resource.
|
39886
39791
|
* @param predicate - Predicate bytes.
|
39887
|
-
* @param predicateData - Predicate data bytes.
|
39888
39792
|
*/
|
39889
|
-
addMessageInput(message) {
|
39793
|
+
addMessageInput(message, predicate) {
|
39890
39794
|
const { recipient, sender, amount } = message;
|
39891
|
-
const assetId = BaseAssetId;
|
39892
39795
|
let witnessIndex;
|
39893
|
-
if (
|
39796
|
+
if (predicate) {
|
39894
39797
|
witnessIndex = 0;
|
39895
39798
|
} else {
|
39896
39799
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39904,10 +39807,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39904
39807
|
sender: sender.toB256(),
|
39905
39808
|
recipient: recipient.toB256(),
|
39906
39809
|
amount,
|
39907
|
-
witnessIndex
|
39810
|
+
witnessIndex,
|
39811
|
+
predicate: predicate?.bytes,
|
39812
|
+
predicateData: predicate?.predicateDataBytes
|
39908
39813
|
};
|
39909
39814
|
this.pushInput(input);
|
39910
|
-
this.addChangeOutput(recipient,
|
39815
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39911
39816
|
}
|
39912
39817
|
/**
|
39913
39818
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39935,6 +39840,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39935
39840
|
resources.forEach((resource) => this.addResource(resource));
|
39936
39841
|
return this;
|
39937
39842
|
}
|
39843
|
+
/**
|
39844
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39845
|
+
* outputs from the related assetIds.
|
39846
|
+
*
|
39847
|
+
* @param resources - The resources to add.
|
39848
|
+
* @returns This transaction.
|
39849
|
+
*/
|
39850
|
+
addPredicateResource(resource, predicate) {
|
39851
|
+
if (isCoin(resource)) {
|
39852
|
+
this.addCoinInput(resource, predicate);
|
39853
|
+
} else {
|
39854
|
+
this.addMessageInput(resource, predicate);
|
39855
|
+
}
|
39856
|
+
return this;
|
39857
|
+
}
|
39858
|
+
/**
|
39859
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39860
|
+
* from the related assetIds.
|
39861
|
+
*
|
39862
|
+
* @param resources - The resources to add.
|
39863
|
+
* @returns This transaction.
|
39864
|
+
*/
|
39865
|
+
addPredicateResources(resources, predicate) {
|
39866
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39867
|
+
return this;
|
39868
|
+
}
|
39938
39869
|
/**
|
39939
39870
|
* Adds a coin output to the transaction.
|
39940
39871
|
*
|
@@ -39942,12 +39873,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39942
39873
|
* @param amount - Amount of coin.
|
39943
39874
|
* @param assetId - Asset ID of coin.
|
39944
39875
|
*/
|
39945
|
-
addCoinOutput(to, amount, assetId
|
39876
|
+
addCoinOutput(to, amount, assetId) {
|
39946
39877
|
this.pushOutput({
|
39947
39878
|
type: OutputType.Coin,
|
39948
39879
|
to: addressify(to).toB256(),
|
39949
39880
|
amount,
|
39950
|
-
assetId
|
39881
|
+
assetId: assetId ?? this.baseAssetId
|
39951
39882
|
});
|
39952
39883
|
return this;
|
39953
39884
|
}
|
@@ -39974,7 +39905,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39974
39905
|
* @param to - Address of the owner.
|
39975
39906
|
* @param assetId - Asset ID of coin.
|
39976
39907
|
*/
|
39977
|
-
addChangeOutput(to, assetId
|
39908
|
+
addChangeOutput(to, assetId) {
|
39978
39909
|
const changeOutput = this.getChangeOutputs().find(
|
39979
39910
|
(output3) => hexlify(output3.assetId) === assetId
|
39980
39911
|
);
|
@@ -39982,7 +39913,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39982
39913
|
this.pushOutput({
|
39983
39914
|
type: OutputType.Change,
|
39984
39915
|
to: addressify(to).toB256(),
|
39985
|
-
assetId
|
39916
|
+
assetId: assetId ?? this.baseAssetId
|
39986
39917
|
});
|
39987
39918
|
}
|
39988
39919
|
}
|
@@ -40014,7 +39945,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40014
39945
|
}
|
40015
39946
|
calculateMaxGas(chainInfo, minGas) {
|
40016
39947
|
const { consensusParameters } = chainInfo;
|
40017
|
-
const { gasPerByte
|
39948
|
+
const { gasPerByte } = consensusParameters;
|
40018
39949
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40019
39950
|
(acc, wit) => acc + wit.dataLength,
|
40020
39951
|
0
|
@@ -40023,8 +39954,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40023
39954
|
gasPerByte,
|
40024
39955
|
minGas,
|
40025
39956
|
witnessesLength,
|
40026
|
-
witnessLimit: this.witnessLimit
|
40027
|
-
maxGasPerTx
|
39957
|
+
witnessLimit: this.witnessLimit
|
40028
39958
|
});
|
40029
39959
|
}
|
40030
39960
|
/**
|
@@ -40034,6 +39964,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40034
39964
|
* @param quantities - CoinQuantity Array.
|
40035
39965
|
*/
|
40036
39966
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39967
|
+
let idCounter = 0;
|
39968
|
+
const generateId = () => {
|
39969
|
+
const counterString = String(idCounter++);
|
39970
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39971
|
+
return id;
|
39972
|
+
};
|
40037
39973
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
40038
39974
|
if ("assetId" in input) {
|
40039
39975
|
return input.assetId === assetId;
|
@@ -40042,27 +39978,24 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40042
39978
|
});
|
40043
39979
|
const updateAssetInput = (assetId, quantity) => {
|
40044
39980
|
const assetInput = findAssetInput(assetId);
|
40045
|
-
let usedQuantity = quantity;
|
40046
|
-
if (assetId === BaseAssetId) {
|
40047
|
-
usedQuantity = bn("1000000000000000000");
|
40048
|
-
}
|
40049
39981
|
if (assetInput && "assetId" in assetInput) {
|
40050
|
-
assetInput.id =
|
40051
|
-
assetInput.amount =
|
39982
|
+
assetInput.id = generateId();
|
39983
|
+
assetInput.amount = quantity;
|
40052
39984
|
} else {
|
40053
39985
|
this.addResources([
|
40054
39986
|
{
|
40055
|
-
id:
|
40056
|
-
amount:
|
39987
|
+
id: generateId(),
|
39988
|
+
amount: quantity,
|
40057
39989
|
assetId,
|
40058
39990
|
owner: resourcesOwner || Address.fromRandom(),
|
39991
|
+
maturity: 0,
|
40059
39992
|
blockCreated: bn(1),
|
40060
39993
|
txCreatedIdx: bn(1)
|
40061
39994
|
}
|
40062
39995
|
]);
|
40063
39996
|
}
|
40064
39997
|
};
|
40065
|
-
updateAssetInput(
|
39998
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
40066
39999
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40067
40000
|
}
|
40068
40001
|
/**
|
@@ -40087,7 +40020,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40087
40020
|
toJSON() {
|
40088
40021
|
return normalizeJSON(this);
|
40089
40022
|
}
|
40090
|
-
|
40023
|
+
updatePredicateInputs(inputs) {
|
40091
40024
|
this.inputs.forEach((i) => {
|
40092
40025
|
let correspondingInput;
|
40093
40026
|
switch (i.type) {
|
@@ -40109,15 +40042,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40109
40042
|
}
|
40110
40043
|
});
|
40111
40044
|
}
|
40112
|
-
shiftPredicateData() {
|
40113
|
-
this.inputs.forEach((input) => {
|
40114
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40115
|
-
input.predicateData = input.paddPredicateData(
|
40116
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40117
|
-
);
|
40118
|
-
}
|
40119
|
-
});
|
40120
|
-
}
|
40121
40045
|
};
|
40122
40046
|
|
40123
40047
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40251,8 +40175,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40251
40175
|
return {
|
40252
40176
|
type: TransactionType.Create,
|
40253
40177
|
...baseTransaction,
|
40178
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40254
40179
|
bytecodeWitnessIndex,
|
40255
|
-
storageSlotsCount:
|
40180
|
+
storageSlotsCount: storageSlots.length,
|
40256
40181
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40257
40182
|
storageSlots
|
40258
40183
|
};
|
@@ -40366,8 +40291,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40366
40291
|
type: TransactionType.Script,
|
40367
40292
|
scriptGasLimit: this.gasLimit,
|
40368
40293
|
...super.getBaseTransaction(),
|
40369
|
-
scriptLength:
|
40370
|
-
scriptDataLength:
|
40294
|
+
scriptLength: script.length,
|
40295
|
+
scriptDataLength: scriptData.length,
|
40371
40296
|
receiptsRoot: ZeroBytes32,
|
40372
40297
|
script: hexlify(script),
|
40373
40298
|
scriptData: hexlify(scriptData)
|
@@ -40431,7 +40356,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40431
40356
|
}
|
40432
40357
|
calculateMaxGas(chainInfo, minGas) {
|
40433
40358
|
const { consensusParameters } = chainInfo;
|
40434
|
-
const { gasPerByte
|
40359
|
+
const { gasPerByte } = consensusParameters;
|
40435
40360
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40436
40361
|
(acc, wit) => acc + wit.dataLength,
|
40437
40362
|
0
|
@@ -40441,8 +40366,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40441
40366
|
minGas,
|
40442
40367
|
witnessesLength,
|
40443
40368
|
witnessLimit: this.witnessLimit,
|
40444
|
-
gasLimit: this.gasLimit
|
40445
|
-
maxGasPerTx
|
40369
|
+
gasLimit: this.gasLimit
|
40446
40370
|
});
|
40447
40371
|
}
|
40448
40372
|
/**
|
@@ -40515,29 +40439,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40515
40439
|
}
|
40516
40440
|
}
|
40517
40441
|
};
|
40518
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40519
|
-
(acc, input) => {
|
40520
|
-
if (input.type === InputType.Coin && input.owner === owner) {
|
40521
|
-
acc.utxos.push(input.id);
|
40522
|
-
}
|
40523
|
-
if (input.type === InputType.Message && input.recipient === owner) {
|
40524
|
-
acc.messages.push(input.nonce);
|
40525
|
-
}
|
40526
|
-
return acc;
|
40527
|
-
},
|
40528
|
-
{
|
40529
|
-
utxos: [],
|
40530
|
-
messages: []
|
40531
|
-
}
|
40532
|
-
);
|
40533
40442
|
|
40534
40443
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40535
40444
|
var calculateTransactionFee = (params) => {
|
40536
40445
|
const {
|
40537
|
-
|
40446
|
+
gasUsed,
|
40538
40447
|
rawPayload,
|
40539
|
-
|
40540
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40448
|
+
consensusParameters: { gasCosts, feeParams }
|
40541
40449
|
} = params;
|
40542
40450
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40543
40451
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40547,7 +40455,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40547
40455
|
return {
|
40548
40456
|
fee: bn(0),
|
40549
40457
|
minFee: bn(0),
|
40550
|
-
maxFee: bn(0)
|
40458
|
+
maxFee: bn(0),
|
40459
|
+
feeFromGasUsed: bn(0)
|
40551
40460
|
};
|
40552
40461
|
}
|
40553
40462
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40579,6 +40488,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40579
40488
|
metadataGas,
|
40580
40489
|
txBytesSize: transactionBytes.length
|
40581
40490
|
});
|
40491
|
+
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40582
40492
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40583
40493
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40584
40494
|
const maxGas = getMaxGas({
|
@@ -40586,25 +40496,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40586
40496
|
minGas,
|
40587
40497
|
witnessesLength,
|
40588
40498
|
gasLimit,
|
40589
|
-
witnessLimit
|
40590
|
-
maxGasPerTx
|
40591
|
-
});
|
40592
|
-
const minFee = calculateGasFee({
|
40593
|
-
gasPrice,
|
40594
|
-
gas: minGas,
|
40595
|
-
priceFactor: gasPriceFactor,
|
40596
|
-
tip
|
40597
|
-
});
|
40598
|
-
const maxFee = calculateGasFee({
|
40599
|
-
gasPrice,
|
40600
|
-
gas: maxGas,
|
40601
|
-
priceFactor: gasPriceFactor,
|
40602
|
-
tip
|
40499
|
+
witnessLimit
|
40603
40500
|
});
|
40501
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40502
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40503
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40504
|
+
const fee = minFee.add(feeFromGasUsed);
|
40604
40505
|
return {
|
40506
|
+
fee,
|
40605
40507
|
minFee,
|
40606
40508
|
maxFee,
|
40607
|
-
|
40509
|
+
feeFromGasUsed
|
40608
40510
|
};
|
40609
40511
|
};
|
40610
40512
|
|
@@ -41205,9 +41107,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41205
41107
|
gqlTransactionStatus,
|
41206
41108
|
abiMap = {},
|
41207
41109
|
maxInputs,
|
41208
|
-
gasCosts
|
41209
|
-
maxGasPerTx,
|
41210
|
-
gasPrice
|
41110
|
+
gasCosts
|
41211
41111
|
} = params;
|
41212
41112
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41213
41113
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41221,14 +41121,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41221
41121
|
maxInputs
|
41222
41122
|
});
|
41223
41123
|
const typeName = getTransactionTypeName(transaction.type);
|
41224
|
-
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41225
41124
|
const { fee } = calculateTransactionFee({
|
41226
|
-
|
41125
|
+
gasUsed,
|
41227
41126
|
rawPayload,
|
41228
|
-
tip,
|
41229
41127
|
consensusParameters: {
|
41230
41128
|
gasCosts,
|
41231
|
-
maxGasPerTx,
|
41232
41129
|
feeParams: {
|
41233
41130
|
gasPerByte,
|
41234
41131
|
gasPriceFactor
|
@@ -41364,13 +41261,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41364
41261
|
const decodedTransaction = this.decodeTransaction(
|
41365
41262
|
transaction
|
41366
41263
|
);
|
41367
|
-
|
41368
|
-
|
41369
|
-
txReceipts = transaction.status.receipts;
|
41370
|
-
}
|
41371
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41372
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41373
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
41264
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
41265
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
41374
41266
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41375
41267
|
const transactionSummary = assembleTransactionSummary({
|
41376
41268
|
id: this.id,
|
@@ -41382,9 +41274,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41382
41274
|
gasPriceFactor,
|
41383
41275
|
abiMap: contractsAbiMap,
|
41384
41276
|
maxInputs,
|
41385
|
-
gasCosts
|
41386
|
-
maxGasPerTx,
|
41387
|
-
gasPrice
|
41277
|
+
gasCosts
|
41388
41278
|
});
|
41389
41279
|
return transactionSummary;
|
41390
41280
|
}
|
@@ -41528,12 +41418,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41528
41418
|
gasPerByte: bn(feeParams.gasPerByte),
|
41529
41419
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41530
41420
|
chainId: bn(consensusParameters.chainId),
|
41421
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41531
41422
|
gasCosts
|
41532
41423
|
},
|
41533
41424
|
gasCosts,
|
41534
41425
|
latestBlock: {
|
41535
41426
|
id: latestBlock.id,
|
41536
|
-
height: bn(latestBlock.height),
|
41427
|
+
height: bn(latestBlock.header.height),
|
41537
41428
|
time: latestBlock.header.time,
|
41538
41429
|
transactions: latestBlock.transactions.map((i) => ({
|
41539
41430
|
id: i.id
|
@@ -41627,8 +41518,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41627
41518
|
* Returns some helpful parameters related to gas fees.
|
41628
41519
|
*/
|
41629
41520
|
getGasConfig() {
|
41521
|
+
const { minGasPrice } = this.getNode();
|
41630
41522
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41631
41523
|
return {
|
41524
|
+
minGasPrice,
|
41632
41525
|
maxGasPerTx,
|
41633
41526
|
maxGasPerPredicate,
|
41634
41527
|
gasPriceFactor,
|
@@ -41726,7 +41619,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41726
41619
|
*/
|
41727
41620
|
async getBlockNumber() {
|
41728
41621
|
const { chain } = await this.operations.getChain();
|
41729
|
-
return bn(chain.latestBlock.height, 10);
|
41622
|
+
return bn(chain.latestBlock.header.height, 10);
|
41730
41623
|
}
|
41731
41624
|
/**
|
41732
41625
|
* Returns the chain information.
|
@@ -41738,9 +41631,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41738
41631
|
const processedNodeInfo = {
|
41739
41632
|
maxDepth: bn(nodeInfo.maxDepth),
|
41740
41633
|
maxTx: bn(nodeInfo.maxTx),
|
41634
|
+
minGasPrice: bn(nodeInfo.minGasPrice),
|
41741
41635
|
nodeVersion: nodeInfo.nodeVersion,
|
41742
41636
|
utxoValidation: nodeInfo.utxoValidation,
|
41743
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41637
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
41638
|
+
peers: nodeInfo.peers
|
41744
41639
|
};
|
41745
41640
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41746
41641
|
return processedNodeInfo;
|
@@ -41766,6 +41661,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41766
41661
|
} = this.getChain();
|
41767
41662
|
return chainId.toNumber();
|
41768
41663
|
}
|
41664
|
+
/**
|
41665
|
+
* Returns the base asset ID
|
41666
|
+
*
|
41667
|
+
* @returns A promise that resolves to the base asset ID
|
41668
|
+
*/
|
41669
|
+
getBaseAssetId() {
|
41670
|
+
const {
|
41671
|
+
consensusParameters: { baseAssetId }
|
41672
|
+
} = this.getChain();
|
41673
|
+
return baseAssetId;
|
41674
|
+
}
|
41769
41675
|
/**
|
41770
41676
|
* Submits a transaction to the chain to be executed.
|
41771
41677
|
*
|
@@ -41826,13 +41732,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41826
41732
|
return this.estimateTxDependencies(transactionRequest);
|
41827
41733
|
}
|
41828
41734
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41829
|
-
const { dryRun:
|
41830
|
-
|
41735
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41736
|
+
encodedTransaction,
|
41831
41737
|
utxoValidation: utxoValidation || false
|
41832
41738
|
});
|
41833
|
-
const
|
41834
|
-
|
41835
|
-
|
41739
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41740
|
+
return {
|
41741
|
+
receipts
|
41742
|
+
};
|
41836
41743
|
}
|
41837
41744
|
/**
|
41838
41745
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41871,6 +41778,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41871
41778
|
* If there are missing variable outputs,
|
41872
41779
|
* `addVariableOutputs` is called on the transaction.
|
41873
41780
|
*
|
41781
|
+
* @privateRemarks
|
41782
|
+
* TODO: Investigate support for missing contract IDs
|
41783
|
+
* TODO: Add support for missing output messages
|
41874
41784
|
*
|
41875
41785
|
* @param transactionRequest - The transaction request object.
|
41876
41786
|
* @returns A promise.
|
@@ -41883,19 +41793,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41883
41793
|
missingContractIds: []
|
41884
41794
|
};
|
41885
41795
|
}
|
41796
|
+
await this.estimatePredicates(transactionRequest);
|
41886
41797
|
let receipts = [];
|
41887
41798
|
const missingContractIds = [];
|
41888
41799
|
let outputVariables = 0;
|
41889
|
-
let dryrunStatus;
|
41890
41800
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41891
|
-
const {
|
41892
|
-
|
41893
|
-
} = await this.operations.dryRun({
|
41894
|
-
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41801
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41802
|
+
encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
|
41895
41803
|
utxoValidation: false
|
41896
41804
|
});
|
41897
|
-
receipts =
|
41898
|
-
dryrunStatus = status;
|
41805
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
41899
41806
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41900
41807
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41901
41808
|
if (hasMissingOutputs) {
|
@@ -41905,11 +41812,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41905
41812
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41906
41813
|
missingContractIds.push(contractId);
|
41907
41814
|
});
|
41908
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41909
|
-
transactionRequest,
|
41910
|
-
optimizeGas: false
|
41911
|
-
});
|
41912
|
-
transactionRequest.maxFee = maxFee;
|
41913
41815
|
} else {
|
41914
41816
|
break;
|
41915
41817
|
}
|
@@ -41917,133 +41819,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41917
41819
|
return {
|
41918
41820
|
receipts,
|
41919
41821
|
outputVariables,
|
41920
|
-
missingContractIds
|
41921
|
-
dryrunStatus
|
41922
|
-
};
|
41923
|
-
}
|
41924
|
-
/**
|
41925
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41926
|
-
*
|
41927
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41928
|
-
* further modifications are identified. The method iteratively updates these transactions
|
41929
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41930
|
-
*
|
41931
|
-
* @param transactionRequests - Array of transaction request objects.
|
41932
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
41933
|
-
*/
|
41934
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
41935
|
-
const results = transactionRequests.map(() => ({
|
41936
|
-
receipts: [],
|
41937
|
-
outputVariables: 0,
|
41938
|
-
missingContractIds: [],
|
41939
|
-
dryrunStatus: void 0
|
41940
|
-
}));
|
41941
|
-
const allRequests = clone_default(transactionRequests);
|
41942
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41943
|
-
allRequests.forEach((req, index) => {
|
41944
|
-
if (req.type === TransactionType.Script) {
|
41945
|
-
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41946
|
-
}
|
41947
|
-
});
|
41948
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41949
|
-
let attempt = 0;
|
41950
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41951
|
-
const encodedTransactions = transactionsToProcess.map(
|
41952
|
-
(index) => serializedTransactionsMap.get(index)
|
41953
|
-
);
|
41954
|
-
const dryRunResults = await this.operations.dryRun({
|
41955
|
-
encodedTransactions,
|
41956
|
-
utxoValidation: false
|
41957
|
-
});
|
41958
|
-
const nextRoundTransactions = [];
|
41959
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41960
|
-
const currentResultIndex = transactionsToProcess[i];
|
41961
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41962
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41963
|
-
results[currentResultIndex].dryrunStatus = status;
|
41964
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41965
|
-
results[currentResultIndex].receipts
|
41966
|
-
);
|
41967
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41968
|
-
const requestToProcess = allRequests[currentResultIndex];
|
41969
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41970
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41971
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41972
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
41973
|
-
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41974
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
41975
|
-
});
|
41976
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
41977
|
-
transactionRequest: requestToProcess,
|
41978
|
-
optimizeGas: false
|
41979
|
-
});
|
41980
|
-
requestToProcess.maxFee = maxFee;
|
41981
|
-
serializedTransactionsMap.set(
|
41982
|
-
currentResultIndex,
|
41983
|
-
hexlify(requestToProcess.toTransactionBytes())
|
41984
|
-
);
|
41985
|
-
nextRoundTransactions.push(currentResultIndex);
|
41986
|
-
allRequests[currentResultIndex] = requestToProcess;
|
41987
|
-
}
|
41988
|
-
}
|
41989
|
-
transactionsToProcess = nextRoundTransactions;
|
41990
|
-
attempt += 1;
|
41991
|
-
}
|
41992
|
-
return results;
|
41993
|
-
}
|
41994
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
41995
|
-
if (estimateTxDependencies) {
|
41996
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
41997
|
-
}
|
41998
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
41999
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42000
|
-
encodedTransactions,
|
42001
|
-
utxoValidation: utxoValidation || false
|
42002
|
-
});
|
42003
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42004
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
42005
|
-
return { receipts, dryrunStatus: status };
|
42006
|
-
});
|
42007
|
-
return results;
|
42008
|
-
}
|
42009
|
-
async estimateTxGasAndFee(params) {
|
42010
|
-
const { transactionRequest, optimizeGas = true } = params;
|
42011
|
-
let { gasPrice } = params;
|
42012
|
-
const chainInfo = this.getChain();
|
42013
|
-
const { gasPriceFactor } = this.getGasConfig();
|
42014
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42015
|
-
if (!gasPrice) {
|
42016
|
-
gasPrice = await this.estimateGasPrice(10);
|
42017
|
-
}
|
42018
|
-
const minFee = calculateGasFee({
|
42019
|
-
gasPrice: bn(gasPrice),
|
42020
|
-
gas: minGas,
|
42021
|
-
priceFactor: gasPriceFactor,
|
42022
|
-
tip: transactionRequest.tip
|
42023
|
-
}).add(1);
|
42024
|
-
let gasLimit = bn(0);
|
42025
|
-
if (transactionRequest.type === TransactionType.Script) {
|
42026
|
-
gasLimit = transactionRequest.gasLimit;
|
42027
|
-
if (!optimizeGas) {
|
42028
|
-
transactionRequest.gasLimit = minGas;
|
42029
|
-
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42030
|
-
transactionRequest.gasLimit = gasLimit;
|
42031
|
-
}
|
42032
|
-
}
|
42033
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42034
|
-
const maxFee = calculateGasFee({
|
42035
|
-
gasPrice: bn(gasPrice),
|
42036
|
-
gas: maxGas,
|
42037
|
-
priceFactor: gasPriceFactor,
|
42038
|
-
tip: transactionRequest.tip
|
42039
|
-
}).add(1);
|
42040
|
-
return {
|
42041
|
-
minGas,
|
42042
|
-
minFee,
|
42043
|
-
maxGas,
|
42044
|
-
maxFee,
|
42045
|
-
gasPrice,
|
42046
|
-
gasLimit
|
41822
|
+
missingContractIds
|
42047
41823
|
};
|
42048
41824
|
}
|
42049
41825
|
/**
|
@@ -42061,17 +41837,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42061
41837
|
if (estimateTxDependencies) {
|
42062
41838
|
return this.estimateTxDependencies(transactionRequest);
|
42063
41839
|
}
|
42064
|
-
const
|
42065
|
-
const { dryRun:
|
42066
|
-
|
41840
|
+
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41841
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
41842
|
+
encodedTransaction,
|
42067
41843
|
utxoValidation: true
|
42068
41844
|
});
|
42069
|
-
const
|
42070
|
-
|
42071
|
-
|
42072
|
-
|
42073
|
-
});
|
42074
|
-
return { receipts: callResult[0].receipts };
|
41845
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
41846
|
+
return {
|
41847
|
+
receipts
|
41848
|
+
};
|
42075
41849
|
}
|
42076
41850
|
/**
|
42077
41851
|
* Returns a transaction cost to enable user
|
@@ -42088,80 +41862,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42088
41862
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
42089
41863
|
* @returns A promise that resolves to the transaction cost object.
|
42090
41864
|
*/
|
42091
|
-
async getTransactionCost(transactionRequestLike,
|
41865
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
41866
|
+
estimateTxDependencies = true,
|
41867
|
+
estimatePredicates = true,
|
41868
|
+
resourcesOwner,
|
41869
|
+
signatureCallback
|
41870
|
+
} = {}) {
|
42092
41871
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41872
|
+
const chainInfo = this.getChain();
|
41873
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41874
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
42093
41875
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
42094
41876
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
42095
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
41877
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
42096
41878
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
42097
|
-
|
42098
|
-
|
42099
|
-
|
42100
|
-
|
42101
|
-
|
42102
|
-
|
41879
|
+
if (estimatePredicates) {
|
41880
|
+
if (isScriptTransaction) {
|
41881
|
+
txRequestClone.gasLimit = bn(0);
|
41882
|
+
}
|
41883
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41884
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41885
|
+
}
|
41886
|
+
await this.estimatePredicates(txRequestClone);
|
42103
41887
|
}
|
42104
|
-
const signedRequest = clone_default(txRequestClone);
|
42105
|
-
let addedSignatures = 0;
|
42106
41888
|
if (signatureCallback && isScriptTransaction) {
|
42107
|
-
|
42108
|
-
|
42109
|
-
|
42110
|
-
|
42111
|
-
await this.estimatePredicates(signedRequest);
|
42112
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42113
|
-
transactionRequest: signedRequest,
|
42114
|
-
optimizeGas: false
|
42115
|
-
});
|
42116
|
-
txRequestClone.maxFee = maxFee;
|
41889
|
+
await signatureCallback(txRequestClone);
|
41890
|
+
}
|
41891
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41892
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
42117
41893
|
let receipts = [];
|
42118
41894
|
let missingContractIds = [];
|
42119
41895
|
let outputVariables = 0;
|
42120
|
-
|
42121
|
-
|
42122
|
-
|
42123
|
-
if (signatureCallback) {
|
42124
|
-
await signatureCallback(txRequestClone);
|
42125
|
-
}
|
42126
|
-
txRequestClone.gasLimit = gasLimit;
|
41896
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
41897
|
+
txRequestClone.gasPrice = bn(0);
|
41898
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
42127
41899
|
const result = await this.estimateTxDependencies(txRequestClone);
|
42128
41900
|
receipts = result.receipts;
|
42129
41901
|
outputVariables = result.outputVariables;
|
42130
41902
|
missingContractIds = result.missingContractIds;
|
42131
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
42132
|
-
txRequestClone.gasLimit = gasUsed;
|
42133
|
-
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42134
|
-
transactionRequest: txRequestClone,
|
42135
|
-
gasPrice
|
42136
|
-
}));
|
42137
41903
|
}
|
41904
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41905
|
+
const usedFee = calculatePriceWithFactor(
|
41906
|
+
gasUsed,
|
41907
|
+
gasPrice,
|
41908
|
+
gasPriceFactor
|
41909
|
+
).normalizeZeroToOne();
|
41910
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41911
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
42138
41912
|
return {
|
42139
41913
|
requiredQuantities: allQuantities,
|
42140
41914
|
receipts,
|
42141
41915
|
gasUsed,
|
41916
|
+
minGasPrice,
|
42142
41917
|
gasPrice,
|
42143
41918
|
minGas,
|
42144
41919
|
maxGas,
|
41920
|
+
usedFee,
|
42145
41921
|
minFee,
|
42146
41922
|
maxFee,
|
41923
|
+
estimatedInputs: txRequestClone.inputs,
|
42147
41924
|
outputVariables,
|
42148
|
-
missingContractIds
|
42149
|
-
addedSignatures,
|
42150
|
-
estimatedPredicates: txRequestClone.inputs
|
41925
|
+
missingContractIds
|
42151
41926
|
};
|
42152
41927
|
}
|
42153
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
41928
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
42154
41929
|
const ownerAddress = Address.fromAddressOrString(owner);
|
42155
41930
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
42156
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42157
|
-
quantitiesToContract
|
42158
|
-
});
|
41931
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
42159
41932
|
transactionRequest.addResources(
|
42160
41933
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
42161
41934
|
);
|
42162
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
42163
|
-
|
42164
|
-
|
41935
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41936
|
+
transactionRequest,
|
41937
|
+
forwardingQuantities
|
41938
|
+
);
|
42165
41939
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
42166
41940
|
return {
|
42167
41941
|
resources,
|
@@ -42185,6 +41959,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42185
41959
|
assetId: coin.assetId,
|
42186
41960
|
amount: bn(coin.amount),
|
42187
41961
|
owner: Address.fromAddressOrString(coin.owner),
|
41962
|
+
maturity: bn(coin.maturity).toNumber(),
|
42188
41963
|
blockCreated: bn(coin.blockCreated),
|
42189
41964
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42190
41965
|
}));
|
@@ -42236,6 +42011,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42236
42011
|
amount: bn(coin.amount),
|
42237
42012
|
assetId: coin.assetId,
|
42238
42013
|
owner: Address.fromAddressOrString(coin.owner),
|
42014
|
+
maturity: bn(coin.maturity).toNumber(),
|
42239
42015
|
blockCreated: bn(coin.blockCreated),
|
42240
42016
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42241
42017
|
};
|
@@ -42268,7 +42044,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42268
42044
|
}
|
42269
42045
|
return {
|
42270
42046
|
id: block2.id,
|
42271
|
-
height: bn(block2.height),
|
42047
|
+
height: bn(block2.header.height),
|
42272
42048
|
time: block2.header.time,
|
42273
42049
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42274
42050
|
};
|
@@ -42283,7 +42059,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42283
42059
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42284
42060
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42285
42061
|
id: block2.id,
|
42286
|
-
height: bn(block2.height),
|
42062
|
+
height: bn(block2.header.height),
|
42287
42063
|
time: block2.header.time,
|
42288
42064
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42289
42065
|
}));
|
@@ -42310,7 +42086,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42310
42086
|
}
|
42311
42087
|
return {
|
42312
42088
|
id: block2.id,
|
42313
|
-
height: bn(block2.height, 10),
|
42089
|
+
height: bn(block2.header.height, 10),
|
42314
42090
|
time: block2.header.time,
|
42315
42091
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42316
42092
|
transactions: block2.transactions.map(
|
@@ -42490,6 +42266,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42490
42266
|
prevRoot: messageBlockHeader.prevRoot,
|
42491
42267
|
time: messageBlockHeader.time,
|
42492
42268
|
applicationHash: messageBlockHeader.applicationHash,
|
42269
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
42493
42270
|
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
|
42494
42271
|
},
|
42495
42272
|
commitBlockHeader: {
|
@@ -42501,6 +42278,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42501
42278
|
prevRoot: commitBlockHeader.prevRoot,
|
42502
42279
|
time: commitBlockHeader.time,
|
42503
42280
|
applicationHash: commitBlockHeader.applicationHash,
|
42281
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
42504
42282
|
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
|
42505
42283
|
},
|
42506
42284
|
sender: Address.fromAddressOrString(sender),
|
@@ -42510,16 +42288,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42510
42288
|
data
|
42511
42289
|
};
|
42512
42290
|
}
|
42513
|
-
async getLatestGasPrice() {
|
42514
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42515
|
-
return bn(latestGasPrice.gasPrice);
|
42516
|
-
}
|
42517
|
-
async estimateGasPrice(blockHorizon) {
|
42518
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42519
|
-
blockHorizon: String(blockHorizon)
|
42520
|
-
});
|
42521
|
-
return bn(estimateGasPrice.gasPrice);
|
42522
|
-
}
|
42523
42291
|
/**
|
42524
42292
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42525
42293
|
*
|
@@ -42580,15 +42348,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42580
42348
|
arrayify(gqlTransaction.rawPayload),
|
42581
42349
|
0
|
42582
42350
|
);
|
42583
|
-
|
42584
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42585
|
-
txReceipts = gqlTransaction.status.receipts;
|
42586
|
-
}
|
42587
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42351
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
42588
42352
|
const {
|
42589
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42353
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42590
42354
|
} = provider.getChain();
|
42591
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42592
42355
|
const transactionInfo = assembleTransactionSummary({
|
42593
42356
|
id: gqlTransaction.id,
|
42594
42357
|
receipts,
|
@@ -42599,9 +42362,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42599
42362
|
gasPriceFactor: bn(gasPriceFactor),
|
42600
42363
|
abiMap,
|
42601
42364
|
maxInputs,
|
42602
|
-
gasCosts
|
42603
|
-
maxGasPerTx,
|
42604
|
-
gasPrice
|
42365
|
+
gasCosts
|
42605
42366
|
});
|
42606
42367
|
return {
|
42607
42368
|
gqlTransaction,
|
@@ -42611,11 +42372,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42611
42372
|
async function getTransactionSummaryFromRequest(params) {
|
42612
42373
|
const { provider, transactionRequest, abiMap } = params;
|
42613
42374
|
const { receipts } = await provider.call(transactionRequest);
|
42614
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
42375
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42615
42376
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42616
42377
|
const transaction = transactionRequest.toTransaction();
|
42617
42378
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42618
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42619
42379
|
const transactionSummary = assembleTransactionSummary({
|
42620
42380
|
receipts,
|
42621
42381
|
transaction,
|
@@ -42624,9 +42384,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42624
42384
|
gasPerByte,
|
42625
42385
|
gasPriceFactor,
|
42626
42386
|
maxInputs,
|
42627
|
-
gasCosts
|
42628
|
-
maxGasPerTx,
|
42629
|
-
gasPrice
|
42387
|
+
gasCosts
|
42630
42388
|
});
|
42631
42389
|
return transactionSummary;
|
42632
42390
|
}
|
@@ -42635,18 +42393,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42635
42393
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42636
42394
|
const { edges, pageInfo } = transactionsByOwner;
|
42637
42395
|
const {
|
42638
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
42396
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42639
42397
|
} = provider.getChain();
|
42640
|
-
const gasPrice = await provider.getLatestGasPrice();
|
42641
42398
|
const transactions = edges.map((edge) => {
|
42642
42399
|
const { node: gqlTransaction } = edge;
|
42643
|
-
const { id, rawPayload, status } = gqlTransaction;
|
42400
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
42644
42401
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42645
|
-
|
42646
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42647
|
-
txReceipts = gqlTransaction.status.receipts;
|
42648
|
-
}
|
42649
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
42402
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
42650
42403
|
const transactionSummary = assembleTransactionSummary({
|
42651
42404
|
id,
|
42652
42405
|
receipts,
|
@@ -42657,9 +42410,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42657
42410
|
gasPerByte,
|
42658
42411
|
gasPriceFactor,
|
42659
42412
|
maxInputs,
|
42660
|
-
gasCosts
|
42661
|
-
maxGasPerTx,
|
42662
|
-
gasPrice
|
42413
|
+
gasCosts
|
42663
42414
|
});
|
42664
42415
|
const output3 = {
|
42665
42416
|
gqlTransaction,
|
@@ -42950,8 +42701,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42950
42701
|
* @param assetId - The asset ID to check the balance for.
|
42951
42702
|
* @returns A promise that resolves to the balance amount.
|
42952
42703
|
*/
|
42953
|
-
async getBalance(assetId
|
42954
|
-
const
|
42704
|
+
async getBalance(assetId) {
|
42705
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42706
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42955
42707
|
return amount;
|
42956
42708
|
}
|
42957
42709
|
/**
|
@@ -42988,33 +42740,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42988
42740
|
* @param fee - The estimated transaction fee.
|
42989
42741
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42990
42742
|
*/
|
42991
|
-
async fund(request,
|
42992
|
-
const
|
42993
|
-
const
|
42994
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42743
|
+
async fund(request, coinQuantities, fee) {
|
42744
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42745
|
+
const updatedQuantities = addAmountToAsset({
|
42995
42746
|
amount: bn(fee),
|
42996
|
-
assetId:
|
42997
|
-
coinQuantities
|
42747
|
+
assetId: baseAssetId,
|
42748
|
+
coinQuantities
|
42998
42749
|
});
|
42999
42750
|
const quantitiesDict = {};
|
43000
|
-
|
42751
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
43001
42752
|
quantitiesDict[assetId] = {
|
43002
42753
|
required: amount,
|
43003
42754
|
owned: bn(0)
|
43004
42755
|
};
|
43005
42756
|
});
|
43006
|
-
|
42757
|
+
const cachedUtxos = [];
|
42758
|
+
const cachedMessages = [];
|
42759
|
+
const owner = this.address.toB256();
|
42760
|
+
request.inputs.forEach((input) => {
|
43007
42761
|
const isResource = "amount" in input;
|
43008
42762
|
if (isResource) {
|
43009
42763
|
const isCoin2 = "owner" in input;
|
43010
42764
|
if (isCoin2) {
|
43011
42765
|
const assetId = String(input.assetId);
|
43012
|
-
if (quantitiesDict[assetId]) {
|
42766
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
43013
42767
|
const amount = bn(input.amount);
|
43014
42768
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42769
|
+
cachedUtxos.push(input.id);
|
43015
42770
|
}
|
43016
|
-
} else if (input.amount && quantitiesDict[
|
43017
|
-
quantitiesDict[
|
42771
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42772
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42773
|
+
cachedMessages.push(input.nonce);
|
43018
42774
|
}
|
43019
42775
|
}
|
43020
42776
|
});
|
@@ -43029,23 +42785,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43029
42785
|
});
|
43030
42786
|
const needsToBeFunded = missingQuantities.length;
|
43031
42787
|
if (needsToBeFunded) {
|
43032
|
-
const
|
43033
|
-
|
43034
|
-
|
43035
|
-
|
43036
|
-
|
43037
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43038
|
-
const requestToBeReEstimate = clone_default(txRequest);
|
43039
|
-
if (addedSignatures) {
|
43040
|
-
Array.from({ length: addedSignatures }).forEach(
|
43041
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
43042
|
-
);
|
42788
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
42789
|
+
messages: cachedMessages,
|
42790
|
+
utxos: cachedUtxos
|
42791
|
+
});
|
42792
|
+
request.addResources(resources);
|
43043
42793
|
}
|
43044
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43045
|
-
transactionRequest: requestToBeReEstimate
|
43046
|
-
});
|
43047
|
-
txRequest.maxFee = maxFee;
|
43048
|
-
return txRequest;
|
43049
42794
|
}
|
43050
42795
|
/**
|
43051
42796
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -43053,25 +42798,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43053
42798
|
* @param destination - The address of the destination.
|
43054
42799
|
* @param amount - The amount of coins to transfer.
|
43055
42800
|
* @param assetId - The asset ID of the coins to transfer.
|
43056
|
-
* @param txParams - The transaction parameters (gasLimit,
|
42801
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43057
42802
|
* @returns A promise that resolves to the prepared transaction request.
|
43058
42803
|
*/
|
43059
|
-
async createTransfer(destination, amount, assetId
|
43060
|
-
const
|
43061
|
-
|
43062
|
-
const
|
42804
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42805
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42806
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42807
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42808
|
+
const request = new ScriptTransactionRequest(params);
|
42809
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42810
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43063
42811
|
estimateTxDependencies: true,
|
43064
42812
|
resourcesOwner: this
|
43065
42813
|
});
|
43066
|
-
|
43067
|
-
|
43068
|
-
|
43069
|
-
|
43070
|
-
|
43071
|
-
|
43072
|
-
|
43073
|
-
|
43074
|
-
await this.fund(request,
|
42814
|
+
request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
|
42815
|
+
request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
|
42816
|
+
this.validateGas({
|
42817
|
+
gasUsed,
|
42818
|
+
gasPrice: request.gasPrice,
|
42819
|
+
gasLimit: request.gasLimit,
|
42820
|
+
minGasPrice
|
42821
|
+
});
|
42822
|
+
await this.fund(request, requiredQuantities, maxFee);
|
42823
|
+
request.updatePredicateInputs(estimatedInputs);
|
43075
42824
|
return request;
|
43076
42825
|
}
|
43077
42826
|
/**
|
@@ -43083,14 +42832,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43083
42832
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
43084
42833
|
* @returns A promise that resolves to the transaction response.
|
43085
42834
|
*/
|
43086
|
-
async transfer(destination, amount, assetId
|
42835
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
43087
42836
|
if (bn(amount).lte(0)) {
|
43088
42837
|
throw new FuelError(
|
43089
42838
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
43090
42839
|
"Transfer amount must be a positive number."
|
43091
42840
|
);
|
43092
42841
|
}
|
43093
|
-
const
|
42842
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42843
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
43094
42844
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
43095
42845
|
}
|
43096
42846
|
/**
|
@@ -43102,7 +42852,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43102
42852
|
* @param txParams - The optional transaction parameters.
|
43103
42853
|
* @returns A promise that resolves to the transaction response.
|
43104
42854
|
*/
|
43105
|
-
async transferToContract(contractId, amount, assetId
|
42855
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
43106
42856
|
if (bn(amount).lte(0)) {
|
43107
42857
|
throw new FuelError(
|
43108
42858
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -43110,30 +42860,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43110
42860
|
);
|
43111
42861
|
}
|
43112
42862
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42863
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42864
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42865
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
43113
42866
|
const { script, scriptData } = await assembleTransferToContractScript({
|
43114
42867
|
hexlifiedContractId: contractAddress.toB256(),
|
43115
42868
|
amountToTransfer: bn(amount),
|
43116
|
-
assetId
|
42869
|
+
assetId: assetIdToTransfer
|
43117
42870
|
});
|
43118
42871
|
const request = new ScriptTransactionRequest({
|
43119
|
-
...
|
42872
|
+
...params,
|
43120
42873
|
script,
|
43121
42874
|
scriptData
|
43122
42875
|
});
|
43123
42876
|
request.addContractInputAndOutput(contractAddress);
|
43124
|
-
const
|
43125
|
-
|
43126
|
-
|
42877
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42878
|
+
request,
|
42879
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42880
|
+
);
|
42881
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42882
|
+
this.validateGas({
|
42883
|
+
gasUsed,
|
42884
|
+
gasPrice: request.gasPrice,
|
42885
|
+
gasLimit: request.gasLimit,
|
42886
|
+
minGasPrice
|
43127
42887
|
});
|
43128
|
-
|
43129
|
-
this.validateGas({
|
43130
|
-
gasUsed: txCost.gasUsed,
|
43131
|
-
gasLimit: request.gasLimit
|
43132
|
-
});
|
43133
|
-
}
|
43134
|
-
request.gasLimit = txCost.gasUsed;
|
43135
|
-
request.maxFee = txCost.maxFee;
|
43136
|
-
await this.fund(request, txCost);
|
42888
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43137
42889
|
return this.sendTransaction(request);
|
43138
42890
|
}
|
43139
42891
|
/**
|
@@ -43145,6 +42897,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43145
42897
|
* @returns A promise that resolves to the transaction response.
|
43146
42898
|
*/
|
43147
42899
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42900
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
42901
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
43148
42902
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
43149
42903
|
const recipientDataArray = arrayify(
|
43150
42904
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -43157,19 +42911,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43157
42911
|
...recipientDataArray,
|
43158
42912
|
...amountDataArray
|
43159
42913
|
]);
|
43160
|
-
const params = { script, ...txParams };
|
42914
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
43161
42915
|
const request = new ScriptTransactionRequest(params);
|
43162
|
-
const
|
43163
|
-
const
|
43164
|
-
|
43165
|
-
|
43166
|
-
|
43167
|
-
|
43168
|
-
|
43169
|
-
|
43170
|
-
|
43171
|
-
|
43172
|
-
|
42916
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42917
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42918
|
+
request,
|
42919
|
+
forwardingQuantities
|
42920
|
+
);
|
42921
|
+
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42922
|
+
this.validateGas({
|
42923
|
+
gasUsed,
|
42924
|
+
gasPrice: request.gasPrice,
|
42925
|
+
gasLimit: request.gasLimit,
|
42926
|
+
minGasPrice
|
42927
|
+
});
|
42928
|
+
await this.fund(request, requiredQuantities, maxFee);
|
43173
42929
|
return this.sendTransaction(request);
|
43174
42930
|
}
|
43175
42931
|
async signMessage(message) {
|
@@ -43227,7 +42983,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43227
42983
|
}
|
43228
42984
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
43229
42985
|
}
|
43230
|
-
validateGas({
|
42986
|
+
validateGas({
|
42987
|
+
gasUsed,
|
42988
|
+
gasPrice,
|
42989
|
+
gasLimit,
|
42990
|
+
minGasPrice
|
42991
|
+
}) {
|
42992
|
+
if (minGasPrice.gt(gasPrice)) {
|
42993
|
+
throw new FuelError(
|
42994
|
+
ErrorCode.GAS_PRICE_TOO_LOW,
|
42995
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
42996
|
+
);
|
42997
|
+
}
|
43231
42998
|
if (gasUsed.gt(gasLimit)) {
|
43232
42999
|
throw new FuelError(
|
43233
43000
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44610,12 +44377,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44610
44377
|
};
|
44611
44378
|
|
44612
44379
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44613
|
-
var
|
44380
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44614
44381
|
var rnds8Pool = new Uint8Array(256);
|
44615
44382
|
var poolPtr = rnds8Pool.length;
|
44616
44383
|
function rng() {
|
44617
44384
|
if (poolPtr > rnds8Pool.length - 16) {
|
44618
|
-
|
44385
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44619
44386
|
poolPtr = 0;
|
44620
44387
|
}
|
44621
44388
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44631,9 +44398,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44631
44398
|
}
|
44632
44399
|
|
44633
44400
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44634
|
-
var
|
44401
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44635
44402
|
var native_default = {
|
44636
|
-
randomUUID:
|
44403
|
+
randomUUID: import_crypto16.default.randomUUID
|
44637
44404
|
};
|
44638
44405
|
|
44639
44406
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -44816,7 +44583,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44816
44583
|
* @param transactionRequestLike - The transaction request to send.
|
44817
44584
|
* @returns A promise that resolves to the TransactionResponse object.
|
44818
44585
|
*/
|
44819
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44586
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
44820
44587
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44821
44588
|
if (estimateTxDependencies) {
|
44822
44589
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -48082,7 +47849,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48082
47849
|
this.interface = predicateInterface;
|
48083
47850
|
if (inputData !== void 0 && inputData.length > 0) {
|
48084
47851
|
this.predicateData = inputData;
|
48085
|
-
this.predicateDataBytes = this.getPredicateData(0);
|
48086
47852
|
}
|
48087
47853
|
}
|
48088
47854
|
/**
|
@@ -48096,8 +47862,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48096
47862
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
48097
47863
|
request.inputs?.forEach((input) => {
|
48098
47864
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
48099
|
-
input.predicate =
|
48100
|
-
input.predicateData =
|
47865
|
+
input.predicate = this.bytes;
|
47866
|
+
input.predicateData = this.getPredicateData(policies.length);
|
48101
47867
|
}
|
48102
47868
|
});
|
48103
47869
|
return request;
|
@@ -48111,8 +47877,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48111
47877
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
48112
47878
|
* @returns A promise that resolves to the prepared transaction request.
|
48113
47879
|
*/
|
48114
|
-
async createTransfer(destination, amount, assetId
|
48115
|
-
|
47880
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47881
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47882
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47883
|
+
return this.populateTransactionPredicateData(request);
|
48116
47884
|
}
|
48117
47885
|
/**
|
48118
47886
|
* Sends a transaction with the populated predicate data.
|
@@ -48120,9 +47888,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48120
47888
|
* @param transactionRequestLike - The transaction request-like object.
|
48121
47889
|
* @returns A promise that resolves to the transaction response.
|
48122
47890
|
*/
|
48123
|
-
sendTransaction(transactionRequestLike) {
|
48124
|
-
const transactionRequest =
|
48125
|
-
return super.sendTransaction(transactionRequest,
|
47891
|
+
sendTransaction(transactionRequestLike, options) {
|
47892
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47893
|
+
return super.sendTransaction(transactionRequest, options);
|
48126
47894
|
}
|
48127
47895
|
/**
|
48128
47896
|
* Simulates a transaction with the populated predicate data.
|
@@ -48131,8 +47899,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48131
47899
|
* @returns A promise that resolves to the call result.
|
48132
47900
|
*/
|
48133
47901
|
simulateTransaction(transactionRequestLike) {
|
48134
|
-
const transactionRequest =
|
48135
|
-
return super.simulateTransaction(transactionRequest
|
47902
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47903
|
+
return super.simulateTransaction(transactionRequest);
|
48136
47904
|
}
|
48137
47905
|
getPredicateData(policiesLength) {
|
48138
47906
|
if (!this.predicateData.length) {
|
@@ -48178,26 +47946,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48178
47946
|
predicateInterface: abiInterface
|
48179
47947
|
};
|
48180
47948
|
}
|
48181
|
-
/**
|
48182
|
-
* Retrieves resources satisfying the spend query for the account.
|
48183
|
-
*
|
48184
|
-
* @param quantities - IDs of coins to exclude.
|
48185
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
48186
|
-
* @returns A promise that resolves to an array of Resources.
|
48187
|
-
*/
|
48188
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
48189
|
-
const resources = await this.provider.getResourcesToSpend(
|
48190
|
-
this.address,
|
48191
|
-
quantities,
|
48192
|
-
excludedIds
|
48193
|
-
);
|
48194
|
-
return resources.map((resource) => ({
|
48195
|
-
...resource,
|
48196
|
-
predicate: hexlify(this.bytes),
|
48197
|
-
predicateData: hexlify(this.predicateDataBytes),
|
48198
|
-
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48199
|
-
}));
|
48200
|
-
}
|
48201
47949
|
/**
|
48202
47950
|
* Sets the configurable constants for the predicate.
|
48203
47951
|
*
|