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