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