@fuel-ts/account 0.0.0-rc-1976-20240404073406 → 0.0.0-rc-1764-20240404125616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +912 -544
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1032 -714
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +909 -587
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +822 -303
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +3 -3
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +3 -0
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +44 -31
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +9 -29
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +36 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +871 -540
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +944 -671
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +832 -551
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
@@ -280,7 +280,7 @@
|
|
280
280
|
}
|
281
281
|
return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
|
282
282
|
};
|
283
|
-
BN2.max = function
|
283
|
+
BN2.max = function max(left, right) {
|
284
284
|
if (left.cmp(right) > 0)
|
285
285
|
return left;
|
286
286
|
return right;
|
@@ -5104,7 +5104,7 @@
|
|
5104
5104
|
function isBlob(obj) {
|
5105
5105
|
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]);
|
5106
5106
|
}
|
5107
|
-
function
|
5107
|
+
function clone3(instance) {
|
5108
5108
|
let p1, p2;
|
5109
5109
|
let body = instance.body;
|
5110
5110
|
if (instance.bodyUsed) {
|
@@ -6038,7 +6038,7 @@
|
|
6038
6038
|
* @return Response
|
6039
6039
|
*/
|
6040
6040
|
clone() {
|
6041
|
-
return new Response2(
|
6041
|
+
return new Response2(clone3(this), {
|
6042
6042
|
url: this.url,
|
6043
6043
|
status: this.status,
|
6044
6044
|
statusText: this.statusText,
|
@@ -6088,7 +6088,7 @@
|
|
6088
6088
|
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
6089
6089
|
throw new TypeError("Request with GET/HEAD method cannot have body");
|
6090
6090
|
}
|
6091
|
-
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ?
|
6091
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
|
6092
6092
|
Body.call(this, inputBody, {
|
6093
6093
|
timeout: init.timeout || input.timeout || 0,
|
6094
6094
|
size: init.size || input.size || 0
|
@@ -31914,8 +31914,8 @@ spurious results.`);
|
|
31914
31914
|
// ../versions/dist/index.mjs
|
31915
31915
|
function getBuiltinVersions() {
|
31916
31916
|
return {
|
31917
|
-
FORC: "0.
|
31918
|
-
FUEL_CORE: "0.
|
31917
|
+
FORC: "0.51.1",
|
31918
|
+
FUEL_CORE: "0.23.0",
|
31919
31919
|
FUELS: "0.79.0"
|
31920
31920
|
};
|
31921
31921
|
}
|
@@ -32045,6 +32045,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32045
32045
|
})(ErrorCode || {});
|
32046
32046
|
var _FuelError = class extends Error {
|
32047
32047
|
VERSIONS = versions;
|
32048
|
+
metadata;
|
32048
32049
|
static parse(e) {
|
32049
32050
|
const error = e;
|
32050
32051
|
if (error.code === void 0) {
|
@@ -32064,14 +32065,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32064
32065
|
return new _FuelError(error.code, error.message);
|
32065
32066
|
}
|
32066
32067
|
code;
|
32067
|
-
constructor(code, message) {
|
32068
|
+
constructor(code, message, metadata = {}) {
|
32068
32069
|
super(message);
|
32069
32070
|
this.code = code;
|
32070
32071
|
this.name = "FuelError";
|
32072
|
+
this.metadata = metadata;
|
32071
32073
|
}
|
32072
32074
|
toObject() {
|
32073
|
-
const { code, name, message, VERSIONS } = this;
|
32074
|
-
return { code, name, message, VERSIONS };
|
32075
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
32076
|
+
return { code, name, message, metadata, VERSIONS };
|
32075
32077
|
}
|
32076
32078
|
};
|
32077
32079
|
var FuelError = _FuelError;
|
@@ -32483,8 +32485,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32483
32485
|
fee_params: {
|
32484
32486
|
gas_price_factor: 92,
|
32485
32487
|
gas_per_byte: 4
|
32486
|
-
}
|
32487
|
-
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32488
|
+
}
|
32488
32489
|
},
|
32489
32490
|
gas_costs: {
|
32490
32491
|
add: 1,
|
@@ -32708,7 +32709,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32708
32709
|
var defaultConsensusKey = "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298";
|
32709
32710
|
|
32710
32711
|
// ../crypto/dist/index.mjs
|
32711
|
-
var
|
32712
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
32712
32713
|
|
32713
32714
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
32714
32715
|
var version = "6.7.1";
|
@@ -33780,6 +33781,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33780
33781
|
};
|
33781
33782
|
Object.freeze(pbkdf22);
|
33782
33783
|
|
33784
|
+
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
33785
|
+
var locked5 = false;
|
33786
|
+
var _randomBytes = function(length) {
|
33787
|
+
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
33788
|
+
};
|
33789
|
+
var __randomBytes = _randomBytes;
|
33790
|
+
function randomBytes3(length) {
|
33791
|
+
return __randomBytes(length);
|
33792
|
+
}
|
33793
|
+
randomBytes3._ = _randomBytes;
|
33794
|
+
randomBytes3.lock = function() {
|
33795
|
+
locked5 = true;
|
33796
|
+
};
|
33797
|
+
randomBytes3.register = function(func) {
|
33798
|
+
if (locked5) {
|
33799
|
+
throw new Error("randomBytes is locked");
|
33800
|
+
}
|
33801
|
+
__randomBytes = func;
|
33802
|
+
};
|
33803
|
+
Object.freeze(randomBytes3);
|
33804
|
+
|
33783
33805
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
33784
33806
|
var BN_03 = BigInt(0);
|
33785
33807
|
var BN_36 = BigInt(36);
|
@@ -34364,8 +34386,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34364
34386
|
}
|
34365
34387
|
|
34366
34388
|
// ../crypto/dist/index.mjs
|
34367
|
-
var import_crypto9 = __toESM(__require("crypto"), 1);
|
34368
34389
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
34390
|
+
var import_crypto11 = __toESM(__require("crypto"), 1);
|
34369
34391
|
var scrypt3 = (params) => {
|
34370
34392
|
const { password, salt, n, p, r, dklen } = params;
|
34371
34393
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -34374,7 +34396,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34374
34396
|
var keccak2562 = (data) => keccak_256(data);
|
34375
34397
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
34376
34398
|
var randomBytes4 = (length) => {
|
34377
|
-
const randomValues = Uint8Array.from(
|
34399
|
+
const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
|
34378
34400
|
return randomValues;
|
34379
34401
|
};
|
34380
34402
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -34389,7 +34411,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34389
34411
|
const salt = randomBytes4(32);
|
34390
34412
|
const secret = keyFromPassword(password, salt);
|
34391
34413
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
34392
|
-
const cipher = await
|
34414
|
+
const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
|
34393
34415
|
let cipherData = cipher.update(dataBuffer);
|
34394
34416
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
34395
34417
|
return {
|
@@ -34403,7 +34425,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34403
34425
|
const salt = bufferFromString(keystore.salt);
|
34404
34426
|
const secret = keyFromPassword(password, salt);
|
34405
34427
|
const encryptedText = bufferFromString(keystore.data);
|
34406
|
-
const decipher = await
|
34428
|
+
const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
|
34407
34429
|
const decrypted = decipher.update(encryptedText);
|
34408
34430
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
34409
34431
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -34414,12 +34436,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34414
34436
|
}
|
34415
34437
|
};
|
34416
34438
|
async function encryptJsonWalletData(data, key, iv) {
|
34417
|
-
const cipher = await
|
34439
|
+
const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34418
34440
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
34419
34441
|
return new Uint8Array(encrypted);
|
34420
34442
|
}
|
34421
34443
|
async function decryptJsonWalletData(data, key, iv) {
|
34422
|
-
const decipher =
|
34444
|
+
const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34423
34445
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
34424
34446
|
return new Uint8Array(decrypted);
|
34425
34447
|
}
|
@@ -34753,6 +34775,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34753
34775
|
}
|
34754
34776
|
};
|
34755
34777
|
|
34778
|
+
// ../address/dist/configs.mjs
|
34779
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34780
|
+
var BaseAssetId = ZeroBytes32;
|
34781
|
+
|
34756
34782
|
// ../math/dist/index.mjs
|
34757
34783
|
var import_bn = __toESM(require_bn(), 1);
|
34758
34784
|
var DEFAULT_PRECISION = 9;
|
@@ -34972,32 +34998,182 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34972
34998
|
function toBytes3(value, bytesPadding) {
|
34973
34999
|
return bn(value).toBytes(bytesPadding);
|
34974
35000
|
}
|
34975
|
-
|
34976
|
-
|
35001
|
+
|
35002
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
35003
|
+
function _isPlaceholder(a) {
|
35004
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
35005
|
+
}
|
35006
|
+
|
35007
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
35008
|
+
function _curry1(fn) {
|
35009
|
+
return function f1(a) {
|
35010
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
35011
|
+
return f1;
|
35012
|
+
} else {
|
35013
|
+
return fn.apply(this, arguments);
|
35014
|
+
}
|
35015
|
+
};
|
35016
|
+
}
|
35017
|
+
|
35018
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
35019
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
35020
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
35021
|
+
};
|
35022
|
+
|
35023
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
35024
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
35025
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
35026
|
+
});
|
35027
|
+
var type_default = type;
|
35028
|
+
|
35029
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
35030
|
+
var pad = function pad2(n) {
|
35031
|
+
return (n < 10 ? "0" : "") + n;
|
35032
|
+
};
|
35033
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
35034
|
+
return d.toISOString();
|
35035
|
+
} : function _toISOString3(d) {
|
35036
|
+
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";
|
35037
|
+
};
|
35038
|
+
|
35039
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
35040
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
35041
|
+
return n << 0 === n;
|
35042
|
+
};
|
35043
|
+
|
35044
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
35045
|
+
function _cloneRegExp(pattern) {
|
35046
|
+
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" : ""));
|
35047
|
+
}
|
35048
|
+
|
35049
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
35050
|
+
function _clone(value, deep, map) {
|
35051
|
+
map || (map = new _ObjectMap());
|
35052
|
+
if (_isPrimitive(value)) {
|
35053
|
+
return value;
|
35054
|
+
}
|
35055
|
+
var copy = function copy2(copiedValue) {
|
35056
|
+
var cachedCopy = map.get(value);
|
35057
|
+
if (cachedCopy) {
|
35058
|
+
return cachedCopy;
|
35059
|
+
}
|
35060
|
+
map.set(value, copiedValue);
|
35061
|
+
for (var key in value) {
|
35062
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
35063
|
+
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
35064
|
+
}
|
35065
|
+
}
|
35066
|
+
return copiedValue;
|
35067
|
+
};
|
35068
|
+
switch (type_default(value)) {
|
35069
|
+
case "Object":
|
35070
|
+
return copy(Object.create(Object.getPrototypeOf(value)));
|
35071
|
+
case "Array":
|
35072
|
+
return copy([]);
|
35073
|
+
case "Date":
|
35074
|
+
return new Date(value.valueOf());
|
35075
|
+
case "RegExp":
|
35076
|
+
return _cloneRegExp(value);
|
35077
|
+
case "Int8Array":
|
35078
|
+
case "Uint8Array":
|
35079
|
+
case "Uint8ClampedArray":
|
35080
|
+
case "Int16Array":
|
35081
|
+
case "Uint16Array":
|
35082
|
+
case "Int32Array":
|
35083
|
+
case "Uint32Array":
|
35084
|
+
case "Float32Array":
|
35085
|
+
case "Float64Array":
|
35086
|
+
case "BigInt64Array":
|
35087
|
+
case "BigUint64Array":
|
35088
|
+
return value.slice();
|
35089
|
+
default:
|
35090
|
+
return value;
|
35091
|
+
}
|
35092
|
+
}
|
35093
|
+
function _isPrimitive(param) {
|
35094
|
+
var type3 = typeof param;
|
35095
|
+
return param == null || type3 != "object" && type3 != "function";
|
34977
35096
|
}
|
35097
|
+
var _ObjectMap = /* @__PURE__ */ function() {
|
35098
|
+
function _ObjectMap2() {
|
35099
|
+
this.map = {};
|
35100
|
+
this.length = 0;
|
35101
|
+
}
|
35102
|
+
_ObjectMap2.prototype.set = function(key, value) {
|
35103
|
+
const hashedKey = this.hash(key);
|
35104
|
+
let bucket = this.map[hashedKey];
|
35105
|
+
if (!bucket) {
|
35106
|
+
this.map[hashedKey] = bucket = [];
|
35107
|
+
}
|
35108
|
+
bucket.push([key, value]);
|
35109
|
+
this.length += 1;
|
35110
|
+
};
|
35111
|
+
_ObjectMap2.prototype.hash = function(key) {
|
35112
|
+
let hashedKey = [];
|
35113
|
+
for (var value in key) {
|
35114
|
+
hashedKey.push(Object.prototype.toString.call(key[value]));
|
35115
|
+
}
|
35116
|
+
return hashedKey.join();
|
35117
|
+
};
|
35118
|
+
_ObjectMap2.prototype.get = function(key) {
|
35119
|
+
if (this.length <= 180) {
|
35120
|
+
for (const p in this.map) {
|
35121
|
+
const bucket2 = this.map[p];
|
35122
|
+
for (let i = 0; i < bucket2.length; i += 1) {
|
35123
|
+
const element = bucket2[i];
|
35124
|
+
if (element[0] === key) {
|
35125
|
+
return element[1];
|
35126
|
+
}
|
35127
|
+
}
|
35128
|
+
}
|
35129
|
+
return;
|
35130
|
+
}
|
35131
|
+
const hashedKey = this.hash(key);
|
35132
|
+
const bucket = this.map[hashedKey];
|
35133
|
+
if (!bucket) {
|
35134
|
+
return;
|
35135
|
+
}
|
35136
|
+
for (let i = 0; i < bucket.length; i += 1) {
|
35137
|
+
const element = bucket[i];
|
35138
|
+
if (element[0] === key) {
|
35139
|
+
return element[1];
|
35140
|
+
}
|
35141
|
+
}
|
35142
|
+
};
|
35143
|
+
return _ObjectMap2;
|
35144
|
+
}();
|
35145
|
+
|
35146
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
35147
|
+
var clone = /* @__PURE__ */ _curry1(function clone2(value) {
|
35148
|
+
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
35149
|
+
});
|
35150
|
+
var clone_default = clone;
|
35151
|
+
|
35152
|
+
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
35153
|
+
var hasProtoTrim = typeof String.prototype.trim === "function";
|
34978
35154
|
|
34979
35155
|
// src/providers/coin-quantity.ts
|
34980
35156
|
var coinQuantityfy = (coinQuantityLike) => {
|
34981
35157
|
let assetId;
|
34982
35158
|
let amount;
|
34983
|
-
let
|
35159
|
+
let max;
|
34984
35160
|
if (Array.isArray(coinQuantityLike)) {
|
34985
35161
|
amount = coinQuantityLike[0];
|
34986
|
-
assetId = coinQuantityLike[1];
|
34987
|
-
|
35162
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
35163
|
+
max = coinQuantityLike[2] ?? void 0;
|
34988
35164
|
} else {
|
34989
35165
|
amount = coinQuantityLike.amount;
|
34990
|
-
assetId = coinQuantityLike.assetId;
|
34991
|
-
|
35166
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
35167
|
+
max = coinQuantityLike.max ?? void 0;
|
34992
35168
|
}
|
34993
35169
|
const bnAmount = bn(amount);
|
34994
35170
|
return {
|
34995
35171
|
assetId: hexlify(assetId),
|
34996
35172
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
34997
|
-
max:
|
35173
|
+
max: max ? bn(max) : void 0
|
34998
35174
|
};
|
34999
35175
|
};
|
35000
|
-
var
|
35176
|
+
var addAmountToCoinQuantities = (params) => {
|
35001
35177
|
const { amount, assetId } = params;
|
35002
35178
|
const coinQuantities = [...params.coinQuantities];
|
35003
35179
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -35091,7 +35267,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35091
35267
|
ASSET_ID_LEN + // Asset id
|
35092
35268
|
TX_POINTER_LEN + // TxPointer
|
35093
35269
|
WORD_SIZE + // Witnesses index
|
35094
|
-
WORD_SIZE + // Maturity
|
35095
35270
|
WORD_SIZE + // Predicate size
|
35096
35271
|
WORD_SIZE + // Predicate data size
|
35097
35272
|
WORD_SIZE;
|
@@ -35424,7 +35599,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35424
35599
|
constructor(name, coders) {
|
35425
35600
|
const caseIndexCoder = new BigNumberCoder("u64");
|
35426
35601
|
const encodedValueSize = Object.values(coders).reduce(
|
35427
|
-
(
|
35602
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
35428
35603
|
0
|
35429
35604
|
);
|
35430
35605
|
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -36114,7 +36289,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36114
36289
|
constructor(name, coders) {
|
36115
36290
|
const caseIndexCoder = new BigNumberCoder("u64");
|
36116
36291
|
const encodedValueSize = Object.values(coders).reduce(
|
36117
|
-
(
|
36292
|
+
(max, coder) => Math.max(max, coder.encodedLength),
|
36118
36293
|
0
|
36119
36294
|
);
|
36120
36295
|
super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
@@ -36791,7 +36966,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36791
36966
|
parts.push(new B256Coder().encode(value.assetId));
|
36792
36967
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
36793
36968
|
parts.push(new NumberCoder("u8").encode(value.witnessIndex));
|
36794
|
-
parts.push(new NumberCoder("u32").encode(value.maturity));
|
36795
36969
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
36796
36970
|
parts.push(new NumberCoder("u32").encode(value.predicateLength));
|
36797
36971
|
parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
|
@@ -36816,8 +36990,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36816
36990
|
const txPointer = decoded;
|
36817
36991
|
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
36818
36992
|
const witnessIndex = Number(decoded);
|
36819
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
36820
|
-
const maturity = decoded;
|
36821
36993
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
36822
36994
|
const predicateGasUsed = decoded;
|
36823
36995
|
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
@@ -36838,7 +37010,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36838
37010
|
assetId,
|
36839
37011
|
txPointer,
|
36840
37012
|
witnessIndex,
|
36841
|
-
maturity,
|
36842
37013
|
predicateGasUsed,
|
36843
37014
|
predicateLength,
|
36844
37015
|
predicateDataLength,
|
@@ -37270,7 +37441,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37270
37441
|
}
|
37271
37442
|
};
|
37272
37443
|
var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
|
37273
|
-
PolicyType2[PolicyType2["
|
37444
|
+
PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
|
37274
37445
|
PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
|
37275
37446
|
PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
|
37276
37447
|
PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
|
@@ -37318,9 +37489,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37318
37489
|
let o = offset;
|
37319
37490
|
const policies = [];
|
37320
37491
|
if (policyTypes & 1) {
|
37321
|
-
const [
|
37492
|
+
const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
37322
37493
|
o = nextOffset;
|
37323
|
-
policies.push({ type: 1, data:
|
37494
|
+
policies.push({ type: 1, data: tip });
|
37324
37495
|
}
|
37325
37496
|
if (policyTypes & 2) {
|
37326
37497
|
const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
|
@@ -38033,159 +38204,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
38033
38204
|
// src/providers/provider.ts
|
38034
38205
|
var import_graphql_request = __toESM(require_dist2());
|
38035
38206
|
|
38036
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
|
38037
|
-
function _isPlaceholder(a) {
|
38038
|
-
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
38039
|
-
}
|
38040
|
-
|
38041
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
|
38042
|
-
function _curry1(fn) {
|
38043
|
-
return function f1(a) {
|
38044
|
-
if (arguments.length === 0 || _isPlaceholder(a)) {
|
38045
|
-
return f1;
|
38046
|
-
} else {
|
38047
|
-
return fn.apply(this, arguments);
|
38048
|
-
}
|
38049
|
-
};
|
38050
|
-
}
|
38051
|
-
|
38052
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
|
38053
|
-
var isArray_default = Array.isArray || function _isArray(val) {
|
38054
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
38055
|
-
};
|
38056
|
-
|
38057
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
|
38058
|
-
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
38059
|
-
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
38060
|
-
});
|
38061
|
-
var type_default = type;
|
38062
|
-
|
38063
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
|
38064
|
-
var pad = function pad2(n) {
|
38065
|
-
return (n < 10 ? "0" : "") + n;
|
38066
|
-
};
|
38067
|
-
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
38068
|
-
return d.toISOString();
|
38069
|
-
} : function _toISOString3(d) {
|
38070
|
-
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";
|
38071
|
-
};
|
38072
|
-
|
38073
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
|
38074
|
-
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
38075
|
-
return n << 0 === n;
|
38076
|
-
};
|
38077
|
-
|
38078
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
|
38079
|
-
function _cloneRegExp(pattern) {
|
38080
|
-
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" : ""));
|
38081
|
-
}
|
38082
|
-
|
38083
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
|
38084
|
-
function _clone(value, deep, map) {
|
38085
|
-
map || (map = new _ObjectMap());
|
38086
|
-
if (_isPrimitive(value)) {
|
38087
|
-
return value;
|
38088
|
-
}
|
38089
|
-
var copy = function copy2(copiedValue) {
|
38090
|
-
var cachedCopy = map.get(value);
|
38091
|
-
if (cachedCopy) {
|
38092
|
-
return cachedCopy;
|
38093
|
-
}
|
38094
|
-
map.set(value, copiedValue);
|
38095
|
-
for (var key in value) {
|
38096
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
38097
|
-
copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
|
38098
|
-
}
|
38099
|
-
}
|
38100
|
-
return copiedValue;
|
38101
|
-
};
|
38102
|
-
switch (type_default(value)) {
|
38103
|
-
case "Object":
|
38104
|
-
return copy(Object.create(Object.getPrototypeOf(value)));
|
38105
|
-
case "Array":
|
38106
|
-
return copy([]);
|
38107
|
-
case "Date":
|
38108
|
-
return new Date(value.valueOf());
|
38109
|
-
case "RegExp":
|
38110
|
-
return _cloneRegExp(value);
|
38111
|
-
case "Int8Array":
|
38112
|
-
case "Uint8Array":
|
38113
|
-
case "Uint8ClampedArray":
|
38114
|
-
case "Int16Array":
|
38115
|
-
case "Uint16Array":
|
38116
|
-
case "Int32Array":
|
38117
|
-
case "Uint32Array":
|
38118
|
-
case "Float32Array":
|
38119
|
-
case "Float64Array":
|
38120
|
-
case "BigInt64Array":
|
38121
|
-
case "BigUint64Array":
|
38122
|
-
return value.slice();
|
38123
|
-
default:
|
38124
|
-
return value;
|
38125
|
-
}
|
38126
|
-
}
|
38127
|
-
function _isPrimitive(param) {
|
38128
|
-
var type3 = typeof param;
|
38129
|
-
return param == null || type3 != "object" && type3 != "function";
|
38130
|
-
}
|
38131
|
-
var _ObjectMap = /* @__PURE__ */ function() {
|
38132
|
-
function _ObjectMap2() {
|
38133
|
-
this.map = {};
|
38134
|
-
this.length = 0;
|
38135
|
-
}
|
38136
|
-
_ObjectMap2.prototype.set = function(key, value) {
|
38137
|
-
const hashedKey = this.hash(key);
|
38138
|
-
let bucket = this.map[hashedKey];
|
38139
|
-
if (!bucket) {
|
38140
|
-
this.map[hashedKey] = bucket = [];
|
38141
|
-
}
|
38142
|
-
bucket.push([key, value]);
|
38143
|
-
this.length += 1;
|
38144
|
-
};
|
38145
|
-
_ObjectMap2.prototype.hash = function(key) {
|
38146
|
-
let hashedKey = [];
|
38147
|
-
for (var value in key) {
|
38148
|
-
hashedKey.push(Object.prototype.toString.call(key[value]));
|
38149
|
-
}
|
38150
|
-
return hashedKey.join();
|
38151
|
-
};
|
38152
|
-
_ObjectMap2.prototype.get = function(key) {
|
38153
|
-
if (this.length <= 180) {
|
38154
|
-
for (const p in this.map) {
|
38155
|
-
const bucket2 = this.map[p];
|
38156
|
-
for (let i = 0; i < bucket2.length; i += 1) {
|
38157
|
-
const element = bucket2[i];
|
38158
|
-
if (element[0] === key) {
|
38159
|
-
return element[1];
|
38160
|
-
}
|
38161
|
-
}
|
38162
|
-
}
|
38163
|
-
return;
|
38164
|
-
}
|
38165
|
-
const hashedKey = this.hash(key);
|
38166
|
-
const bucket = this.map[hashedKey];
|
38167
|
-
if (!bucket) {
|
38168
|
-
return;
|
38169
|
-
}
|
38170
|
-
for (let i = 0; i < bucket.length; i += 1) {
|
38171
|
-
const element = bucket[i];
|
38172
|
-
if (element[0] === key) {
|
38173
|
-
return element[1];
|
38174
|
-
}
|
38175
|
-
}
|
38176
|
-
};
|
38177
|
-
return _ObjectMap2;
|
38178
|
-
}();
|
38179
|
-
|
38180
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
|
38181
|
-
var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
|
38182
|
-
return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
|
38183
|
-
});
|
38184
|
-
var clone_default = clone2;
|
38185
|
-
|
38186
|
-
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
|
38187
|
-
var hasProtoTrim = typeof String.prototype.trim === "function";
|
38188
|
-
|
38189
38207
|
// ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
|
38190
38208
|
var __assign = function() {
|
38191
38209
|
__assign = Object.assign || function __assign2(t) {
|
@@ -41353,14 +41371,10 @@ spurious results.`);
|
|
41353
41371
|
// src/providers/__generated__/operations.ts
|
41354
41372
|
var ReceiptFragmentFragmentDoc = lib_default2`
|
41355
41373
|
fragment receiptFragment on Receipt {
|
41356
|
-
|
41357
|
-
id
|
41358
|
-
}
|
41374
|
+
id
|
41359
41375
|
pc
|
41360
41376
|
is
|
41361
|
-
to
|
41362
|
-
id
|
41363
|
-
}
|
41377
|
+
to
|
41364
41378
|
toAddress
|
41365
41379
|
amount
|
41366
41380
|
assetId
|
@@ -41398,10 +41412,16 @@ spurious results.`);
|
|
41398
41412
|
id
|
41399
41413
|
}
|
41400
41414
|
time
|
41415
|
+
receipts {
|
41416
|
+
...receiptFragment
|
41417
|
+
}
|
41401
41418
|
programState {
|
41402
41419
|
returnType
|
41403
41420
|
data
|
41404
41421
|
}
|
41422
|
+
receipts {
|
41423
|
+
...receiptFragment
|
41424
|
+
}
|
41405
41425
|
}
|
41406
41426
|
... on FailureStatus {
|
41407
41427
|
block {
|
@@ -41409,26 +41429,24 @@ spurious results.`);
|
|
41409
41429
|
}
|
41410
41430
|
time
|
41411
41431
|
reason
|
41432
|
+
receipts {
|
41433
|
+
...receiptFragment
|
41434
|
+
}
|
41412
41435
|
}
|
41413
41436
|
... on SqueezedOutStatus {
|
41414
41437
|
reason
|
41415
41438
|
}
|
41416
41439
|
}
|
41417
|
-
`;
|
41440
|
+
${ReceiptFragmentFragmentDoc}`;
|
41418
41441
|
var TransactionFragmentFragmentDoc = lib_default2`
|
41419
41442
|
fragment transactionFragment on Transaction {
|
41420
41443
|
id
|
41421
41444
|
rawPayload
|
41422
|
-
gasPrice
|
41423
|
-
receipts {
|
41424
|
-
...receiptFragment
|
41425
|
-
}
|
41426
41445
|
status {
|
41427
41446
|
...transactionStatusFragment
|
41428
41447
|
}
|
41429
41448
|
}
|
41430
|
-
${
|
41431
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
41449
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
41432
41450
|
var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
|
41433
41451
|
fragment inputEstimatePredicatesFragment on Input {
|
41434
41452
|
... on InputCoin {
|
@@ -41446,6 +41464,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
41446
41464
|
}
|
41447
41465
|
}
|
41448
41466
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
41467
|
+
var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
|
41468
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
41469
|
+
reason
|
41470
|
+
programState {
|
41471
|
+
returnType
|
41472
|
+
data
|
41473
|
+
}
|
41474
|
+
}
|
41475
|
+
`;
|
41476
|
+
var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
|
41477
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
41478
|
+
programState {
|
41479
|
+
returnType
|
41480
|
+
data
|
41481
|
+
}
|
41482
|
+
}
|
41483
|
+
`;
|
41484
|
+
var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
|
41485
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
41486
|
+
... on DryRunFailureStatus {
|
41487
|
+
...dryRunFailureStatusFragment
|
41488
|
+
}
|
41489
|
+
... on DryRunSuccessStatus {
|
41490
|
+
...dryRunSuccessStatusFragment
|
41491
|
+
}
|
41492
|
+
}
|
41493
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
41494
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
41495
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
|
41496
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
41497
|
+
id
|
41498
|
+
status {
|
41499
|
+
...dryRunTransactionStatusFragment
|
41500
|
+
}
|
41501
|
+
receipts {
|
41502
|
+
...receiptFragment
|
41503
|
+
}
|
41504
|
+
}
|
41505
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
41506
|
+
${ReceiptFragmentFragmentDoc}`;
|
41449
41507
|
var CoinFragmentFragmentDoc = lib_default2`
|
41450
41508
|
fragment coinFragment on Coin {
|
41451
41509
|
__typename
|
@@ -41453,7 +41511,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
41453
41511
|
owner
|
41454
41512
|
amount
|
41455
41513
|
assetId
|
41456
|
-
maturity
|
41457
41514
|
blockCreated
|
41458
41515
|
txCreatedIdx
|
41459
41516
|
}
|
@@ -41530,8 +41587,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
41530
41587
|
var BlockFragmentFragmentDoc = lib_default2`
|
41531
41588
|
fragment blockFragment on Block {
|
41532
41589
|
id
|
41590
|
+
height
|
41533
41591
|
header {
|
41534
|
-
height
|
41535
41592
|
time
|
41536
41593
|
}
|
41537
41594
|
transactions {
|
@@ -41601,7 +41658,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
41601
41658
|
cb
|
41602
41659
|
cfei
|
41603
41660
|
cfsi
|
41604
|
-
croo
|
41605
41661
|
div
|
41606
41662
|
divi
|
41607
41663
|
ecr1
|
@@ -41684,6 +41740,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
|
|
41684
41740
|
ccp {
|
41685
41741
|
...DependentCostFragment
|
41686
41742
|
}
|
41743
|
+
croo {
|
41744
|
+
...DependentCostFragment
|
41745
|
+
}
|
41687
41746
|
csiz {
|
41688
41747
|
...DependentCostFragment
|
41689
41748
|
}
|
@@ -41806,14 +41865,6 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
41806
41865
|
maxTx
|
41807
41866
|
maxDepth
|
41808
41867
|
nodeVersion
|
41809
|
-
peers {
|
41810
|
-
id
|
41811
|
-
addresses
|
41812
|
-
clientVersion
|
41813
|
-
blockHeight
|
41814
|
-
lastHeartbeatMs
|
41815
|
-
appScore
|
41816
|
-
}
|
41817
41868
|
}
|
41818
41869
|
`;
|
41819
41870
|
var GetVersionDocument = lib_default2`
|
@@ -41848,13 +41899,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
|
|
41848
41899
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
41849
41900
|
transaction(id: $transactionId) {
|
41850
41901
|
...transactionFragment
|
41851
|
-
receipts {
|
41852
|
-
...receiptFragment
|
41853
|
-
}
|
41854
41902
|
}
|
41855
41903
|
}
|
41856
|
-
${TransactionFragmentFragmentDoc}
|
41857
|
-
${ReceiptFragmentFragmentDoc}`;
|
41904
|
+
${TransactionFragmentFragmentDoc}`;
|
41858
41905
|
var GetTransactionsDocument = lib_default2`
|
41859
41906
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
41860
41907
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -41982,6 +42029,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41982
42029
|
}
|
41983
42030
|
}
|
41984
42031
|
${BalanceFragmentFragmentDoc}`;
|
42032
|
+
var GetLatestGasPriceDocument = lib_default2`
|
42033
|
+
query getLatestGasPrice {
|
42034
|
+
latestGasPrice {
|
42035
|
+
gasPrice
|
42036
|
+
}
|
42037
|
+
}
|
42038
|
+
`;
|
42039
|
+
var EstimateGasPriceDocument = lib_default2`
|
42040
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
42041
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
42042
|
+
gasPrice
|
42043
|
+
}
|
42044
|
+
}
|
42045
|
+
`;
|
41985
42046
|
var GetBalancesDocument = lib_default2`
|
41986
42047
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
41987
42048
|
balances(
|
@@ -42036,12 +42097,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42036
42097
|
}
|
42037
42098
|
`;
|
42038
42099
|
var DryRunDocument = lib_default2`
|
42039
|
-
mutation dryRun($
|
42040
|
-
dryRun(
|
42041
|
-
...
|
42100
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
42101
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
42102
|
+
...dryRunTransactionExecutionStatusFragment
|
42042
42103
|
}
|
42043
42104
|
}
|
42044
|
-
${
|
42105
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
42045
42106
|
var SubmitDocument = lib_default2`
|
42046
42107
|
mutation submit($encodedTransaction: HexString!) {
|
42047
42108
|
submit(tx: $encodedTransaction) {
|
@@ -42124,6 +42185,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42124
42185
|
getBalance(variables, options) {
|
42125
42186
|
return requester(GetBalanceDocument, variables, options);
|
42126
42187
|
},
|
42188
|
+
getLatestGasPrice(variables, options) {
|
42189
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
42190
|
+
},
|
42191
|
+
estimateGasPrice(variables, options) {
|
42192
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
42193
|
+
},
|
42127
42194
|
getBalances(variables, options) {
|
42128
42195
|
return requester(GetBalancesDocument, variables, options);
|
42129
42196
|
},
|
@@ -42279,9 +42346,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42279
42346
|
}
|
42280
42347
|
};
|
42281
42348
|
|
42282
|
-
// ../address/dist/configs.mjs
|
42283
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42284
|
-
|
42285
42349
|
// src/providers/transaction-request/input.ts
|
42286
42350
|
var inputify = (value) => {
|
42287
42351
|
const { type: type3 } = value;
|
@@ -42301,7 +42365,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42301
42365
|
txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
|
42302
42366
|
},
|
42303
42367
|
witnessIndex: value.witnessIndex,
|
42304
|
-
maturity: value.maturity ?? 0,
|
42305
42368
|
predicateGasUsed: bn(value.predicateGasUsed),
|
42306
42369
|
predicateLength: predicate.length,
|
42307
42370
|
predicateDataLength: predicateData.length,
|
@@ -42413,7 +42476,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42413
42476
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42414
42477
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42415
42478
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42479
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42416
42480
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42481
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42482
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42483
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42484
|
+
var PANIC_REASONS = [
|
42485
|
+
"UnknownPanicReason",
|
42486
|
+
"Revert",
|
42487
|
+
"OutOfGas",
|
42488
|
+
"TransactionValidity",
|
42489
|
+
"MemoryOverflow",
|
42490
|
+
"ArithmeticOverflow",
|
42491
|
+
"ContractNotFound",
|
42492
|
+
"MemoryOwnership",
|
42493
|
+
"NotEnoughBalance",
|
42494
|
+
"ExpectedInternalContext",
|
42495
|
+
"AssetIdNotFound",
|
42496
|
+
"InputNotFound",
|
42497
|
+
"OutputNotFound",
|
42498
|
+
"WitnessNotFound",
|
42499
|
+
"TransactionMaturity",
|
42500
|
+
"InvalidMetadataIdentifier",
|
42501
|
+
"MalformedCallStructure",
|
42502
|
+
"ReservedRegisterNotWritable",
|
42503
|
+
"InvalidFlags",
|
42504
|
+
"InvalidImmediateValue",
|
42505
|
+
"ExpectedCoinInput",
|
42506
|
+
"EcalError",
|
42507
|
+
"MemoryWriteOverlap",
|
42508
|
+
"ContractNotInInputs",
|
42509
|
+
"InternalBalanceOverflow",
|
42510
|
+
"ContractMaxSize",
|
42511
|
+
"ExpectedUnallocatedStack",
|
42512
|
+
"MaxStaticContractsReached",
|
42513
|
+
"TransferAmountCannotBeZero",
|
42514
|
+
"ExpectedOutputVariable",
|
42515
|
+
"ExpectedParentInternalContext",
|
42516
|
+
"PredicateReturnedNonOne",
|
42517
|
+
"ContractIdAlreadyDeployed",
|
42518
|
+
"ContractMismatch",
|
42519
|
+
"MessageDataTooLong",
|
42520
|
+
"ArithmeticError",
|
42521
|
+
"ContractInstructionNotAllowed",
|
42522
|
+
"TransferZeroCoins",
|
42523
|
+
"InvalidInstruction",
|
42524
|
+
"MemoryNotExecutable",
|
42525
|
+
"PolicyIsNotSet",
|
42526
|
+
"PolicyNotFound",
|
42527
|
+
"TooManyReceipts",
|
42528
|
+
"BalanceOverflow",
|
42529
|
+
"InvalidBlockHeight",
|
42530
|
+
"TooManySlots"
|
42531
|
+
];
|
42532
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42417
42533
|
|
42418
42534
|
// src/providers/utils/receipts.ts
|
42419
42535
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42440,8 +42556,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42440
42556
|
case "CALL" /* Call */: {
|
42441
42557
|
const callReceipt = {
|
42442
42558
|
type: ReceiptType.Call,
|
42443
|
-
from: hexOrZero(receipt.
|
42444
|
-
to: hexOrZero(receipt?.to
|
42559
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
42560
|
+
to: hexOrZero(receipt?.to),
|
42445
42561
|
amount: bn(receipt.amount),
|
42446
42562
|
assetId: hexOrZero(receipt.assetId),
|
42447
42563
|
gas: bn(receipt.gas),
|
@@ -42455,7 +42571,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42455
42571
|
case "RETURN" /* Return */: {
|
42456
42572
|
const returnReceipt = {
|
42457
42573
|
type: ReceiptType.Return,
|
42458
|
-
id: hexOrZero(receipt.
|
42574
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
42459
42575
|
val: bn(receipt.val),
|
42460
42576
|
pc: bn(receipt.pc),
|
42461
42577
|
is: bn(receipt.is)
|
@@ -42465,7 +42581,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42465
42581
|
case "RETURN_DATA" /* ReturnData */: {
|
42466
42582
|
const returnDataReceipt = {
|
42467
42583
|
type: ReceiptType.ReturnData,
|
42468
|
-
id: hexOrZero(receipt.
|
42584
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
42469
42585
|
ptr: bn(receipt.ptr),
|
42470
42586
|
len: bn(receipt.len),
|
42471
42587
|
digest: hexOrZero(receipt.digest),
|
@@ -42477,7 +42593,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42477
42593
|
case "PANIC" /* Panic */: {
|
42478
42594
|
const panicReceipt = {
|
42479
42595
|
type: ReceiptType.Panic,
|
42480
|
-
id: hexOrZero(receipt.
|
42596
|
+
id: hexOrZero(receipt.id),
|
42481
42597
|
reason: bn(receipt.reason),
|
42482
42598
|
pc: bn(receipt.pc),
|
42483
42599
|
is: bn(receipt.is),
|
@@ -42488,7 +42604,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42488
42604
|
case "REVERT" /* Revert */: {
|
42489
42605
|
const revertReceipt = {
|
42490
42606
|
type: ReceiptType.Revert,
|
42491
|
-
id: hexOrZero(receipt.
|
42607
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
42492
42608
|
val: bn(receipt.ra),
|
42493
42609
|
pc: bn(receipt.pc),
|
42494
42610
|
is: bn(receipt.is)
|
@@ -42498,7 +42614,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42498
42614
|
case "LOG" /* Log */: {
|
42499
42615
|
const logReceipt = {
|
42500
42616
|
type: ReceiptType.Log,
|
42501
|
-
id: hexOrZero(receipt.
|
42617
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
42502
42618
|
val0: bn(receipt.ra),
|
42503
42619
|
val1: bn(receipt.rb),
|
42504
42620
|
val2: bn(receipt.rc),
|
@@ -42511,7 +42627,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42511
42627
|
case "LOG_DATA" /* LogData */: {
|
42512
42628
|
const logDataReceipt = {
|
42513
42629
|
type: ReceiptType.LogData,
|
42514
|
-
id: hexOrZero(receipt.
|
42630
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
42515
42631
|
val0: bn(receipt.ra),
|
42516
42632
|
val1: bn(receipt.rb),
|
42517
42633
|
ptr: bn(receipt.ptr),
|
@@ -42525,8 +42641,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42525
42641
|
case "TRANSFER" /* Transfer */: {
|
42526
42642
|
const transferReceipt = {
|
42527
42643
|
type: ReceiptType.Transfer,
|
42528
|
-
from: hexOrZero(receipt.
|
42529
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
42644
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
42645
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
42530
42646
|
amount: bn(receipt.amount),
|
42531
42647
|
assetId: hexOrZero(receipt.assetId),
|
42532
42648
|
pc: bn(receipt.pc),
|
@@ -42537,8 +42653,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42537
42653
|
case "TRANSFER_OUT" /* TransferOut */: {
|
42538
42654
|
const transferOutReceipt = {
|
42539
42655
|
type: ReceiptType.TransferOut,
|
42540
|
-
from: hexOrZero(receipt.
|
42541
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
42656
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
42657
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
42542
42658
|
amount: bn(receipt.amount),
|
42543
42659
|
assetId: hexOrZero(receipt.assetId),
|
42544
42660
|
pc: bn(receipt.pc),
|
@@ -42581,7 +42697,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42581
42697
|
return receiptMessageOut;
|
42582
42698
|
}
|
42583
42699
|
case "MINT" /* Mint */: {
|
42584
|
-
const contractId = hexOrZero(receipt.
|
42700
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
42585
42701
|
const subId = hexOrZero(receipt.subId);
|
42586
42702
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
42587
42703
|
const mintReceipt = {
|
@@ -42596,7 +42712,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42596
42712
|
return mintReceipt;
|
42597
42713
|
}
|
42598
42714
|
case "BURN" /* Burn */: {
|
42599
|
-
const contractId = hexOrZero(receipt.
|
42715
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
42600
42716
|
const subId = hexOrZero(receipt.subId);
|
42601
42717
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
42602
42718
|
const burnReceipt = {
|
@@ -42616,7 +42732,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42616
42732
|
}
|
42617
42733
|
|
42618
42734
|
// src/providers/utils/gas.ts
|
42619
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
42620
42735
|
var getGasUsedFromReceipts = (receipts) => {
|
42621
42736
|
const scriptResult = receipts.filter(
|
42622
42737
|
(receipt) => receipt.type === ReceiptType.ScriptResult
|
@@ -42637,18 +42752,28 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42637
42752
|
}
|
42638
42753
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
42639
42754
|
const witnessCache = [];
|
42640
|
-
const
|
42755
|
+
const chargeableInputs = inputs.filter((input) => {
|
42756
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
42757
|
+
if (isCoinOrMessage) {
|
42758
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
42759
|
+
return true;
|
42760
|
+
}
|
42761
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
42762
|
+
witnessCache.push(input.witnessIndex);
|
42763
|
+
return true;
|
42764
|
+
}
|
42765
|
+
}
|
42766
|
+
return false;
|
42767
|
+
});
|
42768
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
42769
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
42641
42770
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
42642
42771
|
return total.add(
|
42643
|
-
|
42772
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
|
42644
42773
|
);
|
42645
42774
|
}
|
42646
|
-
|
42647
|
-
|
42648
|
-
return total.add(gasCosts.ecr1);
|
42649
|
-
}
|
42650
|
-
return total;
|
42651
|
-
}, bn());
|
42775
|
+
return total.add(gasCosts.ecr1);
|
42776
|
+
}, bn(0));
|
42652
42777
|
return totalGas;
|
42653
42778
|
}
|
42654
42779
|
function getMinGas(params) {
|
@@ -42660,12 +42785,20 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42660
42785
|
return minGas;
|
42661
42786
|
}
|
42662
42787
|
function getMaxGas(params) {
|
42663
|
-
const {
|
42788
|
+
const {
|
42789
|
+
gasPerByte,
|
42790
|
+
witnessesLength,
|
42791
|
+
witnessLimit,
|
42792
|
+
minGas,
|
42793
|
+
gasLimit = bn(0),
|
42794
|
+
maxGasPerTx
|
42795
|
+
} = params;
|
42664
42796
|
let remainingAllowedWitnessGas = bn(0);
|
42665
42797
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
42666
42798
|
remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
42667
42799
|
}
|
42668
|
-
|
42800
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
42801
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
42669
42802
|
}
|
42670
42803
|
function calculateMetadataGasForTxCreate({
|
42671
42804
|
gasCosts,
|
@@ -42687,6 +42820,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42687
42820
|
}) {
|
42688
42821
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
42689
42822
|
}
|
42823
|
+
var calculateGasFee = (params) => {
|
42824
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
42825
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
42826
|
+
};
|
42690
42827
|
|
42691
42828
|
// src/providers/utils/json.ts
|
42692
42829
|
function normalize2(object) {
|
@@ -42726,6 +42863,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42726
42863
|
});
|
42727
42864
|
}
|
42728
42865
|
|
42866
|
+
// src/providers/utils/extract-tx-error.ts
|
42867
|
+
var assemblePanicError = (status) => {
|
42868
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42869
|
+
const reason = status.reason;
|
42870
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42871
|
+
errorMessage = `${errorMessage}
|
42872
|
+
|
42873
|
+
You can read more about this error at:
|
42874
|
+
|
42875
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42876
|
+
}
|
42877
|
+
return { errorMessage, reason };
|
42878
|
+
};
|
42879
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42880
|
+
var assembleRevertError = (receipts, logs) => {
|
42881
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42882
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42883
|
+
let reason = "";
|
42884
|
+
if (revertReceipt) {
|
42885
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42886
|
+
switch (reasonHex) {
|
42887
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42888
|
+
reason = "require";
|
42889
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42890
|
+
break;
|
42891
|
+
}
|
42892
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42893
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42894
|
+
reason = "assert_eq";
|
42895
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42896
|
+
break;
|
42897
|
+
}
|
42898
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42899
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42900
|
+
reason = "assert_ne";
|
42901
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42902
|
+
break;
|
42903
|
+
}
|
42904
|
+
case FAILED_ASSERT_SIGNAL:
|
42905
|
+
reason = "assert";
|
42906
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42907
|
+
break;
|
42908
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42909
|
+
reason = "MissingOutputChange";
|
42910
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42911
|
+
break;
|
42912
|
+
default:
|
42913
|
+
reason = "unknown";
|
42914
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42915
|
+
}
|
42916
|
+
}
|
42917
|
+
return { errorMessage, reason };
|
42918
|
+
};
|
42919
|
+
var extractTxError = (params) => {
|
42920
|
+
const { receipts, status, logs } = params;
|
42921
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42922
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42923
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42924
|
+
const metadata = {
|
42925
|
+
logs,
|
42926
|
+
receipts,
|
42927
|
+
panic: isPanic,
|
42928
|
+
revert: isRevert,
|
42929
|
+
reason
|
42930
|
+
};
|
42931
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42932
|
+
};
|
42933
|
+
|
42729
42934
|
// src/providers/transaction-request/errors.ts
|
42730
42935
|
var NoWitnessAtIndexError = class extends Error {
|
42731
42936
|
constructor(index) {
|
@@ -42748,7 +42953,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42748
42953
|
// src/providers/transaction-request/transaction-request.ts
|
42749
42954
|
var BaseTransactionRequest = class {
|
42750
42955
|
/** Gas price for transaction */
|
42751
|
-
|
42956
|
+
tip;
|
42752
42957
|
/** Block until which tx cannot be included */
|
42753
42958
|
maturity;
|
42754
42959
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -42761,38 +42966,34 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42761
42966
|
outputs = [];
|
42762
42967
|
/** List of witnesses */
|
42763
42968
|
witnesses = [];
|
42764
|
-
/** Base asset ID - should be fetched from the chain */
|
42765
|
-
baseAssetId = ZeroBytes32;
|
42766
42969
|
/**
|
42767
42970
|
* Constructor for initializing a base transaction request.
|
42768
42971
|
*
|
42769
42972
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
42770
42973
|
*/
|
42771
42974
|
constructor({
|
42772
|
-
|
42975
|
+
tip,
|
42773
42976
|
maturity,
|
42774
42977
|
maxFee,
|
42775
42978
|
witnessLimit,
|
42776
42979
|
inputs,
|
42777
42980
|
outputs,
|
42778
|
-
witnesses
|
42779
|
-
baseAssetId
|
42981
|
+
witnesses
|
42780
42982
|
} = {}) {
|
42781
|
-
this.
|
42983
|
+
this.tip = bn(tip);
|
42782
42984
|
this.maturity = maturity ?? 0;
|
42783
42985
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
42784
42986
|
this.maxFee = maxFee ? bn(maxFee) : void 0;
|
42785
42987
|
this.inputs = inputs ?? [];
|
42786
42988
|
this.outputs = outputs ?? [];
|
42787
42989
|
this.witnesses = witnesses ?? [];
|
42788
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42789
42990
|
}
|
42790
42991
|
static getPolicyMeta(req) {
|
42791
42992
|
let policyTypes = 0;
|
42792
42993
|
const policies = [];
|
42793
|
-
if (req.
|
42794
|
-
policyTypes += PolicyType.
|
42795
|
-
policies.push({ data: req.
|
42994
|
+
if (req.tip) {
|
42995
|
+
policyTypes += PolicyType.Tip;
|
42996
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
42796
42997
|
}
|
42797
42998
|
if (req.witnessLimit) {
|
42798
42999
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -42979,10 +43180,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42979
43180
|
* @param predicate - Predicate bytes.
|
42980
43181
|
* @param predicateData - Predicate data bytes.
|
42981
43182
|
*/
|
42982
|
-
addCoinInput(coin
|
43183
|
+
addCoinInput(coin) {
|
42983
43184
|
const { assetId, owner, amount } = coin;
|
42984
43185
|
let witnessIndex;
|
42985
|
-
if (predicate) {
|
43186
|
+
if (coin.predicate) {
|
42986
43187
|
witnessIndex = 0;
|
42987
43188
|
} else {
|
42988
43189
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -42997,9 +43198,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42997
43198
|
amount,
|
42998
43199
|
assetId,
|
42999
43200
|
txPointer: "0x00000000000000000000000000000000",
|
43000
|
-
witnessIndex
|
43001
|
-
predicate: predicate?.bytes,
|
43002
|
-
predicateData: predicate?.predicateDataBytes
|
43201
|
+
witnessIndex
|
43003
43202
|
};
|
43004
43203
|
this.pushInput(input);
|
43005
43204
|
this.addChangeOutput(owner, assetId);
|
@@ -43010,11 +43209,13 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43010
43209
|
*
|
43011
43210
|
* @param message - Message resource.
|
43012
43211
|
* @param predicate - Predicate bytes.
|
43212
|
+
* @param predicateData - Predicate data bytes.
|
43013
43213
|
*/
|
43014
|
-
addMessageInput(message
|
43214
|
+
addMessageInput(message) {
|
43015
43215
|
const { recipient, sender, amount } = message;
|
43216
|
+
const assetId = BaseAssetId;
|
43016
43217
|
let witnessIndex;
|
43017
|
-
if (predicate) {
|
43218
|
+
if (message.predicate) {
|
43018
43219
|
witnessIndex = 0;
|
43019
43220
|
} else {
|
43020
43221
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -43028,12 +43229,10 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43028
43229
|
sender: sender.toB256(),
|
43029
43230
|
recipient: recipient.toB256(),
|
43030
43231
|
amount,
|
43031
|
-
witnessIndex
|
43032
|
-
predicate: predicate?.bytes,
|
43033
|
-
predicateData: predicate?.predicateDataBytes
|
43232
|
+
witnessIndex
|
43034
43233
|
};
|
43035
43234
|
this.pushInput(input);
|
43036
|
-
this.addChangeOutput(recipient,
|
43235
|
+
this.addChangeOutput(recipient, assetId);
|
43037
43236
|
}
|
43038
43237
|
/**
|
43039
43238
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43061,32 +43260,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43061
43260
|
resources.forEach((resource) => this.addResource(resource));
|
43062
43261
|
return this;
|
43063
43262
|
}
|
43064
|
-
/**
|
43065
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
43066
|
-
* outputs from the related assetIds.
|
43067
|
-
*
|
43068
|
-
* @param resources - The resources to add.
|
43069
|
-
* @returns This transaction.
|
43070
|
-
*/
|
43071
|
-
addPredicateResource(resource, predicate) {
|
43072
|
-
if (isCoin(resource)) {
|
43073
|
-
this.addCoinInput(resource, predicate);
|
43074
|
-
} else {
|
43075
|
-
this.addMessageInput(resource, predicate);
|
43076
|
-
}
|
43077
|
-
return this;
|
43078
|
-
}
|
43079
|
-
/**
|
43080
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
43081
|
-
* from the related assetIds.
|
43082
|
-
*
|
43083
|
-
* @param resources - The resources to add.
|
43084
|
-
* @returns This transaction.
|
43085
|
-
*/
|
43086
|
-
addPredicateResources(resources, predicate) {
|
43087
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
43088
|
-
return this;
|
43089
|
-
}
|
43090
43263
|
/**
|
43091
43264
|
* Adds a coin output to the transaction.
|
43092
43265
|
*
|
@@ -43094,12 +43267,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43094
43267
|
* @param amount - Amount of coin.
|
43095
43268
|
* @param assetId - Asset ID of coin.
|
43096
43269
|
*/
|
43097
|
-
addCoinOutput(to, amount, assetId) {
|
43270
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43098
43271
|
this.pushOutput({
|
43099
43272
|
type: OutputType.Coin,
|
43100
43273
|
to: addressify(to).toB256(),
|
43101
43274
|
amount,
|
43102
|
-
assetId
|
43275
|
+
assetId
|
43103
43276
|
});
|
43104
43277
|
return this;
|
43105
43278
|
}
|
@@ -43126,7 +43299,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43126
43299
|
* @param to - Address of the owner.
|
43127
43300
|
* @param assetId - Asset ID of coin.
|
43128
43301
|
*/
|
43129
|
-
addChangeOutput(to, assetId) {
|
43302
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43130
43303
|
const changeOutput = this.getChangeOutputs().find(
|
43131
43304
|
(output3) => hexlify(output3.assetId) === assetId
|
43132
43305
|
);
|
@@ -43134,7 +43307,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43134
43307
|
this.pushOutput({
|
43135
43308
|
type: OutputType.Change,
|
43136
43309
|
to: addressify(to).toB256(),
|
43137
|
-
assetId
|
43310
|
+
assetId
|
43138
43311
|
});
|
43139
43312
|
}
|
43140
43313
|
}
|
@@ -43166,7 +43339,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43166
43339
|
}
|
43167
43340
|
calculateMaxGas(chainInfo, minGas) {
|
43168
43341
|
const { consensusParameters } = chainInfo;
|
43169
|
-
const { gasPerByte } = consensusParameters;
|
43342
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
43170
43343
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
43171
43344
|
(acc, wit) => acc + wit.dataLength,
|
43172
43345
|
0
|
@@ -43175,7 +43348,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43175
43348
|
gasPerByte,
|
43176
43349
|
minGas,
|
43177
43350
|
witnessesLength,
|
43178
|
-
witnessLimit: this.witnessLimit
|
43351
|
+
witnessLimit: this.witnessLimit,
|
43352
|
+
maxGasPerTx
|
43179
43353
|
});
|
43180
43354
|
}
|
43181
43355
|
/**
|
@@ -43185,12 +43359,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43185
43359
|
* @param quantities - CoinQuantity Array.
|
43186
43360
|
*/
|
43187
43361
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43188
|
-
let idCounter = 0;
|
43189
|
-
const generateId = () => {
|
43190
|
-
const counterString = String(idCounter++);
|
43191
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43192
|
-
return id;
|
43193
|
-
};
|
43194
43362
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43195
43363
|
if ("assetId" in input) {
|
43196
43364
|
return input.assetId === assetId;
|
@@ -43199,24 +43367,27 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43199
43367
|
});
|
43200
43368
|
const updateAssetInput = (assetId, quantity) => {
|
43201
43369
|
const assetInput = findAssetInput(assetId);
|
43370
|
+
let usedQuantity = quantity;
|
43371
|
+
if (assetId === BaseAssetId) {
|
43372
|
+
usedQuantity = bn("1000000000000000000");
|
43373
|
+
}
|
43202
43374
|
if (assetInput && "assetId" in assetInput) {
|
43203
|
-
assetInput.id =
|
43204
|
-
assetInput.amount =
|
43375
|
+
assetInput.id = hexlify(randomBytes3(33));
|
43376
|
+
assetInput.amount = usedQuantity;
|
43205
43377
|
} else {
|
43206
43378
|
this.addResources([
|
43207
43379
|
{
|
43208
|
-
id:
|
43209
|
-
amount:
|
43380
|
+
id: hexlify(randomBytes3(33)),
|
43381
|
+
amount: usedQuantity,
|
43210
43382
|
assetId,
|
43211
43383
|
owner: resourcesOwner || Address.fromRandom(),
|
43212
|
-
maturity: 0,
|
43213
43384
|
blockCreated: bn(1),
|
43214
43385
|
txCreatedIdx: bn(1)
|
43215
43386
|
}
|
43216
43387
|
]);
|
43217
43388
|
}
|
43218
43389
|
};
|
43219
|
-
updateAssetInput(
|
43390
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43220
43391
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43221
43392
|
}
|
43222
43393
|
/**
|
@@ -43241,7 +43412,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43241
43412
|
toJSON() {
|
43242
43413
|
return normalizeJSON(this);
|
43243
43414
|
}
|
43244
|
-
|
43415
|
+
updatePredicateGasUsed(inputs) {
|
43245
43416
|
this.inputs.forEach((i) => {
|
43246
43417
|
let correspondingInput;
|
43247
43418
|
switch (i.type) {
|
@@ -43263,6 +43434,15 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43263
43434
|
}
|
43264
43435
|
});
|
43265
43436
|
}
|
43437
|
+
shiftPredicateData() {
|
43438
|
+
this.inputs.forEach((input) => {
|
43439
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
43440
|
+
input.predicateData = input.paddPredicateData(
|
43441
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
43442
|
+
);
|
43443
|
+
}
|
43444
|
+
});
|
43445
|
+
}
|
43266
43446
|
};
|
43267
43447
|
|
43268
43448
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -43577,7 +43757,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43577
43757
|
}
|
43578
43758
|
calculateMaxGas(chainInfo, minGas) {
|
43579
43759
|
const { consensusParameters } = chainInfo;
|
43580
|
-
const { gasPerByte } = consensusParameters;
|
43760
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
43581
43761
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
43582
43762
|
(acc, wit) => acc + wit.dataLength,
|
43583
43763
|
0
|
@@ -43587,7 +43767,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43587
43767
|
minGas,
|
43588
43768
|
witnessesLength,
|
43589
43769
|
witnessLimit: this.witnessLimit,
|
43590
|
-
gasLimit: this.gasLimit
|
43770
|
+
gasLimit: this.gasLimit,
|
43771
|
+
maxGasPerTx
|
43591
43772
|
});
|
43592
43773
|
}
|
43593
43774
|
/**
|
@@ -43660,13 +43841,29 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43660
43841
|
}
|
43661
43842
|
}
|
43662
43843
|
};
|
43844
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
43845
|
+
(acc, input) => {
|
43846
|
+
if (input.type === InputType.Coin && input.owner === owner) {
|
43847
|
+
acc.utxos.push(input.id);
|
43848
|
+
}
|
43849
|
+
if (input.type === InputType.Message && input.recipient === owner) {
|
43850
|
+
acc.messages.push(input.nonce);
|
43851
|
+
}
|
43852
|
+
return acc;
|
43853
|
+
},
|
43854
|
+
{
|
43855
|
+
utxos: [],
|
43856
|
+
messages: []
|
43857
|
+
}
|
43858
|
+
);
|
43663
43859
|
|
43664
43860
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
43665
43861
|
var calculateTransactionFee = (params) => {
|
43666
43862
|
const {
|
43667
|
-
|
43863
|
+
gasPrice,
|
43668
43864
|
rawPayload,
|
43669
|
-
|
43865
|
+
tip,
|
43866
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
43670
43867
|
} = params;
|
43671
43868
|
const gasPerByte = bn(feeParams.gasPerByte);
|
43672
43869
|
const gasPriceFactor = bn(feeParams.gasPriceFactor);
|
@@ -43676,8 +43873,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43676
43873
|
return {
|
43677
43874
|
fee: bn(0),
|
43678
43875
|
minFee: bn(0),
|
43679
|
-
maxFee: bn(0)
|
43680
|
-
feeFromGasUsed: bn(0)
|
43876
|
+
maxFee: bn(0)
|
43681
43877
|
};
|
43682
43878
|
}
|
43683
43879
|
const { type: type3, witnesses, inputs, policies } = transaction;
|
@@ -43709,7 +43905,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43709
43905
|
metadataGas,
|
43710
43906
|
txBytesSize: transactionBytes.length
|
43711
43907
|
});
|
43712
|
-
const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
|
43713
43908
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
|
43714
43909
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
43715
43910
|
const maxGas = getMaxGas({
|
@@ -43717,17 +43912,25 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43717
43912
|
minGas,
|
43718
43913
|
witnessesLength,
|
43719
43914
|
gasLimit,
|
43720
|
-
witnessLimit
|
43915
|
+
witnessLimit,
|
43916
|
+
maxGasPerTx
|
43917
|
+
});
|
43918
|
+
const minFee = calculateGasFee({
|
43919
|
+
gasPrice,
|
43920
|
+
gas: minGas,
|
43921
|
+
priceFactor: gasPriceFactor,
|
43922
|
+
tip
|
43923
|
+
});
|
43924
|
+
const maxFee = calculateGasFee({
|
43925
|
+
gasPrice,
|
43926
|
+
gas: maxGas,
|
43927
|
+
priceFactor: gasPriceFactor,
|
43928
|
+
tip
|
43721
43929
|
});
|
43722
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
43723
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
43724
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
43725
|
-
const fee = minFee.add(feeFromGasUsed);
|
43726
43930
|
return {
|
43727
|
-
fee,
|
43728
43931
|
minFee,
|
43729
43932
|
maxFee,
|
43730
|
-
|
43933
|
+
fee: maxFee
|
43731
43934
|
};
|
43732
43935
|
};
|
43733
43936
|
|
@@ -44281,7 +44484,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44281
44484
|
gqlTransactionStatus,
|
44282
44485
|
abiMap = {},
|
44283
44486
|
maxInputs,
|
44284
|
-
gasCosts
|
44487
|
+
gasCosts,
|
44488
|
+
maxGasPerTx,
|
44489
|
+
gasPrice
|
44285
44490
|
} = params;
|
44286
44491
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
44287
44492
|
const rawPayload = hexlify(transactionBytes);
|
@@ -44295,11 +44500,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44295
44500
|
maxInputs
|
44296
44501
|
});
|
44297
44502
|
const typeName = getTransactionTypeName(transaction.type);
|
44503
|
+
const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
|
44298
44504
|
const { fee } = calculateTransactionFee({
|
44299
|
-
|
44505
|
+
gasPrice,
|
44300
44506
|
rawPayload,
|
44507
|
+
tip,
|
44301
44508
|
consensusParameters: {
|
44302
44509
|
gasCosts,
|
44510
|
+
maxGasPerTx,
|
44303
44511
|
feeParams: {
|
44304
44512
|
gasPerByte,
|
44305
44513
|
gasPriceFactor
|
@@ -44435,8 +44643,13 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44435
44643
|
const decodedTransaction = this.decodeTransaction(
|
44436
44644
|
transaction
|
44437
44645
|
);
|
44438
|
-
|
44439
|
-
|
44646
|
+
let txReceipts = [];
|
44647
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
44648
|
+
txReceipts = transaction.status.receipts;
|
44649
|
+
}
|
44650
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
44651
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
44652
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
44440
44653
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
44441
44654
|
const transactionSummary = assembleTransactionSummary({
|
44442
44655
|
id: this.id,
|
@@ -44448,7 +44661,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44448
44661
|
gasPriceFactor,
|
44449
44662
|
abiMap: contractsAbiMap,
|
44450
44663
|
maxInputs,
|
44451
|
-
gasCosts
|
44664
|
+
gasCosts,
|
44665
|
+
maxGasPerTx,
|
44666
|
+
gasPrice
|
44452
44667
|
});
|
44453
44668
|
return transactionSummary;
|
44454
44669
|
}
|
@@ -44485,14 +44700,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44485
44700
|
gqlTransaction: this.gqlTransaction,
|
44486
44701
|
...transactionSummary
|
44487
44702
|
};
|
44703
|
+
let logs = [];
|
44488
44704
|
if (this.abis) {
|
44489
|
-
|
44705
|
+
logs = getDecodedLogs(
|
44490
44706
|
transactionSummary.receipts,
|
44491
44707
|
this.abis.main,
|
44492
44708
|
this.abis.otherContractsAbis
|
44493
44709
|
);
|
44494
44710
|
transactionResult.logs = logs;
|
44495
44711
|
}
|
44712
|
+
if (transactionResult.isStatusFailure) {
|
44713
|
+
const {
|
44714
|
+
receipts,
|
44715
|
+
gqlTransaction: { status }
|
44716
|
+
} = transactionResult;
|
44717
|
+
throw extractTxError({
|
44718
|
+
receipts,
|
44719
|
+
status,
|
44720
|
+
logs
|
44721
|
+
});
|
44722
|
+
}
|
44496
44723
|
return transactionResult;
|
44497
44724
|
}
|
44498
44725
|
/**
|
@@ -44501,14 +44728,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44501
44728
|
* @param contractsAbiMap - The contracts ABI map.
|
44502
44729
|
*/
|
44503
44730
|
async wait(contractsAbiMap) {
|
44504
|
-
|
44505
|
-
if (result.isStatusFailure) {
|
44506
|
-
throw new FuelError(
|
44507
|
-
ErrorCode.TRANSACTION_FAILED,
|
44508
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44509
|
-
);
|
44510
|
-
}
|
44511
|
-
return result;
|
44731
|
+
return this.waitForResult(contractsAbiMap);
|
44512
44732
|
}
|
44513
44733
|
};
|
44514
44734
|
|
@@ -44587,13 +44807,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44587
44807
|
gasPerByte: bn(feeParams.gasPerByte),
|
44588
44808
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44589
44809
|
chainId: bn(consensusParameters.chainId),
|
44590
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44591
44810
|
gasCosts
|
44592
44811
|
},
|
44593
44812
|
gasCosts,
|
44594
44813
|
latestBlock: {
|
44595
44814
|
id: latestBlock.id,
|
44596
|
-
height: bn(latestBlock.
|
44815
|
+
height: bn(latestBlock.height),
|
44597
44816
|
time: latestBlock.header.time,
|
44598
44817
|
transactions: latestBlock.transactions.map((i) => ({
|
44599
44818
|
id: i.id
|
@@ -44788,7 +45007,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44788
45007
|
*/
|
44789
45008
|
async getBlockNumber() {
|
44790
45009
|
const { chain } = await this.operations.getChain();
|
44791
|
-
return bn(chain.latestBlock.
|
45010
|
+
return bn(chain.latestBlock.height, 10);
|
44792
45011
|
}
|
44793
45012
|
/**
|
44794
45013
|
* Returns the chain information.
|
@@ -44803,8 +45022,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44803
45022
|
minGasPrice: bn(nodeInfo.minGasPrice),
|
44804
45023
|
nodeVersion: nodeInfo.nodeVersion,
|
44805
45024
|
utxoValidation: nodeInfo.utxoValidation,
|
44806
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
44807
|
-
peers: nodeInfo.peers
|
45025
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
44808
45026
|
};
|
44809
45027
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
44810
45028
|
return processedNodeInfo;
|
@@ -44830,17 +45048,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44830
45048
|
} = this.getChain();
|
44831
45049
|
return chainId.toNumber();
|
44832
45050
|
}
|
44833
|
-
/**
|
44834
|
-
* Returns the base asset ID
|
44835
|
-
*
|
44836
|
-
* @returns A promise that resolves to the base asset ID
|
44837
|
-
*/
|
44838
|
-
getBaseAssetId() {
|
44839
|
-
const {
|
44840
|
-
consensusParameters: { baseAssetId }
|
44841
|
-
} = this.getChain();
|
44842
|
-
return baseAssetId;
|
44843
|
-
}
|
44844
45051
|
/**
|
44845
45052
|
* Submits a transaction to the chain to be executed.
|
44846
45053
|
*
|
@@ -44901,14 +45108,13 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44901
45108
|
return this.estimateTxDependencies(transactionRequest);
|
44902
45109
|
}
|
44903
45110
|
const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
|
44904
|
-
const { dryRun:
|
44905
|
-
encodedTransaction,
|
45111
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
45112
|
+
encodedTransactions: encodedTransaction,
|
44906
45113
|
utxoValidation: utxoValidation || false
|
44907
45114
|
});
|
44908
|
-
const receipts =
|
44909
|
-
|
44910
|
-
|
44911
|
-
};
|
45115
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
45116
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
45117
|
+
return { receipts, dryrunStatus: status };
|
44912
45118
|
}
|
44913
45119
|
/**
|
44914
45120
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -44947,9 +45153,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44947
45153
|
* If there are missing variable outputs,
|
44948
45154
|
* `addVariableOutputs` is called on the transaction.
|
44949
45155
|
*
|
44950
|
-
* @privateRemarks
|
44951
|
-
* TODO: Investigate support for missing contract IDs
|
44952
|
-
* TODO: Add support for missing output messages
|
44953
45156
|
*
|
44954
45157
|
* @param transactionRequest - The transaction request object.
|
44955
45158
|
* @returns A promise.
|
@@ -44962,16 +45165,19 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44962
45165
|
missingContractIds: []
|
44963
45166
|
};
|
44964
45167
|
}
|
44965
|
-
await this.estimatePredicates(transactionRequest);
|
44966
45168
|
let receipts = [];
|
44967
45169
|
const missingContractIds = [];
|
44968
45170
|
let outputVariables = 0;
|
45171
|
+
let dryrunStatus;
|
44969
45172
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
44970
|
-
const {
|
44971
|
-
|
45173
|
+
const {
|
45174
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
45175
|
+
} = await this.operations.dryRun({
|
45176
|
+
encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
|
44972
45177
|
utxoValidation: false
|
44973
45178
|
});
|
44974
|
-
receipts =
|
45179
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
45180
|
+
dryrunStatus = status;
|
44975
45181
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
44976
45182
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
44977
45183
|
if (hasMissingOutputs) {
|
@@ -44981,6 +45187,11 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44981
45187
|
transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
|
44982
45188
|
missingContractIds.push(contractId);
|
44983
45189
|
});
|
45190
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
45191
|
+
transactionRequest,
|
45192
|
+
optimizeGas: false
|
45193
|
+
});
|
45194
|
+
transactionRequest.maxFee = maxFee;
|
44984
45195
|
} else {
|
44985
45196
|
break;
|
44986
45197
|
}
|
@@ -44988,7 +45199,133 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44988
45199
|
return {
|
44989
45200
|
receipts,
|
44990
45201
|
outputVariables,
|
44991
|
-
missingContractIds
|
45202
|
+
missingContractIds,
|
45203
|
+
dryrunStatus
|
45204
|
+
};
|
45205
|
+
}
|
45206
|
+
/**
|
45207
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
45208
|
+
*
|
45209
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
45210
|
+
* further modifications are identified. The method iteratively updates these transactions
|
45211
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
45212
|
+
*
|
45213
|
+
* @param transactionRequests - Array of transaction request objects.
|
45214
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
45215
|
+
*/
|
45216
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
45217
|
+
const results = transactionRequests.map(() => ({
|
45218
|
+
receipts: [],
|
45219
|
+
outputVariables: 0,
|
45220
|
+
missingContractIds: [],
|
45221
|
+
dryrunStatus: void 0
|
45222
|
+
}));
|
45223
|
+
const allRequests = clone_default(transactionRequests);
|
45224
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
45225
|
+
allRequests.forEach((req, index) => {
|
45226
|
+
if (req.type === TransactionType.Script) {
|
45227
|
+
serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
|
45228
|
+
}
|
45229
|
+
});
|
45230
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
45231
|
+
let attempt = 0;
|
45232
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
45233
|
+
const encodedTransactions = transactionsToProcess.map(
|
45234
|
+
(index) => serializedTransactionsMap.get(index)
|
45235
|
+
);
|
45236
|
+
const dryRunResults = await this.operations.dryRun({
|
45237
|
+
encodedTransactions,
|
45238
|
+
utxoValidation: false
|
45239
|
+
});
|
45240
|
+
const nextRoundTransactions = [];
|
45241
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
45242
|
+
const currentResultIndex = transactionsToProcess[i];
|
45243
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
45244
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
45245
|
+
results[currentResultIndex].dryrunStatus = status;
|
45246
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
45247
|
+
results[currentResultIndex].receipts
|
45248
|
+
);
|
45249
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
45250
|
+
const requestToProcess = allRequests[currentResultIndex];
|
45251
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
|
45252
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
45253
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
45254
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
45255
|
+
requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
|
45256
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
45257
|
+
});
|
45258
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
45259
|
+
transactionRequest: requestToProcess,
|
45260
|
+
optimizeGas: false
|
45261
|
+
});
|
45262
|
+
requestToProcess.maxFee = maxFee;
|
45263
|
+
serializedTransactionsMap.set(
|
45264
|
+
currentResultIndex,
|
45265
|
+
hexlify(requestToProcess.toTransactionBytes())
|
45266
|
+
);
|
45267
|
+
nextRoundTransactions.push(currentResultIndex);
|
45268
|
+
allRequests[currentResultIndex] = requestToProcess;
|
45269
|
+
}
|
45270
|
+
}
|
45271
|
+
transactionsToProcess = nextRoundTransactions;
|
45272
|
+
attempt += 1;
|
45273
|
+
}
|
45274
|
+
return results;
|
45275
|
+
}
|
45276
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
45277
|
+
if (estimateTxDependencies) {
|
45278
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
45279
|
+
}
|
45280
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
|
45281
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
45282
|
+
encodedTransactions,
|
45283
|
+
utxoValidation: utxoValidation || false
|
45284
|
+
});
|
45285
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
45286
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
45287
|
+
return { receipts, dryrunStatus: status };
|
45288
|
+
});
|
45289
|
+
return results;
|
45290
|
+
}
|
45291
|
+
async estimateTxGasAndFee(params) {
|
45292
|
+
const { transactionRequest, totalGasUsedByPredicates = bn(0), optimizeGas = true } = params;
|
45293
|
+
let { gasPrice } = params;
|
45294
|
+
const chainInfo = this.getChain();
|
45295
|
+
const { gasPriceFactor } = this.getGasConfig();
|
45296
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
45297
|
+
if (!gasPrice) {
|
45298
|
+
gasPrice = await this.estimateGasPrice(10);
|
45299
|
+
}
|
45300
|
+
const shouldSetGaslimit = transactionRequest.type === TransactionType.Script && !optimizeGas;
|
45301
|
+
const minFee = calculateGasFee({
|
45302
|
+
gasPrice: bn(gasPrice),
|
45303
|
+
gas: minGas,
|
45304
|
+
priceFactor: gasPriceFactor,
|
45305
|
+
tip: transactionRequest.tip
|
45306
|
+
}).add(1);
|
45307
|
+
if (shouldSetGaslimit) {
|
45308
|
+
transactionRequest.gasLimit = chainInfo.consensusParameters.maxGasPerTx.sub(
|
45309
|
+
minGas.add(totalGasUsedByPredicates)
|
45310
|
+
);
|
45311
|
+
}
|
45312
|
+
let maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
45313
|
+
const maxFee = calculateGasFee({
|
45314
|
+
gasPrice: bn(gasPrice),
|
45315
|
+
gas: maxGas,
|
45316
|
+
priceFactor: gasPriceFactor,
|
45317
|
+
tip: transactionRequest.tip
|
45318
|
+
}).add(1);
|
45319
|
+
if (shouldSetGaslimit) {
|
45320
|
+
maxGas = chainInfo.consensusParameters.maxGasPerTx.sub(maxFee);
|
45321
|
+
transactionRequest.gasLimit = maxGas;
|
45322
|
+
}
|
45323
|
+
return {
|
45324
|
+
minGas,
|
45325
|
+
minFee,
|
45326
|
+
maxGas,
|
45327
|
+
maxFee,
|
45328
|
+
gasPrice
|
44992
45329
|
};
|
44993
45330
|
}
|
44994
45331
|
/**
|
@@ -45006,15 +45343,17 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45006
45343
|
if (estimateTxDependencies) {
|
45007
45344
|
return this.estimateTxDependencies(transactionRequest);
|
45008
45345
|
}
|
45009
|
-
const
|
45010
|
-
const { dryRun:
|
45011
|
-
|
45346
|
+
const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
|
45347
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
45348
|
+
encodedTransactions,
|
45012
45349
|
utxoValidation: true
|
45013
45350
|
});
|
45014
|
-
const
|
45015
|
-
|
45016
|
-
receipts
|
45017
|
-
|
45351
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
45352
|
+
const { id, receipts, status } = dryRunStatus;
|
45353
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
45354
|
+
return { id, receipts: processedReceipts, status };
|
45355
|
+
});
|
45356
|
+
return { receipts: callResult[0].receipts };
|
45018
45357
|
}
|
45019
45358
|
/**
|
45020
45359
|
* Returns a transaction cost to enable user
|
@@ -45031,80 +45370,80 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45031
45370
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
45032
45371
|
* @returns A promise that resolves to the transaction cost object.
|
45033
45372
|
*/
|
45034
|
-
async getTransactionCost(transactionRequestLike,
|
45035
|
-
estimateTxDependencies = true,
|
45036
|
-
estimatePredicates = true,
|
45037
|
-
resourcesOwner,
|
45038
|
-
signatureCallback
|
45039
|
-
} = {}) {
|
45373
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
45040
45374
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45041
|
-
const chainInfo = this.getChain();
|
45042
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45043
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45044
45375
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45045
45376
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45046
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
45377
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
45047
45378
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45048
|
-
|
45049
|
-
|
45050
|
-
|
45051
|
-
}
|
45052
|
-
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45053
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45054
|
-
}
|
45055
|
-
await this.estimatePredicates(txRequestClone);
|
45379
|
+
txRequestClone.maxFee = bn(0);
|
45380
|
+
if (isScriptTransaction) {
|
45381
|
+
txRequestClone.gasLimit = bn(0);
|
45056
45382
|
}
|
45057
|
-
if (
|
45058
|
-
|
45383
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45384
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45059
45385
|
}
|
45060
|
-
const
|
45061
|
-
|
45386
|
+
const signedRequest = clone_default(txRequestClone);
|
45387
|
+
let addedSignatures = 0;
|
45388
|
+
if (signatureCallback && isScriptTransaction) {
|
45389
|
+
const lengthBefore = signedRequest.witnesses.length;
|
45390
|
+
await signatureCallback(signedRequest);
|
45391
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
45392
|
+
}
|
45393
|
+
await this.estimatePredicates(signedRequest);
|
45394
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
45395
|
+
transactionRequest: signedRequest,
|
45396
|
+
optimizeGas: false
|
45397
|
+
});
|
45398
|
+
txRequestClone.maxFee = maxFee;
|
45062
45399
|
let receipts = [];
|
45063
45400
|
let missingContractIds = [];
|
45064
45401
|
let outputVariables = 0;
|
45065
|
-
|
45066
|
-
|
45067
|
-
|
45402
|
+
let gasUsed = bn(0);
|
45403
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
45404
|
+
if (isScriptTransaction) {
|
45405
|
+
if (signatureCallback) {
|
45406
|
+
await signatureCallback(txRequestClone);
|
45407
|
+
}
|
45408
|
+
txRequestClone.gasLimit = maxGas;
|
45068
45409
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45069
45410
|
receipts = result.receipts;
|
45070
45411
|
outputVariables = result.outputVariables;
|
45071
45412
|
missingContractIds = result.missingContractIds;
|
45413
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
45414
|
+
txRequestClone.gasLimit = gasUsed;
|
45415
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
45416
|
+
transactionRequest: txRequestClone,
|
45417
|
+
gasPrice
|
45418
|
+
}));
|
45072
45419
|
}
|
45073
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45074
|
-
const usedFee = calculatePriceWithFactor(
|
45075
|
-
gasUsed,
|
45076
|
-
gasPrice,
|
45077
|
-
gasPriceFactor
|
45078
|
-
).normalizeZeroToOne();
|
45079
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45080
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45081
45420
|
return {
|
45082
45421
|
requiredQuantities: allQuantities,
|
45083
45422
|
receipts,
|
45084
45423
|
gasUsed,
|
45085
|
-
minGasPrice,
|
45086
45424
|
gasPrice,
|
45087
45425
|
minGas,
|
45088
45426
|
maxGas,
|
45089
|
-
usedFee,
|
45090
45427
|
minFee,
|
45091
45428
|
maxFee,
|
45092
|
-
estimatedInputs: txRequestClone.inputs,
|
45093
45429
|
outputVariables,
|
45094
|
-
missingContractIds
|
45430
|
+
missingContractIds,
|
45431
|
+
addedSignatures,
|
45432
|
+
estimatedPredicates: txRequestClone.inputs
|
45095
45433
|
};
|
45096
45434
|
}
|
45097
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
45435
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
45098
45436
|
const ownerAddress = Address.fromAddressOrString(owner);
|
45099
45437
|
const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
|
45100
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
45438
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
45439
|
+
quantitiesToContract
|
45440
|
+
});
|
45101
45441
|
transactionRequest.addResources(
|
45102
45442
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
45103
45443
|
);
|
45104
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
45105
|
-
|
45106
|
-
|
45107
|
-
);
|
45444
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
45445
|
+
quantitiesToContract
|
45446
|
+
});
|
45108
45447
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
45109
45448
|
return {
|
45110
45449
|
resources,
|
@@ -45128,7 +45467,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45128
45467
|
assetId: coin.assetId,
|
45129
45468
|
amount: bn(coin.amount),
|
45130
45469
|
owner: Address.fromAddressOrString(coin.owner),
|
45131
|
-
maturity: bn(coin.maturity).toNumber(),
|
45132
45470
|
blockCreated: bn(coin.blockCreated),
|
45133
45471
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
45134
45472
|
}));
|
@@ -45180,7 +45518,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45180
45518
|
amount: bn(coin.amount),
|
45181
45519
|
assetId: coin.assetId,
|
45182
45520
|
owner: Address.fromAddressOrString(coin.owner),
|
45183
|
-
maturity: bn(coin.maturity).toNumber(),
|
45184
45521
|
blockCreated: bn(coin.blockCreated),
|
45185
45522
|
txCreatedIdx: bn(coin.txCreatedIdx)
|
45186
45523
|
};
|
@@ -45213,7 +45550,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45213
45550
|
}
|
45214
45551
|
return {
|
45215
45552
|
id: block2.id,
|
45216
|
-
height: bn(block2.
|
45553
|
+
height: bn(block2.height),
|
45217
45554
|
time: block2.header.time,
|
45218
45555
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
45219
45556
|
};
|
@@ -45228,7 +45565,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45228
45565
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
45229
45566
|
const blocks = fetchedData.edges.map(({ node: block2 }) => ({
|
45230
45567
|
id: block2.id,
|
45231
|
-
height: bn(block2.
|
45568
|
+
height: bn(block2.height),
|
45232
45569
|
time: block2.header.time,
|
45233
45570
|
transactionIds: block2.transactions.map((tx) => tx.id)
|
45234
45571
|
}));
|
@@ -45255,7 +45592,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45255
45592
|
}
|
45256
45593
|
return {
|
45257
45594
|
id: block2.id,
|
45258
|
-
height: bn(block2.
|
45595
|
+
height: bn(block2.height, 10),
|
45259
45596
|
time: block2.header.time,
|
45260
45597
|
transactionIds: block2.transactions.map((tx) => tx.id),
|
45261
45598
|
transactions: block2.transactions.map(
|
@@ -45457,6 +45794,16 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45457
45794
|
data
|
45458
45795
|
};
|
45459
45796
|
}
|
45797
|
+
async getLatestGasPrice() {
|
45798
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
45799
|
+
return bn(latestGasPrice.gasPrice);
|
45800
|
+
}
|
45801
|
+
async estimateGasPrice(blockHorizon) {
|
45802
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
45803
|
+
blockHorizon: String(blockHorizon)
|
45804
|
+
});
|
45805
|
+
return bn(estimateGasPrice.gasPrice);
|
45806
|
+
}
|
45460
45807
|
/**
|
45461
45808
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
45462
45809
|
*
|
@@ -45702,9 +46049,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45702
46049
|
* @param assetId - The asset ID to check the balance for.
|
45703
46050
|
* @returns A promise that resolves to the balance amount.
|
45704
46051
|
*/
|
45705
|
-
async getBalance(assetId) {
|
45706
|
-
const
|
45707
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
46052
|
+
async getBalance(assetId = BaseAssetId) {
|
46053
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45708
46054
|
return amount;
|
45709
46055
|
}
|
45710
46056
|
/**
|
@@ -45741,37 +46087,33 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45741
46087
|
* @param fee - The estimated transaction fee.
|
45742
46088
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45743
46089
|
*/
|
45744
|
-
async fund(request,
|
45745
|
-
const
|
45746
|
-
const
|
46090
|
+
async fund(request, params) {
|
46091
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
46092
|
+
const txRequest = request;
|
46093
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
45747
46094
|
amount: bn(fee),
|
45748
|
-
assetId:
|
45749
|
-
coinQuantities
|
46095
|
+
assetId: BaseAssetId,
|
46096
|
+
coinQuantities: requiredQuantities
|
45750
46097
|
});
|
45751
46098
|
const quantitiesDict = {};
|
45752
|
-
|
46099
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
45753
46100
|
quantitiesDict[assetId] = {
|
45754
46101
|
required: amount,
|
45755
46102
|
owned: bn(0)
|
45756
46103
|
};
|
45757
46104
|
});
|
45758
|
-
|
45759
|
-
const cachedMessages = [];
|
45760
|
-
const owner = this.address.toB256();
|
45761
|
-
request.inputs.forEach((input) => {
|
46105
|
+
txRequest.inputs.forEach((input) => {
|
45762
46106
|
const isResource = "amount" in input;
|
45763
46107
|
if (isResource) {
|
45764
46108
|
const isCoin2 = "owner" in input;
|
45765
46109
|
if (isCoin2) {
|
45766
46110
|
const assetId = String(input.assetId);
|
45767
|
-
if (
|
46111
|
+
if (quantitiesDict[assetId]) {
|
45768
46112
|
const amount = bn(input.amount);
|
45769
46113
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45770
|
-
cachedUtxos.push(input.id);
|
45771
46114
|
}
|
45772
|
-
} else if (input.
|
45773
|
-
quantitiesDict[
|
45774
|
-
cachedMessages.push(input.nonce);
|
46115
|
+
} else if (input.amount && quantitiesDict[BaseAssetId]) {
|
46116
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45775
46117
|
}
|
45776
46118
|
}
|
45777
46119
|
});
|
@@ -45786,12 +46128,23 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45786
46128
|
});
|
45787
46129
|
const needsToBeFunded = missingQuantities.length;
|
45788
46130
|
if (needsToBeFunded) {
|
45789
|
-
const
|
45790
|
-
|
45791
|
-
|
45792
|
-
|
45793
|
-
|
46131
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toString());
|
46132
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
46133
|
+
txRequest.addResources(resources);
|
46134
|
+
}
|
46135
|
+
txRequest.shiftPredicateData();
|
46136
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
46137
|
+
const requestToBeReEstimate = clone_default(txRequest);
|
46138
|
+
if (addedSignatures) {
|
46139
|
+
Array.from({ length: addedSignatures }).forEach(
|
46140
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
46141
|
+
);
|
45794
46142
|
}
|
46143
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
46144
|
+
transactionRequest: requestToBeReEstimate
|
46145
|
+
});
|
46146
|
+
txRequest.maxFee = maxFee;
|
46147
|
+
return txRequest;
|
45795
46148
|
}
|
45796
46149
|
/**
|
45797
46150
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -45799,29 +46152,25 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45799
46152
|
* @param destination - The address of the destination.
|
45800
46153
|
* @param amount - The amount of coins to transfer.
|
45801
46154
|
* @param assetId - The asset ID of the coins to transfer.
|
45802
|
-
* @param txParams - The transaction parameters (gasLimit,
|
46155
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
45803
46156
|
* @returns A promise that resolves to the prepared transaction request.
|
45804
46157
|
*/
|
45805
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45806
|
-
const
|
45807
|
-
|
45808
|
-
const
|
45809
|
-
const request = new ScriptTransactionRequest(params);
|
45810
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
45811
|
-
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
46158
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46159
|
+
const request = new ScriptTransactionRequest(txParams);
|
46160
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
46161
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
45812
46162
|
estimateTxDependencies: true,
|
45813
46163
|
resourcesOwner: this
|
45814
46164
|
});
|
45815
|
-
|
45816
|
-
|
45817
|
-
|
45818
|
-
|
45819
|
-
|
45820
|
-
|
45821
|
-
|
45822
|
-
|
45823
|
-
await this.fund(request,
|
45824
|
-
request.updatePredicateInputs(estimatedInputs);
|
46165
|
+
if ("gasLimit" in txParams) {
|
46166
|
+
this.validateGas({
|
46167
|
+
gasUsed: txCost.gasUsed,
|
46168
|
+
gasLimit: request.gasLimit
|
46169
|
+
});
|
46170
|
+
}
|
46171
|
+
request.gasLimit = txCost.gasUsed;
|
46172
|
+
request.maxFee = txCost.maxFee;
|
46173
|
+
await this.fund(request, txCost);
|
45825
46174
|
return request;
|
45826
46175
|
}
|
45827
46176
|
/**
|
@@ -45833,15 +46182,14 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45833
46182
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45834
46183
|
* @returns A promise that resolves to the transaction response.
|
45835
46184
|
*/
|
45836
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
46185
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45837
46186
|
if (bn(amount).lte(0)) {
|
45838
46187
|
throw new FuelError(
|
45839
46188
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45840
46189
|
"Transfer amount must be a positive number."
|
45841
46190
|
);
|
45842
46191
|
}
|
45843
|
-
const
|
45844
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
46192
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
45845
46193
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
45846
46194
|
}
|
45847
46195
|
/**
|
@@ -45853,7 +46201,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45853
46201
|
* @param txParams - The optional transaction parameters.
|
45854
46202
|
* @returns A promise that resolves to the transaction response.
|
45855
46203
|
*/
|
45856
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46204
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
45857
46205
|
if (bn(amount).lte(0)) {
|
45858
46206
|
throw new FuelError(
|
45859
46207
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -45861,32 +46209,30 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45861
46209
|
);
|
45862
46210
|
}
|
45863
46211
|
const contractAddress = Address.fromAddressOrString(contractId);
|
45864
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
45865
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45866
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
45867
46212
|
const { script, scriptData } = await assembleTransferToContractScript({
|
45868
46213
|
hexlifiedContractId: contractAddress.toB256(),
|
45869
46214
|
amountToTransfer: bn(amount),
|
45870
|
-
assetId
|
46215
|
+
assetId
|
45871
46216
|
});
|
45872
46217
|
const request = new ScriptTransactionRequest({
|
45873
|
-
...
|
46218
|
+
...txParams,
|
45874
46219
|
script,
|
45875
46220
|
scriptData
|
45876
46221
|
});
|
45877
46222
|
request.addContractInputAndOutput(contractAddress);
|
45878
|
-
const
|
45879
|
-
|
45880
|
-
[{ amount: bn(amount), assetId: String(
|
45881
|
-
);
|
45882
|
-
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
45883
|
-
this.validateGas({
|
45884
|
-
gasUsed,
|
45885
|
-
gasPrice: request.gasPrice,
|
45886
|
-
gasLimit: request.gasLimit,
|
45887
|
-
minGasPrice
|
46223
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
46224
|
+
resourcesOwner: this,
|
46225
|
+
quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
|
45888
46226
|
});
|
45889
|
-
|
46227
|
+
if (txParams.gasLimit) {
|
46228
|
+
this.validateGas({
|
46229
|
+
gasUsed: txCost.gasUsed,
|
46230
|
+
gasLimit: request.gasLimit
|
46231
|
+
});
|
46232
|
+
}
|
46233
|
+
request.gasLimit = txCost.gasUsed;
|
46234
|
+
request.maxFee = txCost.maxFee;
|
46235
|
+
await this.fund(request, txCost);
|
45890
46236
|
return this.sendTransaction(request);
|
45891
46237
|
}
|
45892
46238
|
/**
|
@@ -45898,8 +46244,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45898
46244
|
* @returns A promise that resolves to the transaction response.
|
45899
46245
|
*/
|
45900
46246
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
45901
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
45902
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45903
46247
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
45904
46248
|
const recipientDataArray = arrayify(
|
45905
46249
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -45912,21 +46256,19 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45912
46256
|
...recipientDataArray,
|
45913
46257
|
...amountDataArray
|
45914
46258
|
]);
|
45915
|
-
const params = { script,
|
46259
|
+
const params = { script, ...txParams };
|
45916
46260
|
const request = new ScriptTransactionRequest(params);
|
45917
|
-
const
|
45918
|
-
const
|
45919
|
-
|
45920
|
-
|
45921
|
-
|
45922
|
-
|
45923
|
-
|
45924
|
-
|
45925
|
-
|
45926
|
-
|
45927
|
-
|
45928
|
-
});
|
45929
|
-
await this.fund(request, requiredQuantities, maxFee);
|
46261
|
+
const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46262
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
46263
|
+
if (txParams.gasLimit) {
|
46264
|
+
this.validateGas({
|
46265
|
+
gasUsed: txCost.gasUsed,
|
46266
|
+
gasLimit: request.gasLimit
|
46267
|
+
});
|
46268
|
+
}
|
46269
|
+
request.maxFee = txCost.maxFee;
|
46270
|
+
request.gasLimit = txCost.gasUsed;
|
46271
|
+
await this.fund(request, txCost);
|
45930
46272
|
return this.sendTransaction(request);
|
45931
46273
|
}
|
45932
46274
|
async signMessage(message) {
|
@@ -45984,18 +46326,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45984
46326
|
}
|
45985
46327
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
45986
46328
|
}
|
45987
|
-
validateGas({
|
45988
|
-
gasUsed,
|
45989
|
-
gasPrice,
|
45990
|
-
gasLimit,
|
45991
|
-
minGasPrice
|
45992
|
-
}) {
|
45993
|
-
if (minGasPrice.gt(gasPrice)) {
|
45994
|
-
throw new FuelError(
|
45995
|
-
ErrorCode.GAS_PRICE_TOO_LOW,
|
45996
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
45997
|
-
);
|
45998
|
-
}
|
46329
|
+
validateGas({ gasUsed, gasLimit }) {
|
45999
46330
|
if (gasUsed.gt(gasLimit)) {
|
46000
46331
|
throw new FuelError(
|
46001
46332
|
ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -47378,12 +47709,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47378
47709
|
};
|
47379
47710
|
|
47380
47711
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47381
|
-
var
|
47712
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47382
47713
|
var rnds8Pool = new Uint8Array(256);
|
47383
47714
|
var poolPtr = rnds8Pool.length;
|
47384
47715
|
function rng() {
|
47385
47716
|
if (poolPtr > rnds8Pool.length - 16) {
|
47386
|
-
|
47717
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
47387
47718
|
poolPtr = 0;
|
47388
47719
|
}
|
47389
47720
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47399,9 +47730,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47399
47730
|
}
|
47400
47731
|
|
47401
47732
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47402
|
-
var
|
47733
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
47403
47734
|
var native_default = {
|
47404
|
-
randomUUID:
|
47735
|
+
randomUUID: import_crypto17.default.randomUUID
|
47405
47736
|
};
|
47406
47737
|
|
47407
47738
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47584,7 +47915,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47584
47915
|
* @param transactionRequestLike - The transaction request to send.
|
47585
47916
|
* @returns A promise that resolves to the TransactionResponse object.
|
47586
47917
|
*/
|
47587
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
47918
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
47588
47919
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
47589
47920
|
if (estimateTxDependencies) {
|
47590
47921
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -50344,14 +50675,15 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50344
50675
|
process.env.GENESIS_SECRET || randomBytes22(32),
|
50345
50676
|
wallet.provider
|
50346
50677
|
);
|
50347
|
-
const
|
50348
|
-
|
50349
|
-
|
50350
|
-
|
50351
|
-
gasPrice: minGasPrice
|
50678
|
+
const request = new ScriptTransactionRequest();
|
50679
|
+
quantities.forEach((quantity) => {
|
50680
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
50681
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
50352
50682
|
});
|
50353
|
-
|
50354
|
-
|
50683
|
+
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
50684
|
+
request.gasLimit = txCost.gasUsed;
|
50685
|
+
request.maxFee = txCost.maxFee;
|
50686
|
+
await genesisWallet.fund(request, txCost);
|
50355
50687
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
50356
50688
|
};
|
50357
50689
|
|
@@ -50381,7 +50713,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50381
50713
|
|
50382
50714
|
// src/test-utils/launchNode.ts
|
50383
50715
|
var import_child_process = __require("child_process");
|
50384
|
-
var
|
50716
|
+
var import_crypto21 = __require("crypto");
|
50385
50717
|
var import_fs2 = __require("fs");
|
50386
50718
|
var import_os = __toESM(__require("os"));
|
50387
50719
|
var import_path8 = __toESM(__require("path"));
|
@@ -50453,7 +50785,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50453
50785
|
})).toString();
|
50454
50786
|
let chainConfigPathToUse;
|
50455
50787
|
const prefix = basePath || import_os.default.tmpdir();
|
50456
|
-
const suffix = basePath ? "" : (0,
|
50788
|
+
const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
|
50457
50789
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50458
50790
|
if (chainConfigPath) {
|
50459
50791
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50476,7 +50808,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50476
50808
|
{
|
50477
50809
|
owner: signer.address.toHexString(),
|
50478
50810
|
amount: toHex(1e9),
|
50479
|
-
asset_id:
|
50811
|
+
asset_id: BaseAssetId
|
50480
50812
|
}
|
50481
50813
|
]
|
50482
50814
|
}
|
@@ -50492,7 +50824,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50492
50824
|
["--ip", ipToUse],
|
50493
50825
|
["--port", portToUse],
|
50494
50826
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
50495
|
-
["--min-gas-price", "
|
50827
|
+
["--min-gas-price", "1"],
|
50496
50828
|
poaInstant ? ["--poa-instant", "true"] : [],
|
50497
50829
|
["--consensus-key", consensusKey],
|
50498
50830
|
["--chain", chainConfigPathToUse],
|
@@ -50542,10 +50874,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50542
50874
|
})
|
50543
50875
|
);
|
50544
50876
|
var generateWallets = async (count, provider) => {
|
50545
|
-
const baseAssetId = provider.getBaseAssetId();
|
50546
50877
|
const wallets = [];
|
50547
50878
|
for (let i = 0; i < count; i += 1) {
|
50548
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50879
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50549
50880
|
wallets.push(wallet);
|
50550
50881
|
}
|
50551
50882
|
return wallets;
|
@@ -50555,7 +50886,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50555
50886
|
walletCount = 10
|
50556
50887
|
} = {}) => {
|
50557
50888
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
50558
|
-
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
50889
|
+
const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
|
50559
50890
|
const wallets = await generateWallets(walletCount, provider);
|
50560
50891
|
const cleanup = () => {
|
50561
50892
|
closeNode();
|