@fuel-ts/account 0.0.0-rc-1976-20240411153008 → 0.0.0-rc-2021-20240411154255
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 +896 -629
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +874 -621
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +716 -464
- 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 +906 -324
- 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 +7 -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 +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 +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/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1613 -1132
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +852 -620
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +710 -478
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/index.global.js
CHANGED
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
291
291
|
};
|
292
|
-
BN2.max = function
|
292
|
+
BN2.max = function max(left, right) {
|
293
293
|
if (left.cmp(right) > 0)
|
294
294
|
return left;
|
295
295
|
return right;
|
@@ -5113,7 +5113,7 @@
|
|
5113
5113
|
function isBlob(obj) {
|
5114
5114
|
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
5115
5115
|
}
|
5116
|
-
function
|
5116
|
+
function clone3(instance) {
|
5117
5117
|
let p1, p2;
|
5118
5118
|
let body = instance.body;
|
5119
5119
|
if (instance.bodyUsed) {
|
@@ -6047,7 +6047,7 @@
|
|
6047
6047
|
* @return Response
|
6048
6048
|
*/
|
6049
6049
|
clone() {
|
6050
|
-
return new Response2(
|
6050
|
+
return new Response2(clone3(this), {
|
6051
6051
|
url: this.url,
|
6052
6052
|
status: this.status,
|
6053
6053
|
statusText: this.statusText,
|
@@ -6097,7 +6097,7 @@
|
|
6097
6097
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6098
6098
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6099
6099
|
}
|
6100
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6100
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
|
6101
6101
|
Body.call(this, inputBody, {
|
6102
6102
|
timeout: init.timeout || input.timeout || 0,
|
6103
6103
|
size: init.size || input.size || 0
|
@@ -28952,8 +28952,8 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28956
|
-
FUEL_CORE: "0.
|
28955
|
+
FORC: "0.51.1",
|
28956
|
+
FUEL_CORE: "0.24.2",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
@@ -29245,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29245
29245
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29246
29246
|
|
29247
29247
|
// ../crypto/dist/index.mjs
|
29248
|
-
var
|
29248
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
29249
29249
|
|
29250
29250
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
29251
29251
|
var version = "6.7.1";
|
@@ -30317,6 +30317,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30317
30317
|
};
|
30318
30318
|
Object.freeze(pbkdf22);
|
30319
30319
|
|
30320
|
+
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
30321
|
+
var locked5 = false;
|
30322
|
+
var _randomBytes = function(length) {
|
30323
|
+
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
30324
|
+
};
|
30325
|
+
var __randomBytes = _randomBytes;
|
30326
|
+
function randomBytes3(length) {
|
30327
|
+
return __randomBytes(length);
|
30328
|
+
}
|
30329
|
+
randomBytes3._ = _randomBytes;
|
30330
|
+
randomBytes3.lock = function() {
|
30331
|
+
locked5 = true;
|
30332
|
+
};
|
30333
|
+
randomBytes3.register = function(func) {
|
30334
|
+
if (locked5) {
|
30335
|
+
throw new Error("randomBytes is locked");
|
30336
|
+
}
|
30337
|
+
__randomBytes = func;
|
30338
|
+
};
|
30339
|
+
Object.freeze(randomBytes3);
|
30340
|
+
|
30320
30341
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
30321
30342
|
var BN_03 = BigInt(0);
|
30322
30343
|
var BN_36 = BigInt(36);
|
@@ -30901,8 +30922,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30901
30922
|
}
|
30902
30923
|
|
30903
30924
|
// ../crypto/dist/index.mjs
|
30904
|
-
var import_crypto9 = __toESM(__require("crypto"), 1);
|
30905
30925
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
30926
|
+
var import_crypto11 = __toESM(__require("crypto"), 1);
|
30906
30927
|
var scrypt3 = (params) => {
|
30907
30928
|
const { password, salt, n, p, r, dklen } = params;
|
30908
30929
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -30911,7 +30932,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30911
30932
|
var keccak2562 = (data) => keccak_256(data);
|
30912
30933
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
30913
30934
|
var randomBytes4 = (length) => {
|
30914
|
-
const randomValues = Uint8Array.from(
|
30935
|
+
const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
|
30915
30936
|
return randomValues;
|
30916
30937
|
};
|
30917
30938
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -30926,7 +30947,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30926
30947
|
const salt = randomBytes4(32);
|
30927
30948
|
const secret = keyFromPassword(password, salt);
|
30928
30949
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
30929
|
-
const cipher = await
|
30950
|
+
const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
|
30930
30951
|
let cipherData = cipher.update(dataBuffer);
|
30931
30952
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
30932
30953
|
return {
|
@@ -30940,7 +30961,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30940
30961
|
const salt = bufferFromString(keystore.salt);
|
30941
30962
|
const secret = keyFromPassword(password, salt);
|
30942
30963
|
const encryptedText = bufferFromString(keystore.data);
|
30943
|
-
const decipher = await
|
30964
|
+
const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
|
30944
30965
|
const decrypted = decipher.update(encryptedText);
|
30945
30966
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
30946
30967
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -30951,12 +30972,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
30951
30972
|
}
|
30952
30973
|
};
|
30953
30974
|
async function encryptJsonWalletData(data, key, iv) {
|
30954
|
-
const cipher = await
|
30975
|
+
const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30955
30976
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
30956
30977
|
return new Uint8Array(encrypted);
|
30957
30978
|
}
|
30958
30979
|
async function decryptJsonWalletData(data, key, iv) {
|
30959
|
-
const decipher =
|
30980
|
+
const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
30960
30981
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
30961
30982
|
return new Uint8Array(decrypted);
|
30962
30983
|
}
|
@@ -31272,6 +31293,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31293
|
}
|
31273
31294
|
};
|
31274
31295
|
|
31296
|
+
// ../address/dist/configs.mjs
|
31297
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31298
|
+
var BaseAssetId = ZeroBytes32;
|
31299
|
+
|
31275
31300
|
// ../math/dist/index.mjs
|
31276
31301
|
var import_bn = __toESM(require_bn(), 1);
|
31277
31302
|
var DEFAULT_PRECISION = 9;
|
@@ -31491,32 +31516,182 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31491
31516
|
function toBytes3(value, bytesPadding) {
|
31492
31517
|
return bn(value).toBytes(bytesPadding);
|
31493
31518
|
}
|
31494
|
-
|
31495
|
-
|
31519
|
+
|
31520
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
31521
|
+
function _isPlaceholder(a) {
|
31522
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
31523
|
+
}
|
31524
|
+
|
31525
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
31526
|
+
function _curry1(fn) {
|
31527
|
+
return function f1(a) {
|
31528
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
31529
|
+
return f1;
|
31530
|
+
} else {
|
31531
|
+
return fn.apply(this, arguments);
|
31532
|
+
}
|
31533
|
+
};
|
31534
|
+
}
|
31535
|
+
|
31536
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
31537
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
31538
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
31539
|
+
};
|
31540
|
+
|
31541
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
31542
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
31543
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
31544
|
+
});
|
31545
|
+
var type_default = type;
|
31546
|
+
|
31547
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
31548
|
+
var pad = function pad2(n) {
|
31549
|
+
return (n < 10 ? "0" : "") + n;
|
31550
|
+
};
|
31551
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
31552
|
+
return d.toISOString();
|
31553
|
+
} : function _toISOString3(d) {
|
31554
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
31555
|
+
};
|
31556
|
+
|
31557
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
31558
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
31559
|
+
return n << 0 === n;
|
31560
|
+
};
|
31561
|
+
|
31562
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
31563
|
+
function _cloneRegExp(pattern) {
|
31564
|
+
return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
|
31496
31565
|
}
|
31497
31566
|
|
31567
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
31568
|
+
function _clone(value, deep, map) {
|
31569
|
+
map || (map = new _ObjectMap());
|
31570
|
+
if (_isPrimitive(value)) {
|
31571
|
+
return value;
|
31572
|
+
}
|
31573
|
+
var copy = function copy2(copiedValue) {
|
31574
|
+
var cachedCopy = map.get(value);
|
31575
|
+
if (cachedCopy) {
|
31576
|
+
return cachedCopy;
|
31577
|
+
}
|
31578
|
+
map.set(value, copiedValue);
|
31579
|
+
for (var key in value) {
|
31580
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
31581
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
31582
|
+
}
|
31583
|
+
}
|
31584
|
+
return copiedValue;
|
31585
|
+
};
|
31586
|
+
switch (type_default(value)) {
|
31587
|
+
case "Object":
|
31588
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
31589
|
+
case "Array":
|
31590
|
+
return copy([]);
|
31591
|
+
case "Date":
|
31592
|
+
return new Date(value.valueOf());
|
31593
|
+
case "RegExp":
|
31594
|
+
return _cloneRegExp(value);
|
31595
|
+
case "Int8Array":
|
31596
|
+
case "Uint8Array":
|
31597
|
+
case "Uint8ClampedArray":
|
31598
|
+
case "Int16Array":
|
31599
|
+
case "Uint16Array":
|
31600
|
+
case "Int32Array":
|
31601
|
+
case "Uint32Array":
|
31602
|
+
case "Float32Array":
|
31603
|
+
case "Float64Array":
|
31604
|
+
case "BigInt64Array":
|
31605
|
+
case "BigUint64Array":
|
31606
|
+
return value.slice();
|
31607
|
+
default:
|
31608
|
+
return value;
|
31609
|
+
}
|
31610
|
+
}
|
31611
|
+
function _isPrimitive(param) {
|
31612
|
+
var type3 = typeof param;
|
31613
|
+
return param == null || type3 != "object" && type3 != "function";
|
31614
|
+
}
|
31615
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
31616
|
+
function _ObjectMap2() {
|
31617
|
+
this.map = {};
|
31618
|
+
this.length = 0;
|
31619
|
+
}
|
31620
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
31621
|
+
const hashedKey = this.hash(key);
|
31622
|
+
let bucket = this.map[hashedKey];
|
31623
|
+
if (!bucket) {
|
31624
|
+
this.map[hashedKey] = bucket = [];
|
31625
|
+
}
|
31626
|
+
bucket.push([key, value]);
|
31627
|
+
this.length += 1;
|
31628
|
+
};
|
31629
|
+
_ObjectMap2.prototype.hash = function(key) {
|
31630
|
+
let hashedKey = [];
|
31631
|
+
for (var value in key) {
|
31632
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
31633
|
+
}
|
31634
|
+
return hashedKey.join();
|
31635
|
+
};
|
31636
|
+
_ObjectMap2.prototype.get = function(key) {
|
31637
|
+
if (this.length <= 180) {
|
31638
|
+
for (const p in this.map) {
|
31639
|
+
const bucket2 = this.map[p];
|
31640
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
31641
|
+
const element = bucket2[i];
|
31642
|
+
if (element[0] === key) {
|
31643
|
+
return element[1];
|
31644
|
+
}
|
31645
|
+
}
|
31646
|
+
}
|
31647
|
+
return;
|
31648
|
+
}
|
31649
|
+
const hashedKey = this.hash(key);
|
31650
|
+
const bucket = this.map[hashedKey];
|
31651
|
+
if (!bucket) {
|
31652
|
+
return;
|
31653
|
+
}
|
31654
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
31655
|
+
const element = bucket[i];
|
31656
|
+
if (element[0] === key) {
|
31657
|
+
return element[1];
|
31658
|
+
}
|
31659
|
+
}
|
31660
|
+
};
|
31661
|
+
return _ObjectMap2;
|
31662
|
+
}();
|
31663
|
+
|
31664
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
31665
|
+
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
31666
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
31667
|
+
});
|
31668
|
+
var clone_default = clone;
|
31669
|
+
|
31670
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
31671
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
31672
|
+
|
31498
31673
|
// src/providers/coin-quantity.ts
|
31499
31674
|
var coinQuantityfy = (coinQuantityLike) => {
|
31500
31675
|
let assetId;
|
31501
31676
|
let amount;
|
31502
|
-
let
|
31677
|
+
let max;
|
31503
31678
|
if (Array.isArray(coinQuantityLike)) {
|
31504
31679
|
amount = coinQuantityLike[0];
|
31505
|
-
assetId = coinQuantityLike[1];
|
31506
|
-
|
31680
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31681
|
+
max = coinQuantityLike[2] ?? void 0;
|
31507
31682
|
} else {
|
31508
31683
|
amount = coinQuantityLike.amount;
|
31509
|
-
assetId = coinQuantityLike.assetId;
|
31510
|
-
|
31684
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31685
|
+
max = coinQuantityLike.max ?? void 0;
|
31511
31686
|
}
|
31512
31687
|
const bnAmount = bn(amount);
|
31513
31688
|
return {
|
31514
31689
|
assetId: hexlify(assetId),
|
31515
31690
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
31516
|
-
max:
|
31691
|
+
max: max ? bn(max) : void 0
|
31517
31692
|
};
|
31518
31693
|
};
|
31519
|
-
var
|
31694
|
+
var addAmountToCoinQuantities = (params) => {
|
31520
31695
|
const { amount, assetId } = params;
|
31521
31696
|
const coinQuantities = [...params.coinQuantities];
|
31522
31697
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -31608,9 +31783,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31608
31783
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31609
31784
|
var MAX_BYTES = 2 ** 32 - 1;
|
31610
31785
|
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31611
|
-
|
31786
|
+
ASSET_ID_LEN + // Base asset ID
|
31612
31787
|
// Asset ID/Balance coin input pairs
|
31613
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE);
|
31788
|
+
maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
|
31614
31789
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31615
31790
|
WORD_SIZE + // Gas limit
|
31616
31791
|
WORD_SIZE + // Script size
|
@@ -31628,7 +31803,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31628
31803
|
ASSET_ID_LEN + // Asset id
|
31629
31804
|
TX_POINTER_LEN + // TxPointer
|
31630
31805
|
WORD_SIZE + // Witnesses index
|
31631
|
-
WORD_SIZE + // Maturity
|
31632
31806
|
WORD_SIZE + // Predicate size
|
31633
31807
|
WORD_SIZE + // Predicate data size
|
31634
31808
|
WORD_SIZE;
|
@@ -31950,7 +32124,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31950
32124
|
constructor(name, coders) {
|
31951
32125
|
const caseIndexCoder = new BigNumberCoder("u64");
|
31952
32126
|
const encodedValueSize = Object.values(coders).reduce(
|
31953
|
-
(
|
32127
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
31954
32128
|
0
|
31955
32129
|
);
|
31956
32130
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -32654,7 +32828,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32654
32828
|
constructor(name, coders) {
|
32655
32829
|
const caseIndexCoder = new BigNumberCoder("u64");
|
32656
32830
|
const encodedValueSize = Object.values(coders).reduce(
|
32657
|
-
(
|
32831
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
32658
32832
|
0
|
32659
32833
|
);
|
32660
32834
|
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -33366,18 +33540,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33366
33540
|
encode(value) {
|
33367
33541
|
const parts = [];
|
33368
33542
|
parts.push(new B256Coder().encode(value.txID));
|
33369
|
-
parts.push(new NumberCoder("
|
33543
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33370
33544
|
parts.push(new B256Coder().encode(value.owner));
|
33371
33545
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33372
33546
|
parts.push(new B256Coder().encode(value.assetId));
|
33373
33547
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
33374
|
-
parts.push(new NumberCoder("
|
33375
|
-
parts.push(new NumberCoder("u32").encode(value.maturity));
|
33548
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33376
33549
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33377
|
-
parts.push(new
|
33378
|
-
parts.push(new
|
33379
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33380
|
-
parts.push(
|
33550
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33551
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33552
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33553
|
+
parts.push(
|
33554
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33555
|
+
);
|
33381
33556
|
return concat(parts);
|
33382
33557
|
}
|
33383
33558
|
decode(data, offset) {
|
@@ -33385,7 +33560,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33385
33560
|
let o = offset;
|
33386
33561
|
[decoded, o] = new B256Coder().decode(data, o);
|
33387
33562
|
const txID = decoded;
|
33388
|
-
[decoded, o] = new NumberCoder("
|
33563
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33389
33564
|
const outputIndex = decoded;
|
33390
33565
|
[decoded, o] = new B256Coder().decode(data, o);
|
33391
33566
|
const owner = decoded;
|
@@ -33395,19 +33570,17 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33395
33570
|
const assetId = decoded;
|
33396
33571
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
33397
33572
|
const txPointer = decoded;
|
33398
|
-
[decoded, o] = new NumberCoder("
|
33573
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33399
33574
|
const witnessIndex = Number(decoded);
|
33400
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33401
|
-
const maturity = decoded;
|
33402
33575
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33403
33576
|
const predicateGasUsed = decoded;
|
33404
|
-
[decoded, o] = new
|
33577
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33405
33578
|
const predicateLength = decoded;
|
33406
|
-
[decoded, o] = new
|
33579
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33407
33580
|
const predicateDataLength = decoded;
|
33408
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33581
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33409
33582
|
const predicate = decoded;
|
33410
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33583
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33411
33584
|
const predicateData = decoded;
|
33412
33585
|
return [
|
33413
33586
|
{
|
@@ -33419,7 +33592,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33419
33592
|
assetId,
|
33420
33593
|
txPointer,
|
33421
33594
|
witnessIndex,
|
33422
|
-
maturity,
|
33423
33595
|
predicateGasUsed,
|
33424
33596
|
predicateLength,
|
33425
33597
|
predicateDataLength,
|
@@ -33437,7 +33609,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33437
33609
|
encode(value) {
|
33438
33610
|
const parts = [];
|
33439
33611
|
parts.push(new B256Coder().encode(value.txID));
|
33440
|
-
parts.push(new NumberCoder("
|
33612
|
+
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
33441
33613
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33442
33614
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33443
33615
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33449,7 +33621,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33449
33621
|
let o = offset;
|
33450
33622
|
[decoded, o] = new B256Coder().decode(data, o);
|
33451
33623
|
const txID = decoded;
|
33452
|
-
[decoded, o] = new NumberCoder("
|
33624
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33453
33625
|
const outputIndex = decoded;
|
33454
33626
|
[decoded, o] = new B256Coder().decode(data, o);
|
33455
33627
|
const balanceRoot = decoded;
|
@@ -33498,14 +33670,16 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33498
33670
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33499
33671
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33500
33672
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33501
|
-
parts.push(new NumberCoder("
|
33673
|
+
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
33502
33674
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33503
|
-
parts.push(new
|
33504
|
-
parts.push(new
|
33505
|
-
parts.push(new
|
33675
|
+
parts.push(new BigNumberCoder("u64").encode(data.length));
|
33676
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
33677
|
+
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
33506
33678
|
parts.push(new ByteArrayCoder(data.length).encode(data));
|
33507
|
-
parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
|
33508
|
-
parts.push(
|
33679
|
+
parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
|
33680
|
+
parts.push(
|
33681
|
+
new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
|
33682
|
+
);
|
33509
33683
|
return concat(parts);
|
33510
33684
|
}
|
33511
33685
|
static decodeData(messageData) {
|
@@ -33525,21 +33699,21 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33525
33699
|
const amount = decoded;
|
33526
33700
|
[decoded, o] = new B256Coder().decode(data, o);
|
33527
33701
|
const nonce = decoded;
|
33528
|
-
[decoded, o] = new NumberCoder("
|
33702
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33529
33703
|
const witnessIndex = Number(decoded);
|
33530
33704
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33531
33705
|
const predicateGasUsed = decoded;
|
33532
33706
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33533
33707
|
const dataLength2 = decoded;
|
33534
|
-
[decoded, o] = new
|
33708
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33535
33709
|
const predicateLength = decoded;
|
33536
|
-
[decoded, o] = new
|
33710
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33537
33711
|
const predicateDataLength = decoded;
|
33538
33712
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33539
33713
|
const messageData = decoded;
|
33540
|
-
[decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
|
33714
|
+
[decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
|
33541
33715
|
const predicate = decoded;
|
33542
|
-
[decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
|
33716
|
+
[decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
|
33543
33717
|
const predicateData = decoded;
|
33544
33718
|
return [
|
33545
33719
|
{
|
@@ -33851,7 +34025,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33851
34025
|
}
|
33852
34026
|
};
|
33853
34027
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
33854
|
-
PolicyType2[PolicyType2["
|
34028
|
+
PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
|
33855
34029
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
33856
34030
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
33857
34031
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -33899,9 +34073,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33899
34073
|
let o = offset;
|
33900
34074
|
const policies = [];
|
33901
34075
|
if (policyTypes & 1) {
|
33902
|
-
const [
|
34076
|
+
const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
33903
34077
|
o = nextOffset;
|
33904
|
-
policies.push({ type: 1, data:
|
34078
|
+
policies.push({ type: 1, data: tip });
|
33905
34079
|
}
|
33906
34080
|
if (policyTypes & 2) {
|
33907
34081
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -34133,15 +34307,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34133
34307
|
encode(value) {
|
34134
34308
|
const parts = [];
|
34135
34309
|
parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
|
34136
|
-
parts.push(new NumberCoder("u32").encode(value.scriptLength));
|
34137
|
-
parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
|
34138
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34139
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34140
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34141
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34142
34310
|
parts.push(new B256Coder().encode(value.receiptsRoot));
|
34143
|
-
parts.push(new
|
34144
|
-
parts.push(new
|
34311
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
|
34312
|
+
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
34313
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34314
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34315
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34316
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34317
|
+
parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
|
34318
|
+
parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
|
34145
34319
|
parts.push(new PoliciesCoder().encode(value.policies));
|
34146
34320
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34147
34321
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
@@ -34153,23 +34327,23 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34153
34327
|
let o = offset;
|
34154
34328
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34155
34329
|
const scriptGasLimit = decoded;
|
34156
|
-
[decoded, o] = new
|
34330
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34331
|
+
const receiptsRoot = decoded;
|
34332
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34157
34333
|
const scriptLength = decoded;
|
34158
|
-
[decoded, o] = new
|
34334
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34159
34335
|
const scriptDataLength = decoded;
|
34160
34336
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34161
34337
|
const policyTypes = decoded;
|
34162
|
-
[decoded, o] = new NumberCoder("
|
34338
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34163
34339
|
const inputsCount = decoded;
|
34164
|
-
[decoded, o] = new NumberCoder("
|
34340
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34165
34341
|
const outputsCount = decoded;
|
34166
|
-
[decoded, o] = new NumberCoder("
|
34342
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34167
34343
|
const witnessesCount = decoded;
|
34168
|
-
[decoded, o] = new
|
34169
|
-
const receiptsRoot = decoded;
|
34170
|
-
[decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
|
34344
|
+
[decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
|
34171
34345
|
const script = decoded;
|
34172
|
-
[decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
|
34346
|
+
[decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
|
34173
34347
|
const scriptData = decoded;
|
34174
34348
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34175
34349
|
const policies = decoded;
|
@@ -34207,18 +34381,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34207
34381
|
}
|
34208
34382
|
encode(value) {
|
34209
34383
|
const parts = [];
|
34210
|
-
parts.push(new NumberCoder("
|
34211
|
-
parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
|
34212
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34213
|
-
parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
|
34214
|
-
parts.push(new NumberCoder("u8").encode(value.inputsCount));
|
34215
|
-
parts.push(new NumberCoder("u8").encode(value.outputsCount));
|
34216
|
-
parts.push(new NumberCoder("u8").encode(value.witnessesCount));
|
34384
|
+
parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
|
34217
34385
|
parts.push(new B256Coder().encode(value.salt));
|
34218
|
-
parts.push(new
|
34386
|
+
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
34387
|
+
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
34388
|
+
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
34389
|
+
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
34390
|
+
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
34219
34391
|
parts.push(
|
34220
|
-
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(
|
34392
|
+
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
|
34393
|
+
value.storageSlots
|
34394
|
+
)
|
34221
34395
|
);
|
34396
|
+
parts.push(new PoliciesCoder().encode(value.policies));
|
34222
34397
|
parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
|
34223
34398
|
parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
|
34224
34399
|
parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
|
@@ -34227,26 +34402,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34227
34402
|
decode(data, offset) {
|
34228
34403
|
let decoded;
|
34229
34404
|
let o = offset;
|
34230
|
-
[decoded, o] = new NumberCoder("
|
34231
|
-
const bytecodeLength = decoded;
|
34232
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34405
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34233
34406
|
const bytecodeWitnessIndex = decoded;
|
34407
|
+
[decoded, o] = new B256Coder().decode(data, o);
|
34408
|
+
const salt = decoded;
|
34409
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34410
|
+
const storageSlotsCount = decoded;
|
34234
34411
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
34235
34412
|
const policyTypes = decoded;
|
34236
34413
|
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34237
|
-
const storageSlotsCount = decoded;
|
34238
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
34239
34414
|
const inputsCount = decoded;
|
34240
|
-
[decoded, o] = new NumberCoder("
|
34415
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34241
34416
|
const outputsCount = decoded;
|
34242
|
-
[decoded, o] = new NumberCoder("
|
34417
|
+
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
34243
34418
|
const witnessesCount = decoded;
|
34244
|
-
[decoded, o] = new
|
34245
|
-
|
34419
|
+
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
|
34420
|
+
data,
|
34421
|
+
o
|
34422
|
+
);
|
34423
|
+
const storageSlots = decoded;
|
34246
34424
|
[decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
|
34247
34425
|
const policies = decoded;
|
34248
|
-
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
|
34249
|
-
const storageSlots = decoded;
|
34250
34426
|
[decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
|
34251
34427
|
const inputs = decoded;
|
34252
34428
|
[decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
|
@@ -34256,7 +34432,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34256
34432
|
return [
|
34257
34433
|
{
|
34258
34434
|
type: 1,
|
34259
|
-
bytecodeLength,
|
34260
34435
|
bytecodeWitnessIndex,
|
34261
34436
|
policyTypes,
|
34262
34437
|
storageSlotsCount,
|
@@ -34285,6 +34460,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34285
34460
|
parts.push(new OutputContractCoder().encode(value.outputContract));
|
34286
34461
|
parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
|
34287
34462
|
parts.push(new B256Coder().encode(value.mintAssetId));
|
34463
|
+
parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
|
34288
34464
|
return concat(parts);
|
34289
34465
|
}
|
34290
34466
|
decode(data, offset) {
|
@@ -34300,6 +34476,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34300
34476
|
const mintAmount = decoded;
|
34301
34477
|
[decoded, o] = new B256Coder().decode(data, o);
|
34302
34478
|
const mintAssetId = decoded;
|
34479
|
+
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
34480
|
+
const gasPrice = decoded;
|
34303
34481
|
return [
|
34304
34482
|
{
|
34305
34483
|
type: 2,
|
@@ -34307,7 +34485,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34307
34485
|
inputContract,
|
34308
34486
|
outputContract,
|
34309
34487
|
mintAmount,
|
34310
|
-
mintAssetId
|
34488
|
+
mintAssetId,
|
34489
|
+
gasPrice
|
34311
34490
|
},
|
34312
34491
|
o
|
34313
34492
|
];
|
@@ -34614,159 +34793,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34614
34793
|
// src/providers/provider.ts
|
34615
34794
|
var import_graphql_request = __toESM(require_dist2());
|
34616
34795
|
|
34617
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
34618
|
-
function _isPlaceholder(a) {
|
34619
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
34620
|
-
}
|
34621
|
-
|
34622
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
34623
|
-
function _curry1(fn) {
|
34624
|
-
return function f1(a) {
|
34625
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
34626
|
-
return f1;
|
34627
|
-
} else {
|
34628
|
-
return fn.apply(this, arguments);
|
34629
|
-
}
|
34630
|
-
};
|
34631
|
-
}
|
34632
|
-
|
34633
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
34634
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
34635
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
34636
|
-
};
|
34637
|
-
|
34638
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
34639
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
34640
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
34641
|
-
});
|
34642
|
-
var type_default = type;
|
34643
|
-
|
34644
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
34645
|
-
var pad = function pad2(n) {
|
34646
|
-
return (n < 10 ? "0" : "") + n;
|
34647
|
-
};
|
34648
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
34649
|
-
return d.toISOString();
|
34650
|
-
} : function _toISOString3(d) {
|
34651
|
-
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";
|
34652
|
-
};
|
34653
|
-
|
34654
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
34655
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
34656
|
-
return n << 0 === n;
|
34657
|
-
};
|
34658
|
-
|
34659
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
34660
|
-
function _cloneRegExp(pattern) {
|
34661
|
-
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" : ""));
|
34662
|
-
}
|
34663
|
-
|
34664
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
34665
|
-
function _clone(value, deep, map) {
|
34666
|
-
map || (map = new _ObjectMap());
|
34667
|
-
if (_isPrimitive(value)) {
|
34668
|
-
return value;
|
34669
|
-
}
|
34670
|
-
var copy = function copy2(copiedValue) {
|
34671
|
-
var cachedCopy = map.get(value);
|
34672
|
-
if (cachedCopy) {
|
34673
|
-
return cachedCopy;
|
34674
|
-
}
|
34675
|
-
map.set(value, copiedValue);
|
34676
|
-
for (var key in value) {
|
34677
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
34678
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
34679
|
-
}
|
34680
|
-
}
|
34681
|
-
return copiedValue;
|
34682
|
-
};
|
34683
|
-
switch (type_default(value)) {
|
34684
|
-
case "Object":
|
34685
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
34686
|
-
case "Array":
|
34687
|
-
return copy([]);
|
34688
|
-
case "Date":
|
34689
|
-
return new Date(value.valueOf());
|
34690
|
-
case "RegExp":
|
34691
|
-
return _cloneRegExp(value);
|
34692
|
-
case "Int8Array":
|
34693
|
-
case "Uint8Array":
|
34694
|
-
case "Uint8ClampedArray":
|
34695
|
-
case "Int16Array":
|
34696
|
-
case "Uint16Array":
|
34697
|
-
case "Int32Array":
|
34698
|
-
case "Uint32Array":
|
34699
|
-
case "Float32Array":
|
34700
|
-
case "Float64Array":
|
34701
|
-
case "BigInt64Array":
|
34702
|
-
case "BigUint64Array":
|
34703
|
-
return value.slice();
|
34704
|
-
default:
|
34705
|
-
return value;
|
34706
|
-
}
|
34707
|
-
}
|
34708
|
-
function _isPrimitive(param) {
|
34709
|
-
var type3 = typeof param;
|
34710
|
-
return param == null || type3 != "object" && type3 != "function";
|
34711
|
-
}
|
34712
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
34713
|
-
function _ObjectMap2() {
|
34714
|
-
this.map = {};
|
34715
|
-
this.length = 0;
|
34716
|
-
}
|
34717
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
34718
|
-
const hashedKey = this.hash(key);
|
34719
|
-
let bucket = this.map[hashedKey];
|
34720
|
-
if (!bucket) {
|
34721
|
-
this.map[hashedKey] = bucket = [];
|
34722
|
-
}
|
34723
|
-
bucket.push([key, value]);
|
34724
|
-
this.length += 1;
|
34725
|
-
};
|
34726
|
-
_ObjectMap2.prototype.hash = function(key) {
|
34727
|
-
let hashedKey = [];
|
34728
|
-
for (var value in key) {
|
34729
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
34730
|
-
}
|
34731
|
-
return hashedKey.join();
|
34732
|
-
};
|
34733
|
-
_ObjectMap2.prototype.get = function(key) {
|
34734
|
-
if (this.length <= 180) {
|
34735
|
-
for (const p in this.map) {
|
34736
|
-
const bucket2 = this.map[p];
|
34737
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
34738
|
-
const element = bucket2[i];
|
34739
|
-
if (element[0] === key) {
|
34740
|
-
return element[1];
|
34741
|
-
}
|
34742
|
-
}
|
34743
|
-
}
|
34744
|
-
return;
|
34745
|
-
}
|
34746
|
-
const hashedKey = this.hash(key);
|
34747
|
-
const bucket = this.map[hashedKey];
|
34748
|
-
if (!bucket) {
|
34749
|
-
return;
|
34750
|
-
}
|
34751
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
34752
|
-
const element = bucket[i];
|
34753
|
-
if (element[0] === key) {
|
34754
|
-
return element[1];
|
34755
|
-
}
|
34756
|
-
}
|
34757
|
-
};
|
34758
|
-
return _ObjectMap2;
|
34759
|
-
}();
|
34760
|
-
|
34761
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
34762
|
-
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
34763
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
34764
|
-
});
|
34765
|
-
var clone_default = clone2;
|
34766
|
-
|
34767
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
34768
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34769
|
-
|
34770
34796
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
34771
34797
|
var __assign = function() {
|
34772
34798
|
__assign = Object.assign || function __assign2(t) {
|
@@ -37934,14 +37960,10 @@ spurious results.`);
|
|
37934
37960
|
// src/providers/__generated__/operations.ts
|
37935
37961
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
37936
37962
|
fragment receiptFragment on Receipt {
|
37937
|
-
|
37938
|
-
id
|
37939
|
-
}
|
37963
|
+
id
|
37940
37964
|
pc
|
37941
37965
|
is
|
37942
|
-
to
|
37943
|
-
id
|
37944
|
-
}
|
37966
|
+
to
|
37945
37967
|
toAddress
|
37946
37968
|
amount
|
37947
37969
|
assetId
|
@@ -37979,10 +38001,16 @@ spurious results.`);
|
|
37979
38001
|
id
|
37980
38002
|
}
|
37981
38003
|
time
|
38004
|
+
receipts {
|
38005
|
+
...receiptFragment
|
38006
|
+
}
|
37982
38007
|
programState {
|
37983
38008
|
returnType
|
37984
38009
|
data
|
37985
38010
|
}
|
38011
|
+
receipts {
|
38012
|
+
...receiptFragment
|
38013
|
+
}
|
37986
38014
|
}
|
37987
38015
|
... on FailureStatus {
|
37988
38016
|
block {
|
@@ -37990,26 +38018,24 @@ spurious results.`);
|
|
37990
38018
|
}
|
37991
38019
|
time
|
37992
38020
|
reason
|
38021
|
+
receipts {
|
38022
|
+
...receiptFragment
|
38023
|
+
}
|
37993
38024
|
}
|
37994
38025
|
... on SqueezedOutStatus {
|
37995
38026
|
reason
|
37996
38027
|
}
|
37997
38028
|
}
|
37998
|
-
`;
|
38029
|
+
${ReceiptFragmentFragmentDoc}`;
|
37999
38030
|
var TransactionFragmentFragmentDoc = lib_default2`
|
38000
38031
|
fragment transactionFragment on Transaction {
|
38001
38032
|
id
|
38002
38033
|
rawPayload
|
38003
|
-
gasPrice
|
38004
|
-
receipts {
|
38005
|
-
...receiptFragment
|
38006
|
-
}
|
38007
38034
|
status {
|
38008
38035
|
...transactionStatusFragment
|
38009
38036
|
}
|
38010
38037
|
}
|
38011
|
-
${
|
38012
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
38038
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
38013
38039
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
38014
38040
|
fragment inputEstimatePredicatesFragment on Input {
|
38015
38041
|
... on InputCoin {
|
@@ -38027,6 +38053,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38027
38053
|
}
|
38028
38054
|
}
|
38029
38055
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
38056
|
+
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
38057
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
38058
|
+
reason
|
38059
|
+
programState {
|
38060
|
+
returnType
|
38061
|
+
data
|
38062
|
+
}
|
38063
|
+
}
|
38064
|
+
`;
|
38065
|
+
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
38066
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
38067
|
+
programState {
|
38068
|
+
returnType
|
38069
|
+
data
|
38070
|
+
}
|
38071
|
+
}
|
38072
|
+
`;
|
38073
|
+
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
38074
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
38075
|
+
... on DryRunFailureStatus {
|
38076
|
+
...dryRunFailureStatusFragment
|
38077
|
+
}
|
38078
|
+
... on DryRunSuccessStatus {
|
38079
|
+
...dryRunSuccessStatusFragment
|
38080
|
+
}
|
38081
|
+
}
|
38082
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
38083
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
38084
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
38085
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
38086
|
+
id
|
38087
|
+
status {
|
38088
|
+
...dryRunTransactionStatusFragment
|
38089
|
+
}
|
38090
|
+
receipts {
|
38091
|
+
...receiptFragment
|
38092
|
+
}
|
38093
|
+
}
|
38094
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
38095
|
+
${ReceiptFragmentFragmentDoc}`;
|
38030
38096
|
var CoinFragmentFragmentDoc = lib_default2`
|
38031
38097
|
fragment coinFragment on Coin {
|
38032
38098
|
__typename
|
@@ -38034,7 +38100,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38034
38100
|
owner
|
38035
38101
|
amount
|
38036
38102
|
assetId
|
38037
|
-
maturity
|
38038
38103
|
blockCreated
|
38039
38104
|
txCreatedIdx
|
38040
38105
|
}
|
@@ -38073,26 +38138,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38073
38138
|
messageBlockHeader {
|
38074
38139
|
id
|
38075
38140
|
daHeight
|
38141
|
+
consensusParametersVersion
|
38142
|
+
stateTransitionBytecodeVersion
|
38076
38143
|
transactionsCount
|
38144
|
+
messageReceiptCount
|
38077
38145
|
transactionsRoot
|
38146
|
+
messageOutboxRoot
|
38147
|
+
eventInboxRoot
|
38078
38148
|
height
|
38079
38149
|
prevRoot
|
38080
38150
|
time
|
38081
38151
|
applicationHash
|
38082
|
-
messageReceiptRoot
|
38083
|
-
messageReceiptCount
|
38084
38152
|
}
|
38085
38153
|
commitBlockHeader {
|
38086
38154
|
id
|
38087
38155
|
daHeight
|
38156
|
+
consensusParametersVersion
|
38157
|
+
stateTransitionBytecodeVersion
|
38088
38158
|
transactionsCount
|
38159
|
+
messageReceiptCount
|
38089
38160
|
transactionsRoot
|
38161
|
+
messageOutboxRoot
|
38162
|
+
eventInboxRoot
|
38090
38163
|
height
|
38091
38164
|
prevRoot
|
38092
38165
|
time
|
38093
38166
|
applicationHash
|
38094
|
-
messageReceiptRoot
|
38095
|
-
messageReceiptCount
|
38096
38167
|
}
|
38097
38168
|
sender
|
38098
38169
|
recipient
|
@@ -38111,8 +38182,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38111
38182
|
var BlockFragmentFragmentDoc = lib_default2`
|
38112
38183
|
fragment blockFragment on Block {
|
38113
38184
|
id
|
38185
|
+
height
|
38114
38186
|
header {
|
38115
|
-
height
|
38116
38187
|
time
|
38117
38188
|
}
|
38118
38189
|
transactions {
|
@@ -38170,6 +38241,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38170
38241
|
`;
|
38171
38242
|
var GasCostsFragmentFragmentDoc = lib_default2`
|
38172
38243
|
fragment GasCostsFragment on GasCosts {
|
38244
|
+
version {
|
38245
|
+
... on Version {
|
38246
|
+
value
|
38247
|
+
}
|
38248
|
+
}
|
38173
38249
|
add
|
38174
38250
|
addi
|
38175
38251
|
aloc
|
@@ -38182,7 +38258,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38182
38258
|
cb
|
38183
38259
|
cfei
|
38184
38260
|
cfsi
|
38185
|
-
croo
|
38186
38261
|
div
|
38187
38262
|
divi
|
38188
38263
|
ecr1
|
@@ -38265,6 +38340,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38265
38340
|
ccp {
|
38266
38341
|
...DependentCostFragment
|
38267
38342
|
}
|
38343
|
+
croo {
|
38344
|
+
...DependentCostFragment
|
38345
|
+
}
|
38268
38346
|
csiz {
|
38269
38347
|
...DependentCostFragment
|
38270
38348
|
}
|
@@ -38324,6 +38402,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
38324
38402
|
${DependentCostFragmentFragmentDoc}`;
|
38325
38403
|
var ConsensusParametersFragmentFragmentDoc = lib_default2`
|
38326
38404
|
fragment consensusParametersFragment on ConsensusParameters {
|
38405
|
+
version {
|
38406
|
+
... on Version {
|
38407
|
+
value
|
38408
|
+
}
|
38409
|
+
}
|
38327
38410
|
txParams {
|
38328
38411
|
...TxParametersFragment
|
38329
38412
|
}
|
@@ -38383,18 +38466,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38383
38466
|
fragment nodeInfoFragment on NodeInfo {
|
38384
38467
|
utxoValidation
|
38385
38468
|
vmBacktrace
|
38386
|
-
minGasPrice
|
38387
38469
|
maxTx
|
38388
38470
|
maxDepth
|
38389
38471
|
nodeVersion
|
38390
|
-
peers {
|
38391
|
-
id
|
38392
|
-
addresses
|
38393
|
-
clientVersion
|
38394
|
-
blockHeight
|
38395
|
-
lastHeartbeatMs
|
38396
|
-
appScore
|
38397
|
-
}
|
38398
38472
|
}
|
38399
38473
|
`;
|
38400
38474
|
var GetVersionDocument = lib_default2`
|
@@ -38429,13 +38503,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
38429
38503
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
38430
38504
|
transaction(id: $transactionId) {
|
38431
38505
|
...transactionFragment
|
38432
|
-
receipts {
|
38433
|
-
...receiptFragment
|
38434
|
-
}
|
38435
38506
|
}
|
38436
38507
|
}
|
38437
|
-
${TransactionFragmentFragmentDoc}
|
38438
|
-
${ReceiptFragmentFragmentDoc}`;
|
38508
|
+
${TransactionFragmentFragmentDoc}`;
|
38439
38509
|
var GetTransactionsDocument = lib_default2`
|
38440
38510
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
38441
38511
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -38563,6 +38633,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38563
38633
|
}
|
38564
38634
|
}
|
38565
38635
|
${BalanceFragmentFragmentDoc}`;
|
38636
|
+
var GetLatestGasPriceDocument = lib_default2`
|
38637
|
+
query getLatestGasPrice {
|
38638
|
+
latestGasPrice {
|
38639
|
+
gasPrice
|
38640
|
+
}
|
38641
|
+
}
|
38642
|
+
`;
|
38643
|
+
var EstimateGasPriceDocument = lib_default2`
|
38644
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
38645
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
38646
|
+
gasPrice
|
38647
|
+
}
|
38648
|
+
}
|
38649
|
+
`;
|
38566
38650
|
var GetBalancesDocument = lib_default2`
|
38567
38651
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
38568
38652
|
balances(
|
@@ -38617,12 +38701,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38617
38701
|
}
|
38618
38702
|
`;
|
38619
38703
|
var DryRunDocument = lib_default2`
|
38620
|
-
mutation dryRun($
|
38621
|
-
dryRun(
|
38622
|
-
...
|
38704
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
38705
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
38706
|
+
...dryRunTransactionExecutionStatusFragment
|
38623
38707
|
}
|
38624
38708
|
}
|
38625
|
-
${
|
38709
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
38626
38710
|
var SubmitDocument = lib_default2`
|
38627
38711
|
mutation submit($encodedTransaction: HexString!) {
|
38628
38712
|
submit(tx: $encodedTransaction) {
|
@@ -38705,6 +38789,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38705
38789
|
getBalance(variables, options) {
|
38706
38790
|
return requester(GetBalanceDocument, variables, options);
|
38707
38791
|
},
|
38792
|
+
getLatestGasPrice(variables, options) {
|
38793
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
38794
|
+
},
|
38795
|
+
estimateGasPrice(variables, options) {
|
38796
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
38797
|
+
},
|
38708
38798
|
getBalances(variables, options) {
|
38709
38799
|
return requester(GetBalancesDocument, variables, options);
|
38710
38800
|
},
|
@@ -38772,11 +38862,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38772
38862
|
let data;
|
38773
38863
|
let errors;
|
38774
38864
|
try {
|
38775
|
-
|
38865
|
+
const sanitizedText = text.replace(/\s/g, "");
|
38866
|
+
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
38776
38867
|
} catch (e) {
|
38777
38868
|
throw new FuelError(
|
38778
38869
|
ErrorCode.STREAM_PARSING_ERROR,
|
38779
|
-
`Error while parsing stream data response: ${text}
|
38870
|
+
`Error while parsing stream data response: ${text}
|
38871
|
+
|
38872
|
+
Thrown error: ${e}`
|
38780
38873
|
);
|
38781
38874
|
}
|
38782
38875
|
if (Array.isArray(errors)) {
|
@@ -38860,9 +38953,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38860
38953
|
}
|
38861
38954
|
};
|
38862
38955
|
|
38863
|
-
// ../address/dist/configs.mjs
|
38864
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38865
|
-
|
38866
38956
|
// src/providers/transaction-request/input.ts
|
38867
38957
|
var inputify = (value) => {
|
38868
38958
|
const { type: type3 } = value;
|
@@ -38873,7 +38963,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38873
38963
|
return {
|
38874
38964
|
type: InputType.Coin,
|
38875
38965
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38876
|
-
outputIndex: arrayify(value.id)
|
38966
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 34)),
|
38877
38967
|
owner: hexlify(value.owner),
|
38878
38968
|
amount: bn(value.amount),
|
38879
38969
|
assetId: hexlify(value.assetId),
|
@@ -38882,10 +38972,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38882
38972
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
38883
38973
|
},
|
38884
38974
|
witnessIndex: value.witnessIndex,
|
38885
|
-
maturity: value.maturity ?? 0,
|
38886
38975
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38887
|
-
predicateLength: predicate.length,
|
38888
|
-
predicateDataLength: predicateData.length,
|
38976
|
+
predicateLength: bn(predicate.length),
|
38977
|
+
predicateDataLength: bn(predicateData.length),
|
38889
38978
|
predicate: hexlify(predicate),
|
38890
38979
|
predicateData: hexlify(predicateData)
|
38891
38980
|
};
|
@@ -38916,8 +39005,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38916
39005
|
nonce: hexlify(value.nonce),
|
38917
39006
|
witnessIndex: value.witnessIndex,
|
38918
39007
|
predicateGasUsed: bn(value.predicateGasUsed),
|
38919
|
-
predicateLength: predicate.length,
|
38920
|
-
predicateDataLength: predicateData.length,
|
39008
|
+
predicateLength: bn(predicate.length),
|
39009
|
+
predicateDataLength: bn(predicateData.length),
|
38921
39010
|
predicate: hexlify(predicate),
|
38922
39011
|
predicateData: hexlify(predicateData),
|
38923
39012
|
data: hexlify(data),
|
@@ -39077,8 +39166,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39077
39166
|
case "CALL" /* Call */: {
|
39078
39167
|
const callReceipt = {
|
39079
39168
|
type: ReceiptType.Call,
|
39080
|
-
from: hexOrZero(receipt.
|
39081
|
-
to: hexOrZero(receipt?.to
|
39169
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39170
|
+
to: hexOrZero(receipt?.to),
|
39082
39171
|
amount: bn(receipt.amount),
|
39083
39172
|
assetId: hexOrZero(receipt.assetId),
|
39084
39173
|
gas: bn(receipt.gas),
|
@@ -39092,7 +39181,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39092
39181
|
case "RETURN" /* Return */: {
|
39093
39182
|
const returnReceipt = {
|
39094
39183
|
type: ReceiptType.Return,
|
39095
|
-
id: hexOrZero(receipt.
|
39184
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39096
39185
|
val: bn(receipt.val),
|
39097
39186
|
pc: bn(receipt.pc),
|
39098
39187
|
is: bn(receipt.is)
|
@@ -39102,7 +39191,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39102
39191
|
case "RETURN_DATA" /* ReturnData */: {
|
39103
39192
|
const returnDataReceipt = {
|
39104
39193
|
type: ReceiptType.ReturnData,
|
39105
|
-
id: hexOrZero(receipt.
|
39194
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39106
39195
|
ptr: bn(receipt.ptr),
|
39107
39196
|
len: bn(receipt.len),
|
39108
39197
|
digest: hexOrZero(receipt.digest),
|
@@ -39114,7 +39203,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39114
39203
|
case "PANIC" /* Panic */: {
|
39115
39204
|
const panicReceipt = {
|
39116
39205
|
type: ReceiptType.Panic,
|
39117
|
-
id: hexOrZero(receipt.
|
39206
|
+
id: hexOrZero(receipt.id),
|
39118
39207
|
reason: bn(receipt.reason),
|
39119
39208
|
pc: bn(receipt.pc),
|
39120
39209
|
is: bn(receipt.is),
|
@@ -39125,7 +39214,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39125
39214
|
case "REVERT" /* Revert */: {
|
39126
39215
|
const revertReceipt = {
|
39127
39216
|
type: ReceiptType.Revert,
|
39128
|
-
id: hexOrZero(receipt.
|
39217
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39129
39218
|
val: bn(receipt.ra),
|
39130
39219
|
pc: bn(receipt.pc),
|
39131
39220
|
is: bn(receipt.is)
|
@@ -39135,7 +39224,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39135
39224
|
case "LOG" /* Log */: {
|
39136
39225
|
const logReceipt = {
|
39137
39226
|
type: ReceiptType.Log,
|
39138
|
-
id: hexOrZero(receipt.
|
39227
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39139
39228
|
val0: bn(receipt.ra),
|
39140
39229
|
val1: bn(receipt.rb),
|
39141
39230
|
val2: bn(receipt.rc),
|
@@ -39148,7 +39237,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39148
39237
|
case "LOG_DATA" /* LogData */: {
|
39149
39238
|
const logDataReceipt = {
|
39150
39239
|
type: ReceiptType.LogData,
|
39151
|
-
id: hexOrZero(receipt.
|
39240
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
39152
39241
|
val0: bn(receipt.ra),
|
39153
39242
|
val1: bn(receipt.rb),
|
39154
39243
|
ptr: bn(receipt.ptr),
|
@@ -39162,8 +39251,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39162
39251
|
case "TRANSFER" /* Transfer */: {
|
39163
39252
|
const transferReceipt = {
|
39164
39253
|
type: ReceiptType.Transfer,
|
39165
|
-
from: hexOrZero(receipt.
|
39166
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
39254
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39255
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
39167
39256
|
amount: bn(receipt.amount),
|
39168
39257
|
assetId: hexOrZero(receipt.assetId),
|
39169
39258
|
pc: bn(receipt.pc),
|
@@ -39174,8 +39263,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39174
39263
|
case "TRANSFER_OUT" /* TransferOut */: {
|
39175
39264
|
const transferOutReceipt = {
|
39176
39265
|
type: ReceiptType.TransferOut,
|
39177
|
-
from: hexOrZero(receipt.
|
39178
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
39266
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
39267
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
39179
39268
|
amount: bn(receipt.amount),
|
39180
39269
|
assetId: hexOrZero(receipt.assetId),
|
39181
39270
|
pc: bn(receipt.pc),
|
@@ -39218,7 +39307,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39218
39307
|
return receiptMessageOut;
|
39219
39308
|
}
|
39220
39309
|
case "MINT" /* Mint */: {
|
39221
|
-
const contractId = hexOrZero(receipt.
|
39310
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39222
39311
|
const subId = hexOrZero(receipt.subId);
|
39223
39312
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
39224
39313
|
const mintReceipt = {
|
@@ -39233,7 +39322,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39233
39322
|
return mintReceipt;
|
39234
39323
|
}
|
39235
39324
|
case "BURN" /* Burn */: {
|
39236
|
-
const contractId = hexOrZero(receipt.
|
39325
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
39237
39326
|
const subId = hexOrZero(receipt.subId);
|
39238
39327
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
39239
39328
|
const burnReceipt = {
|
@@ -39314,7 +39403,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39314
39403
|
};
|
39315
39404
|
|
39316
39405
|
// src/providers/utils/gas.ts
|
39317
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
39318
39406
|
var getGasUsedFromReceipts = (receipts) => {
|
39319
39407
|
const scriptResult = receipts.filter(
|
39320
39408
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -39335,18 +39423,28 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39335
39423
|
}
|
39336
39424
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
39337
39425
|
const witnessCache = [];
|
39338
|
-
const
|
39426
|
+
const chargeableInputs = inputs.filter((input) => {
|
39427
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
39428
|
+
if (isCoinOrMessage) {
|
39429
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39430
|
+
return true;
|
39431
|
+
}
|
39432
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
39433
|
+
witnessCache.push(input.witnessIndex);
|
39434
|
+
return true;
|
39435
|
+
}
|
39436
|
+
}
|
39437
|
+
return false;
|
39438
|
+
});
|
39439
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
39440
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
39339
39441
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
39340
39442
|
return total.add(
|
39341
|
-
|
39443
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
39342
39444
|
);
|
39343
39445
|
}
|
39344
|
-
|
39345
|
-
|
39346
|
-
return total.add(gasCosts.ecr1);
|
39347
|
-
}
|
39348
|
-
return total;
|
39349
|
-
}, bn());
|
39446
|
+
return total.add(gasCosts.ecr1);
|
39447
|
+
}, bn(0));
|
39350
39448
|
return totalGas;
|
39351
39449
|
}
|
39352
39450
|
function getMinGas(params) {
|
@@ -39358,12 +39456,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39358
39456
|
return minGas;
|
39359
39457
|
}
|
39360
39458
|
function getMaxGas(params) {
|
39361
|
-
const {
|
39459
|
+
const {
|
39460
|
+
gasPerByte,
|
39461
|
+
witnessesLength,
|
39462
|
+
witnessLimit,
|
39463
|
+
minGas,
|
39464
|
+
gasLimit = bn(0),
|
39465
|
+
maxGasPerTx
|
39466
|
+
} = params;
|
39362
39467
|
let remainingAllowedWitnessGas = bn(0);
|
39363
39468
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
39364
39469
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
39365
39470
|
}
|
39366
|
-
|
39471
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
39472
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
39367
39473
|
}
|
39368
39474
|
function calculateMetadataGasForTxCreate({
|
39369
39475
|
gasCosts,
|
@@ -39385,6 +39491,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39385
39491
|
}) {
|
39386
39492
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
39387
39493
|
}
|
39494
|
+
var calculateGasFee = (params) => {
|
39495
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
39496
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
39497
|
+
};
|
39388
39498
|
|
39389
39499
|
// src/providers/utils/json.ts
|
39390
39500
|
function normalize2(object) {
|
@@ -39526,7 +39636,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39526
39636
|
// src/providers/transaction-request/transaction-request.ts
|
39527
39637
|
var BaseTransactionRequest = class {
|
39528
39638
|
/** Gas price for transaction */
|
39529
|
-
|
39639
|
+
tip;
|
39530
39640
|
/** Block until which tx cannot be included */
|
39531
39641
|
maturity;
|
39532
39642
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -39539,38 +39649,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39539
39649
|
outputs = [];
|
39540
39650
|
/** List of witnesses */
|
39541
39651
|
witnesses = [];
|
39542
|
-
/** Base asset ID - should be fetched from the chain */
|
39543
|
-
baseAssetId;
|
39544
39652
|
/**
|
39545
39653
|
* Constructor for initializing a base transaction request.
|
39546
39654
|
*
|
39547
39655
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
39548
39656
|
*/
|
39549
39657
|
constructor({
|
39550
|
-
|
39658
|
+
tip,
|
39551
39659
|
maturity,
|
39552
39660
|
maxFee,
|
39553
39661
|
witnessLimit,
|
39554
39662
|
inputs,
|
39555
39663
|
outputs,
|
39556
|
-
witnesses
|
39557
|
-
|
39558
|
-
|
39559
|
-
this.gasPrice = bn(gasPrice);
|
39664
|
+
witnesses
|
39665
|
+
} = {}) {
|
39666
|
+
this.tip = bn(tip);
|
39560
39667
|
this.maturity = maturity ?? 0;
|
39561
39668
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
39562
39669
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
39563
39670
|
this.inputs = inputs ?? [];
|
39564
39671
|
this.outputs = outputs ?? [];
|
39565
39672
|
this.witnesses = witnesses ?? [];
|
39566
|
-
this.baseAssetId = baseAssetId;
|
39567
39673
|
}
|
39568
39674
|
static getPolicyMeta(req) {
|
39569
39675
|
let policyTypes = 0;
|
39570
39676
|
const policies = [];
|
39571
|
-
if (req.
|
39572
|
-
policyTypes += PolicyType.
|
39573
|
-
policies.push({ data: req.
|
39677
|
+
if (req.tip) {
|
39678
|
+
policyTypes += PolicyType.Tip;
|
39679
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
39574
39680
|
}
|
39575
39681
|
if (req.witnessLimit) {
|
39576
39682
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -39757,10 +39863,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39757
39863
|
* @param predicate - Predicate bytes.
|
39758
39864
|
* @param predicateData - Predicate data bytes.
|
39759
39865
|
*/
|
39760
|
-
addCoinInput(coin
|
39866
|
+
addCoinInput(coin) {
|
39761
39867
|
const { assetId, owner, amount } = coin;
|
39762
39868
|
let witnessIndex;
|
39763
|
-
if (predicate) {
|
39869
|
+
if (coin.predicate) {
|
39764
39870
|
witnessIndex = 0;
|
39765
39871
|
} else {
|
39766
39872
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -39775,8 +39881,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39775
39881
|
amount,
|
39776
39882
|
assetId,
|
39777
39883
|
txPointer: "0x00000000000000000000000000000000",
|
39778
|
-
witnessIndex
|
39779
|
-
predicate: predicate?.bytes
|
39884
|
+
witnessIndex
|
39780
39885
|
};
|
39781
39886
|
this.pushInput(input);
|
39782
39887
|
this.addChangeOutput(owner, assetId);
|
@@ -39787,11 +39892,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39787
39892
|
*
|
39788
39893
|
* @param message - Message resource.
|
39789
39894
|
* @param predicate - Predicate bytes.
|
39895
|
+
* @param predicateData - Predicate data bytes.
|
39790
39896
|
*/
|
39791
|
-
addMessageInput(message
|
39897
|
+
addMessageInput(message) {
|
39792
39898
|
const { recipient, sender, amount } = message;
|
39899
|
+
const assetId = BaseAssetId;
|
39793
39900
|
let witnessIndex;
|
39794
|
-
if (predicate) {
|
39901
|
+
if (message.predicate) {
|
39795
39902
|
witnessIndex = 0;
|
39796
39903
|
} else {
|
39797
39904
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -39805,11 +39912,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39805
39912
|
sender: sender.toB256(),
|
39806
39913
|
recipient: recipient.toB256(),
|
39807
39914
|
amount,
|
39808
|
-
witnessIndex
|
39809
|
-
predicate: predicate?.bytes
|
39915
|
+
witnessIndex
|
39810
39916
|
};
|
39811
39917
|
this.pushInput(input);
|
39812
|
-
this.addChangeOutput(recipient,
|
39918
|
+
this.addChangeOutput(recipient, assetId);
|
39813
39919
|
}
|
39814
39920
|
/**
|
39815
39921
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39837,32 +39943,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39837
39943
|
resources.forEach((resource) => this.addResource(resource));
|
39838
39944
|
return this;
|
39839
39945
|
}
|
39840
|
-
/**
|
39841
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39842
|
-
* outputs from the related assetIds.
|
39843
|
-
*
|
39844
|
-
* @param resources - The resources to add.
|
39845
|
-
* @returns This transaction.
|
39846
|
-
*/
|
39847
|
-
addPredicateResource(resource, predicate) {
|
39848
|
-
if (isCoin(resource)) {
|
39849
|
-
this.addCoinInput(resource, predicate);
|
39850
|
-
} else {
|
39851
|
-
this.addMessageInput(resource, predicate);
|
39852
|
-
}
|
39853
|
-
return this;
|
39854
|
-
}
|
39855
|
-
/**
|
39856
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39857
|
-
* from the related assetIds.
|
39858
|
-
*
|
39859
|
-
* @param resources - The resources to add.
|
39860
|
-
* @returns This transaction.
|
39861
|
-
*/
|
39862
|
-
addPredicateResources(resources, predicate) {
|
39863
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39864
|
-
return this;
|
39865
|
-
}
|
39866
39946
|
/**
|
39867
39947
|
* Adds a coin output to the transaction.
|
39868
39948
|
*
|
@@ -39870,12 +39950,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39870
39950
|
* @param amount - Amount of coin.
|
39871
39951
|
* @param assetId - Asset ID of coin.
|
39872
39952
|
*/
|
39873
|
-
addCoinOutput(to, amount, assetId) {
|
39953
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39874
39954
|
this.pushOutput({
|
39875
39955
|
type: OutputType.Coin,
|
39876
39956
|
to: addressify(to).toB256(),
|
39877
39957
|
amount,
|
39878
|
-
assetId
|
39958
|
+
assetId
|
39879
39959
|
});
|
39880
39960
|
return this;
|
39881
39961
|
}
|
@@ -39902,7 +39982,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39902
39982
|
* @param to - Address of the owner.
|
39903
39983
|
* @param assetId - Asset ID of coin.
|
39904
39984
|
*/
|
39905
|
-
addChangeOutput(to, assetId) {
|
39985
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39906
39986
|
const changeOutput = this.getChangeOutputs().find(
|
39907
39987
|
(output3) => hexlify(output3.assetId) === assetId
|
39908
39988
|
);
|
@@ -39910,7 +39990,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39910
39990
|
this.pushOutput({
|
39911
39991
|
type: OutputType.Change,
|
39912
39992
|
to: addressify(to).toB256(),
|
39913
|
-
assetId
|
39993
|
+
assetId
|
39914
39994
|
});
|
39915
39995
|
}
|
39916
39996
|
}
|
@@ -39942,7 +40022,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39942
40022
|
}
|
39943
40023
|
calculateMaxGas(chainInfo, minGas) {
|
39944
40024
|
const { consensusParameters } = chainInfo;
|
39945
|
-
const { gasPerByte } = consensusParameters;
|
40025
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
39946
40026
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
39947
40027
|
(acc, wit) => acc + wit.dataLength,
|
39948
40028
|
0
|
@@ -39951,7 +40031,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39951
40031
|
gasPerByte,
|
39952
40032
|
minGas,
|
39953
40033
|
witnessesLength,
|
39954
|
-
witnessLimit: this.witnessLimit
|
40034
|
+
witnessLimit: this.witnessLimit,
|
40035
|
+
maxGasPerTx
|
39955
40036
|
});
|
39956
40037
|
}
|
39957
40038
|
/**
|
@@ -39961,12 +40042,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39961
40042
|
* @param quantities - CoinQuantity Array.
|
39962
40043
|
*/
|
39963
40044
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39964
|
-
let idCounter = 0;
|
39965
|
-
const generateId = () => {
|
39966
|
-
const counterString = String(idCounter++);
|
39967
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39968
|
-
return id;
|
39969
|
-
};
|
39970
40045
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39971
40046
|
if ("assetId" in input) {
|
39972
40047
|
return input.assetId === assetId;
|
@@ -39975,24 +40050,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39975
40050
|
});
|
39976
40051
|
const updateAssetInput = (assetId, quantity) => {
|
39977
40052
|
const assetInput = findAssetInput(assetId);
|
40053
|
+
let usedQuantity = quantity;
|
40054
|
+
if (assetId === BaseAssetId) {
|
40055
|
+
usedQuantity = bn("1000000000000000000");
|
40056
|
+
}
|
39978
40057
|
if (assetInput && "assetId" in assetInput) {
|
39979
|
-
assetInput.id =
|
39980
|
-
assetInput.amount =
|
40058
|
+
assetInput.id = hexlify(randomBytes3(34));
|
40059
|
+
assetInput.amount = usedQuantity;
|
39981
40060
|
} else {
|
39982
40061
|
this.addResources([
|
39983
40062
|
{
|
39984
|
-
id:
|
39985
|
-
amount:
|
40063
|
+
id: hexlify(randomBytes3(34)),
|
40064
|
+
amount: usedQuantity,
|
39986
40065
|
assetId,
|
39987
40066
|
owner: resourcesOwner || Address.fromRandom(),
|
39988
|
-
maturity: 0,
|
39989
40067
|
blockCreated: bn(1),
|
39990
40068
|
txCreatedIdx: bn(1)
|
39991
40069
|
}
|
39992
40070
|
]);
|
39993
40071
|
}
|
39994
40072
|
};
|
39995
|
-
updateAssetInput(
|
40073
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
39996
40074
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39997
40075
|
}
|
39998
40076
|
/**
|
@@ -40017,7 +40095,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40017
40095
|
toJSON() {
|
40018
40096
|
return normalizeJSON(this);
|
40019
40097
|
}
|
40020
|
-
|
40098
|
+
updatePredicateGasUsed(inputs) {
|
40021
40099
|
this.inputs.forEach((i) => {
|
40022
40100
|
let correspondingInput;
|
40023
40101
|
switch (i.type) {
|
@@ -40039,6 +40117,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40039
40117
|
}
|
40040
40118
|
});
|
40041
40119
|
}
|
40120
|
+
shiftPredicateData() {
|
40121
|
+
this.inputs.forEach((input) => {
|
40122
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
40123
|
+
input.predicateData = input.paddPredicateData(
|
40124
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
40125
|
+
);
|
40126
|
+
}
|
40127
|
+
});
|
40128
|
+
}
|
40042
40129
|
};
|
40043
40130
|
|
40044
40131
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40149,7 +40236,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40149
40236
|
*
|
40150
40237
|
* @param createTransactionRequestLike - The initial values for the instance
|
40151
40238
|
*/
|
40152
|
-
constructor({
|
40239
|
+
constructor({
|
40240
|
+
bytecodeWitnessIndex,
|
40241
|
+
salt,
|
40242
|
+
storageSlots,
|
40243
|
+
...rest
|
40244
|
+
} = {}) {
|
40153
40245
|
super(rest);
|
40154
40246
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40155
40247
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40167,9 +40259,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40167
40259
|
return {
|
40168
40260
|
type: TransactionType.Create,
|
40169
40261
|
...baseTransaction,
|
40170
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
40171
40262
|
bytecodeWitnessIndex,
|
40172
|
-
storageSlotsCount: storageSlots.length,
|
40263
|
+
storageSlotsCount: bn(storageSlots.length),
|
40173
40264
|
salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
|
40174
40265
|
storageSlots
|
40175
40266
|
};
|
@@ -40264,7 +40355,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40264
40355
|
*
|
40265
40356
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40266
40357
|
*/
|
40267
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40358
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
40268
40359
|
super(rest);
|
40269
40360
|
this.gasLimit = bn(gasLimit);
|
40270
40361
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -40283,8 +40374,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40283
40374
|
type: TransactionType.Script,
|
40284
40375
|
scriptGasLimit: this.gasLimit,
|
40285
40376
|
...super.getBaseTransaction(),
|
40286
|
-
scriptLength: script.length,
|
40287
|
-
scriptDataLength: scriptData.length,
|
40377
|
+
scriptLength: bn(script.length),
|
40378
|
+
scriptDataLength: bn(scriptData.length),
|
40288
40379
|
receiptsRoot: ZeroBytes32,
|
40289
40380
|
script: hexlify(script),
|
40290
40381
|
scriptData: hexlify(scriptData)
|
@@ -40348,7 +40439,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40348
40439
|
}
|
40349
40440
|
calculateMaxGas(chainInfo, minGas) {
|
40350
40441
|
const { consensusParameters } = chainInfo;
|
40351
|
-
const { gasPerByte } = consensusParameters;
|
40442
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
40352
40443
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
40353
40444
|
(acc, wit) => acc + wit.dataLength,
|
40354
40445
|
0
|
@@ -40358,7 +40449,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40358
40449
|
minGas,
|
40359
40450
|
witnessesLength,
|
40360
40451
|
witnessLimit: this.witnessLimit,
|
40361
|
-
gasLimit: this.gasLimit
|
40452
|
+
gasLimit: this.gasLimit,
|
40453
|
+
maxGasPerTx
|
40362
40454
|
});
|
40363
40455
|
}
|
40364
40456
|
/**
|
@@ -40431,13 +40523,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40431
40523
|
}
|
40432
40524
|
}
|
40433
40525
|
};
|
40526
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
40527
|
+
(acc, input) => {
|
40528
|
+
if (input.type === InputType.Coin && input.owner === owner) {
|
40529
|
+
acc.utxos.push(input.id);
|
40530
|
+
}
|
40531
|
+
if (input.type === InputType.Message && input.recipient === owner) {
|
40532
|
+
acc.messages.push(input.nonce);
|
40533
|
+
}
|
40534
|
+
return acc;
|
40535
|
+
},
|
40536
|
+
{
|
40537
|
+
utxos: [],
|
40538
|
+
messages: []
|
40539
|
+
}
|
40540
|
+
);
|
40434
40541
|
|
40435
40542
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
40436
40543
|
var calculateTransactionFee = (params) => {
|
40437
40544
|
const {
|
40438
|
-
|
40545
|
+
gasPrice,
|
40439
40546
|
rawPayload,
|
40440
|
-
|
40547
|
+
tip,
|
40548
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
40441
40549
|
} = params;
|
40442
40550
|
const gasPerByte = bn(feeParams.gasPerByte);
|
40443
40551
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -40447,8 +40555,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40447
40555
|
return {
|
40448
40556
|
fee: bn(0),
|
40449
40557
|
minFee: bn(0),
|
40450
|
-
maxFee: bn(0)
|
40451
|
-
feeFromGasUsed: bn(0)
|
40558
|
+
maxFee: bn(0)
|
40452
40559
|
};
|
40453
40560
|
}
|
40454
40561
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -40480,7 +40587,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40480
40587
|
metadataGas,
|
40481
40588
|
txBytesSize: transactionBytes.length
|
40482
40589
|
});
|
40483
|
-
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
40484
40590
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
40485
40591
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
40486
40592
|
const maxGas = getMaxGas({
|
@@ -40488,17 +40594,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40488
40594
|
minGas,
|
40489
40595
|
witnessesLength,
|
40490
40596
|
gasLimit,
|
40491
|
-
witnessLimit
|
40597
|
+
witnessLimit,
|
40598
|
+
maxGasPerTx
|
40599
|
+
});
|
40600
|
+
const minFee = calculateGasFee({
|
40601
|
+
gasPrice,
|
40602
|
+
gas: minGas,
|
40603
|
+
priceFactor: gasPriceFactor,
|
40604
|
+
tip
|
40605
|
+
});
|
40606
|
+
const maxFee = calculateGasFee({
|
40607
|
+
gasPrice,
|
40608
|
+
gas: maxGas,
|
40609
|
+
priceFactor: gasPriceFactor,
|
40610
|
+
tip
|
40492
40611
|
});
|
40493
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
40494
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
40495
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
40496
|
-
const fee = minFee.add(feeFromGasUsed);
|
40497
40612
|
return {
|
40498
|
-
fee,
|
40499
40613
|
minFee,
|
40500
40614
|
maxFee,
|
40501
|
-
|
40615
|
+
fee: maxFee
|
40502
40616
|
};
|
40503
40617
|
};
|
40504
40618
|
|
@@ -41099,7 +41213,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41099
41213
|
gqlTransactionStatus,
|
41100
41214
|
abiMap = {},
|
41101
41215
|
maxInputs,
|
41102
|
-
gasCosts
|
41216
|
+
gasCosts,
|
41217
|
+
maxGasPerTx,
|
41218
|
+
gasPrice
|
41103
41219
|
} = params;
|
41104
41220
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
41105
41221
|
const rawPayload = hexlify(transactionBytes);
|
@@ -41113,11 +41229,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41113
41229
|
maxInputs
|
41114
41230
|
});
|
41115
41231
|
const typeName = getTransactionTypeName(transaction.type);
|
41232
|
+
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
41116
41233
|
const { fee } = calculateTransactionFee({
|
41117
|
-
|
41234
|
+
gasPrice,
|
41118
41235
|
rawPayload,
|
41236
|
+
tip,
|
41119
41237
|
consensusParameters: {
|
41120
41238
|
gasCosts,
|
41239
|
+
maxGasPerTx,
|
41121
41240
|
feeParams: {
|
41122
41241
|
gasPerByte,
|
41123
41242
|
gasPriceFactor
|
@@ -41253,8 +41372,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41253
41372
|
const decodedTransaction = this.decodeTransaction(
|
41254
41373
|
transaction
|
41255
41374
|
);
|
41256
|
-
|
41257
|
-
|
41375
|
+
let txReceipts = [];
|
41376
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
41377
|
+
txReceipts = transaction.status.receipts;
|
41378
|
+
}
|
41379
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
41380
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
41381
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
41258
41382
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
41259
41383
|
const transactionSummary = assembleTransactionSummary({
|
41260
41384
|
id: this.id,
|
@@ -41266,7 +41390,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41266
41390
|
gasPriceFactor,
|
41267
41391
|
abiMap: contractsAbiMap,
|
41268
41392
|
maxInputs,
|
41269
|
-
gasCosts
|
41393
|
+
gasCosts,
|
41394
|
+
maxGasPerTx,
|
41395
|
+
gasPrice
|
41270
41396
|
});
|
41271
41397
|
return transactionSummary;
|
41272
41398
|
}
|
@@ -41410,13 +41536,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41410
41536
|
gasPerByte: bn(feeParams.gasPerByte),
|
41411
41537
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41412
41538
|
chainId: bn(consensusParameters.chainId),
|
41413
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41414
41539
|
gasCosts
|
41415
41540
|
},
|
41416
41541
|
gasCosts,
|
41417
41542
|
latestBlock: {
|
41418
41543
|
id: latestBlock.id,
|
41419
|
-
height: bn(latestBlock.
|
41544
|
+
height: bn(latestBlock.height),
|
41420
41545
|
time: latestBlock.header.time,
|
41421
41546
|
transactions: latestBlock.transactions.map((i) => ({
|
41422
41547
|
id: i.id
|
@@ -41510,10 +41635,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41510
41635
|
* Returns some helpful parameters related to gas fees.
|
41511
41636
|
*/
|
41512
41637
|
getGasConfig() {
|
41513
|
-
const { minGasPrice } = this.getNode();
|
41514
41638
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
41515
41639
|
return {
|
41516
|
-
minGasPrice,
|
41517
41640
|
maxGasPerTx,
|
41518
41641
|
maxGasPerPredicate,
|
41519
41642
|
gasPriceFactor,
|
@@ -41611,7 +41734,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41611
41734
|
*/
|
41612
41735
|
async getBlockNumber() {
|
41613
41736
|
const { chain } = await this.operations.getChain();
|
41614
|
-
return bn(chain.latestBlock.
|
41737
|
+
return bn(chain.latestBlock.height, 10);
|
41615
41738
|
}
|
41616
41739
|
/**
|
41617
41740
|
* Returns the chain information.
|
@@ -41623,11 +41746,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41623
41746
|
const processedNodeInfo = {
|
41624
41747
|
maxDepth: bn(nodeInfo.maxDepth),
|
41625
41748
|
maxTx: bn(nodeInfo.maxTx),
|
41626
|
-
minGasPrice: bn(nodeInfo.minGasPrice),
|
41627
41749
|
nodeVersion: nodeInfo.nodeVersion,
|
41628
41750
|
utxoValidation: nodeInfo.utxoValidation,
|
41629
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
41630
|
-
peers: nodeInfo.peers
|
41751
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
41631
41752
|
};
|
41632
41753
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
41633
41754
|
return processedNodeInfo;
|
@@ -41653,17 +41774,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41653
41774
|
} = this.getChain();
|
41654
41775
|
return chainId.toNumber();
|
41655
41776
|
}
|
41656
|
-
/**
|
41657
|
-
* Returns the base asset ID
|
41658
|
-
*
|
41659
|
-
* @returns A promise that resolves to the base asset ID
|
41660
|
-
*/
|
41661
|
-
getBaseAssetId() {
|
41662
|
-
const {
|
41663
|
-
consensusParameters: { baseAssetId }
|
41664
|
-
} = this.getChain();
|
41665
|
-
return baseAssetId;
|
41666
|
-
}
|
41667
41777
|
/**
|
41668
41778
|
* Submits a transaction to the chain to be executed.
|
41669
41779
|
*
|
@@ -41724,14 +41834,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41724
41834
|
return this.estimateTxDependencies(transactionRequest);
|
41725
41835
|
}
|
41726
41836
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
41727
|
-
const { dryRun:
|
41728
|
-
encodedTransaction,
|
41837
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
41838
|
+
encodedTransactions: encodedTransaction,
|
41729
41839
|
utxoValidation: utxoValidation || false
|
41730
41840
|
});
|
41731
|
-
const receipts =
|
41732
|
-
|
41733
|
-
|
41734
|
-
};
|
41841
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
41842
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
41843
|
+
return { receipts, dryrunStatus: status };
|
41735
41844
|
}
|
41736
41845
|
/**
|
41737
41846
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -41770,9 +41879,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41770
41879
|
* If there are missing variable outputs,
|
41771
41880
|
* `addVariableOutputs` is called on the transaction.
|
41772
41881
|
*
|
41773
|
-
* @privateRemarks
|
41774
|
-
* TODO: Investigate support for missing contract IDs
|
41775
|
-
* TODO: Add support for missing output messages
|
41776
41882
|
*
|
41777
41883
|
* @param transactionRequest - The transaction request object.
|
41778
41884
|
* @returns A promise.
|
@@ -41785,16 +41891,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41785
41891
|
missingContractIds: []
|
41786
41892
|
};
|
41787
41893
|
}
|
41788
|
-
await this.estimatePredicates(transactionRequest);
|
41789
41894
|
let receipts = [];
|
41790
41895
|
const missingContractIds = [];
|
41791
41896
|
let outputVariables = 0;
|
41897
|
+
let dryrunStatus;
|
41792
41898
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
41793
|
-
const {
|
41794
|
-
|
41899
|
+
const {
|
41900
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
41901
|
+
} = await this.operations.dryRun({
|
41902
|
+
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
41795
41903
|
utxoValidation: false
|
41796
41904
|
});
|
41797
|
-
receipts =
|
41905
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
41906
|
+
dryrunStatus = status;
|
41798
41907
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
41799
41908
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
41800
41909
|
if (hasMissingOutputs) {
|
@@ -41804,6 +41913,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41804
41913
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
41805
41914
|
missingContractIds.push(contractId);
|
41806
41915
|
});
|
41916
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41917
|
+
transactionRequest,
|
41918
|
+
optimizeGas: false
|
41919
|
+
});
|
41920
|
+
transactionRequest.maxFee = maxFee;
|
41807
41921
|
} else {
|
41808
41922
|
break;
|
41809
41923
|
}
|
@@ -41811,7 +41925,133 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41811
41925
|
return {
|
41812
41926
|
receipts,
|
41813
41927
|
outputVariables,
|
41814
|
-
missingContractIds
|
41928
|
+
missingContractIds,
|
41929
|
+
dryrunStatus
|
41930
|
+
};
|
41931
|
+
}
|
41932
|
+
/**
|
41933
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
41934
|
+
*
|
41935
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
41936
|
+
* further modifications are identified. The method iteratively updates these transactions
|
41937
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
41938
|
+
*
|
41939
|
+
* @param transactionRequests - Array of transaction request objects.
|
41940
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
41941
|
+
*/
|
41942
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
41943
|
+
const results = transactionRequests.map(() => ({
|
41944
|
+
receipts: [],
|
41945
|
+
outputVariables: 0,
|
41946
|
+
missingContractIds: [],
|
41947
|
+
dryrunStatus: void 0
|
41948
|
+
}));
|
41949
|
+
const allRequests = clone_default(transactionRequests);
|
41950
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
41951
|
+
allRequests.forEach((req, index) => {
|
41952
|
+
if (req.type === TransactionType.Script) {
|
41953
|
+
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
41954
|
+
}
|
41955
|
+
});
|
41956
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
41957
|
+
let attempt = 0;
|
41958
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
41959
|
+
const encodedTransactions = transactionsToProcess.map(
|
41960
|
+
(index) => serializedTransactionsMap.get(index)
|
41961
|
+
);
|
41962
|
+
const dryRunResults = await this.operations.dryRun({
|
41963
|
+
encodedTransactions,
|
41964
|
+
utxoValidation: false
|
41965
|
+
});
|
41966
|
+
const nextRoundTransactions = [];
|
41967
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
41968
|
+
const currentResultIndex = transactionsToProcess[i];
|
41969
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
41970
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
41971
|
+
results[currentResultIndex].dryrunStatus = status;
|
41972
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
41973
|
+
results[currentResultIndex].receipts
|
41974
|
+
);
|
41975
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
41976
|
+
const requestToProcess = allRequests[currentResultIndex];
|
41977
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
41978
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
41979
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
41980
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
41981
|
+
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
41982
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
41983
|
+
});
|
41984
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
41985
|
+
transactionRequest: requestToProcess,
|
41986
|
+
optimizeGas: false
|
41987
|
+
});
|
41988
|
+
requestToProcess.maxFee = maxFee;
|
41989
|
+
serializedTransactionsMap.set(
|
41990
|
+
currentResultIndex,
|
41991
|
+
hexlify(requestToProcess.toTransactionBytes())
|
41992
|
+
);
|
41993
|
+
nextRoundTransactions.push(currentResultIndex);
|
41994
|
+
allRequests[currentResultIndex] = requestToProcess;
|
41995
|
+
}
|
41996
|
+
}
|
41997
|
+
transactionsToProcess = nextRoundTransactions;
|
41998
|
+
attempt += 1;
|
41999
|
+
}
|
42000
|
+
return results;
|
42001
|
+
}
|
42002
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
42003
|
+
if (estimateTxDependencies) {
|
42004
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
42005
|
+
}
|
42006
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
42007
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42008
|
+
encodedTransactions,
|
42009
|
+
utxoValidation: utxoValidation || false
|
42010
|
+
});
|
42011
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
42012
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
42013
|
+
return { receipts, dryrunStatus: status };
|
42014
|
+
});
|
42015
|
+
return results;
|
42016
|
+
}
|
42017
|
+
async estimateTxGasAndFee(params) {
|
42018
|
+
const { transactionRequest, optimizeGas = true } = params;
|
42019
|
+
let { gasPrice } = params;
|
42020
|
+
const chainInfo = this.getChain();
|
42021
|
+
const { gasPriceFactor } = this.getGasConfig();
|
42022
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
42023
|
+
if (!gasPrice) {
|
42024
|
+
gasPrice = await this.estimateGasPrice(10);
|
42025
|
+
}
|
42026
|
+
const minFee = calculateGasFee({
|
42027
|
+
gasPrice: bn(gasPrice),
|
42028
|
+
gas: minGas,
|
42029
|
+
priceFactor: gasPriceFactor,
|
42030
|
+
tip: transactionRequest.tip
|
42031
|
+
}).add(1);
|
42032
|
+
let gasLimit = bn(0);
|
42033
|
+
if (transactionRequest.type === TransactionType.Script) {
|
42034
|
+
gasLimit = transactionRequest.gasLimit;
|
42035
|
+
if (!optimizeGas) {
|
42036
|
+
transactionRequest.gasLimit = minGas;
|
42037
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42038
|
+
transactionRequest.gasLimit = gasLimit;
|
42039
|
+
}
|
42040
|
+
}
|
42041
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
42042
|
+
const maxFee = calculateGasFee({
|
42043
|
+
gasPrice: bn(gasPrice),
|
42044
|
+
gas: maxGas,
|
42045
|
+
priceFactor: gasPriceFactor,
|
42046
|
+
tip: transactionRequest.tip
|
42047
|
+
}).add(1);
|
42048
|
+
return {
|
42049
|
+
minGas,
|
42050
|
+
minFee,
|
42051
|
+
maxGas,
|
42052
|
+
maxFee,
|
42053
|
+
gasPrice,
|
42054
|
+
gasLimit
|
41815
42055
|
};
|
41816
42056
|
}
|
41817
42057
|
/**
|
@@ -41829,15 +42069,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41829
42069
|
if (estimateTxDependencies) {
|
41830
42070
|
return this.estimateTxDependencies(transactionRequest);
|
41831
42071
|
}
|
41832
|
-
const
|
41833
|
-
const { dryRun:
|
41834
|
-
|
42072
|
+
const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
|
42073
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
42074
|
+
encodedTransactions,
|
41835
42075
|
utxoValidation: true
|
41836
42076
|
});
|
41837
|
-
const
|
41838
|
-
|
41839
|
-
receipts
|
41840
|
-
|
42077
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
42078
|
+
const { id, receipts, status } = dryRunStatus;
|
42079
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
42080
|
+
return { id, receipts: processedReceipts, status };
|
42081
|
+
});
|
42082
|
+
return { receipts: callResult[0].receipts };
|
41841
42083
|
}
|
41842
42084
|
/**
|
41843
42085
|
* Returns a transaction cost to enable user
|
@@ -41854,80 +42096,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41854
42096
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
41855
42097
|
* @returns A promise that resolves to the transaction cost object.
|
41856
42098
|
*/
|
41857
|
-
async getTransactionCost(transactionRequestLike,
|
41858
|
-
estimateTxDependencies = true,
|
41859
|
-
estimatePredicates = true,
|
41860
|
-
resourcesOwner,
|
41861
|
-
signatureCallback
|
41862
|
-
} = {}) {
|
42099
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
41863
42100
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41864
|
-
const chainInfo = this.getChain();
|
41865
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41866
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41867
42101
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41868
42102
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41869
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
42103
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
41870
42104
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41871
|
-
|
41872
|
-
|
41873
|
-
|
41874
|
-
}
|
41875
|
-
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41876
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41877
|
-
}
|
41878
|
-
await this.estimatePredicates(txRequestClone);
|
42105
|
+
txRequestClone.maxFee = bn(0);
|
42106
|
+
if (isScriptTransaction) {
|
42107
|
+
txRequestClone.gasLimit = bn(0);
|
41879
42108
|
}
|
41880
|
-
if (
|
41881
|
-
|
42109
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
42110
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41882
42111
|
}
|
41883
|
-
const
|
41884
|
-
|
42112
|
+
const signedRequest = clone_default(txRequestClone);
|
42113
|
+
let addedSignatures = 0;
|
42114
|
+
if (signatureCallback && isScriptTransaction) {
|
42115
|
+
const lengthBefore = signedRequest.witnesses.length;
|
42116
|
+
await signatureCallback(signedRequest);
|
42117
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
42118
|
+
}
|
42119
|
+
await this.estimatePredicates(signedRequest);
|
42120
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
42121
|
+
transactionRequest: signedRequest,
|
42122
|
+
optimizeGas: false
|
42123
|
+
});
|
42124
|
+
txRequestClone.maxFee = maxFee;
|
41885
42125
|
let receipts = [];
|
41886
42126
|
let missingContractIds = [];
|
41887
42127
|
let outputVariables = 0;
|
41888
|
-
|
41889
|
-
|
41890
|
-
|
42128
|
+
let gasUsed = bn(0);
|
42129
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
42130
|
+
if (isScriptTransaction) {
|
42131
|
+
if (signatureCallback) {
|
42132
|
+
await signatureCallback(txRequestClone);
|
42133
|
+
}
|
42134
|
+
txRequestClone.gasLimit = gasLimit;
|
41891
42135
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41892
42136
|
receipts = result.receipts;
|
41893
42137
|
outputVariables = result.outputVariables;
|
41894
42138
|
missingContractIds = result.missingContractIds;
|
42139
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
42140
|
+
txRequestClone.gasLimit = gasUsed;
|
42141
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
42142
|
+
transactionRequest: txRequestClone,
|
42143
|
+
gasPrice
|
42144
|
+
}));
|
41895
42145
|
}
|
41896
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41897
|
-
const usedFee = calculatePriceWithFactor(
|
41898
|
-
gasUsed,
|
41899
|
-
gasPrice,
|
41900
|
-
gasPriceFactor
|
41901
|
-
).normalizeZeroToOne();
|
41902
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41903
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41904
42146
|
return {
|
41905
42147
|
requiredQuantities: allQuantities,
|
41906
42148
|
receipts,
|
41907
42149
|
gasUsed,
|
41908
|
-
minGasPrice,
|
41909
42150
|
gasPrice,
|
41910
42151
|
minGas,
|
41911
42152
|
maxGas,
|
41912
|
-
usedFee,
|
41913
42153
|
minFee,
|
41914
42154
|
maxFee,
|
41915
|
-
estimatedInputs: txRequestClone.inputs,
|
41916
42155
|
outputVariables,
|
41917
|
-
missingContractIds
|
42156
|
+
missingContractIds,
|
42157
|
+
addedSignatures,
|
42158
|
+
estimatedPredicates: txRequestClone.inputs
|
41918
42159
|
};
|
41919
42160
|
}
|
41920
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
42161
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
41921
42162
|
const ownerAddress = Address.fromAddressOrString(owner);
|
41922
42163
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
41923
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
42164
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
42165
|
+
quantitiesToContract
|
42166
|
+
});
|
41924
42167
|
transactionRequest.addResources(
|
41925
42168
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
41926
42169
|
);
|
41927
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
41928
|
-
|
41929
|
-
|
41930
|
-
);
|
42170
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
42171
|
+
quantitiesToContract
|
42172
|
+
});
|
41931
42173
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
41932
42174
|
return {
|
41933
42175
|
resources,
|
@@ -41951,7 +42193,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41951
42193
|
assetId: coin.assetId,
|
41952
42194
|
amount: bn(coin.amount),
|
41953
42195
|
owner: Address.fromAddressOrString(coin.owner),
|
41954
|
-
maturity: bn(coin.maturity).toNumber(),
|
41955
42196
|
blockCreated: bn(coin.blockCreated),
|
41956
42197
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
41957
42198
|
}));
|
@@ -42003,7 +42244,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42003
42244
|
amount: bn(coin.amount),
|
42004
42245
|
assetId: coin.assetId,
|
42005
42246
|
owner: Address.fromAddressOrString(coin.owner),
|
42006
|
-
maturity: bn(coin.maturity).toNumber(),
|
42007
42247
|
blockCreated: bn(coin.blockCreated),
|
42008
42248
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
42009
42249
|
};
|
@@ -42036,7 +42276,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42036
42276
|
}
|
42037
42277
|
return {
|
42038
42278
|
id: block2.id,
|
42039
|
-
height: bn(block2.
|
42279
|
+
height: bn(block2.height),
|
42040
42280
|
time: block2.header.time,
|
42041
42281
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42042
42282
|
};
|
@@ -42051,7 +42291,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42051
42291
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
42052
42292
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
42053
42293
|
id: block2.id,
|
42054
|
-
height: bn(block2.
|
42294
|
+
height: bn(block2.height),
|
42055
42295
|
time: block2.header.time,
|
42056
42296
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
42057
42297
|
}));
|
@@ -42078,7 +42318,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42078
42318
|
}
|
42079
42319
|
return {
|
42080
42320
|
id: block2.id,
|
42081
|
-
height: bn(block2.
|
42321
|
+
height: bn(block2.height, 10),
|
42082
42322
|
time: block2.header.time,
|
42083
42323
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
42084
42324
|
transactions: block2.transactions.map(
|
@@ -42258,8 +42498,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42258
42498
|
prevRoot: messageBlockHeader.prevRoot,
|
42259
42499
|
time: messageBlockHeader.time,
|
42260
42500
|
applicationHash: messageBlockHeader.applicationHash,
|
42261
|
-
|
42262
|
-
|
42501
|
+
messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
|
42502
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
42503
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
42504
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
42505
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
42263
42506
|
},
|
42264
42507
|
commitBlockHeader: {
|
42265
42508
|
id: commitBlockHeader.id,
|
@@ -42270,8 +42513,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42270
42513
|
prevRoot: commitBlockHeader.prevRoot,
|
42271
42514
|
time: commitBlockHeader.time,
|
42272
42515
|
applicationHash: commitBlockHeader.applicationHash,
|
42273
|
-
|
42274
|
-
|
42516
|
+
messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
|
42517
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
42518
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
42519
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
42520
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
42275
42521
|
},
|
42276
42522
|
sender: Address.fromAddressOrString(sender),
|
42277
42523
|
recipient: Address.fromAddressOrString(recipient),
|
@@ -42280,6 +42526,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42280
42526
|
data
|
42281
42527
|
};
|
42282
42528
|
}
|
42529
|
+
async getLatestGasPrice() {
|
42530
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
42531
|
+
return bn(latestGasPrice.gasPrice);
|
42532
|
+
}
|
42533
|
+
async estimateGasPrice(blockHorizon) {
|
42534
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
42535
|
+
blockHorizon: String(blockHorizon)
|
42536
|
+
});
|
42537
|
+
return bn(estimateGasPrice.gasPrice);
|
42538
|
+
}
|
42283
42539
|
/**
|
42284
42540
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
42285
42541
|
*
|
@@ -42340,10 +42596,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42340
42596
|
arrayify(gqlTransaction.rawPayload),
|
42341
42597
|
0
|
42342
42598
|
);
|
42343
|
-
|
42599
|
+
let txReceipts = [];
|
42600
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42601
|
+
txReceipts = gqlTransaction.status.receipts;
|
42602
|
+
}
|
42603
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42344
42604
|
const {
|
42345
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42605
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42346
42606
|
} = provider.getChain();
|
42607
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42347
42608
|
const transactionInfo = assembleTransactionSummary({
|
42348
42609
|
id: gqlTransaction.id,
|
42349
42610
|
receipts,
|
@@ -42354,7 +42615,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42354
42615
|
gasPriceFactor: bn(gasPriceFactor),
|
42355
42616
|
abiMap,
|
42356
42617
|
maxInputs,
|
42357
|
-
gasCosts
|
42618
|
+
gasCosts,
|
42619
|
+
maxGasPerTx,
|
42620
|
+
gasPrice
|
42358
42621
|
});
|
42359
42622
|
return {
|
42360
42623
|
gqlTransaction,
|
@@ -42364,10 +42627,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42364
42627
|
async function getTransactionSummaryFromRequest(params) {
|
42365
42628
|
const { provider, transactionRequest, abiMap } = params;
|
42366
42629
|
const { receipts } = await provider.call(transactionRequest);
|
42367
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
42630
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
42368
42631
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
42369
42632
|
const transaction = transactionRequest.toTransaction();
|
42370
42633
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
42634
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42371
42635
|
const transactionSummary = assembleTransactionSummary({
|
42372
42636
|
receipts,
|
42373
42637
|
transaction,
|
@@ -42376,7 +42640,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42376
42640
|
gasPerByte,
|
42377
42641
|
gasPriceFactor,
|
42378
42642
|
maxInputs,
|
42379
|
-
gasCosts
|
42643
|
+
gasCosts,
|
42644
|
+
maxGasPerTx,
|
42645
|
+
gasPrice
|
42380
42646
|
});
|
42381
42647
|
return transactionSummary;
|
42382
42648
|
}
|
@@ -42385,13 +42651,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42385
42651
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
42386
42652
|
const { edges, pageInfo } = transactionsByOwner;
|
42387
42653
|
const {
|
42388
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
42654
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
42389
42655
|
} = provider.getChain();
|
42656
|
+
const gasPrice = await provider.getLatestGasPrice();
|
42390
42657
|
const transactions = edges.map((edge) => {
|
42391
42658
|
const { node: gqlTransaction } = edge;
|
42392
|
-
const { id, rawPayload,
|
42659
|
+
const { id, rawPayload, status } = gqlTransaction;
|
42393
42660
|
const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
42394
|
-
|
42661
|
+
let txReceipts = [];
|
42662
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
42663
|
+
txReceipts = gqlTransaction.status.receipts;
|
42664
|
+
}
|
42665
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
42395
42666
|
const transactionSummary = assembleTransactionSummary({
|
42396
42667
|
id,
|
42397
42668
|
receipts,
|
@@ -42402,7 +42673,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42402
42673
|
gasPerByte,
|
42403
42674
|
gasPriceFactor,
|
42404
42675
|
maxInputs,
|
42405
|
-
gasCosts
|
42676
|
+
gasCosts,
|
42677
|
+
maxGasPerTx,
|
42678
|
+
gasPrice
|
42406
42679
|
});
|
42407
42680
|
const output3 = {
|
42408
42681
|
gqlTransaction,
|
@@ -42693,9 +42966,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42693
42966
|
* @param assetId - The asset ID to check the balance for.
|
42694
42967
|
* @returns A promise that resolves to the balance amount.
|
42695
42968
|
*/
|
42696
|
-
async getBalance(assetId) {
|
42697
|
-
const
|
42698
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42969
|
+
async getBalance(assetId = BaseAssetId) {
|
42970
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42699
42971
|
return amount;
|
42700
42972
|
}
|
42701
42973
|
/**
|
@@ -42732,37 +43004,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42732
43004
|
* @param fee - The estimated transaction fee.
|
42733
43005
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42734
43006
|
*/
|
42735
|
-
async fund(request,
|
42736
|
-
const
|
42737
|
-
const
|
43007
|
+
async fund(request, params) {
|
43008
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
43009
|
+
const txRequest = request;
|
43010
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
42738
43011
|
amount: bn(fee),
|
42739
|
-
assetId:
|
42740
|
-
coinQuantities
|
43012
|
+
assetId: BaseAssetId,
|
43013
|
+
coinQuantities: requiredQuantities
|
42741
43014
|
});
|
42742
43015
|
const quantitiesDict = {};
|
42743
|
-
|
43016
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
42744
43017
|
quantitiesDict[assetId] = {
|
42745
43018
|
required: amount,
|
42746
43019
|
owned: bn(0)
|
42747
43020
|
};
|
42748
43021
|
});
|
42749
|
-
|
42750
|
-
const cachedMessages = [];
|
42751
|
-
const owner = this.address.toB256();
|
42752
|
-
request.inputs.forEach((input) => {
|
43022
|
+
txRequest.inputs.forEach((input) => {
|
42753
43023
|
const isResource = "amount" in input;
|
42754
43024
|
if (isResource) {
|
42755
43025
|
const isCoin2 = "owner" in input;
|
42756
43026
|
if (isCoin2) {
|
42757
43027
|
const assetId = String(input.assetId);
|
42758
|
-
if (
|
43028
|
+
if (quantitiesDict[assetId]) {
|
42759
43029
|
const amount = bn(input.amount);
|
42760
43030
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42761
|
-
cachedUtxos.push(input.id);
|
42762
43031
|
}
|
42763
|
-
} else if (input.
|
42764
|
-
quantitiesDict[
|
42765
|
-
cachedMessages.push(input.nonce);
|
43032
|
+
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
43033
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42766
43034
|
}
|
42767
43035
|
}
|
42768
43036
|
});
|
@@ -42777,12 +43045,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42777
43045
|
});
|
42778
43046
|
const needsToBeFunded = missingQuantities.length;
|
42779
43047
|
if (needsToBeFunded) {
|
42780
|
-
const
|
42781
|
-
|
42782
|
-
|
42783
|
-
|
42784
|
-
|
43048
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
43049
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
43050
|
+
txRequest.addResources(resources);
|
43051
|
+
}
|
43052
|
+
txRequest.shiftPredicateData();
|
43053
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
43054
|
+
const requestToBeReEstimate = clone_default(txRequest);
|
43055
|
+
if (addedSignatures) {
|
43056
|
+
Array.from({ length: addedSignatures }).forEach(
|
43057
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
43058
|
+
);
|
42785
43059
|
}
|
43060
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
43061
|
+
transactionRequest: requestToBeReEstimate
|
43062
|
+
});
|
43063
|
+
txRequest.maxFee = maxFee;
|
43064
|
+
return txRequest;
|
42786
43065
|
}
|
42787
43066
|
/**
|
42788
43067
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -42790,30 +43069,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42790
43069
|
* @param destination - The address of the destination.
|
42791
43070
|
* @param amount - The amount of coins to transfer.
|
42792
43071
|
* @param assetId - The asset ID of the coins to transfer.
|
42793
|
-
* @param txParams - The transaction parameters (gasLimit,
|
43072
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
42794
43073
|
* @returns A promise that resolves to the prepared transaction request.
|
42795
43074
|
*/
|
42796
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42797
|
-
const
|
42798
|
-
|
42799
|
-
const
|
42800
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42801
|
-
const request = new ScriptTransactionRequest(params);
|
42802
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42803
|
-
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
43075
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
43076
|
+
const request = new ScriptTransactionRequest(txParams);
|
43077
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
43078
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
42804
43079
|
estimateTxDependencies: true,
|
42805
43080
|
resourcesOwner: this
|
42806
43081
|
});
|
42807
|
-
|
42808
|
-
|
42809
|
-
|
42810
|
-
|
42811
|
-
|
42812
|
-
|
42813
|
-
|
42814
|
-
|
42815
|
-
await this.fund(request,
|
42816
|
-
request.updatePredicateInputs(estimatedInputs);
|
43082
|
+
if ("gasLimit" in txParams) {
|
43083
|
+
this.validateGas({
|
43084
|
+
gasUsed: txCost.gasUsed,
|
43085
|
+
gasLimit: request.gasLimit
|
43086
|
+
});
|
43087
|
+
}
|
43088
|
+
request.gasLimit = txCost.gasUsed;
|
43089
|
+
request.maxFee = txCost.maxFee;
|
43090
|
+
await this.fund(request, txCost);
|
42817
43091
|
return request;
|
42818
43092
|
}
|
42819
43093
|
/**
|
@@ -42825,15 +43099,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42825
43099
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42826
43100
|
* @returns A promise that resolves to the transaction response.
|
42827
43101
|
*/
|
42828
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
43102
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42829
43103
|
if (bn(amount).lte(0)) {
|
42830
43104
|
throw new FuelError(
|
42831
43105
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42832
43106
|
"Transfer amount must be a positive number."
|
42833
43107
|
);
|
42834
43108
|
}
|
42835
|
-
const
|
42836
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
43109
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42837
43110
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42838
43111
|
}
|
42839
43112
|
/**
|
@@ -42845,7 +43118,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42845
43118
|
* @param txParams - The optional transaction parameters.
|
42846
43119
|
* @returns A promise that resolves to the transaction response.
|
42847
43120
|
*/
|
42848
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
43121
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42849
43122
|
if (bn(amount).lte(0)) {
|
42850
43123
|
throw new FuelError(
|
42851
43124
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42853,33 +43126,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42853
43126
|
);
|
42854
43127
|
}
|
42855
43128
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42856
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42857
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42858
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42859
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42860
43129
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42861
43130
|
hexlifiedContractId: contractAddress.toB256(),
|
42862
43131
|
amountToTransfer: bn(amount),
|
42863
|
-
assetId
|
43132
|
+
assetId
|
42864
43133
|
});
|
42865
43134
|
const request = new ScriptTransactionRequest({
|
42866
|
-
...
|
43135
|
+
...txParams,
|
42867
43136
|
script,
|
42868
43137
|
scriptData
|
42869
43138
|
});
|
42870
43139
|
request.addContractInputAndOutput(contractAddress);
|
42871
|
-
const
|
42872
|
-
|
42873
|
-
[{ amount: bn(amount), assetId: String(
|
42874
|
-
);
|
42875
|
-
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42876
|
-
this.validateGas({
|
42877
|
-
gasUsed,
|
42878
|
-
gasPrice: request.gasPrice,
|
42879
|
-
gasLimit: request.gasLimit,
|
42880
|
-
minGasPrice
|
43140
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
43141
|
+
resourcesOwner: this,
|
43142
|
+
quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
|
42881
43143
|
});
|
42882
|
-
|
43144
|
+
if (txParams.gasLimit) {
|
43145
|
+
this.validateGas({
|
43146
|
+
gasUsed: txCost.gasUsed,
|
43147
|
+
gasLimit: request.gasLimit
|
43148
|
+
});
|
43149
|
+
}
|
43150
|
+
request.gasLimit = txCost.gasUsed;
|
43151
|
+
request.maxFee = txCost.maxFee;
|
43152
|
+
await this.fund(request, txCost);
|
42883
43153
|
return this.sendTransaction(request);
|
42884
43154
|
}
|
42885
43155
|
/**
|
@@ -42891,8 +43161,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42891
43161
|
* @returns A promise that resolves to the transaction response.
|
42892
43162
|
*/
|
42893
43163
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42894
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
42895
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42896
43164
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42897
43165
|
const recipientDataArray = arrayify(
|
42898
43166
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42905,26 +43173,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42905
43173
|
...recipientDataArray,
|
42906
43174
|
...amountDataArray
|
42907
43175
|
]);
|
42908
|
-
const params = {
|
42909
|
-
script,
|
42910
|
-
gasPrice: minGasPrice,
|
42911
|
-
baseAssetId,
|
42912
|
-
...txParams
|
42913
|
-
};
|
43176
|
+
const params = { script, ...txParams };
|
42914
43177
|
const request = new ScriptTransactionRequest(params);
|
42915
|
-
const
|
42916
|
-
const
|
42917
|
-
|
42918
|
-
|
42919
|
-
|
42920
|
-
|
42921
|
-
|
42922
|
-
|
42923
|
-
|
42924
|
-
|
42925
|
-
|
42926
|
-
});
|
42927
|
-
await this.fund(request, requiredQuantities, maxFee);
|
43178
|
+
const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
|
43179
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
43180
|
+
if (txParams.gasLimit) {
|
43181
|
+
this.validateGas({
|
43182
|
+
gasUsed: txCost.gasUsed,
|
43183
|
+
gasLimit: request.gasLimit
|
43184
|
+
});
|
43185
|
+
}
|
43186
|
+
request.maxFee = txCost.maxFee;
|
43187
|
+
request.gasLimit = txCost.gasUsed;
|
43188
|
+
await this.fund(request, txCost);
|
42928
43189
|
return this.sendTransaction(request);
|
42929
43190
|
}
|
42930
43191
|
async signMessage(message) {
|
@@ -42982,18 +43243,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42982
43243
|
}
|
42983
43244
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
42984
43245
|
}
|
42985
|
-
validateGas({
|
42986
|
-
gasUsed,
|
42987
|
-
gasPrice,
|
42988
|
-
gasLimit,
|
42989
|
-
minGasPrice
|
42990
|
-
}) {
|
42991
|
-
if (minGasPrice.gt(gasPrice)) {
|
42992
|
-
throw new FuelError(
|
42993
|
-
ErrorCode.GAS_PRICE_TOO_LOW,
|
42994
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
42995
|
-
);
|
42996
|
-
}
|
43246
|
+
validateGas({ gasUsed, gasLimit }) {
|
42997
43247
|
if (gasUsed.gt(gasLimit)) {
|
42998
43248
|
throw new FuelError(
|
42999
43249
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -44376,12 +44626,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44376
44626
|
};
|
44377
44627
|
|
44378
44628
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44379
|
-
var
|
44629
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44380
44630
|
var rnds8Pool = new Uint8Array(256);
|
44381
44631
|
var poolPtr = rnds8Pool.length;
|
44382
44632
|
function rng() {
|
44383
44633
|
if (poolPtr > rnds8Pool.length - 16) {
|
44384
|
-
|
44634
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44385
44635
|
poolPtr = 0;
|
44386
44636
|
}
|
44387
44637
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44397,9 +44647,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44397
44647
|
}
|
44398
44648
|
|
44399
44649
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44400
|
-
var
|
44650
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44401
44651
|
var native_default = {
|
44402
|
-
randomUUID:
|
44652
|
+
randomUUID: import_crypto17.default.randomUUID
|
44403
44653
|
};
|
44404
44654
|
|
44405
44655
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -44582,7 +44832,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44582
44832
|
* @param transactionRequestLike - The transaction request to send.
|
44583
44833
|
* @returns A promise that resolves to the TransactionResponse object.
|
44584
44834
|
*/
|
44585
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
44835
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
44586
44836
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
44587
44837
|
if (estimateTxDependencies) {
|
44588
44838
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -47860,8 +48110,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47860
48110
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47861
48111
|
request.inputs?.forEach((input) => {
|
47862
48112
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47863
|
-
input.predicate = this.bytes;
|
47864
|
-
input.predicateData = this.getPredicateData(policies.length);
|
48113
|
+
input.predicate = hexlify(this.bytes);
|
48114
|
+
input.predicateData = hexlify(this.getPredicateData(policies.length));
|
47865
48115
|
}
|
47866
48116
|
});
|
47867
48117
|
return request;
|
@@ -47875,10 +48125,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47875
48125
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47876
48126
|
* @returns A promise that resolves to the prepared transaction request.
|
47877
48127
|
*/
|
47878
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47879
|
-
|
47880
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47881
|
-
return this.populateTransactionPredicateData(request);
|
48128
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
48129
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
47882
48130
|
}
|
47883
48131
|
/**
|
47884
48132
|
* Sends a transaction with the populated predicate data.
|
@@ -47886,9 +48134,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47886
48134
|
* @param transactionRequestLike - The transaction request-like object.
|
47887
48135
|
* @returns A promise that resolves to the transaction response.
|
47888
48136
|
*/
|
47889
|
-
sendTransaction(transactionRequestLike
|
47890
|
-
const transactionRequest =
|
47891
|
-
return super.sendTransaction(transactionRequest,
|
48137
|
+
sendTransaction(transactionRequestLike) {
|
48138
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48139
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
47892
48140
|
}
|
47893
48141
|
/**
|
47894
48142
|
* Simulates a transaction with the populated predicate data.
|
@@ -47897,8 +48145,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47897
48145
|
* @returns A promise that resolves to the call result.
|
47898
48146
|
*/
|
47899
48147
|
simulateTransaction(transactionRequestLike) {
|
47900
|
-
const transactionRequest =
|
47901
|
-
return super.simulateTransaction(transactionRequest);
|
48148
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
48149
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
47902
48150
|
}
|
47903
48151
|
getPredicateData(policiesLength) {
|
47904
48152
|
if (!this.predicateData.length) {
|
@@ -47944,6 +48192,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47944
48192
|
predicateInterface: abiInterface
|
47945
48193
|
};
|
47946
48194
|
}
|
48195
|
+
/**
|
48196
|
+
* Retrieves resources satisfying the spend query for the account.
|
48197
|
+
*
|
48198
|
+
* @param quantities - IDs of coins to exclude.
|
48199
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
48200
|
+
* @returns A promise that resolves to an array of Resources.
|
48201
|
+
*/
|
48202
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
48203
|
+
const resources = await this.provider.getResourcesToSpend(
|
48204
|
+
this.address,
|
48205
|
+
quantities,
|
48206
|
+
excludedIds
|
48207
|
+
);
|
48208
|
+
return resources.map((resource) => ({
|
48209
|
+
...resource,
|
48210
|
+
predicate: hexlify(this.bytes),
|
48211
|
+
paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
48212
|
+
}));
|
48213
|
+
}
|
47947
48214
|
/**
|
47948
48215
|
* Sets the configurable constants for the predicate.
|
47949
48216
|
*
|